Changeset 192023 in webkit


Ignore:
Timestamp:
Nov 4, 2015 9:49:46 AM (9 years ago)
Author:
dino@apple.com
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:
Location:
trunk
Files:
2 added
8 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r192022 r192023  
     12015-11-03  Dean Jackson  <dino@apple.com>
     2
     3        Accept 8 and 4 value hex colors (#RRGGBBAA)
     4        https://bugs.webkit.org/show_bug.cgi?id=150853
     5        <rdar://problem/23380930>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Add a new test for hex colors that covers 4 and 8 value forms.
     10        Also update existing tests now that the syntax has changed.
     11
     12        For the deleted philip tests, they are now in the W3C web-latform-tests import.
     13
     14        * canvas/philip/tests/2d.fillStyle.parse.invalid.hex4-expected.txt: Removed.
     15        * canvas/philip/tests/2d.fillStyle.parse.invalid.hex4.html: Removed.
     16        * canvas/philip/tests/2d.fillStyle.parse.invalid.hex8-expected.txt: Removed.
     17        * canvas/philip/tests/2d.fillStyle.parse.invalid.hex8.html: Removed.
     18        * fast/css/hex-colors-expected.txt: Added.
     19        * fast/css/hex-colors.html: Added.
     20        * fast/css/invalid-hex-color-expected.txt:
     21        * fast/css/invalid-hex-color.html:
     22        * fast/css/invalid-predefined-color-expected.txt:
     23        * fast/css/invalid-predefined-color.html:
     24        * fast/css/script-tests/invalid-predefined-color.js:
     25        * fast/dom/attribute-legacy-colors-expected.txt:
     26        * fast/dom/script-tests/attribute-legacy-colors.js:
     27        * svg/dom/rgb-color-parser-expected.txt:
     28        * svg/dom/rgb-color-parser.html:
     29
    1302015-11-04  Joanmarie Diggs  <jdiggs@igalia.com>
    231
  • trunk/LayoutTests/fast/css/invalid-hex-color-expected.txt

    r67158 r192023  
    33Test 2 (Invalid: 2 hexadecimal digits) [EXPECTED] [ACTUAL] PASS
    44Test 3 (Valid: 3 hexadecimal digits) [EXPECTED] [ACTUAL] PASS
    5 Test 4 (Invalid: 4 hexadecimal digits) [EXPECTED] [ACTUAL] PASS
     5Test 4 (Valid: 4 hexadecimal digits) [EXPECTED] [ACTUAL] PASS
    66Test 5 (Invalid: 5 hexadecimal digits) [EXPECTED] [ACTUAL] PASS
    77Test 6 (Valid: 6 hexadecimal digits) [EXPECTED] [ACTUAL] PASS
    88Test 7 (Invalid: 7 hexadecimal digits) [EXPECTED] [ACTUAL] PASS
    9 Test 8 (Invalid: 0 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
    10 Test 9 (Invalid: 1 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
    11 Test 10 (Invalid: 2 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
    12 Test 11 (Invalid: 3 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
    13 Test 12 (Invalid: 4 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
    14 Test 13 (Invalid: 5 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
    15 Test 14 (Invalid: 6 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
    16 Test 15 (Invalid: 7 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
     9Test 8 (Valid: 8 hexadecimal digits) [EXPECTED] [ACTUAL] PASS
     10Test 9 (Invalid: 0 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
     11Test 10 (Invalid: 1 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
     12Test 11 (Invalid: 2 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
     13Test 12 (Invalid: 3 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
     14Test 13 (Invalid: 4 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
     15Test 14 (Invalid: 5 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
     16Test 15 (Invalid: 6 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
     17Test 16 (Invalid: 7 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
     18Test 17 (Invalid: 8 hexadecimal digits concatenated with 'px') [EXPECTED] [ACTUAL] PASS
  • trunk/LayoutTests/fast/css/invalid-hex-color.html

    r120683 r192023  
    2020        ["Invalid: 2 hexadecimal digits", "", "border-bottom: solid #11"],
    2121        ["Valid: 3 hexadecimal digits", "border-bottom: solid rgb(17,17,17)", "border-bottom: solid #111"],
    22         ["Invalid: 4 hexadecimal digits", "", "border-bottom: solid #1111"],
     22        ["Valid: 4 hexadecimal digits", "border-bottom: solid rgba(17,17,17,255)", "border-bottom: solid #111f"],
    2323        ["Invalid: 5 hexadecimal digits", "", "border-bottom: solid #11111"],
    2424        ["Valid: 6 hexadecimal digits", "border-bottom: solid rgb(17,17,17)", "border-bottom: solid #111111"],
    2525        ["Invalid: 7 hexadecimal digits", "", "border-bottom: solid #1111111"],
     26        ["Valid: 8 hexadecimal digits", "border-bottom: solid rgba(17,17,17,255)", "border-bottom: solid #111111ff"],
    2627        ["Invalid: 0 hexadecimal digits concatenated with 'px'", "", "border-bottom: solid #px"],
    2728        ["Invalid: 1 hexadecimal digits concatenated with 'px'", "", "border-bottom: solid #1px"],
     
    3233        ["Invalid: 6 hexadecimal digits concatenated with 'px'", "", "border-bottom: solid #111111px"],
    3334        ["Invalid: 7 hexadecimal digits concatenated with 'px'", "", "border-bottom: solid #1111111px"],
     35        ["Invalid: 8 hexadecimal digits concatenated with 'px'", "", "border-bottom: solid #11111111px"],
    3436    ];
    3537
  • trunk/LayoutTests/fast/css/invalid-predefined-color-expected.txt

    r83046 r192023  
    99PASS getComputedStyle(div, null).color is red
    1010PASS getComputedStyle(div, null).color is red
    11 PASS getComputedStyle(div, null).color is black
    1211PASS getComputedStyle(div, null).color is black
    1312PASS getComputedStyle(div, null).color is black
     
    2625This style is "color: #green"
    2726This style is "color: #FFAALL"
    28 This style is "color: #FF000000"
  • trunk/LayoutTests/fast/css/invalid-predefined-color.html

    r155263 r192023  
    1515<div id="invalid3" style="color: #green">This style is "color: #green"</div>
    1616<div id="invalid4" style="color: #FFAALL">This style is "color: #FFAALL"</div>
    17 <div id="invalid5" style="color: #FF000000">This style is "color: #FF000000"</div>
    1817
    1918<script src="script-tests/invalid-predefined-color.js"></script>
  • trunk/LayoutTests/fast/css/script-tests/invalid-predefined-color.js

    r98407 r192023  
    1212}
    1313
    14 for (var i=1;i<=5;i++)
     14for (var i=1;i<=4;i++)
    1515{
    1616    var div = document.getElementById("invalid"+i);
  • trunk/LayoutTests/fast/dom/attribute-legacy-colors-expected.txt

    r91217 r192023  
    1717PASS document.body.bgColor='f00';getComputedStyle(document.body).backgroundColor; is 'rgb(15, 0, 0)'
    1818PASS document.body.bgColor='ff0000';getComputedStyle(document.body).backgroundColor; is 'rgb(255, 0, 0)'
    19 PASS document.body.bgColor='#00000000';getComputedStyle(document.body).backgroundColor; is 'rgb(0, 0, 0)'
    2019PASS document.body.bgColor='foo';getComputedStyle(document.body).backgroundColor; is 'rgb(15, 0, 0)'
    2120PASS document.body.bgColor='cheese';getComputedStyle(document.body).backgroundColor; is 'rgb(192, 238, 14)'
     
    3635PASS document.body.bgColor='#55';getComputedStyle(document.body).backgroundColor; is 'rgb(5, 5, 0)'
    3736PASS document.body.bgColor='#555';getComputedStyle(document.body).backgroundColor; is 'rgb(85, 85, 85)'
    38 PASS document.body.bgColor='#5555';getComputedStyle(document.body).backgroundColor; is 'rgb(85, 85, 0)'
    3937PASS document.body.bgColor='#55555';getComputedStyle(document.body).backgroundColor; is 'rgb(85, 85, 80)'
    4038PASS document.body.bgColor='#555555';getComputedStyle(document.body).backgroundColor; is 'rgb(85, 85, 85)'
    4139PASS document.body.bgColor='#5555555';getComputedStyle(document.body).backgroundColor; is 'rgb(85, 85, 80)'
    42 PASS document.body.bgColor='#55555555';getComputedStyle(document.body).backgroundColor; is 'rgb(85, 85, 85)'
    4340PASS document.body.bgColor='5';getComputedStyle(document.body).backgroundColor; is 'rgb(5, 0, 0)'
    4441PASS document.body.bgColor='55';getComputedStyle(document.body).backgroundColor; is 'rgb(5, 5, 0)'
  • trunk/LayoutTests/fast/dom/script-tests/attribute-legacy-colors.js

    r98407 r192023  
    1616        {'test':'f00', 'expected':[15, 0, 0]},
    1717        {'test':'ff0000', 'expected':[255, 0, 0]},
    18         {'test':'#00000000', 'expected':[0, 0, 0]},
    1918        {'test':'foo', 'expected':[15, 0, 0]},
    2019        {'test':'cheese', 'expected':[192, 238, 14]},
     
    3534        {'test':'#55', 'expected':[5, 5, 0]},
    3635        {'test':'#555', 'expected':[85, 85, 85]},
    37         {'test':'#5555', 'expected':[85, 85, 0]},
    3836        {'test':'#55555', 'expected':[85, 85, 80]},
    3937        {'test':'#555555', 'expected':[85, 85, 85]},
    4038        {'test':'#5555555', 'expected':[85, 85, 80]},
    41         {'test':'#55555555', 'expected':[85, 85, 85]},
    4239        {'test':'5', 'expected':[5, 0, 0]},
    4340        {'test':'55', 'expected':[5, 5, 0]},
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r191981 r192023  
     12015-11-03  Dean Jackson  <dino@apple.com>
     2
     3        Accept 8 and 4 value hex colors (#RRGGBBAA)
     4        https://bugs.webkit.org/show_bug.cgi?id=150853
     5        <rdar://problem/23380930>
     6
     7        Reviewed by Simon Fraser.
     8
     9        Delete these tests. The have been updated in the original repository,
     10        so we'll get the new versions soon. Meanwhile, they are covered by
     11        other tests.
     12
     13        * canvas/2d.fillStyle.parse.invalid.hex4-expected.txt: Removed.
     14        * canvas/2d.fillStyle.parse.invalid.hex4.html: Removed.
     15        * canvas/2d.fillStyle.parse.invalid.hex8-expected.txt: Removed.
     16        * canvas/2d.fillStyle.parse.invalid.hex8.html: Removed.
     17        * css/css-color-3/t421-rgb-hex-parsing-f.xht:
     18
    1192015-11-02  Jon Honeycutt  <jhoneycutt@apple.com>
    220
  • trunk/LayoutTests/imported/w3c/css/css-color-3/t421-rgb-hex-parsing-f.xht

    r189353 r192023  
    1313                        p { color: #f; }
    1414                        p { color: #ff; }
    15                         p { color: #ff00; }
    1615                        p { color: #ff000; }
    1716                        p { color: #ff00000; }
    18                         p { color: #ff000000; }
    1917                        p { color: #ff0000000; }
    2018                        p { color: #ff00000000; }
  • trunk/LayoutTests/svg/dom/rgb-color-parser-expected.txt

    r170933 r192023  
    164164Failed to parse: #f
    165165Failed to parse: #ff
    166 Failed to parse: #ffff
    167166Failed to parse: #fffff
    168167Failed to parse: #fffffff
     
    178177Parsed as rgb(0,10,20): rgb(0, 10, 20)
    179178Parsed as rgb(255,255,255): #fff
     179Parsed as rgb(255,255,255): #ffff
    180180Parsed as rgb(255,255,255): #ffffff
     181Parsed as rgb(255,255,255): #ffffffff
    181182Parsed as rgb(255,255,255): #FFF
    182183Parsed as rgb(255,255,255): #FFFFFF
  • trunk/LayoutTests/svg/dom/rgb-color-parser.html

    r170933 r192023  
    227227        parseRGBColor("#f");
    228228        parseRGBColor("#ff");
    229         parseRGBColor("#ffff");
    230229        parseRGBColor("#fffff");
    231230        parseRGBColor("#fffffff");
     
    243242        parseRGBColor("rgb(0, 10, 20)");
    244243        parseRGBColor("#fff");
     244        parseRGBColor("#ffff");
    245245        parseRGBColor("#ffffff");
     246        parseRGBColor("#ffffffff");
    246247        parseRGBColor("#FFF");
    247248        parseRGBColor("#FFFFFF");
  • trunk/Source/WebCore/ChangeLog

    r192022 r192023  
     12015-11-03  Dean Jackson  <dino@apple.com>
     2
     3        Accept 8 and 4 value hex colors (#RRGGBBAA)
     4        https://bugs.webkit.org/show_bug.cgi?id=150853
     5        <rdar://problem/23380930>
     6
     7        Reviewed by Simon Fraser.
     8
     9        CSS Color Level 4 allows #RGBA and #RRGGBBAA values
     10        for colors.
     11
     12        Test: fast/css/hex-colors.html
     13
     14        * platform/graphics/Color.cpp:
     15        (WebCore::parseHexColorInternal): Update the color parsing for
     16        the new syntax.
     17
    1182015-11-04  Mario Sanchez Prada  <mario@webkit.org>
    219
  • trunk/Source/WebCore/platform/graphics/Color.cpp

    r191243 r192023  
    129129static inline bool parseHexColorInternal(const CharacterType* name, unsigned length, RGBA32& rgb)
    130130{
    131     if (length != 3 && length != 6)
     131    if (length != 3 && length != 4 && length != 6 && length != 8)
    132132        return false;
    133133    unsigned value = 0;
     
    140140    if (length == 6) {
    141141        rgb = 0xFF000000 | value;
     142        return true;
     143    }
     144    if (length == 8) {
     145        // We parsed the values into RGBA order, but the RGBA32 type
     146        // expects them to be in ARGB order, so we right rotate eight bits.
     147        rgb = value << 24 | value >> 8;
     148        return true;
     149    }
     150    if (length == 4) {
     151        // #abcd converts to ddaabbcc in RGBA32.
     152        rgb = (value & 0xF) << 28 | (value & 0xF) << 24
     153            | (value & 0xF000) << 8 | (value & 0xF000) << 4
     154            | (value & 0xF00) << 4 | (value & 0xF00)
     155            | (value & 0xF0) | (value & 0xF0) >> 4;
    142156        return true;
    143157    }
Note: See TracChangeset for help on using the changeset viewer.