Changeset 207317 in webkit
- Timestamp:
- Oct 13, 2016 6:10:30 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r207314 r207317 1 2016-10-13 Dean Jackson <dino@apple.com> 2 3 CSS parsing should use Color not RGBA32 4 https://bugs.webkit.org/show_bug.cgi?id=163423 5 <rdar://problem/28766903> 6 7 Reviewed by Simon Fraser. 8 9 In order to allow CSS to use the ExtendedColor variant of 10 Color, we need to stop using RGBA32. This is a fairly big 11 change that goes through all the places in the parser 12 related to colors, and moves them from RGBA32 to Color. 13 14 No change in functionality, so covered by existing tests. 15 16 * WebCore.xcodeproj/project.pbxproj: Add the new ColorHash.h file. 17 18 * css/CSSPrimitiveValue.cpp: CSSPrimitiveValue now can hold a Color* 19 rather than an unsigned int for colors. 20 (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): 21 (WebCore::CSSPrimitiveValue::cleanup): 22 (WebCore::CSSPrimitiveValue::getRGBColorValue): 23 (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText): 24 (WebCore::CSSPrimitiveValue::cloneForCSSOM): 25 (WebCore::CSSPrimitiveValue::equals): 26 * css/CSSPrimitiveValue.h: Move to Color* and also use some 27 nullptrs. 28 * css/CSSPrimitiveValueMappings.h: 29 (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Add a new inline 30 constructor. 31 32 * css/CSSValuePool.cpp: Move to Color. 33 (WebCore::CSSValuePool::CSSValuePool): 34 (WebCore::CSSValuePool::createColorValue): 35 * css/CSSValuePool.h: Change the ColorValueCache to a new type. 36 37 * css/StyleResolver.cpp: Move to Color. 38 (WebCore::StyleResolver::colorFromPrimitiveValue): 39 * css/parser/CSSParser.cpp: 40 (WebCore::parseColorValue): 41 (WebCore::CSSParser::parseColor): 42 (WebCore::CSSParser::parseColorFromString): 43 (WebCore::CSSParser::parseSystemColor): 44 (WebCore::fastParseColorInternal): 45 (WebCore::CSSParser::fastParseColor): 46 (WebCore::CSSParser::parseColorFromValue): 47 * css/parser/CSSParser.h: 48 * css/parser/CSSParserFastPaths.cpp: 49 (WebCore::fastParseColorInternal): 50 (WebCore::CSSParserFastPaths::parseColor): 51 * css/parser/CSSPropertyParserHelpers.cpp: 52 (WebCore::CSSPropertyParserHelpers::consumeColor): 53 * css/parser/SVGCSSParser.cpp: 54 (WebCore::CSSParser::parseSVGValue): 55 (WebCore::CSSParser::parseSVGPaint): 56 (WebCore::CSSParser::parseSVGColor): 57 * editing/EditingStyle.cpp: 58 (WebCore::cssValueToColor): 59 (WebCore::textColorFromStyle): 60 (WebCore::backgroundColorFromStyle): 61 (WebCore::rgbaBackgroundColorInEffect): 62 (WebCore::EditingStyle::prepareToApplyAt): 63 (WebCore::isTransparentColorValue): 64 (WebCore::cssValueToRGBA): Deleted. 65 * editing/cocoa/HTMLConverter.mm: 66 (HTMLConverterCaches::colorPropertyValueForNode): 67 * html/HTMLBodyElement.cpp: 68 (WebCore::HTMLBodyElement::parseAttribute): 69 * html/canvas/CanvasGradient.cpp: 70 (WebCore::CanvasGradient::addColorStop): 71 * html/canvas/CanvasRenderingContext2D.cpp: Ditto, but leave a FIXME to 72 remind myself to come back when colorWithOverrideAlpha has been updated. 73 (WebCore::CanvasRenderingContext2D::setStrokeStyle): 74 (WebCore::CanvasRenderingContext2D::setFillStyle): 75 (WebCore::CanvasRenderingContext2D::setShadowColor): 76 (WebCore::CanvasRenderingContext2D::setShadow): 77 * html/canvas/CanvasStyle.cpp: 78 (WebCore::isCurrentColorString): 79 (WebCore::parseColor): 80 (WebCore::currentColor): 81 (WebCore::parseColorOrCurrentColor): 82 (WebCore::CanvasStyle::createFromString): 83 (WebCore::CanvasStyle::createFromStringWithOverrideAlpha): 84 * html/canvas/CanvasStyle.h: 85 * svg/SVGColor.cpp: 86 (WebCore::SVGColor::colorFromRGBColorString): 87 88 * platform/graphics/Color.h: Add new constructors for the special 89 empty and deleted Color values used in HashTables. 90 (WebCore::Color::Color): 91 (WebCore::Color::isHashTableDeletedValue): 92 (WebCore::Color::asUint64): New accessor to get the raw uint64_t value. 93 94 * platform/graphics/ColorHash.h: Added. Implement the traits for a Color HashTable. 95 (WTF::ColorHash::hash): 96 (WTF::ColorHash::equal): 97 (WTF::HashTraits<WebCore::Color>::emptyValue): 98 (WTF::HashTraits<WebCore::Color>::constructDeletedValue): 99 (WTF::HashTraits<WebCore::Color>::isDeletedValue): 100 1 101 2016-10-13 Nan Wang <n_wang@apple.com> 2 102 -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r207280 r207317 1298 1298 2EF1BFEB121C9F4200C27627 /* FileStream.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EF1BFE9121C9F4200C27627 /* FileStream.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1299 1299 2EF1BFF9121CB0CE00C27627 /* FileStreamClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 2EF1BFF8121CB0CE00C27627 /* FileStreamClient.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1300 3103B7DF1DB01567008BB890 /* ColorHash.h in Headers */ = {isa = PBXBuildFile; fileRef = 3103B7DE1DB01556008BB890 /* ColorHash.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1300 1301 3106036F14327D2E00ABF4BA /* WebKitCSSFilterValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3106036C14327D2E00ABF4BA /* WebKitCSSFilterValue.cpp */; }; 1301 1302 3106037014327D2E00ABF4BA /* WebKitCSSFilterValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 3106036D14327D2E00ABF4BA /* WebKitCSSFilterValue.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 8262 8263 2EF1BFE9121C9F4200C27627 /* FileStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileStream.h; sourceTree = "<group>"; }; 8263 8264 2EF1BFF8121CB0CE00C27627 /* FileStreamClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FileStreamClient.h; sourceTree = "<group>"; }; 8265 3103B7DE1DB01556008BB890 /* ColorHash.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ColorHash.h; sourceTree = "<group>"; }; 8264 8266 3106036C14327D2E00ABF4BA /* WebKitCSSFilterValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebKitCSSFilterValue.cpp; sourceTree = "<group>"; }; 8265 8267 3106036D14327D2E00ABF4BA /* WebKitCSSFilterValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitCSSFilterValue.h; sourceTree = "<group>"; }; … … 20735 20737 B27535380B053814002CE64F /* Color.cpp */, 20736 20738 B27535390B053814002CE64F /* Color.h */, 20739 3103B7DE1DB01556008BB890 /* ColorHash.h */, 20737 20740 31DCDF411DA1C45400EA5B93 /* ExtendedColor.cpp */, 20738 20741 31DCDF421DA1C45400EA5B93 /* ExtendedColor.h */, … … 25387 25390 FDA15ECE12B03F61003A583A /* JSScriptProcessorNode.h in Headers */, 25388 25391 CED06AD11C77754800FDFAF1 /* JSSecurityPolicyViolationEvent.h in Headers */, 25392 3103B7DF1DB01567008BB890 /* ColorHash.h in Headers */, 25389 25393 9BDA64D81B975CF2009C4387 /* JSShadowRoot.h in Headers */, 25390 25394 CD9DE17B17AAC75B00EA386D /* JSSourceBuffer.h in Headers */, -
trunk/Source/WebCore/css/CSSPrimitiveValue.cpp
r206603 r207317 351 351 } 352 352 353 CSSPrimitiveValue::CSSPrimitiveValue( RGBA32color)353 CSSPrimitiveValue::CSSPrimitiveValue(const Color& color) 354 354 : CSSValue(PrimitiveClass) 355 355 { 356 356 m_primitiveUnitType = CSS_RGBCOLOR; 357 m_value. rgbcolor = color;357 m_value.color = new Color(color); 358 358 } 359 359 … … 575 575 m_value.fontFamily = nullptr; 576 576 break; 577 case CSS_RGBCOLOR: 578 ASSERT(m_value.color); 579 delete m_value.color; 580 m_value.color = nullptr; 581 break; 577 582 case CSS_NUMBER: 578 583 case CSS_PARSER_INTEGER: … … 606 611 case CSS_FR: 607 612 case CSS_IDENT: 608 case CSS_RGBCOLOR:609 613 case CSS_UNKNOWN: 610 614 case CSS_UNICODE_RANGE: … … 1029 1033 1030 1034 // FIMXE: This should not return a new object for each invocation. 1031 return RGBColor::create(m_value. rgbcolor);1035 return RGBColor::create(m_value.color->rgb()); 1032 1036 } 1033 1037 … … 1176 1180 return getLengthRepeatValue()->cssText(); 1177 1181 #endif 1182 case CSS_PARSER_HEXCOLOR: { 1183 RGBA32 rgb; 1184 Color::parseHexColor((String)m_value.string, rgb); 1185 return Color(rgb).cssText(); 1186 } 1178 1187 case CSS_RGBCOLOR: 1179 case CSS_PARSER_HEXCOLOR: { 1180 RGBA32 rgbColor = m_value.rgbcolor; 1181 if (m_primitiveUnitType == CSS_PARSER_HEXCOLOR) 1182 Color::parseHexColor((String)m_value.string, rgbColor); 1183 return Color(rgbColor).cssText(); 1184 } 1188 return color().cssText(); 1185 1189 case CSS_PAIR: 1186 1190 return getPairValue()->cssText(); … … 1352 1356 break; 1353 1357 case CSS_RGBCOLOR: 1354 result = CSSPrimitiveValue::create Color(m_value.rgbcolor);1358 result = CSSPrimitiveValue::create(*m_value.color); 1355 1359 break; 1356 1360 case CSS_DIMENSION: … … 1431 1435 #endif 1432 1436 case CSS_RGBCOLOR: 1433 return m_value.rgbcolor == other.m_value.rgbcolor;1437 return color() == other.color(); 1434 1438 case CSS_PAIR: 1435 1439 return m_value.pair && other.m_value.pair && m_value.pair->equals(*other.m_value.pair); -
trunk/Source/WebCore/css/CSSPrimitiveValue.h
r206603 r207317 254 254 static Ref<CSSPrimitiveValue> createParserOperator(int parserOperator) { return adoptRef(*new CSSPrimitiveValue(parserOperator)); } 255 255 256 static Ref<CSSPrimitiveValue> createColor(unsigned rgbValue) { return adoptRef(*new CSSPrimitiveValue(rgbValue)); }257 256 static Ref<CSSPrimitiveValue> create(double value, UnitTypes type) { return adoptRef(*new CSSPrimitiveValue(value, type)); } 258 257 static Ref<CSSPrimitiveValue> create(const String& value, UnitTypes type) { return adoptRef(*new CSSPrimitiveValue(value, type)); } … … 343 342 344 343 WEBCORE_EXPORT Counter* getCounterValue(ExceptionCode&) const; 345 Counter* getCounterValue() const { return m_primitiveUnitType != CSS_COUNTER ? 0: m_value.counter; }344 Counter* getCounterValue() const { return m_primitiveUnitType != CSS_COUNTER ? nullptr : m_value.counter; } 346 345 347 346 WEBCORE_EXPORT Rect* getRectValue(ExceptionCode&) const; 348 Rect* getRectValue() const { return m_primitiveUnitType != CSS_RECT ? 0: m_value.rect; }347 Rect* getRectValue() const { return m_primitiveUnitType != CSS_RECT ? nullptr : m_value.rect; } 349 348 350 349 Quad* getQuadValue(ExceptionCode&) const; 351 Quad* getQuadValue() const { return m_primitiveUnitType != CSS_QUAD ? 0: m_value.quad; }350 Quad* getQuadValue() const { return m_primitiveUnitType != CSS_QUAD ? nullptr : m_value.quad; } 352 351 353 352 #if ENABLE(CSS_SCROLL_SNAP) 354 353 LengthRepeat* getLengthRepeatValue(ExceptionCode&) const; 355 LengthRepeat* getLengthRepeatValue() const { return m_primitiveUnitType != CSS_LENGTH_REPEAT ? 0: m_value.lengthRepeat; }354 LengthRepeat* getLengthRepeatValue() const { return m_primitiveUnitType != CSS_LENGTH_REPEAT ? nullptr : m_value.lengthRepeat; } 356 355 #endif 357 356 358 357 WEBCORE_EXPORT RefPtr<RGBColor> getRGBColorValue(ExceptionCode&) const; 359 RGBA32 getRGBA32Value() const { return m_primitiveUnitType != CSS_RGBCOLOR ? 0 : m_value.rgbcolor; }358 const Color& color() const { ASSERT(m_primitiveUnitType == CSS_RGBCOLOR); return *m_value.color; } 360 359 361 360 Pair* getPairValue(ExceptionCode&) const; … … 405 404 // FIXME: int vs. unsigned overloading is too subtle to distinguish the color and operator cases. 406 405 CSSPrimitiveValue(int parserOperator); 407 CSSPrimitiveValue( unsigned color); // RGB value406 CSSPrimitiveValue(const Color&); 408 407 CSSPrimitiveValue(const Length&); 409 408 CSSPrimitiveValue(const Length&, const RenderStyle&); … … 465 464 LengthRepeat* lengthRepeat; 466 465 #endif 467 unsigned rgbcolor;466 const Color* color; 468 467 Pair* pair; 469 468 DashboardRegion* region; -
trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h
r206181 r207317 4940 4940 } 4941 4941 4942 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(const Color& color) 4943 : CSSValue(PrimitiveClass) 4944 { 4945 m_primitiveUnitType = CSS_RGBCOLOR; 4946 m_value.color = new Color(color); 4947 } 4948 4942 4949 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(CSSFontFamily fontFamily) 4943 4950 : CSSValue(PrimitiveClass) -
trunk/Source/WebCore/css/CSSValuePool.cpp
r194848 r207317 49 49 m_revertValue.construct(); 50 50 51 m_transparentColor.construct(Color ::transparent);52 m_whiteColor.construct(Color ::white);53 m_blackColor.construct(Color ::black);51 m_transparentColor.construct(Color(Color::transparent)); 52 m_whiteColor.construct(Color(Color::white)); 53 m_blackColor.construct(Color(Color::black)); 54 54 55 55 for (unsigned i = 0; i < numCSSValueKeywords; ++i) … … 74 74 } 75 75 76 Ref<CSSPrimitiveValue> CSSValuePool::createColorValue( unsigned rgbValue)76 Ref<CSSPrimitiveValue> CSSValuePool::createColorValue(const Color& color) 77 77 { 78 78 // These are the empty and deleted values of the hash table. 79 if ( rgbValue== Color::transparent)79 if (color == Color::transparent) 80 80 return m_transparentColor.get(); 81 if ( rgbValue== Color::white)81 if (color == Color::white) 82 82 return m_whiteColor.get(); 83 83 // Just because it is common. 84 if ( rgbValue== Color::black)84 if (color == Color::black) 85 85 return m_blackColor.get(); 86 86 … … 90 90 m_colorValueCache.remove(m_colorValueCache.begin()); 91 91 92 ColorValueCache::AddResult entry = m_colorValueCache.add( rgbValue, nullptr);92 ColorValueCache::AddResult entry = m_colorValueCache.add(color, nullptr); 93 93 if (entry.isNewEntry) 94 entry.iterator->value = CSSPrimitiveValue::create Color(rgbValue);94 entry.iterator->value = CSSPrimitiveValue::create(color); 95 95 return *entry.iterator->value; 96 96 } -
trunk/Source/WebCore/css/CSSValuePool.h
r194848 r207317 35 35 #include "CSSUnsetValue.h" 36 36 #include "CSSValueKeywords.h" 37 #include "ColorHash.h" 37 38 #include <utility> 38 39 #include <wtf/HashMap.h> … … 61 62 Ref<CSSPrimitiveValue> createIdentifierValue(CSSValueID identifier); 62 63 Ref<CSSPrimitiveValue> createIdentifierValue(CSSPropertyID identifier); 63 Ref<CSSPrimitiveValue> createColorValue( unsigned rgbValue);64 Ref<CSSPrimitiveValue> createColorValue(const Color&); 64 65 Ref<CSSPrimitiveValue> createValue(double value, CSSPrimitiveValue::UnitTypes); 65 66 Ref<CSSPrimitiveValue> createValue(const String& value, CSSPrimitiveValue::UnitTypes type) { return CSSPrimitiveValue::create(value, type); } … … 73 74 CSSValuePool(); 74 75 75 typedef HashMap< unsigned, RefPtr<CSSPrimitiveValue>> ColorValueCache;76 typedef HashMap<Color, RefPtr<CSSPrimitiveValue>> ColorValueCache; 76 77 ColorValueCache m_colorValueCache; 77 78 -
trunk/Source/WebCore/css/StyleResolver.cpp
r207280 r207317 1832 1832 { 1833 1833 if (value.isRGBColor()) 1834 return Color(value.getRGBA32Value());1834 return value.color(); 1835 1835 1836 1836 const State& state = m_state; -
trunk/Source/WebCore/css/parser/CSSParser.cpp
r206839 r207317 495 495 return declaration.addParsedProperty(CSSProperty(propertyId, WTFMove(value), important)) ? CSSParser::ParseResult::Changed : CSSParser::ParseResult::Unchanged; 496 496 } 497 RGBA32 color;498 if (! CSSParser::fastParseColor(color, string, strict && string[0] != '#'))497 Color color = CSSParser::fastParseColor(string, strict && string[0] != '#'); 498 if (!color.isValid()) 499 499 return CSSParser::ParseResult::Error; 500 500 … … 1371 1371 } 1372 1372 1373 // The color will only be changed when string contains a valid CSS color, so callers 1374 // can set it to a default color and ignore the boolean result. 1375 bool CSSParser::parseColor(RGBA32& color, const String& string, bool strict) 1373 Color CSSParser::parseColor(const String& string, bool strict) 1376 1374 { 1377 1375 if (string.isEmpty()) 1378 return false;1376 return Color(); 1379 1377 1380 1378 // First try creating a color specified by name, rgba(), rgb() or "#" syntax. 1381 if (fastParseColor(color, string, strict)) 1382 return true; 1379 Color color = fastParseColor(string, strict); 1380 if (color.isValid()) 1381 return color; 1383 1382 1384 1383 CSSParser parser(HTMLStandardMode); 1385 1384 1386 1385 // In case the fast-path parser didn't understand the color, try the full parser. 1387 if (!parser.parseColor (string))1388 return false;1386 if (!parser.parseColorFromString(string)) 1387 return Color(); 1389 1388 1390 1389 CSSValue& value = *parser.m_parsedProperties.first().value(); 1391 1390 if (!is<CSSPrimitiveValue>(value)) 1392 return false;1391 return Color(); 1393 1392 1394 1393 CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(value); 1395 1394 if (!primitiveValue.isRGBColor()) 1396 return false; 1397 1398 color = primitiveValue.getRGBA32Value(); 1399 return true; 1400 } 1401 1402 bool CSSParser::parseColor(const String& string) 1395 return Color(); 1396 1397 return primitiveValue.color(); 1398 } 1399 1400 bool CSSParser::parseColorFromString(const String& string) 1403 1401 { 1404 1402 setupParser("@-webkit-decls{color:", string, "} "); … … 1409 1407 } 1410 1408 1411 bool CSSParser::parseSystemColor(RGBA32& color,const String& string, Document* document)1409 Color CSSParser::parseSystemColor(const String& string, Document* document) 1412 1410 { 1413 1411 if (!document || !document->page()) 1414 return false;1412 return Color(); 1415 1413 1416 1414 CSSParserString cssColor; … … 1418 1416 CSSValueID id = cssValueKeywordID(cssColor); 1419 1417 if (!validPrimitiveValueColor(id)) 1420 return false; 1421 1422 Color parsedColor = document->page()->theme().systemColor(id); 1423 if (!parsedColor.isValid()) 1424 return false; 1425 1426 color = parsedColor.rgb(); 1427 return true; 1418 return Color(); 1419 1420 return document->page()->theme().systemColor(id); 1428 1421 } 1429 1422 … … 7482 7475 7483 7476 template <typename CharacterType> 7484 static inline bool fastParseColorInternal(RGBA32& rgb,const CharacterType* characters, unsigned length , bool strict)7477 static inline Color fastParseColorInternal(const CharacterType* characters, unsigned length , bool strict) 7485 7478 { 7486 7479 CSSPrimitiveValue::UnitTypes expect = CSSPrimitiveValue::CSS_UNKNOWN; 7487 7480 7488 7481 if (!strict && length >= 3) { 7482 RGBA32 rgb; 7489 7483 if (characters[0] == '#') { 7490 7484 if (Color::parseHexColor(characters + 1, length - 1, rgb)) 7491 return true;7485 return Color(rgb); 7492 7486 } else { 7493 7487 if (Color::parseHexColor(characters, length, rgb)) 7494 return true;7488 return Color(rgb); 7495 7489 } 7496 7490 } … … 7506 7500 7507 7501 if (!parseColorIntOrPercentage(current, end, ',', expect, red)) 7508 return false;7502 return Color(); 7509 7503 if (!parseColorIntOrPercentage(current, end, ',', expect, green)) 7510 return false;7504 return Color(); 7511 7505 if (!parseColorIntOrPercentage(current, end, ',', expect, blue)) 7512 return false;7506 return Color(); 7513 7507 if (!parseAlphaValue(current, end, ')', alpha)) 7514 return false;7508 return Color(); 7515 7509 if (current != end) 7516 return false; 7517 rgb = makeRGBA(red, green, blue, alpha); 7518 return true; 7510 return Color(); 7511 return Color(makeRGBA(red, green, blue, alpha)); 7519 7512 } 7520 7513 … … 7527 7520 int blue; 7528 7521 if (!parseColorIntOrPercentage(current, end, ',', expect, red)) 7529 return false;7522 return Color(); 7530 7523 if (!parseColorIntOrPercentage(current, end, ',', expect, green)) 7531 return false;7524 return Color(); 7532 7525 if (!parseColorIntOrPercentage(current, end, ')', expect, blue)) 7533 return false;7526 return Color(); 7534 7527 if (current != end) 7535 return false; 7536 rgb = makeRGB(red, green, blue); 7537 return true; 7538 } 7539 7540 return false; 7528 return Color(); 7529 return Color(makeRGB(red, green, blue)); 7530 } 7531 7532 return Color(); 7541 7533 } 7542 7534 7543 7535 template<typename StringType> 7544 bool CSSParser::fastParseColor(RGBA32& rgb,const StringType& name, bool strict)7536 Color CSSParser::fastParseColor(const StringType& name, bool strict) 7545 7537 { 7546 7538 unsigned length = name.length(); 7547 bool parseResult;7548 7539 7549 7540 if (!length) 7550 return false; 7551 7541 return Color(); 7542 7543 Color color; 7552 7544 if (name.is8Bit()) 7553 parseResult = fastParseColorInternal(rgb,name.characters8(), length, strict);7545 color = fastParseColorInternal(name.characters8(), length, strict); 7554 7546 else 7555 parseResult = fastParseColorInternal(rgb,name.characters16(), length, strict);7556 7557 if ( parseResult)7558 return true;7547 color = fastParseColorInternal(name.characters16(), length, strict); 7548 7549 if (color.isValid()) 7550 return color; 7559 7551 7560 7552 // Try named colors. 7561 Color tc; 7562 tc.setNamedColor(name); 7563 if (tc.isValid()) { 7564 rgb = tc.rgb(); 7565 return true; 7566 } 7567 return false; 7553 color.setNamedColor(name); 7554 return color; 7568 7555 } 7569 7556 … … 7681 7668 RefPtr<CSSPrimitiveValue> CSSParser::parseColor(CSSParserValue* value) 7682 7669 { 7683 RGBA32 c = Color::transparent;7684 if (! parseColorFromValue(value ? *value : *m_valueList->current(), c))7670 Color color = parseColorFromValue(value ? *value : *m_valueList->current()); 7671 if (!color.isValid()) 7685 7672 return nullptr; 7686 return CSSValuePool::singleton().createColorValue(c );7687 } 7688 7689 bool CSSParser::parseColorFromValue(CSSParserValue& value, RGBA32& c)7673 return CSSValuePool::singleton().createColorValue(color); 7674 } 7675 7676 Color CSSParser::parseColorFromValue(CSSParserValue& value) 7690 7677 { 7691 7678 if (inQuirksMode() && value.unit == CSSPrimitiveValue::CSS_NUMBER … … 7693 7680 String str = String::format("%06d", static_cast<int>((value.fValue+.5))); 7694 7681 // FIXME: This should be strict parsing for SVG as well. 7695 if (!fastParseColor(c, str, inStrictMode())) 7696 return false; 7682 return fastParseColor(str, inStrictMode()); 7697 7683 } else if (value.unit == CSSPrimitiveValue::CSS_PARSER_HEXCOLOR 7698 7684 || value.unit == CSSPrimitiveValue::CSS_IDENT 7699 7685 || (inQuirksMode() && value.unit == CSSPrimitiveValue::CSS_DIMENSION)) { 7700 if (!fastParseColor(c, value.string, inStrictMode() && value.unit == CSSPrimitiveValue::CSS_IDENT)) 7701 return false; 7686 return fastParseColor(value.string, inStrictMode() && value.unit == CSSPrimitiveValue::CSS_IDENT); 7702 7687 } else if (value.unit == CSSParserValue::Function 7703 7688 && value.function->args … … 7706 7691 int colorValues[3]; 7707 7692 if (!parseRGBParameters(value, colorValues, false)) 7708 return false;7709 c = makeRGB(colorValues[0], colorValues[1], colorValues[2]);7693 return Color(); 7694 return Color(makeRGB(colorValues[0], colorValues[1], colorValues[2])); 7710 7695 } else if (value.unit == CSSParserValue::Function 7711 7696 && value.function->args … … 7714 7699 int colorValues[4]; 7715 7700 if (!parseRGBParameters(value, colorValues, true)) 7716 return false;7717 c = makeRGBA(colorValues[0], colorValues[1], colorValues[2], colorValues[3]);7701 return Color(); 7702 return Color(makeRGBA(colorValues[0], colorValues[1], colorValues[2], colorValues[3])); 7718 7703 } else if (value.unit == CSSParserValue::Function 7719 7704 && value.function->args … … 7722 7707 double colorValues[3]; 7723 7708 if (!parseHSLParameters(value, colorValues, false)) 7724 return false;7725 c = makeRGBAFromHSLA(colorValues[0], colorValues[1], colorValues[2], 1.0);7709 return Color(); 7710 return Color(makeRGBAFromHSLA(colorValues[0], colorValues[1], colorValues[2], 1.0)); 7726 7711 } else if (value.unit == CSSParserValue::Function 7727 7712 && value.function->args … … 7730 7715 double colorValues[4]; 7731 7716 if (!parseHSLParameters(value, colorValues, true)) 7732 return false; 7733 c = makeRGBAFromHSLA(colorValues[0], colorValues[1], colorValues[2], colorValues[3]); 7734 } else 7735 return false; 7736 7737 return true; 7717 return Color(); 7718 return Color(makeRGBAFromHSLA(colorValues[0], colorValues[1], colorValues[2], colorValues[3])); 7719 } 7720 7721 return Color(); 7738 7722 } 7739 7723 -
trunk/Source/WebCore/css/parser/CSSParser.h
r206753 r207317 135 135 static ParseResult parseCustomPropertyValue(MutableStyleProperties&, const AtomicString& propertyName, const String&, bool important, const CSSParserContext&, StyleSheetContents* contextStyleSheet); 136 136 137 static bool parseColor(RGBA32& color,const String&, bool strict = false);137 static Color parseColor(const String&, bool strict = false); 138 138 static bool isValidSystemColorValue(CSSValueID); 139 static bool parseSystemColor(RGBA32& color,const String&, Document*);139 static Color parseSystemColor(const String&, Document*); 140 140 static RefPtr<CSSValueList> parseFontFaceValue(const AtomicString&); 141 141 RefPtr<CSSPrimitiveValue> parseValidPrimitive(CSSValueID ident, ValueWithCalculation&); … … 279 279 bool parseHSLParameters(CSSParserValue&, double* colorValues, bool parseAlpha); 280 280 RefPtr<CSSPrimitiveValue> parseColor(CSSParserValue* = nullptr); 281 bool parseColorFromValue(CSSParserValue&, RGBA32&);281 Color parseColorFromValue(CSSParserValue&); 282 282 void parseSelector(const String&, CSSSelectorList&); 283 283 284 284 template<typename StringType> 285 static bool fastParseColor(RGBA32&,const StringType&, bool strict);285 static Color fastParseColor(const StringType&, bool strict); 286 286 287 287 bool parseLineHeight(bool important); … … 619 619 bool parseFontFaceSrcLocal(CSSValueList&); 620 620 621 bool parseColor (const String&);621 bool parseColorFromString(const String&); 622 622 623 623 #if ENABLE(CSS_GRID_LAYOUT) -
trunk/Source/WebCore/css/parser/CSSParserFastPaths.cpp
r206181 r207317 412 412 413 413 template <typename CharacterType> 414 static bool fastParseColorInternal(RGBA32& rgb,const CharacterType* characters, unsigned length, bool quirksMode)414 static Color fastParseColorInternal(const CharacterType* characters, unsigned length, bool quirksMode) 415 415 { 416 416 CSSPrimitiveValue::UnitTypes expect = CSSPrimitiveValue::UnitTypes::CSS_UNKNOWN; 417 417 418 if (length >= 4 && characters[0] == '#') 419 return Color::parseHexColor(characters + 1, length - 1, rgb); 418 if (length >= 4 && characters[0] == '#') { 419 // FIXME: Why doesn't this check if the parse worked? Is the fallback black? 420 RGBA32 rgb; 421 Color::parseHexColor(characters + 1, length - 1, rgb); 422 return Color(rgb); 423 } 420 424 421 425 if (quirksMode && (length == 3 || length == 6)) { 426 RGBA32 rgb; 422 427 if (Color::parseHexColor(characters, length, rgb)) 423 return true;428 return Color(rgb); 424 429 } 425 430 … … 434 439 435 440 if (!parseColorIntOrPercentage(current, end, ',', expect, red)) 436 return false;441 return Color(); 437 442 if (!parseColorIntOrPercentage(current, end, ',', expect, green)) 438 return false;443 return Color(); 439 444 if (!parseColorIntOrPercentage(current, end, ',', expect, blue)) 440 return false;445 return Color(); 441 446 if (!parseAlphaValue(current, end, ')', alpha)) 442 return false;447 return Color(); 443 448 if (current != end) 444 return false; 445 rgb = makeRGBA(red, green, blue, alpha); 446 return true; 449 return Color(); 450 return Color(makeRGBA(red, green, blue, alpha)); 447 451 } 448 452 … … 455 459 int blue; 456 460 if (!parseColorIntOrPercentage(current, end, ',', expect, red)) 457 return false;461 return Color(); 458 462 if (!parseColorIntOrPercentage(current, end, ',', expect, green)) 459 return false;463 return Color(); 460 464 if (!parseColorIntOrPercentage(current, end, ')', expect, blue)) 461 return false;465 return Color(); 462 466 if (current != end) 463 return false; 464 rgb = makeRGB(red, green, blue); 465 return true; 466 } 467 468 return false; 467 return Color(); 468 return Color(makeRGB(red, green, blue)); 469 } 470 471 return Color(); 469 472 } 470 473 … … 479 482 } 480 483 481 RGBA32 color;482 484 bool quirksMode = isQuirksModeBehavior(parserMode); 483 485 484 486 // Fast path for hex colors and rgb()/rgba() colors 485 bool parseResult;487 Color color; 486 488 if (string.is8Bit()) 487 parseResult = fastParseColorInternal(color,string.characters8(), string.length(), quirksMode);489 color = fastParseColorInternal(string.characters8(), string.length(), quirksMode); 488 490 else 489 parseResult = fastParseColorInternal(color,string.characters16(), string.length(), quirksMode);490 if (! parseResult)491 color = fastParseColorInternal(string.characters16(), string.length(), quirksMode); 492 if (!color.isValid()) 491 493 return nullptr; 492 494 return CSSValuePool::singleton().createColorValue(color); -
trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp
r206043 r207317 510 510 if (!parseHexColor(range, color, acceptQuirkyColors) && !parseColorFunction(range, color)) 511 511 return nullptr; 512 return CSSPrimitiveValue::create Color(color);512 return CSSPrimitiveValue::create(Color(color)); 513 513 } 514 514 -
trunk/Source/WebCore/css/parser/SVGCSSParser.cpp
r205926 r207317 132 132 parsedValue = SVGPaint::createColor(RenderTheme::defaultTheme()->systemColor(id)); 133 133 else if (valueWithCalculation.value().unit == CSSPrimitiveValue::CSS_URI) { 134 RGBA32 c = Color::transparent;135 134 if (m_valueList->next()) { 136 if (parseColorFromValue(*m_valueList->current(), c)) 137 parsedValue = SVGPaint::createURIAndColor(valueWithCalculation.value().string, c); 135 Color color = parseColorFromValue(*m_valueList->current()); 136 if (color.isValid()) 137 parsedValue = SVGPaint::createURIAndColor(valueWithCalculation.value().string, color); 138 138 else if (m_valueList->current()->id == CSSValueNone) 139 139 parsedValue = SVGPaint::createURIAndNone(valueWithCalculation.value().string); … … 287 287 RefPtr<SVGPaint> CSSParser::parseSVGPaint() 288 288 { 289 RGBA32 c = Color::transparent;290 if (! parseColorFromValue(*m_valueList->current(), c))289 Color color = parseColorFromValue(*m_valueList->current()); 290 if (!color.isValid()) 291 291 return nullptr; 292 return SVGPaint::createColor( Color(c));292 return SVGPaint::createColor(color); 293 293 } 294 294 295 295 RefPtr<SVGColor> CSSParser::parseSVGColor() 296 296 { 297 RGBA32 c = Color::transparent;298 if (! parseColorFromValue(*m_valueList->current(), c))297 Color color = parseColorFromValue(*m_valueList->current()); 298 if (!color.isValid()) 299 299 return nullptr; 300 return SVGColor::createFromColor( Color(c));300 return SVGColor::createFromColor(color); 301 301 } 302 302 -
trunk/Source/WebCore/editing/EditingStyle.cpp
r206395 r207317 383 383 } 384 384 385 static RGBA32 cssValueToRGBA(CSSValue* colorValue)385 static Color cssValueToColor(CSSValue* colorValue) 386 386 { 387 387 if (!is<CSSPrimitiveValue>(colorValue)) … … 390 390 CSSPrimitiveValue& primitiveColor = downcast<CSSPrimitiveValue>(*colorValue); 391 391 if (primitiveColor.isRGBColor()) 392 return primitiveColor. getRGBA32Value();392 return primitiveColor.color(); 393 393 394 RGBA32 rgba = 0; 395 CSSParser::parseColor(rgba, colorValue->cssText()); 396 return rgba; 394 return CSSParser::parseColor(colorValue->cssText()); 397 395 } 398 396 399 397 template<typename T> 400 static inline RGBA32textColorFromStyle(T& style)401 { 402 return cssValueTo RGBA(extractPropertyValue(style, CSSPropertyColor).get());398 static inline Color textColorFromStyle(T& style) 399 { 400 return cssValueToColor(extractPropertyValue(style, CSSPropertyColor).get()); 403 401 } 404 402 405 403 template<typename T> 406 static inline RGBA32backgroundColorFromStyle(T& style)407 { 408 return cssValueTo RGBA(extractPropertyValue(style, CSSPropertyBackgroundColor).get());409 } 410 411 static inline RGBA32rgbaBackgroundColorInEffect(Node* node)412 { 413 return cssValueTo RGBA(backgroundColorInEffect(node).get());404 static inline Color backgroundColorFromStyle(T& style) 405 { 406 return cssValueToColor(extractPropertyValue(style, CSSPropertyBackgroundColor).get()); 407 } 408 409 static inline Color rgbaBackgroundColorInEffect(Node* node) 410 { 411 return cssValueToColor(backgroundColorInEffect(node).get()); 414 412 } 415 413 … … 1097 1095 1098 1096 if (hasTransparentBackgroundColor(m_mutableStyle.get()) 1099 || cssValueTo RGBA(m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgroundColor).get()) == rgbaBackgroundColorInEffect(position.containerNode()))1097 || cssValueToColor(m_mutableStyle->getPropertyCSSValue(CSSPropertyBackgroundColor).get()) == rgbaBackgroundColorInEffect(position.containerNode())) 1100 1098 m_mutableStyle->removeProperty(CSSPropertyBackgroundColor); 1101 1099 … … 1841 1839 CSSPrimitiveValue& value = downcast<CSSPrimitiveValue>(*cssValue); 1842 1840 if (value.isRGBColor()) 1843 return !alphaChannel(value.getRGBA32Value());1841 return value.color().hasAlpha(); 1844 1842 return value.getValueID() == CSSValueTransparent; 1845 1843 } -
trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm
r206802 r207317 990 990 if (RefPtr<CSSValue> value = computedStylePropertyForElement(element, propertyId)) { 991 991 if (is<CSSPrimitiveValue>(*value) && downcast<CSSPrimitiveValue>(*value).isRGBColor()) 992 return normalizedColor(Color(downcast<CSSPrimitiveValue>(*value). getRGBA32Value()), propertyId == CSSPropertyColor);992 return normalizedColor(Color(downcast<CSSPrimitiveValue>(*value).color().rgb()), propertyId == CSSPropertyColor); 993 993 } 994 994 … … 996 996 if (RefPtr<CSSValue> value = inlineStylePropertyForElement(element, propertyId)) { 997 997 if (is<CSSPrimitiveValue>(*value) && downcast<CSSPrimitiveValue>(*value).isRGBColor()) 998 return normalizedColor(Color(downcast<CSSPrimitiveValue>(*value). getRGBA32Value()), propertyId == CSSPropertyColor);998 return normalizedColor(Color(downcast<CSSPrimitiveValue>(*value).color().rgb()), propertyId == CSSPropertyColor); 999 999 if (value->isInheritedValue()) 1000 1000 inherit = true; -
trunk/Source/WebCore/html/HTMLBodyElement.cpp
r207040 r207317 159 159 document().resetActiveLinkColor(); 160 160 } else { 161 RGBA32 color;162 if ( CSSParser::parseColor(color, value, !document().inQuirksMode())) {161 Color color = CSSParser::parseColor(value, !document().inQuirksMode()); 162 if (color.isValid()) { 163 163 if (name == linkAttr) 164 164 document().setLinkColor(color); -
trunk/Source/WebCore/html/canvas/CanvasGradient.cpp
r199537 r207317 51 51 } 52 52 53 void CanvasGradient::addColorStop(float value, const String& color , ExceptionCode& ec)53 void CanvasGradient::addColorStop(float value, const String& colorString, ExceptionCode& ec) 54 54 { 55 55 if (!(value >= 0 && value <= 1.0f)) { … … 58 58 } 59 59 60 RGBA32 rgba = 0;61 if (! parseColorOrCurrentColor(rgba, color, 0 /*canvas*/)) {60 Color color = parseColorOrCurrentColor(colorString, 0 /*canvas*/); 61 if (!color.isValid()) { 62 62 #if ENABLE(DASHBOARD_SUPPORT) 63 63 if (!m_dashboardCompatibilityMode) … … 69 69 } 70 70 71 m_gradient->addColorStop(value, Color(rgba));71 m_gradient->addColorStop(value, color); 72 72 } 73 73 -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r206538 r207317 405 405 406 406 if (style.isCurrentColor()) { 407 if (style.hasOverrideAlpha()) 408 style = CanvasStyle(colorWithOverrideAlpha(currentColor(canvas()), style.overrideAlpha())); 409 else 407 if (style.hasOverrideAlpha()) { 408 // FIXME: Should not use RGBA32 here. 409 style = CanvasStyle(colorWithOverrideAlpha(currentColor(canvas()).rgb(), style.overrideAlpha())); 410 } else 410 411 style = CanvasStyle(currentColor(canvas())); 411 412 } else … … 431 432 432 433 if (style.isCurrentColor()) { 433 if (style.hasOverrideAlpha()) 434 style = CanvasStyle(colorWithOverrideAlpha(currentColor(canvas()), style.overrideAlpha())); 435 else 434 if (style.hasOverrideAlpha()) { 435 // FIXME: Should not use RGBA32 here. 436 style = CanvasStyle(colorWithOverrideAlpha(currentColor(canvas()).rgb(), style.overrideAlpha())); 437 } else 436 438 style = CanvasStyle(currentColor(canvas())); 437 439 } else … … 579 581 } 580 582 581 void CanvasRenderingContext2D::setShadowColor(const String& color )582 { 583 RGBA32 rgba;584 if (! parseColorOrCurrentColor(rgba, color, canvas()))585 return; 586 if (state().shadowColor == rgba)587 return; 588 realizeSaves(); 589 modifiableState().shadowColor = rgba;583 void CanvasRenderingContext2D::setShadowColor(const String& colorString) 584 { 585 Color color = parseColorOrCurrentColor(colorString, canvas()); 586 if (!color.isValid()) 587 return; 588 if (state().shadowColor == color) 589 return; 590 realizeSaves(); 591 modifiableState().shadowColor = color; 590 592 applyShadow(); 591 593 } … … 1249 1251 } 1250 1252 1251 void CanvasRenderingContext2D::setShadow(float width, float height, float blur, const String& color, Optional<float> alpha) 1252 { 1253 RGBA32 rgba = Color::transparent; 1254 if (!color.isNull() && !parseColorOrCurrentColor(rgba, color, canvas())) 1255 return; 1256 setShadow(FloatSize(width, height), blur, colorWithOverrideAlpha(rgba, alpha)); 1253 void CanvasRenderingContext2D::setShadow(float width, float height, float blur, const String& colorString, Optional<float> alpha) 1254 { 1255 Color color = parseColorOrCurrentColor(colorString, canvas()); 1256 if (!colorString.isNull() && !color.isValid()) 1257 return; 1258 if (!color.isValid()) 1259 color = Color::transparent; 1260 // FIXME: Should not use RGBA32 here. 1261 setShadow(FloatSize(width, height), blur, colorWithOverrideAlpha(color.rgb(), alpha)); 1257 1262 } 1258 1263 -
trunk/Source/WebCore/html/canvas/CanvasStyle.cpp
r205892 r207317 44 44 namespace WebCore { 45 45 46 enum ColorParseResult { ParsedRGBA, ParsedCurrentColor, ParsedSystemColor, ParseFailed }; 47 48 static ColorParseResult parseColor(RGBA32& parsedColor, const String& colorString, Document* document = nullptr) 49 { 50 if (equalLettersIgnoringASCIICase(colorString, "currentcolor")) 51 return ParsedCurrentColor; 52 if (CSSParser::parseColor(parsedColor, colorString)) 53 return ParsedRGBA; 54 if (CSSParser::parseSystemColor(parsedColor, colorString, document)) 55 return ParsedSystemColor; 56 return ParseFailed; 57 } 58 59 RGBA32 currentColor(HTMLCanvasElement* canvas) 46 static bool isCurrentColorString(const String& colorString) 47 { 48 return equalLettersIgnoringASCIICase(colorString, "currentcolor"); 49 } 50 51 static Color parseColor(const String& colorString, Document* document = nullptr) 52 { 53 Color color = CSSParser::parseColor(colorString); 54 if (color.isValid()) 55 return color; 56 57 return CSSParser::parseSystemColor(colorString, document); 58 } 59 60 Color currentColor(HTMLCanvasElement* canvas) 60 61 { 61 62 if (!canvas || !canvas->inDocument() || !canvas->inlineStyle()) 62 63 return Color::black; 63 RGBA32 rgba = Color::black; 64 CSSParser::parseColor(rgba, canvas->inlineStyle()->getPropertyValue(CSSPropertyColor)); 65 return rgba; 66 } 67 68 bool parseColorOrCurrentColor(RGBA32& parsedColor, const String& colorString, HTMLCanvasElement* canvas) 69 { 70 ColorParseResult parseResult = parseColor(parsedColor, colorString, canvas ? &canvas->document() : 0); 71 switch (parseResult) { 72 case ParsedRGBA: 73 case ParsedSystemColor: 74 return true; 75 case ParsedCurrentColor: 76 parsedColor = currentColor(canvas); 77 return true; 78 case ParseFailed: 79 return false; 80 default: 81 ASSERT_NOT_REACHED(); 82 return false; 83 } 64 Color color = CSSParser::parseColor(canvas->inlineStyle()->getPropertyValue(CSSPropertyColor)); 65 if (!color.isValid()) 66 return Color::black; 67 return color; 68 } 69 70 Color parseColorOrCurrentColor(const String& colorString, HTMLCanvasElement* canvas) 71 { 72 if (isCurrentColorString(colorString)) 73 return currentColor(canvas); 74 75 return parseColor(colorString, canvas ? &canvas->document() : nullptr); 84 76 } 85 77 … … 134 126 } 135 127 136 CanvasStyle CanvasStyle::createFromString(const String& color, Document* document) 137 { 138 RGBA32 rgba; 139 ColorParseResult parseResult = parseColor(rgba, color, document); 140 switch (parseResult) { 141 case ParsedRGBA: 142 case ParsedSystemColor: 143 return CanvasStyle(rgba); 144 case ParsedCurrentColor: 128 CanvasStyle CanvasStyle::createFromString(const String& colorString, Document* document) 129 { 130 if (isCurrentColorString(colorString)) 145 131 return CanvasStyle(ConstructCurrentColor); 146 case ParseFailed: 147 return CanvasStyle(); 148 default: 149 ASSERT_NOT_REACHED(); 150 return CanvasStyle(); 151 } 152 } 153 154 CanvasStyle CanvasStyle::createFromStringWithOverrideAlpha(const String& color, float alpha) 155 { 156 RGBA32 rgba; 157 ColorParseResult parseResult = parseColor(rgba, color); 158 switch (parseResult) { 159 case ParsedRGBA: 160 return CanvasStyle(colorWithOverrideAlpha(rgba, alpha)); 161 case ParsedCurrentColor: 132 133 Color color = parseColor(colorString, document); 134 if (color.isValid()) 135 return CanvasStyle(color); 136 137 return CanvasStyle(); 138 } 139 140 CanvasStyle CanvasStyle::createFromStringWithOverrideAlpha(const String& colorString, float alpha) 141 { 142 if (isCurrentColorString(colorString)) 162 143 return CanvasStyle(CurrentColorWithOverrideAlpha, alpha); 163 case ParseFailed: 164 return CanvasStyle();165 default:166 ASSERT_NOT_REACHED();167 return CanvasStyle(); 168 }144 145 Color color = parseColor(colorString); 146 if (color.isValid()) 147 return CanvasStyle(colorWithOverrideAlpha(color.rgb(), alpha)); 148 149 return CanvasStyle(); 169 150 } 170 151 -
trunk/Source/WebCore/html/canvas/CanvasStyle.h
r205892 r207317 114 114 }; 115 115 116 RGBA32currentColor(HTMLCanvasElement*);117 bool parseColorOrCurrentColor(RGBA32& parsedColor,const String& colorString, HTMLCanvasElement*);116 Color currentColor(HTMLCanvasElement*); 117 Color parseColorOrCurrentColor(const String& colorString, HTMLCanvasElement*); 118 118 119 119 inline CanvasStyle::CanvasStyle() -
trunk/Source/WebCore/platform/graphics/Color.h
r207265 r207317 142 142 explicit Color(const char*); 143 143 144 explicit Color(WTF::HashTableDeletedValueType) 145 { 146 m_colorData.rgbaAndFlags = 0xfffffffffffffffd; 147 ASSERT(!isExtended()); 148 } 149 150 bool isHashTableDeletedValue() const 151 { 152 return m_colorData.rgbaAndFlags == 0xfffffffffffffffd; 153 } 154 155 explicit Color(WTF::HashTableEmptyValueType) 156 { 157 m_colorData.rgbaAndFlags = 0xffffffffffffffb; 158 ASSERT(!isExtended()); 159 } 160 144 161 // FIXME: Add constructor for ExtendedColor type. 145 162 … … 185 202 void setRGB(int r, int g, int b) { setRGB(makeRGB(r, g, b)); } 186 203 void setRGB(RGBA32); 204 uint64_t asUint64() const { return m_colorData.rgbaAndFlags; } 187 205 188 206 WEBCORE_EXPORT void getRGBA(float& r, float& g, float& b, float& a) const; -
trunk/Source/WebCore/svg/SVGColor.cpp
r190003 r207317 52 52 // FIXME: Move this out of the SVGColor class? 53 53 // FIXME: Is it really OK to do stripWhitespace here instead of stripLeadingAndTrailingHTMLSpaces? 54 RGBA32 color; 55 if (CSSParser::parseColor(color, colorString.stripWhiteSpace())) 56 return color; 57 return Color(); 54 return CSSParser::parseColor(colorString.stripWhiteSpace()); 58 55 } 59 56
Note: See TracChangeset
for help on using the changeset viewer.