WebKit Bugzilla
Attachment 340897 Details for
Bug 180209
: Update RGB/RGBA parsing to match CSS Color 4
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-180209-20180521174848.patch (text/plain), 7.27 KB, created by
Chris Nardi
on 2018-05-21 14:48:46 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Chris Nardi
Created:
2018-05-21 14:48:46 PDT
Size:
7.27 KB
patch
obsolete
>Subversion Revision: 231849 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 1adef6425cb6f8bf058ae5f9b2d00a707cd1ca8a..864bf238ea736642cf92928745e17b3174907509 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,21 @@ >+2018-05-21 Chris Nardi <cnardi@chromium.org> >+ >+ Update RGB/RGBA parsing to match CSS Color 4 >+ https://bugs.webkit.org/show_bug.cgi?id=180209 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ In CSS Color 4, RGB() and RGBA() were synonymized, along with allowing whitespace to >+ separate the channels instead of commas, introducing a backslash as a new way to separate >+ the alpha parameter, allowing percent values for the alpha parameter, and allowing decimal >+ values for the color channels. This updates our parsing behavior to reflect these changes, >+ and enables now-passing WPT tests. The new spec is at >+ https://drafts.csswg.org/css-color/#rgb-functions. >+ >+ * css/parser/CSSPropertyParserHelpers.cpp: >+ (WebCore::CSSPropertyParserHelpers::parseRGBParameters): >+ (WebCore::CSSPropertyParserHelpers::parseColorFunction): >+ > 2018-05-16 Chris Nardi <cnardi@chromium.org> > > Remove Document#selectedStylesheetSet/preferredStylesheetSet >diff --git a/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp b/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp >index 87f58e8569806045a71b7da3c981e8838dc16a6c..85ee12626eda870a2967a8e96f85df99eb6728a0 100644 >--- a/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp >+++ b/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp >@@ -488,12 +488,12 @@ static int clampRGBComponent(const CSSPrimitiveValue& value) > return clampTo<int>(result, 0, 255); > } > >-static Color parseRGBParameters(CSSParserTokenRange& range, bool parseAlpha) >+static Color parseRGBParameters(CSSParserTokenRange& range) > { > ASSERT(range.peek().functionId() == CSSValueRgb || range.peek().functionId() == CSSValueRgba); > Color result; > CSSParserTokenRange args = consumeFunction(range); >- RefPtr<CSSPrimitiveValue> colorParameter = consumeInteger(args); >+ RefPtr<CSSPrimitiveValue> colorParameter = consumeNumber(args, ValueRangeAll); > if (!colorParameter) > colorParameter = consumePercent(args, ValueRangeAll); > if (!colorParameter) >@@ -501,20 +501,31 @@ static Color parseRGBParameters(CSSParserTokenRange& range, bool parseAlpha) > const bool isPercent = colorParameter->isPercentage(); > int colorArray[3]; > colorArray[0] = clampRGBComponent(*colorParameter); >+ bool requiresCommas = false; > for (int i = 1; i < 3; i++) { >- if (!consumeCommaIncludingWhitespace(args)) >+ if (consumeCommaIncludingWhitespace(args)) { >+ if (i != 1 && !requiresCommas) >+ return Color(); >+ requiresCommas = true; >+ } else if (requiresCommas || args.atEnd()) > return Color(); >- colorParameter = isPercent ? consumePercent(args, ValueRangeAll) : consumeInteger(args); >+ colorParameter = isPercent ? consumePercent(args, ValueRangeAll) : consumeNumber(args, ValueRangeAll); > if (!colorParameter) > return Color(); > colorArray[i] = clampRGBComponent(*colorParameter); > } >- if (parseAlpha) { >- if (!consumeCommaIncludingWhitespace(args)) >- return Color(); >+ bool commaConsumed = consumeCommaIncludingWhitespace(args); >+ bool slashConsumed = consumeSlashIncludingWhitespace(args); >+ if ((commaConsumed && !requiresCommas) || (slashConsumed && requiresCommas)) >+ return Color(); >+ if (commaConsumed || slashConsumed) { > double alpha; >- if (!consumeNumberRaw(args, alpha)) >- return Color(); >+ if (!consumeNumberRaw(args, alpha)) { >+ auto alphaPercent = consumePercent(args, ValueRangeAll); >+ if (!alphaPercent) >+ return Color(); >+ alpha = alphaPercent->doubleValue() / 100.0f; >+ } > // Convert the floating pointer number of alpha to an integer in the range [0, 256), > // with an equal distribution across all 256 values. > int alphaComponent = static_cast<int>(clampTo<double>(alpha, 0.0, 1.0) * nextafter(256.0, 0.0)); >@@ -668,7 +679,7 @@ static Color parseColorFunction(CSSParserTokenRange& range, CSSParserMode cssPar > switch (functionId) { > case CSSValueRgb: > case CSSValueRgba: >- color = parseRGBParameters(colorRange, functionId == CSSValueRgba); >+ color = parseRGBParameters(colorRange); > break; > case CSSValueHsl: > case CSSValueHsla: >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index a6c15b8b7a27d001780540b48b336fbca6010b0c..1a1e2ae041b05599e1c597c98d22999acd1125a3 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,14 @@ >+2018-05-21 Chris Nardi <cnardi@chromium.org> >+ >+ Update RGB/RGBA parsing to match CSS Color 4 >+ https://bugs.webkit.org/show_bug.cgi?id=180209 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Enable now-passing tests. >+ >+ * TestExpectations: >+ > 2018-05-16 Chris Nardi <cnardi@chromium.org> > > Remove Document#selectedStylesheetSet/preferredStylesheetSet >diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations >index d8ad7a168352c9838e85a3fea8f907589b5d494f..4b7020cfac195b3829b73efa2b2081cc6a026bd7 100644 >--- a/LayoutTests/TestExpectations >+++ b/LayoutTests/TestExpectations >@@ -1134,24 +1134,6 @@ imported/w3c/web-platform-tests/css/css-color/lch-005.html [ Skip ] > imported/w3c/web-platform-tests/css/css-color/lch-006.html [ Skip ] > imported/w3c/web-platform-tests/css/css-color/lch-007.html [ Skip ] > >-# New rgb/rgba syntax not supported >-webkit.org/b/180209 imported/w3c/web-platform-tests/css/css-color/rgb-001.html [ Skip ] >-webkit.org/b/180209 imported/w3c/web-platform-tests/css/css-color/rgb-002.html [ Skip ] >-webkit.org/b/180209 imported/w3c/web-platform-tests/css/css-color/rgb-003.html [ Skip ] >-webkit.org/b/180209 imported/w3c/web-platform-tests/css/css-color/rgb-004.html [ Skip ] >-webkit.org/b/180209 imported/w3c/web-platform-tests/css/css-color/rgb-005.html [ Skip ] >-webkit.org/b/180209 imported/w3c/web-platform-tests/css/css-color/rgb-006.html [ Skip ] >-webkit.org/b/180209 imported/w3c/web-platform-tests/css/css-color/rgb-007.html [ Skip ] >-webkit.org/b/180209 imported/w3c/web-platform-tests/css/css-color/rgb-008.html [ Skip ] >-webkit.org/b/180209 imported/w3c/web-platform-tests/css/css-color/rgba-001.html [ Skip ] >-webkit.org/b/180209 imported/w3c/web-platform-tests/css/css-color/rgba-002.html [ Skip ] >-webkit.org/b/180209 imported/w3c/web-platform-tests/css/css-color/rgba-003.html [ Skip ] >-webkit.org/b/180209 imported/w3c/web-platform-tests/css/css-color/rgba-004.html [ Skip ] >-webkit.org/b/180209 imported/w3c/web-platform-tests/css/css-color/rgba-005.html [ Skip ] >-webkit.org/b/180209 imported/w3c/web-platform-tests/css/css-color/rgba-006.html [ Skip ] >-webkit.org/b/180209 imported/w3c/web-platform-tests/css/css-color/rgba-007.html [ Skip ] >-webkit.org/b/180209 imported/w3c/web-platform-tests/css/css-color/rgba-008.html [ Skip ] >- > # Initial failures on the import of css-color > imported/w3c/web-platform-tests/css/css-color/currentcolor-002.html [ ImageOnlyFailure ] > imported/w3c/web-platform-tests/css/css-color/t31-color-text-a.xht [ ImageOnlyFailure ]
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 180209
:
340897
|
340914
|
340917
|
340922
|
340923
|
340926