Changeset 288134 in webkit
- Timestamp:
- Jan 18, 2022 11:59:53 AM (6 months ago)
- Location:
- trunk
- Files:
-
- 18 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/canvas/canvas-color-serialization.html (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/fill-and-stroke-styles/2d.fillStyle.toStringFunctionCallback-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/applicationmanifest/ApplicationManifestParser.cpp (modified) (1 diff)
-
Source/WebCore/css/StyleProperties.cpp (modified) (1 diff)
-
Source/WebCore/css/parser/CSSParser.cpp (modified) (1 diff)
-
Source/WebCore/css/parser/CSSParser.h (modified) (1 diff)
-
Source/WebCore/editing/EditingStyle.cpp (modified) (1 diff)
-
Source/WebCore/html/HTMLBodyElement.cpp (modified) (1 diff)
-
Source/WebCore/html/HTMLMetaElement.cpp (modified) (1 diff)
-
Source/WebCore/html/canvas/CanvasStyle.cpp (modified) (3 diffs)
-
Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.h (modified) (1 diff)
-
Source/WebCore/svg/properties/SVGPropertyTraits.h (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/API/wpe/WebKitColor.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r288132 r288134 1 2022-01-18 Sam Weinig <weinig@apple.com> 2 3 Canvas functions that take colors as strings don't support all the syntax that CSS supports 4 https://bugs.webkit.org/show_bug.cgi?id=235269 5 6 Reviewed by Darin Adler. 7 8 * fast/canvas/canvas-color-serialization.html: 9 Update doctype to set the correct CSS parsing mode which now needs to be set correctly for canvas color setting functions. 10 1 11 2022-01-18 Patrick Griffis <pgriffis@igalia.com> 2 12 -
trunk/LayoutTests/fast/canvas/canvas-color-serialization.html
r267645 r288134 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">1 <!DOCTYPE HTML> 2 2 <html> 3 3 <head> -
trunk/LayoutTests/imported/w3c/ChangeLog
r288132 r288134 1 2022-01-18 Sam Weinig <weinig@apple.com> 2 3 Canvas functions that take colors as strings don't support all the syntax that CSS supports 4 https://bugs.webkit.org/show_bug.cgi?id=235269 5 6 Reviewed by Darin Adler. 7 8 Update expected results now that the test is passing. 9 10 * web-platform-tests/html/canvas/element/fill-and-stroke-styles/2d.fillStyle.toStringFunctionCallback-expected.txt: 11 1 12 2022-01-18 Patrick Griffis <pgriffis@igalia.com> 2 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/canvas/element/fill-and-stroke-styles/2d.fillStyle.toStringFunctionCallback-expected.txt
r279427 r288134 3 3 Actual output: 4 4 5 FAIL Passing a function in to ctx.fillStyle or ctx.strokeStyle with a toString callback works as specified assert_equals: ctx.fillStyle === "#008000" (got #800000[string], expected #008000[string]) expected "#008000" but got "#800000" 5 PASS Passing a function in to ctx.fillStyle or ctx.strokeStyle with a toString callback works as specified 6 6 -
trunk/Source/WebCore/ChangeLog
r288133 r288134 1 2022-01-18 Sam Weinig <weinig@apple.com> 2 3 Canvas functions that take colors as strings don't support all the syntax that CSS supports 4 https://bugs.webkit.org/show_bug.cgi?id=235269 5 6 Reviewed by Darin Adler. 7 8 Add a variant of CSSParser::parseColor() that takes a CSSParserContext 9 and use it (and parser context created from a document) to get the parser 10 to respect the settings. Rename the existing CSSParser::parseColor() to 11 CSSParser::parseColorWithoutContext() and add a comment indicating all 12 uses should eventually be removed. 13 14 Offscreen canvas and custom paint canvas are using the old path with https://webkit.org/b/235270 15 tracking finding a solution for them. 16 17 * Modules/applicationmanifest/ApplicationManifestParser.cpp: 18 (WebCore::ApplicationManifestParser::parseColor): 19 * css/StyleProperties.cpp: 20 (WebCore::StyleProperties::propertyAsColor const): 21 * css/parser/CSSParser.cpp: 22 (WebCore::CSSParser::parseColor): 23 (WebCore::CSSParser::parseColorWithoutContext): 24 * css/parser/CSSParser.h: 25 * editing/EditingStyle.cpp: 26 (WebCore::cssValueToColor): 27 * html/HTMLBodyElement.cpp: 28 (WebCore::HTMLBodyElement::parseAttribute): 29 * html/HTMLMetaElement.cpp: 30 (WebCore::HTMLMetaElement::contentColor): 31 * html/canvas/CanvasStyle.cpp: 32 (WebCore::parseColor): 33 (WebCore::currentColor): 34 * svg/properties/SVGAnimationAdditiveValueFunctionImpl.h: 35 * svg/properties/SVGPropertyTraits.h: 36 (WebCore::SVGPropertyTraits<Color>::fromString): 37 (WebCore::SVGPropertyTraits<Color>::parse): 38 1 39 2022-01-18 Alex Christensen <achristensen@webkit.org> 2 40 -
trunk/Source/WebCore/Modules/applicationmanifest/ApplicationManifestParser.cpp
r286073 r288134 321 321 Color ApplicationManifestParser::parseColor(const JSON::Object& manifest, const String& propertyName) 322 322 { 323 return CSSParser::parseColor (parseGenericString(manifest, propertyName));323 return CSSParser::parseColorWithoutContext(parseGenericString(manifest, propertyName)); 324 324 } 325 325 -
trunk/Source/WebCore/css/StyleProperties.cpp
r287909 r288134 348 348 349 349 auto& primitiveColor = downcast<CSSPrimitiveValue>(*colorValue); 350 return primitiveColor.isRGBColor() ? primitiveColor.color() : CSSParser::parseColor (colorValue->cssText());350 return primitiveColor.isRGBColor() ? primitiveColor.color() : CSSParser::parseColorWithoutContext(colorValue->cssText()); 351 351 } 352 352 -
trunk/Source/WebCore/css/parser/CSSParser.cpp
r284095 r288134 95 95 } 96 96 97 Color CSSParser::parseColor(const String& string, bool strict) 97 Color CSSParser::parseColor(const String& string, const CSSParserContext& context) 98 { 99 bool strict = !isQuirksModeBehavior(context.mode); 100 if (auto color = CSSParserFastPaths::parseSimpleColor(string, strict)) 101 return *color; 102 auto value = parseSingleValue(CSSPropertyColor, string, context); 103 if (!is<CSSPrimitiveValue>(value)) 104 return { }; 105 auto& primitiveValue = downcast<CSSPrimitiveValue>(*value); 106 if (!primitiveValue.isRGBColor()) 107 return { }; 108 return primitiveValue.color(); 109 } 110 111 Color CSSParser::parseColorWithoutContext(const String& string, bool strict) 98 112 { 99 113 if (auto color = CSSParserFastPaths::parseSimpleColor(string, strict)) -
trunk/Source/WebCore/css/parser/CSSParser.h
r281426 r288134 89 89 RefPtr<CSSValue> parseValueWithVariableReferences(CSSPropertyID, const CSSValue&, Style::BuilderState&); 90 90 91 WEBCORE_EXPORT static Color parseColor(const String&, bool strict = false); 91 WEBCORE_EXPORT static Color parseColor(const String&, const CSSParserContext&); 92 // FIXME: All callers are not getting the right Settings for parsing due to lack of CSSParserContext and should switch to the parseColor function above. 93 WEBCORE_EXPORT static Color parseColorWithoutContext(const String&, bool strict = false); 92 94 static Color parseSystemColor(StringView); 93 95 static std::optional<SRGBA<uint8_t>> parseNamedColor(StringView); -
trunk/Source/WebCore/editing/EditingStyle.cpp
r287138 r288134 440 440 return primitiveColor.color(); 441 441 442 return CSSParser::parseColor (colorValue->cssText());442 return CSSParser::parseColorWithoutContext(colorValue->cssText()); 443 443 } 444 444 -
trunk/Source/WebCore/html/HTMLBodyElement.cpp
r287089 r288134 124 124 document().resetActiveLinkColor(); 125 125 } else { 126 Color color = CSSParser::parseColor (value, !document().inQuirksMode());126 Color color = CSSParser::parseColorWithoutContext(value, !document().inQuirksMode()); 127 127 if (color.isValid()) { 128 128 if (name == linkAttr) -
trunk/Source/WebCore/html/HTMLMetaElement.cpp
r283851 r288134 86 86 { 87 87 if (!m_contentColor) 88 m_contentColor = CSSParser::parseColor (content());88 m_contentColor = CSSParser::parseColorWithoutContext(content()); 89 89 return *m_contentColor; 90 90 } -
trunk/Source/WebCore/html/canvas/CanvasStyle.cpp
r284095 r288134 45 45 #endif 46 46 47 #if USE(CG)48 #include <CoreGraphics/CGContext.h>49 #endif50 51 47 namespace WebCore { 52 48 … … 59 55 { 60 56 #if ENABLE(OFFSCREEN_CANVAS) 61 if ( canvasBase.isOffscreenCanvas())57 if (is<OffscreenCanvas>(canvasBase)) 62 58 return CSSPropertyParserWorkerSafe::parseColor(colorString); 63 #else64 UNUSED_PARAM(canvasBase);65 59 #endif 66 Color color = CSSParser::parseColor(colorString); 60 61 Color color; 62 if (is<HTMLCanvasElement>(canvasBase)) 63 color = CSSParser::parseColor(colorString, CSSParserContext { downcast<HTMLCanvasElement>(canvasBase).document() }); 64 else 65 color = CSSParser::parseColorWithoutContext(colorString); 66 67 67 if (color.isValid()) 68 68 return color; … … 78 78 if (!canvas.isConnected() || !canvas.inlineStyle()) 79 79 return Color::black; 80 Color color = CSSParser::parseColor (canvas.inlineStyle()->getPropertyValue(CSSPropertyColor));80 Color color = CSSParser::parseColorWithoutContext(canvas.inlineStyle()->getPropertyValue(CSSPropertyColor)); 81 81 if (!color.isValid()) 82 82 return Color::black; -
trunk/Source/WebCore/svg/properties/SVGAnimationAdditiveValueFunctionImpl.h
r287552 r288134 97 97 std::optional<float> calculateDistance(SVGElement&, const String& from, const String& to) const override 98 98 { 99 Color fromColor = CSSParser::parseColor (from.stripWhiteSpace());99 Color fromColor = CSSParser::parseColorWithoutContext(from.stripWhiteSpace()); 100 100 if (!fromColor.isValid()) 101 101 return { }; 102 Color toColor = CSSParser::parseColor (to.stripWhiteSpace());102 Color toColor = CSSParser::parseColorWithoutContext(to.stripWhiteSpace()); 103 103 if (!toColor.isValid()) 104 104 return { }; -
trunk/Source/WebCore/svg/properties/SVGPropertyTraits.h
r287731 r288134 46 46 struct SVGPropertyTraits<Color> { 47 47 static Color initialValue() { return Color(); } 48 static Color fromString(const String& string) { return CSSParser::parseColor (string.stripWhiteSpace()); }48 static Color fromString(const String& string) { return CSSParser::parseColorWithoutContext(string.stripWhiteSpace()); } 49 49 static std::optional<Color> parse(const QualifiedName&, const String& string) 50 50 { 51 Color color = CSSParser::parseColor (string.stripWhiteSpace());51 Color color = CSSParser::parseColorWithoutContext(string.stripWhiteSpace()); 52 52 if (!color.isValid()) 53 53 return std::nullopt; -
trunk/Source/WebKit/ChangeLog
r288128 r288134 1 2022-01-18 Sam Weinig <weinig@apple.com> 2 3 Canvas functions that take colors as strings don't support all the syntax that CSS supports 4 https://bugs.webkit.org/show_bug.cgi?id=235269 5 6 Reviewed by Darin Adler. 7 8 Update for rename of CSSParser::parseColor() to CSSParser::parseColorWithoutContext(). 9 10 * UIProcess/API/wpe/WebKitColor.cpp: 11 (webkit_color_parse): 12 * WebProcess/InjectedBundle/API/c/WKBundlePage.cpp: 13 (WKBundlePageSetComposition): 14 1 15 2022-01-18 Alex Christensen <achristensen@webkit.org> 2 16 -
trunk/Source/WebKit/UIProcess/API/wpe/WebKitColor.cpp
r287552 r288134 109 109 g_return_val_if_fail(colorString, FALSE); 110 110 111 auto webCoreColor = WebCore::CSSParser::parseColor ({ colorString });111 auto webCoreColor = WebCore::CSSParser::parseColorWithoutContext({ colorString }); 112 112 if (!webCoreColor.isValid()) 113 113 return FALSE; -
trunk/Source/WebKit/WebProcess/InjectedBundle/API/c/WKBundlePage.cpp
r286767 r288134 627 627 static_cast<unsigned>(startOffset), 628 628 static_cast<unsigned>(startOffset + static_cast<API::UInt64*>(dictionary->get("length"))->value()), 629 WebCore::CSSParser::parseColor (static_cast<API::String*>(dictionary->get("color"))->string())629 WebCore::CSSParser::parseColorWithoutContext(static_cast<API::String*>(dictionary->get("color"))->string()) 630 630 }); 631 631 }
Note: See TracChangeset
for help on using the changeset viewer.