Title: [192023] trunk
Revision
192023
Author
d...@apple.com
Date
2015-11-04 09:49:46 -0800 (Wed, 04 Nov 2015)

Log Message

Accept 8 and 4 value hex colors (#RRGGBBAA)
https://bugs.webkit.org/show_bug.cgi?id=150853
<rdar://problem/23380930>

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

Delete these tests. The have been updated in the original repository,
so we'll get the new versions soon. Meanwhile, they are covered by
other tests.

* canvas/2d.fillStyle.parse.invalid.hex4-expected.txt: Removed.
* canvas/2d.fillStyle.parse.invalid.hex4.html: Removed.
* canvas/2d.fillStyle.parse.invalid.hex8-expected.txt: Removed.
* canvas/2d.fillStyle.parse.invalid.hex8.html: Removed.
* css/css-color-3/t421-rgb-hex-parsing-f.xht:

Source/WebCore:

CSS Color Level 4 allows #RGBA and #RRGGBBAA values
for colors.

Test: fast/css/hex-colors.html

* platform/graphics/Color.cpp:
(WebCore::parseHexColorInternal): Update the color parsing for
the new syntax.

LayoutTests:

Add a new test for hex colors that covers 4 and 8 value forms.
Also update existing tests now that the syntax has changed.

For the deleted philip tests, they are now in the W3C web-latform-tests import.

* canvas/philip/tests/2d.fillStyle.parse.invalid.hex4-expected.txt: Removed.
* canvas/philip/tests/2d.fillStyle.parse.invalid.hex4.html: Removed.
* canvas/philip/tests/2d.fillStyle.parse.invalid.hex8-expected.txt: Removed.
* canvas/philip/tests/2d.fillStyle.parse.invalid.hex8.html: Removed.
* fast/css/hex-colors-expected.txt: Added.
* fast/css/hex-colors.html: Added.
* fast/css/invalid-hex-color-expected.txt:
* fast/css/invalid-hex-color.html:
* fast/css/invalid-predefined-color-expected.txt:
* fast/css/invalid-predefined-color.html:
* fast/css/script-tests/invalid-predefined-color.js:
* fast/dom/attribute-legacy-colors-expected.txt:
* fast/dom/script-tests/attribute-legacy-colors.js:
* svg/dom/rgb-color-parser-expected.txt:
* svg/dom/rgb-color-parser.html:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (192022 => 192023)


--- trunk/LayoutTests/ChangeLog	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/ChangeLog	2015-11-04 17:49:46 UTC (rev 192023)
@@ -1,3 +1,32 @@
+2015-11-03  Dean Jackson  <d...@apple.com>
+
+        Accept 8 and 4 value hex colors (#RRGGBBAA)
+        https://bugs.webkit.org/show_bug.cgi?id=150853
+        <rdar://problem/23380930>
+
+        Reviewed by Simon Fraser.
+
+        Add a new test for hex colors that covers 4 and 8 value forms.
+        Also update existing tests now that the syntax has changed.
+
+        For the deleted philip tests, they are now in the W3C web-latform-tests import.
+
+        * canvas/philip/tests/2d.fillStyle.parse.invalid.hex4-expected.txt: Removed.
+        * canvas/philip/tests/2d.fillStyle.parse.invalid.hex4.html: Removed.
+        * canvas/philip/tests/2d.fillStyle.parse.invalid.hex8-expected.txt: Removed.
+        * canvas/philip/tests/2d.fillStyle.parse.invalid.hex8.html: Removed.
+        * fast/css/hex-colors-expected.txt: Added.
+        * fast/css/hex-colors.html: Added.
+        * fast/css/invalid-hex-color-expected.txt:
+        * fast/css/invalid-hex-color.html:
+        * fast/css/invalid-predefined-color-expected.txt:
+        * fast/css/invalid-predefined-color.html:
+        * fast/css/script-tests/invalid-predefined-color.js:
+        * fast/dom/attribute-legacy-colors-expected.txt:
+        * fast/dom/script-tests/attribute-legacy-colors.js:
+        * svg/dom/rgb-color-parser-expected.txt:
+        * svg/dom/rgb-color-parser.html:
+
 2015-11-04  Joanmarie Diggs  <jdi...@igalia.com>
 
         [AX] WebProcess from WebKitGtk+ 2.10.0 compiled in Debug mode hits ASSERT on textUnderElement

Deleted: trunk/LayoutTests/canvas/philip/tests/2d.fillStyle.parse.invalid.hex4-expected.txt (192022 => 192023)


--- trunk/LayoutTests/canvas/philip/tests/2d.fillStyle.parse.invalid.hex4-expected.txt	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/canvas/philip/tests/2d.fillStyle.parse.invalid.hex4-expected.txt	2015-11-04 17:49:46 UTC (rev 192023)
@@ -1 +0,0 @@
-Passed

Deleted: trunk/LayoutTests/canvas/philip/tests/2d.fillStyle.parse.invalid.hex4.html (192022 => 192023)


--- trunk/LayoutTests/canvas/philip/tests/2d.fillStyle.parse.invalid.hex4.html	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/canvas/philip/tests/2d.fillStyle.parse.invalid.hex4.html	2015-11-04 17:49:46 UTC (rev 192023)
@@ -1,24 +0,0 @@
-<!DOCTYPE html>
-<title>Canvas test: 2d.fillStyle.parse.invalid.hex4</title>
-<script src=""
-<link rel="stylesheet" href=""
-<body>
-<p id="passtext">Pass</p>
-<p id="failtext">Fail</p>
-<p class="output">These images should be identical:</p>
-<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
-<p class="output expectedtext">Expected output:<p><img src="" class="output expected" id="expected" alt="">
-<ul id="d"></ul>
-<script>
-_addTest(function(canvas, ctx) {
-
-
-ctx.fillStyle = '#0f0';
-try { ctx.fillStyle = '#ff00'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
-ctx.fillRect(0, 0, 100, 50);
-_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
-
-
-});
-</script>
-

Deleted: trunk/LayoutTests/canvas/philip/tests/2d.fillStyle.parse.invalid.hex8-expected.txt (192022 => 192023)


--- trunk/LayoutTests/canvas/philip/tests/2d.fillStyle.parse.invalid.hex8-expected.txt	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/canvas/philip/tests/2d.fillStyle.parse.invalid.hex8-expected.txt	2015-11-04 17:49:46 UTC (rev 192023)
@@ -1 +0,0 @@
-Passed

Deleted: trunk/LayoutTests/canvas/philip/tests/2d.fillStyle.parse.invalid.hex8.html (192022 => 192023)


--- trunk/LayoutTests/canvas/philip/tests/2d.fillStyle.parse.invalid.hex8.html	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/canvas/philip/tests/2d.fillStyle.parse.invalid.hex8.html	2015-11-04 17:49:46 UTC (rev 192023)
@@ -1,24 +0,0 @@
-<!DOCTYPE html>
-<title>Canvas test: 2d.fillStyle.parse.invalid.hex8</title>
-<script src=""
-<link rel="stylesheet" href=""
-<body>
-<p id="passtext">Pass</p>
-<p id="failtext">Fail</p>
-<p class="output">These images should be identical:</p>
-<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
-<p class="output expectedtext">Expected output:<p><img src="" class="output expected" id="expected" alt="">
-<ul id="d"></ul>
-<script>
-_addTest(function(canvas, ctx) {
-
-
-ctx.fillStyle = '#0f0';
-try { ctx.fillStyle = '#ff0000ff'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
-ctx.fillRect(0, 0, 100, 50);
-_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
-
-
-});
-</script>
-

Added: trunk/LayoutTests/fast/css/hex-colors-expected.txt (0 => 192023)


--- trunk/LayoutTests/fast/css/hex-colors-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/hex-colors-expected.txt	2015-11-04 17:49:46 UTC (rev 192023)
@@ -0,0 +1,23 @@
+PASS #000 was red:0 green: 0 blue: 0
+PASS #001 was red:0 green: 0 blue: 17
+PASS #012 was red:0 green: 17 blue: 34
+PASS #123 was red:17 green: 34 blue: 51
+PASS #0001 was red:0 green: 0 blue: 0 alpha: 17
+PASS #0012 was red:0 green: 0 blue: 17 alpha: 34
+PASS #0123 was red:0 green: 17 blue: 34 alpha: 51
+PASS #1234 was red:17 green: 34 blue: 51 alpha: 68
+PASS #000000 was red:0 green: 0 blue: 0
+PASS #000012 was red:0 green: 0 blue: 18
+PASS #001234 was red:0 green: 18 blue: 52
+PASS #123456 was red:18 green: 52 blue: 86
+PASS #00000000 was red:0 green: 0 blue: 0 alpha: 0
+PASS #00000012 was red:0 green: 0 blue: 0 alpha: 18
+PASS #00001234 was red:0 green: 0 blue: 18 alpha: 52
+PASS #00123456 was red:0 green: 18 blue: 52 alpha: 86
+PASS #12345678 was red:18 green: 52 blue: 86 alpha: 120
+PASS #12x3 was red:255 green: 0 blue: 0
+PASS #123x was red:255 green: 0 blue: 0
+PASS #123x4567 was red:255 green: 0 blue: 0
+PASS #1234567r was red:255 green: 0 blue: 0
+PASS #123456x6 was red:255 green: 0 blue: 0
+
Property changes on: trunk/LayoutTests/fast/css/hex-colors-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/fast/css/hex-colors.html (0 => 192023)


--- trunk/LayoutTests/fast/css/hex-colors.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/hex-colors.html	2015-11-04 17:49:46 UTC (rev 192023)
@@ -0,0 +1,78 @@
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+var TESTS = [
+    ["#000", 0, 0, 0],
+    ["#001", 0, 0, 17],
+    ["#012", 0, 17, 34],
+    ["#123", 17, 34, 51],
+    ["#0001", 0, 0, 0, 17],
+    ["#0012", 0, 0, 17,34],
+    ["#0123", 0, 17, 34, 51],
+    ["#1234", 17, 34, 51, 68],
+    ["#000000", 0, 0, 0],
+    ["#000012", 0, 0, 18],
+    ["#001234", 0, 18, 52],
+    ["#123456", 18, 52, 86],
+    ["#00000000", 0, 0, 0, 0],
+    ["#00000012", 0, 0, 0, 18],
+    ["#00001234", 0, 0, 18, 52],
+    ["#00123456", 0, 18, 52, 86],
+    ["#12345678", 18, 52, 86, 120],
+    // Bad content from here on shows the red failure color.
+    ["#12x3", 255, 0, 0],
+    ["#123x", 255, 0, 0],
+    ["#123x4567", 255, 0, 0],
+    ["#1234567r", 255, 0, 0],
+    ["#123456x6", 255, 0, 0],
+];
+
+function extractComponents(rgbValue) {
+    var re = /rgba?\((\d+),\s(\d+),\s(\d+)(,\s([\d\.]+))?\)/;
+    var match = re.exec(rgbValue);
+    var results = [parseInt(match[1]), parseInt(match[2]), parseInt(match[3])];
+    if (match[5])
+        results.push(Math.round(parseFloat(match[5]) * 255));
+    return results;
+}
+
+function componentsMatch(components, expectedR, expectedG, expectedB, expectedA) {
+    if (components[0] == expectedR && components[1] == expectedG && components[2] == expectedB) {
+        if (components.length != 4)
+            return true;
+        return components[3] == expectedA;
+    }
+}
+
+function componentsAsRGBA(r, g, b, a) {
+    if (a !== undefined)
+        return "red:" + r + " green: " + g + " blue: " + b + " alpha: " + a;
+    return "red:" + r + " green: " + g + " blue: " + b;
+}
+
+function runTest() {
+    var element = document.querySelector("p");
+    var results = "";
+
+    for (var test of TESTS) {
+        element.style.color = test[0];
+        var components = extractComponents(window.getComputedStyle(element).color);
+        if (componentsMatch(components, test[1], test[2], test[3], test[4]))
+            results += "PASS " + test[0] + " was " + componentsAsRGBA(test[1], test[2], test[3], test[4]) + "<br>";
+        else
+            results += "FAIL " + test[0] + " should be " + componentsAsRGBA(test[1], test[2], test[3], test[4]) + " but was " + componentsAsRGBA(components[0], components[1], components[2], components[3]) + "<br>";
+
+        // Force a color reset and style recalc.
+        element.style.color = "red";
+        computedStyle = window.getComputedStyle(element).color;
+    }
+
+    document.querySelector("div").innerHTML = results;
+}
+
+window.addEventListener("load", runTest, false);
+</script>
+<div id="results"></div>
+<p></p>
+
Property changes on: trunk/LayoutTests/fast/css/hex-colors.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Modified: trunk/LayoutTests/fast/css/invalid-hex-color-expected.txt (192022 => 192023)


--- trunk/LayoutTests/fast/css/invalid-hex-color-expected.txt	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/fast/css/invalid-hex-color-expected.txt	2015-11-04 17:49:46 UTC (rev 192023)
@@ -2,15 +2,17 @@
 Test 1 (Invalid: 1 hexadecimal digits) [EXPECTED] [ACTUAL] PASS
 Test 2 (Invalid: 2 hexadecimal digits) [EXPECTED] [ACTUAL] PASS
 Test 3 (Valid: 3 hexadecimal digits) [EXPECTED] [ACTUAL] PASS
-Test 4 (Invalid: 4 hexadecimal digits) [EXPECTED] [ACTUAL] PASS
+Test 4 (Valid: 4 hexadecimal digits) [EXPECTED] [ACTUAL] PASS
 Test 5 (Invalid: 5 hexadecimal digits) [EXPECTED] [ACTUAL] PASS
 Test 6 (Valid: 6 hexadecimal digits) [EXPECTED] [ACTUAL] PASS
 Test 7 (Invalid: 7 hexadecimal digits) [EXPECTED] [ACTUAL] PASS
-Test 8 (Invalid: 0 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
-Test 9 (Invalid: 1 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
-Test 10 (Invalid: 2 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
-Test 11 (Invalid: 3 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
-Test 12 (Invalid: 4 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
-Test 13 (Invalid: 5 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
-Test 14 (Invalid: 6 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
-Test 15 (Invalid: 7 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
+Test 8 (Valid: 8 hexadecimal digits) [EXPECTED] [ACTUAL] PASS
+Test 9 (Invalid: 0 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
+Test 10 (Invalid: 1 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
+Test 11 (Invalid: 2 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
+Test 12 (Invalid: 3 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
+Test 13 (Invalid: 4 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
+Test 14 (Invalid: 5 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
+Test 15 (Invalid: 6 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
+Test 16 (Invalid: 7 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
+Test 17 (Invalid: 8 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS

Modified: trunk/LayoutTests/fast/css/invalid-hex-color.html (192022 => 192023)


--- trunk/LayoutTests/fast/css/invalid-hex-color.html	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/fast/css/invalid-hex-color.html	2015-11-04 17:49:46 UTC (rev 192023)
@@ -19,10 +19,11 @@
         ["Invalid: 1 hexadecimal digits", "", "border-bottom: solid #1"],
         ["Invalid: 2 hexadecimal digits", "", "border-bottom: solid #11"],
         ["Valid: 3 hexadecimal digits", "border-bottom: solid rgb(17,17,17)", "border-bottom: solid #111"],
-        ["Invalid: 4 hexadecimal digits", "", "border-bottom: solid #1111"],
+        ["Valid: 4 hexadecimal digits", "border-bottom: solid rgba(17,17,17,255)", "border-bottom: solid #111f"],
         ["Invalid: 5 hexadecimal digits", "", "border-bottom: solid #11111"],
         ["Valid: 6 hexadecimal digits", "border-bottom: solid rgb(17,17,17)", "border-bottom: solid #111111"],
         ["Invalid: 7 hexadecimal digits", "", "border-bottom: solid #1111111"],
+        ["Valid: 8 hexadecimal digits", "border-bottom: solid rgba(17,17,17,255)", "border-bottom: solid #111111ff"],
         ["Invalid: 0 hexadecimal digits concatenated with 'px'", "", "border-bottom: solid #px"],
         ["Invalid: 1 hexadecimal digits concatenated with 'px'", "", "border-bottom: solid #1px"],
         ["Invalid: 2 hexadecimal digits concatenated with 'px'", "", "border-bottom: solid #11px"],
@@ -31,6 +32,7 @@
         ["Invalid: 5 hexadecimal digits concatenated with 'px'", "", "border-bottom: solid #11111px"],
         ["Invalid: 6 hexadecimal digits concatenated with 'px'", "", "border-bottom: solid #111111px"],
         ["Invalid: 7 hexadecimal digits concatenated with 'px'", "", "border-bottom: solid #1111111px"],
+        ["Invalid: 8 hexadecimal digits concatenated with 'px'", "", "border-bottom: solid #11111111px"],
     ];
 
     var testHtml = "";

Modified: trunk/LayoutTests/fast/css/invalid-predefined-color-expected.txt (192022 => 192023)


--- trunk/LayoutTests/fast/css/invalid-predefined-color-expected.txt	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/fast/css/invalid-predefined-color-expected.txt	2015-11-04 17:49:46 UTC (rev 192023)
@@ -12,7 +12,6 @@
 PASS getComputedStyle(div, null).color is black
 PASS getComputedStyle(div, null).color is black
 PASS getComputedStyle(div, null).color is black
-PASS getComputedStyle(div, null).color is black
 PASS successfullyParsed is true
 
 TEST COMPLETE
@@ -25,4 +24,3 @@
 This style is "color: #yellow"
 This style is "color: #green"
 This style is "color: #FFAALL"
-This style is "color: #FF000000"

Modified: trunk/LayoutTests/fast/css/invalid-predefined-color.html (192022 => 192023)


--- trunk/LayoutTests/fast/css/invalid-predefined-color.html	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/fast/css/invalid-predefined-color.html	2015-11-04 17:49:46 UTC (rev 192023)
@@ -14,7 +14,6 @@
 <div id="invalid2" style="color: #yellow">This style is "color: #yellow"</div>
 <div id="invalid3" style="color: #green">This style is "color: #green"</div>
 <div id="invalid4" style="color: #FFAALL">This style is "color: #FFAALL"</div>
-<div id="invalid5" style="color: #FF000000">This style is "color: #FF000000"</div>
 
 <script src=""
 <script src=""

Modified: trunk/LayoutTests/fast/css/script-tests/invalid-predefined-color.js (192022 => 192023)


--- trunk/LayoutTests/fast/css/script-tests/invalid-predefined-color.js	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/fast/css/script-tests/invalid-predefined-color.js	2015-11-04 17:49:46 UTC (rev 192023)
@@ -11,7 +11,7 @@
     shouldBe("getComputedStyle(div, null).color", "red");
 }
 
-for (var i=1;i<=5;i++)
+for (var i=1;i<=4;i++)
 {
     var div = document.getElementById("invalid"+i);
     shouldBe("getComputedStyle(div, null).color", "black");

Modified: trunk/LayoutTests/fast/dom/attribute-legacy-colors-expected.txt (192022 => 192023)


--- trunk/LayoutTests/fast/dom/attribute-legacy-colors-expected.txt	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/fast/dom/attribute-legacy-colors-expected.txt	2015-11-04 17:49:46 UTC (rev 192023)
@@ -16,7 +16,6 @@
 PASS document.body.bgColor='#ffzzzz';getComputedStyle(document.body).backgroundColor; is 'rgb(255, 0, 0)'
 PASS document.body.bgColor='f00';getComputedStyle(document.body).backgroundColor; is 'rgb(15, 0, 0)'
 PASS document.body.bgColor='ff0000';getComputedStyle(document.body).backgroundColor; is 'rgb(255, 0, 0)'
-PASS document.body.bgColor='#00000000';getComputedStyle(document.body).backgroundColor; is 'rgb(0, 0, 0)'
 PASS document.body.bgColor='foo';getComputedStyle(document.body).backgroundColor; is 'rgb(15, 0, 0)'
 PASS document.body.bgColor='cheese';getComputedStyle(document.body).backgroundColor; is 'rgb(192, 238, 14)'
 PASS document.body.bgColor='ff򀿿ff';getComputedStyle(document.body).backgroundColor; is 'rgb(255, 0, 255)'
@@ -35,11 +34,9 @@
 PASS document.body.bgColor='#5';getComputedStyle(document.body).backgroundColor; is 'rgb(5, 0, 0)'
 PASS document.body.bgColor='#55';getComputedStyle(document.body).backgroundColor; is 'rgb(5, 5, 0)'
 PASS document.body.bgColor='#555';getComputedStyle(document.body).backgroundColor; is 'rgb(85, 85, 85)'
-PASS document.body.bgColor='#5555';getComputedStyle(document.body).backgroundColor; is 'rgb(85, 85, 0)'
 PASS document.body.bgColor='#55555';getComputedStyle(document.body).backgroundColor; is 'rgb(85, 85, 80)'
 PASS document.body.bgColor='#555555';getComputedStyle(document.body).backgroundColor; is 'rgb(85, 85, 85)'
 PASS document.body.bgColor='#5555555';getComputedStyle(document.body).backgroundColor; is 'rgb(85, 85, 80)'
-PASS document.body.bgColor='#55555555';getComputedStyle(document.body).backgroundColor; is 'rgb(85, 85, 85)'
 PASS document.body.bgColor='5';getComputedStyle(document.body).backgroundColor; is 'rgb(5, 0, 0)'
 PASS document.body.bgColor='55';getComputedStyle(document.body).backgroundColor; is 'rgb(5, 5, 0)'
 PASS document.body.bgColor='555';getComputedStyle(document.body).backgroundColor; is 'rgb(5, 5, 5)'

Modified: trunk/LayoutTests/fast/dom/script-tests/attribute-legacy-colors.js (192022 => 192023)


--- trunk/LayoutTests/fast/dom/script-tests/attribute-legacy-colors.js	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/fast/dom/script-tests/attribute-legacy-colors.js	2015-11-04 17:49:46 UTC (rev 192023)
@@ -15,7 +15,6 @@
 	{'test':'#ffzzzz', 'expected':[255, 0, 0]},
 	{'test':'f00', 'expected':[15, 0, 0]},
 	{'test':'ff0000', 'expected':[255, 0, 0]},
-	{'test':'#00000000', 'expected':[0, 0, 0]},
 	{'test':'foo', 'expected':[15, 0, 0]},
 	{'test':'cheese', 'expected':[192, 238, 14]},
 	{'test':'ff򀿿ff', 'expected':[255, 0, 255]},
@@ -34,11 +33,9 @@
 	{'test':'#5', 'expected':[5, 0, 0]},
 	{'test':'#55', 'expected':[5, 5, 0]},
 	{'test':'#555', 'expected':[85, 85, 85]},
-	{'test':'#5555', 'expected':[85, 85, 0]},
 	{'test':'#55555', 'expected':[85, 85, 80]},
 	{'test':'#555555', 'expected':[85, 85, 85]},
 	{'test':'#5555555', 'expected':[85, 85, 80]},
-	{'test':'#55555555', 'expected':[85, 85, 85]},
 	{'test':'5', 'expected':[5, 0, 0]},
 	{'test':'55', 'expected':[5, 5, 0]},
 	{'test':'555', 'expected':[5, 5, 5]},

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (192022 => 192023)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2015-11-04 17:49:46 UTC (rev 192023)
@@ -1,3 +1,21 @@
+2015-11-03  Dean Jackson  <d...@apple.com>
+
+        Accept 8 and 4 value hex colors (#RRGGBBAA)
+        https://bugs.webkit.org/show_bug.cgi?id=150853
+        <rdar://problem/23380930>
+
+        Reviewed by Simon Fraser.
+
+        Delete these tests. The have been updated in the original repository,
+        so we'll get the new versions soon. Meanwhile, they are covered by
+        other tests.
+
+        * canvas/2d.fillStyle.parse.invalid.hex4-expected.txt: Removed.
+        * canvas/2d.fillStyle.parse.invalid.hex4.html: Removed.
+        * canvas/2d.fillStyle.parse.invalid.hex8-expected.txt: Removed.
+        * canvas/2d.fillStyle.parse.invalid.hex8.html: Removed.
+        * css/css-color-3/t421-rgb-hex-parsing-f.xht:
+
 2015-11-02  Jon Honeycutt  <jhoneyc...@apple.com>
 
         Implement support for the autocomplete attribute

Deleted: trunk/LayoutTests/imported/w3c/canvas/2d.fillStyle.parse.invalid.hex4-expected.txt (192022 => 192023)


--- trunk/LayoutTests/imported/w3c/canvas/2d.fillStyle.parse.invalid.hex4-expected.txt	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/imported/w3c/canvas/2d.fillStyle.parse.invalid.hex4-expected.txt	2015-11-04 17:49:46 UTC (rev 192023)
@@ -1,6 +0,0 @@
-2d.fillStyle.parse.invalid.hex4
-Spec references: 2d.colours.parse
-Actual output:
-Expected output:
-
-Passed

Deleted: trunk/LayoutTests/imported/w3c/canvas/2d.fillStyle.parse.invalid.hex4.html (192022 => 192023)


--- trunk/LayoutTests/imported/w3c/canvas/2d.fillStyle.parse.invalid.hex4.html	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/imported/w3c/canvas/2d.fillStyle.parse.invalid.hex4.html	2015-11-04 17:49:46 UTC (rev 192023)
@@ -1,33 +0,0 @@
-<!DOCTYPE html>
-<title>Canvas test: 2d.fillStyle.parse.invalid.hex4</title>
-<meta name="author" content="Philip Taylor">
-<script src=""
-<link rel="stylesheet" href=""
-<body class="show_output">
-
-<h1><a href="" href="" href="" href=""
-<p class="desc"></p>
-
-<div class="refs">Spec references:
-<ul>
-<li><a href=""
-</ul>
-</div>
-
-<p class="output">Actual output:</p>
-<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
-<p class="output expectedtext">Expected output:<p><img src="" class="output expected" id="expected" alt="">
-<ul id="d"></ul>
-<script>
-_addTest(function(canvas, ctx) {
-
-
-ctx.fillStyle = '#0f0';
-try { ctx.fillStyle = '#ff00'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
-ctx.fillRect(0, 0, 100, 50);
-_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
-
-
-});
-</script>
-

Deleted: trunk/LayoutTests/imported/w3c/canvas/2d.fillStyle.parse.invalid.hex8-expected.txt (192022 => 192023)


--- trunk/LayoutTests/imported/w3c/canvas/2d.fillStyle.parse.invalid.hex8-expected.txt	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/imported/w3c/canvas/2d.fillStyle.parse.invalid.hex8-expected.txt	2015-11-04 17:49:46 UTC (rev 192023)
@@ -1,6 +0,0 @@
-2d.fillStyle.parse.invalid.hex8
-Spec references: 2d.colours.parse
-Actual output:
-Expected output:
-
-Passed

Deleted: trunk/LayoutTests/imported/w3c/canvas/2d.fillStyle.parse.invalid.hex8.html (192022 => 192023)


--- trunk/LayoutTests/imported/w3c/canvas/2d.fillStyle.parse.invalid.hex8.html	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/imported/w3c/canvas/2d.fillStyle.parse.invalid.hex8.html	2015-11-04 17:49:46 UTC (rev 192023)
@@ -1,33 +0,0 @@
-<!DOCTYPE html>
-<title>Canvas test: 2d.fillStyle.parse.invalid.hex8</title>
-<meta name="author" content="Philip Taylor">
-<script src=""
-<link rel="stylesheet" href=""
-<body class="show_output">
-
-<h1><a href="" href="" href="" href=""
-<p class="desc"></p>
-
-<div class="refs">Spec references:
-<ul>
-<li><a href=""
-</ul>
-</div>
-
-<p class="output">Actual output:</p>
-<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
-<p class="output expectedtext">Expected output:<p><img src="" class="output expected" id="expected" alt="">
-<ul id="d"></ul>
-<script>
-_addTest(function(canvas, ctx) {
-
-
-ctx.fillStyle = '#0f0';
-try { ctx.fillStyle = '#ff0000ff'; } catch (e) { } // this shouldn't throw, but it shouldn't matter here if it does
-ctx.fillRect(0, 0, 100, 50);
-_assertPixel(canvas, 50,25, 0,255,0,255, "50,25", "0,255,0,255");
-
-
-});
-</script>
-

Modified: trunk/LayoutTests/imported/w3c/css/css-color-3/t421-rgb-hex-parsing-f.xht (192022 => 192023)


--- trunk/LayoutTests/imported/w3c/css/css-color-3/t421-rgb-hex-parsing-f.xht	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/imported/w3c/css/css-color-3/t421-rgb-hex-parsing-f.xht	2015-11-04 17:49:46 UTC (rev 192023)
@@ -12,10 +12,8 @@
 			p { color: green; }
 			p { color: #f; }
 			p { color: #ff; }
-			p { color: #ff00; }
 			p { color: #ff000; }
 			p { color: #ff00000; }
-			p { color: #ff000000; }
 			p { color: #ff0000000; }
 			p { color: #ff00000000; }
 		]]></style>

Modified: trunk/LayoutTests/svg/dom/rgb-color-parser-expected.txt (192022 => 192023)


--- trunk/LayoutTests/svg/dom/rgb-color-parser-expected.txt	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/svg/dom/rgb-color-parser-expected.txt	2015-11-04 17:49:46 UTC (rev 192023)
@@ -163,7 +163,6 @@
 Failed to parse: #
 Failed to parse: #f
 Failed to parse: #ff
-Failed to parse: #ffff
 Failed to parse: #fffff
 Failed to parse: #fffffff
 Failed to parse: green,
@@ -177,7 +176,9 @@
 Failed to parse: 'visual'
 Parsed as rgb(0,10,20): rgb(0, 10, 20)
 Parsed as rgb(255,255,255): #fff
+Parsed as rgb(255,255,255): #ffff
 Parsed as rgb(255,255,255): #ffffff
+Parsed as rgb(255,255,255): #ffffffff
 Parsed as rgb(255,255,255): #FFF
 Parsed as rgb(255,255,255): #FFFFFF
 Parsed as rgb(0,128,0):  green

Modified: trunk/LayoutTests/svg/dom/rgb-color-parser.html (192022 => 192023)


--- trunk/LayoutTests/svg/dom/rgb-color-parser.html	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/LayoutTests/svg/dom/rgb-color-parser.html	2015-11-04 17:49:46 UTC (rev 192023)
@@ -226,7 +226,6 @@
         parseRGBColor("#");
         parseRGBColor("#f");
         parseRGBColor("#ff");
-        parseRGBColor("#ffff");
         parseRGBColor("#fffff");
         parseRGBColor("#fffffff");
         parseRGBColor("green,");
@@ -242,7 +241,9 @@
         // Some more valid ones.
         parseRGBColor("rgb(0, 10, 20)");
         parseRGBColor("#fff");
+        parseRGBColor("#ffff");
         parseRGBColor("#ffffff");
+        parseRGBColor("#ffffffff");
         parseRGBColor("#FFF");
         parseRGBColor("#FFFFFF");
         parseRGBColor(" green");

Modified: trunk/Source/WebCore/ChangeLog (192022 => 192023)


--- trunk/Source/WebCore/ChangeLog	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/Source/WebCore/ChangeLog	2015-11-04 17:49:46 UTC (rev 192023)
@@ -1,3 +1,20 @@
+2015-11-03  Dean Jackson  <d...@apple.com>
+
+        Accept 8 and 4 value hex colors (#RRGGBBAA)
+        https://bugs.webkit.org/show_bug.cgi?id=150853
+        <rdar://problem/23380930>
+
+        Reviewed by Simon Fraser.
+
+        CSS Color Level 4 allows #RGBA and #RRGGBBAA values
+        for colors.
+
+        Test: fast/css/hex-colors.html
+
+        * platform/graphics/Color.cpp:
+        (WebCore::parseHexColorInternal): Update the color parsing for
+        the new syntax.
+
 2015-11-04  Mario Sanchez Prada  <ma...@webkit.org>
 
         [AX] WebProcess from WebKitGtk+ 2.10.0 compiled in Debug mode hits ASSERT on textUnderElement

Modified: trunk/Source/WebCore/platform/graphics/Color.cpp (192022 => 192023)


--- trunk/Source/WebCore/platform/graphics/Color.cpp	2015-11-04 14:46:19 UTC (rev 192022)
+++ trunk/Source/WebCore/platform/graphics/Color.cpp	2015-11-04 17:49:46 UTC (rev 192023)
@@ -128,7 +128,7 @@
 template <typename CharacterType>
 static inline bool parseHexColorInternal(const CharacterType* name, unsigned length, RGBA32& rgb)
 {
-    if (length != 3 && length != 6)
+    if (length != 3 && length != 4 && length != 6 && length != 8)
         return false;
     unsigned value = 0;
     for (unsigned i = 0; i < length; ++i) {
@@ -141,6 +141,20 @@
         rgb = 0xFF000000 | value;
         return true;
     }
+    if (length == 8) {
+        // We parsed the values into RGBA order, but the RGBA32 type
+        // expects them to be in ARGB order, so we right rotate eight bits.
+        rgb = value << 24 | value >> 8;
+        return true;
+    }
+    if (length == 4) {
+        // #abcd converts to ddaabbcc in RGBA32.
+        rgb = (value & 0xF) << 28 | (value & 0xF) << 24
+            | (value & 0xF000) << 8 | (value & 0xF000) << 4
+            | (value & 0xF00) << 4 | (value & 0xF00)
+            | (value & 0xF0) | (value & 0xF0) >> 4;
+        return true;
+    }
     // #abc converts to #aabbcc
     rgb = 0xFF000000
         | (value & 0xF00) << 12 | (value & 0xF00) << 8
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to