Changeset 240550 in webkit


Ignore:
Timestamp:
Jan 26, 2019 3:54:29 PM (5 years ago)
Author:
Devin Rousso
Message:

Web Inspector: handle CSS Color 4 color syntaxes
https://bugs.webkit.org/show_bug.cgi?id=193166
<rdar://problem/47062403>

Reviewed by Simon Fraser.

Source/WebInspectorUI:

  • UserInterface/Models/Color.js:

(WI.Color.fromString):
(WI.Color.fromString.splitFunctionString): Added.
(WI.Color.fromString.parseFunctionAlpha): Added.
(WI.Color.fromString.parseFunctionComponent): Added.
(WI.Color.fromString.parseHueComponent): Added.
(WI.Color.fromString.parsePercentageComponent): Added.

LayoutTests:

  • inspector/model/color.html:
  • inspector/model/color-expected.txt:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r240549 r240550  
     12019-01-26  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: handle CSS Color 4 color syntaxes
     4        https://bugs.webkit.org/show_bug.cgi?id=193166
     5        <rdar://problem/47062403>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * inspector/model/color.html:
     10        * inspector/model/color-expected.txt:
     11
    1122019-01-26  Devin Rousso  <drousso@apple.com>
    213
  • trunk/LayoutTests/inspector/model/color-expected.txt

    r239597 r240550  
    44== Running test suite: WI.Color
    55-- Running test case: WI.Color.fromString
    6 PASS: '#000' should be detected
    7 PASS: '#000' was the expected 'Short HEX' format
    8 PASS: '#a0A' should be detected
    9 PASS: '#a0A' was the expected 'Short HEX' format
    10 PASS: '#000000' should be detected
    11 PASS: '#000000' was the expected 'HEX' format
    12 PASS: '#a0Aa0A' should be detected
    13 PASS: '#a0Aa0A' was the expected 'HEX' format
    14 PASS: '#0000' should be detected
    15 PASS: '#0000' was the expected 'Short HEX with Alpha' format
    16 PASS: '#a0Af' should be detected
    17 PASS: '#a0Af' was the expected 'Short HEX with Alpha' format
    18 PASS: '#00000000' should be detected
    19 PASS: '#00000000' was the expected 'HEX with Alpha' format
    20 PASS: '#a0Aa0Aff' should be detected
    21 PASS: '#a0Aa0Aff' was the expected 'HEX with Alpha' format
    22 PASS: 'rgb(1,2,3)' should be detected
    23 PASS: 'rgb(1,2,3)' was the expected 'RGB' format
    24 PASS: 'RGB(1,2,3)' should be detected
    25 PASS: 'RGB(1,2,3)' was the expected 'RGB' format
    26 PASS: 'rgb(999, 999, 999)' should be detected
    27 PASS: 'rgb(999, 999, 999)' was the expected 'RGB' format
    28 PASS: 'rgb( 1 , 1 , 1 )' should be detected
    29 PASS: 'rgb( 1 , 1 , 1 )' was the expected 'RGB' format
    30 PASS: 'rgba(1,2,3,0)' should be detected
    31 PASS: 'rgba(1,2,3,0)' was the expected 'RGBA' format
    32 PASS: 'RGBA(1,2,3,0)' should be detected
    33 PASS: 'RGBA(1,2,3,0)' was the expected 'RGBA' format
    34 PASS: 'rgba(999, 999, 999, 999)' should be detected
    35 PASS: 'rgba(999, 999, 999, 999)' was the expected 'RGBA' format
    36 PASS: 'rgba( 1 , 1 , 1 , 0.5 )' should be detected
    37 PASS: 'rgba( 1 , 1 , 1 , 0.5 )' was the expected 'RGBA' format
    38 PASS: 'hsl(0, 0%, 50%)' should be detected
    39 PASS: 'hsl(0, 0%, 50%)' was the expected 'HSL' format
    40 PASS: 'HSL(0, 0%, 50%)' should be detected
    41 PASS: 'HSL(0, 0%, 50%)' was the expected 'HSL' format
    42 PASS: 'hsl(999, 999%, 999%)' should be detected
    43 PASS: 'hsl(999, 999%, 999%)' was the expected 'HSL' format
    44 PASS: 'hsl( 0 , 0% , 50% )' should be detected
    45 PASS: 'hsl( 0 , 0% , 50% )' was the expected 'HSL' format
    46 PASS: 'hsla(0, 0%, 50%, 0)' should be detected
    47 PASS: 'hsla(0, 0%, 50%, 0)' was the expected 'HSLA' format
    48 PASS: 'HSLA(0, 0%, 50%, 0)' should be detected
    49 PASS: 'HSLA(0, 0%, 50%, 0)' was the expected 'HSLA' format
    50 PASS: 'hsla(999, 999%, 999%, 999)' should be detected
    51 PASS: 'hsla(999, 999%, 999%, 999)' was the expected 'HSLA' format
    52 PASS: 'hsla( 0 , 0% , 50% , 0.5 )' should be detected
    53 PASS: 'hsla( 0 , 0% , 50% , 0.5 )' was the expected 'HSLA' format
    54 PASS: 'blue' should be detected
    55 PASS: 'blue' was the expected 'Keyword' format
    56 PASS: 'BLuE' should be detected
    57 PASS: 'BLuE' was the expected 'Keyword' format
    58 PASS: 'midnightblue' should be detected
    59 PASS: 'midnightblue' was the expected 'Keyword' format
    60 PASS: 'royalblue' should be detected
    61 PASS: 'royalblue' was the expected 'Keyword' format
    62 PASS: 'steelblue' should be detected
    63 PASS: 'steelblue' was the expected 'Keyword' format
    64 PASS: 'transparent' should be detected
    65 PASS: 'transparent' was the expected 'Keyword' format
     6"#000" resolves to "#000"
     7"#a0A" resolves to "#a0a"
     8"#000000" resolves to "#000000"
     9"#a0Aa0A" resolves to "#a0aa0a"
     10"#0000" resolves to "#0000"
     11"#a0Af" resolves to "#a0af"
     12"#00000000" resolves to "#00000000"
     13"#a0Aa0Aff" resolves to "#a0aa0aff"
     14"rgb(10,20,30)" resolves to "rgb(10, 20, 30)"
     15"RGB(10,20,30)" resolves to "rgb(10, 20, 30)"
     16"rgb( 10 , 20 , 30 )" resolves to "rgb(10, 20, 30)"
     17"rgb(999, 999, 999)" resolves to "rgb(255, 255, 255)"
     18"rgb(10 20 30)" resolves to "rgb(10, 20, 30)"
     19"RGB(10 20 30)" resolves to "rgb(10, 20, 30)"
     20"rgb( 10 20 30 )" resolves to "rgb(10, 20, 30)"
     21"rgb(999 999 999)" resolves to "rgb(255, 255, 255)"
     22"rgb(10,20,30,40)" resolves to "rgba(10, 20, 30, 1)"
     23"RGB(10,20,30,40)" resolves to "rgba(10, 20, 30, 1)"
     24"rgb( 10 , 20 , 30 , 40 )" resolves to "rgba(10, 20, 30, 1)"
     25"rgb(999, 999, 999, 999)" resolves to "rgba(255, 255, 255, 1)"
     26"rgb(10,20,30,40%)" resolves to "rgba(10, 20, 30, 0.4)"
     27"RGB(10,20,30,40%)" resolves to "rgba(10, 20, 30, 0.4)"
     28"rgb( 10 , 20 , 30 , 40% )" resolves to "rgba(10, 20, 30, 0.4)"
     29"rgb(999, 999, 999, 999%)" resolves to "rgba(255, 255, 255, 1)"
     30"rgb(10 20 30 / 40)" resolves to "rgba(10, 20, 30, 1)"
     31"RGB(10 20 30 / 40)" resolves to "rgba(10, 20, 30, 1)"
     32"rgb( 10  20  30 / 40 )" resolves to "rgba(10, 20, 30, 1)"
     33"rgb(999 999 999 / 999)" resolves to "rgba(255, 255, 255, 1)"
     34"rgb(10 20 30 / 40%)" resolves to "rgba(10, 20, 30, 0.4)"
     35"RGB(10 20 30 / 40%)" resolves to "rgba(10, 20, 30, 0.4)"
     36"rgb( 10  20  30 / 40% )" resolves to "rgba(10, 20, 30, 0.4)"
     37"rgb(999 999 999 / 999%)" resolves to "rgba(255, 255, 255, 1)"
     38"rgba(10,20,30,40)" resolves to "rgba(10, 20, 30, 1)"
     39"RGBA(10,20,30,40)" resolves to "rgba(10, 20, 30, 1)"
     40"rgba( 10 , 20 , 30 , 40 )" resolves to "rgba(10, 20, 30, 1)"
     41"rgba(999, 999, 999, 999)" resolves to "rgba(255, 255, 255, 1)"
     42"rgba(10,20,30,40%)" resolves to "rgba(10, 20, 30, 0.4)"
     43"RGBA(10,20,30,40%)" resolves to "rgba(10, 20, 30, 0.4)"
     44"rgba( 10 , 20 , 30 , 40% )" resolves to "rgba(10, 20, 30, 0.4)"
     45"rgba(999, 999, 999, 999%)" resolves to "rgba(255, 255, 255, 1)"
     46"rgba(10 20 30 / 40)" resolves to "rgba(10, 20, 30, 1)"
     47"RGBA(10 20 30 / 40)" resolves to "rgba(10, 20, 30, 1)"
     48"rgba( 10  20  30 / 40 )" resolves to "rgba(10, 20, 30, 1)"
     49"rgba(999 999 999 / 999)" resolves to "rgba(255, 255, 255, 1)"
     50"rgba(10 20 30 / 40%)" resolves to "rgba(10, 20, 30, 0.4)"
     51"RGBA(10 20 30 / 40%)" resolves to "rgba(10, 20, 30, 0.4)"
     52"rgba( 10  20  30 / 40% )" resolves to "rgba(10, 20, 30, 0.4)"
     53"rgba(999 999 999 / 999%)" resolves to "rgba(255, 255, 255, 1)"
     54"rgb(10%,20%,30%)" resolves to "rgb(26, 51, 77)"
     55"RGB(10%,20%,30%)" resolves to "rgb(26, 51, 77)"
     56"rgb( 10% , 20% , 30% )" resolves to "rgb(26, 51, 77)"
     57"rgb(999%, 999%, 999%)" resolves to "rgb(255, 255, 255)"
     58"rgb(10% 20% 30%)" resolves to "rgb(26, 51, 77)"
     59"RGB(10% 20% 30%)" resolves to "rgb(26, 51, 77)"
     60"rgb( 10%  20%  30% )" resolves to "rgb(26, 51, 77)"
     61"rgb(999% 999% 999%)" resolves to "rgb(255, 255, 255)"
     62"rgb(10%,20%,30%,40)" resolves to "rgba(26, 51, 77, 1)"
     63"RGB(10%,20%,30%,40)" resolves to "rgba(26, 51, 77, 1)"
     64"rgb( 10% , 20% , 30% , 40 )" resolves to "rgba(26, 51, 77, 1)"
     65"rgb(999%, 999%, 999%, 999%)" resolves to "rgba(255, 255, 255, 1)"
     66"rgb(10%,20%,30%,40%)" resolves to "rgba(26, 51, 77, 0.4)"
     67"RGB(10%,20%,30%,40%)" resolves to "rgba(26, 51, 77, 0.4)"
     68"rgb( 10% , 20% , 30% , 40% )" resolves to "rgba(26, 51, 77, 0.4)"
     69"rgb(999%, 999%, 999%, 999%)" resolves to "rgba(255, 255, 255, 1)"
     70"rgb(10% 20% 30% / 40)" resolves to "rgba(26, 51, 77, 1)"
     71"RGB(10% 20% 30% / 40)" resolves to "rgba(26, 51, 77, 1)"
     72"rgb( 10%  20%  30% / 40 )" resolves to "rgba(26, 51, 77, 1)"
     73"rgb(999% 999% 999% / 999%)" resolves to "rgba(255, 255, 255, 1)"
     74"rgb(10% 20% 30% / 40%)" resolves to "rgba(26, 51, 77, 0.4)"
     75"RGB(10% 20% 30% / 40%)" resolves to "rgba(26, 51, 77, 0.4)"
     76"rgb( 10%  20%  30% / 40% )" resolves to "rgba(26, 51, 77, 0.4)"
     77"rgb(999% 999% 999% / 999%)" resolves to "rgba(255, 255, 255, 1)"
     78"rgba(10%,20%,30%,40)" resolves to "rgba(26, 51, 77, 1)"
     79"RGBA(10%,20%,30%,40)" resolves to "rgba(26, 51, 77, 1)"
     80"rgba( 10% , 20% , 30% , 40 )" resolves to "rgba(26, 51, 77, 1)"
     81"rgba(999%, 999%, 999%, 999%)" resolves to "rgba(255, 255, 255, 1)"
     82"rgba(10%,20%,30%,40%)" resolves to "rgba(26, 51, 77, 0.4)"
     83"RGBA(10%,20%,30%,40%)" resolves to "rgba(26, 51, 77, 0.4)"
     84"rgba( 10% , 20% , 30% , 40% )" resolves to "rgba(26, 51, 77, 0.4)"
     85"rgba(999%, 999%, 999%, 999%)" resolves to "rgba(255, 255, 255, 1)"
     86"rgba(10% 20% 30% / 40)" resolves to "rgba(26, 51, 77, 1)"
     87"RGBA(10% 20% 30% / 40)" resolves to "rgba(26, 51, 77, 1)"
     88"rgba( 10%  20%  30% / 40 )" resolves to "rgba(26, 51, 77, 1)"
     89"rgba(999% 999% 999% / 999%)" resolves to "rgba(255, 255, 255, 1)"
     90"rgba(10% 20% 30% / 40%)" resolves to "rgba(26, 51, 77, 0.4)"
     91"RGBA(10% 20% 30% / 40%)" resolves to "rgba(26, 51, 77, 0.4)"
     92"rgba( 10%  20%  30% / 40% )" resolves to "rgba(26, 51, 77, 0.4)"
     93"rgba(999% 999% 999% / 999%)" resolves to "rgba(255, 255, 255, 1)"
     94"hsl(10,20%,30%)" resolves to "hsl(10, 20%, 30%)"
     95"HSL(10,20%,30%)" resolves to "hsl(10, 20%, 30%)"
     96"hsl( 10 , 20% , 30% )" resolves to "hsl(10, 20%, 30%)"
     97"hsl(999, 999%, 999%)" resolves to "hsl(360, 100%, 100%)"
     98"hsl(10 20% 30%)" resolves to "hsl(10, 20%, 30%)"
     99"HSL(10 20% 30%)" resolves to "hsl(10, 20%, 30%)"
     100"hsl( 10  20%  30% )" resolves to "hsl(10, 20%, 30%)"
     101"hsl(999 999% 999%)" resolves to "hsl(360, 100%, 100%)"
     102"hsl(10,20%,30%,40)" resolves to "hsla(10, 20%, 30%, 1)"
     103"HSL(10,20%,30%,40)" resolves to "hsla(10, 20%, 30%, 1)"
     104"hsl( 10 , 20% , 30% , 40 )" resolves to "hsla(10, 20%, 30%, 1)"
     105"hsl(999, 999%, 999%, 999)" resolves to "hsla(360, 100%, 100%, 1)"
     106"hsl(10,20%,30%,40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     107"HSL(10,20%,30%,40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     108"hsl( 10 , 20% , 30% , 40% )" resolves to "hsla(10, 20%, 30%, 0.4)"
     109"hsl(999, 999%, 999%, 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     110"hsl(10 20% 30% / 40)" resolves to "hsla(10, 20%, 30%, 1)"
     111"HSL(10 20% 30% / 40)" resolves to "hsla(10, 20%, 30%, 1)"
     112"hsl( 10  20%  30% / 40 )" resolves to "hsla(10, 20%, 30%, 1)"
     113"hsl(999 999% 999% / 999)" resolves to "hsla(360, 100%, 100%, 1)"
     114"hsl(10 20% 30% / 40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     115"HSL(10 20% 30% / 40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     116"hsl( 10  20%  30% / 40% )" resolves to "hsla(10, 20%, 30%, 0.4)"
     117"hsl(999 999% 999% / 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     118"hsl(10,20%,30%,40)" resolves to "hsla(10, 20%, 30%, 1)"
     119"HSL(10,20%,30%,40)" resolves to "hsla(10, 20%, 30%, 1)"
     120"hsl( 10 , 20% , 30% , 40 )" resolves to "hsla(10, 20%, 30%, 1)"
     121"hsl(999, 999%, 999%, 999)" resolves to "hsla(360, 100%, 100%, 1)"
     122"hsl(10,20%,30%,40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     123"HSL(10,20%,30%,40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     124"hsl( 10 , 20% , 30% , 40% )" resolves to "hsla(10, 20%, 30%, 0.4)"
     125"hsl(999, 999%, 999%, 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     126"hsla(10,20%,30%,40)" resolves to "hsla(10, 20%, 30%, 1)"
     127"HSLA(10,20%,30%,40)" resolves to "hsla(10, 20%, 30%, 1)"
     128"hsla( 10 , 0% , 50% , 40 )" resolves to "hsla(10, 0%, 50%, 1)"
     129"hsla(999, 999%, 999%, 999)" resolves to "hsla(360, 100%, 100%, 1)"
     130"hsla(10,20%,30%,40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     131"HSLA(10,20%,30%,40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     132"hsla( 10 , 20% , 30% , 40% )" resolves to "hsla(10, 20%, 30%, 0.4)"
     133"hsla(999, 999%, 999%, 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     134"hsla(10 20% 30% / 40)" resolves to "hsla(10, 20%, 30%, 1)"
     135"HSLA(10 20% 30% / 40)" resolves to "hsla(10, 20%, 30%, 1)"
     136"hsla( 10  20%  30% / 40 )" resolves to "hsla(10, 20%, 30%, 1)"
     137"hsla(999 999% 999% / 999)" resolves to "hsla(360, 100%, 100%, 1)"
     138"hsla(10 20% 30% / 40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     139"HSLA(10 20% 30% / 40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     140"hsla( 10  20%  30% / 40% )" resolves to "hsla(10, 20%, 30%, 0.4)"
     141"hsla(999 999% 999% / 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     142"hsl(10deg,20%,30%)" resolves to "hsl(10, 20%, 30%)"
     143"HSL(10deg,20%,30%)" resolves to "hsl(10, 20%, 30%)"
     144"hsl( 10deg , 20% , 30% )" resolves to "hsl(10, 20%, 30%)"
     145"hsl(999deg, 999%, 999%)" resolves to "hsl(360, 100%, 100%)"
     146"hsl(10deg 20% 30%)" resolves to "hsl(10, 20%, 30%)"
     147"HSL(10deg 20% 30%)" resolves to "hsl(10, 20%, 30%)"
     148"hsl( 10deg  20%  30% )" resolves to "hsl(10, 20%, 30%)"
     149"hsl(999deg 999% 999%)" resolves to "hsl(360, 100%, 100%)"
     150"hsl(10deg,20%,30%,40)" resolves to "hsla(10, 20%, 30%, 1)"
     151"HSL(10deg,20%,30%,40)" resolves to "hsla(10, 20%, 30%, 1)"
     152"hsl( 10deg , 20% , 30% , 40 )" resolves to "hsla(10, 20%, 30%, 1)"
     153"hsl(999deg, 999%, 999%, 999)" resolves to "hsla(360, 100%, 100%, 1)"
     154"hsl(10deg,20%,30%,40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     155"HSL(10deg,20%,30%,40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     156"hsl( 10deg , 20% , 30% , 40% )" resolves to "hsla(10, 20%, 30%, 0.4)"
     157"hsl(999deg, 999%, 999%, 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     158"hsl(10deg 20% 30% / 40)" resolves to "hsla(10, 20%, 30%, 1)"
     159"HSL(10deg 20% 30% / 40)" resolves to "hsla(10, 20%, 30%, 1)"
     160"hsl( 10deg  20%  30% / 40 )" resolves to "hsla(10, 20%, 30%, 1)"
     161"hsl(999deg 999% 999% / 999)" resolves to "hsla(360, 100%, 100%, 1)"
     162"hsl(10deg 20% 30% / 40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     163"HSL(10deg 20% 30% / 40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     164"hsl( 10deg  20%  30% / 40% )" resolves to "hsla(10, 20%, 30%, 0.4)"
     165"hsl(999deg 999% 999% / 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     166"hsl(10deg,20%,30%,40)" resolves to "hsla(10, 20%, 30%, 1)"
     167"HSL(10deg,20%,30%,40)" resolves to "hsla(10, 20%, 30%, 1)"
     168"hsl( 10deg , 20% , 30% , 40 )" resolves to "hsla(10, 20%, 30%, 1)"
     169"hsl(999deg, 999%, 999%, 999)" resolves to "hsla(360, 100%, 100%, 1)"
     170"hsl(10deg,20%,30%,40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     171"HSL(10deg,20%,30%,40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     172"hsl( 10deg , 20% , 30% , 40% )" resolves to "hsla(10, 20%, 30%, 0.4)"
     173"hsl(999deg, 999%, 999%, 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     174"hsla(10deg,20%,30%,40)" resolves to "hsla(10, 20%, 30%, 1)"
     175"HSLA(10deg,20%,30%,40)" resolves to "hsla(10, 20%, 30%, 1)"
     176"hsla( 10deg , 0% , 50% , 40 )" resolves to "hsla(10, 0%, 50%, 1)"
     177"hsla(999deg, 999%, 999%, 999)" resolves to "hsla(360, 100%, 100%, 1)"
     178"hsla(10deg,20%,30%,40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     179"HSLA(10deg,20%,30%,40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     180"hsla( 10deg , 20% , 30% , 40% )" resolves to "hsla(10, 20%, 30%, 0.4)"
     181"hsla(999deg, 999%, 999%, 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     182"hsla(10deg 20% 30% / 40)" resolves to "hsla(10, 20%, 30%, 1)"
     183"HSLA(10deg 20% 30% / 40)" resolves to "hsla(10, 20%, 30%, 1)"
     184"hsla( 10deg  20%  30% / 40 )" resolves to "hsla(10, 20%, 30%, 1)"
     185"hsla(999deg 999% 999% / 999)" resolves to "hsla(360, 100%, 100%, 1)"
     186"hsla(10deg 20% 30% / 40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     187"HSLA(10deg 20% 30% / 40%)" resolves to "hsla(10, 20%, 30%, 0.4)"
     188"hsla( 10deg  20%  30% / 40% )" resolves to "hsla(10, 20%, 30%, 0.4)"
     189"hsla(999deg 999% 999% / 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     190"hsl(10rad,20%,30%)" resolves to "hsl(360, 20%, 30%)"
     191"HSL(10rad,20%,30%)" resolves to "hsl(360, 20%, 30%)"
     192"hsl( 10rad , 20% , 30% )" resolves to "hsl(360, 20%, 30%)"
     193"hsl(999rad, 999%, 999%)" resolves to "hsl(360, 100%, 100%)"
     194"hsl(10rad 20% 30%)" resolves to "hsl(360, 20%, 30%)"
     195"HSL(10rad 20% 30%)" resolves to "hsl(360, 20%, 30%)"
     196"hsl( 10rad  20%  30% )" resolves to "hsl(360, 20%, 30%)"
     197"hsl(999rad 999% 999%)" resolves to "hsl(360, 100%, 100%)"
     198"hsl(10rad,20%,30%,40)" resolves to "hsla(360, 20%, 30%, 1)"
     199"HSL(10rad,20%,30%,40)" resolves to "hsla(360, 20%, 30%, 1)"
     200"hsl( 10rad , 20% , 30% , 40 )" resolves to "hsla(360, 20%, 30%, 1)"
     201"hsl(999rad, 999%, 999%, 999)" resolves to "hsla(360, 100%, 100%, 1)"
     202"hsl(10rad,20%,30%,40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     203"HSL(10rad,20%,30%,40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     204"hsl( 10rad , 20% , 30% , 40% )" resolves to "hsla(360, 20%, 30%, 0.4)"
     205"hsl(999rad, 999%, 999%, 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     206"hsl(10rad 20% 30% / 40)" resolves to "hsla(360, 20%, 30%, 1)"
     207"HSL(10rad 20% 30% / 40)" resolves to "hsla(360, 20%, 30%, 1)"
     208"hsl( 10rad  20%  30% / 40 )" resolves to "hsla(360, 20%, 30%, 1)"
     209"hsl(999rad 999% 999% / 999)" resolves to "hsla(360, 100%, 100%, 1)"
     210"hsl(10rad 20% 30% / 40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     211"HSL(10rad 20% 30% / 40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     212"hsl( 10rad  20%  30% / 40% )" resolves to "hsla(360, 20%, 30%, 0.4)"
     213"hsl(999rad 999% 999% / 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     214"hsl(10rad,20%,30%,40)" resolves to "hsla(360, 20%, 30%, 1)"
     215"HSL(10rad,20%,30%,40)" resolves to "hsla(360, 20%, 30%, 1)"
     216"hsl( 10rad , 20% , 30% , 40 )" resolves to "hsla(360, 20%, 30%, 1)"
     217"hsl(999rad, 999%, 999%, 999)" resolves to "hsla(360, 100%, 100%, 1)"
     218"hsl(10rad,20%,30%,40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     219"HSL(10rad,20%,30%,40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     220"hsl( 10rad , 20% , 30% , 40% )" resolves to "hsla(360, 20%, 30%, 0.4)"
     221"hsl(999rad, 999%, 999%, 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     222"hsla(10rad,20%,30%,40)" resolves to "hsla(360, 20%, 30%, 1)"
     223"HSLA(10rad,20%,30%,40)" resolves to "hsla(360, 20%, 30%, 1)"
     224"hsla( 10rad , 0% , 50% , 40 )" resolves to "hsla(360, 0%, 50%, 1)"
     225"hsla(999rad, 999%, 999%, 999)" resolves to "hsla(360, 100%, 100%, 1)"
     226"hsla(10rad,20%,30%,40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     227"HSLA(10rad,20%,30%,40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     228"hsla( 10rad , 20% , 30% , 40% )" resolves to "hsla(360, 20%, 30%, 0.4)"
     229"hsla(999rad, 999%, 999%, 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     230"hsla(10rad 20% 30% / 40)" resolves to "hsla(360, 20%, 30%, 1)"
     231"HSLA(10rad 20% 30% / 40)" resolves to "hsla(360, 20%, 30%, 1)"
     232"hsla( 10rad  20%  30% / 40 )" resolves to "hsla(360, 20%, 30%, 1)"
     233"hsla(999rad 999% 999% / 999)" resolves to "hsla(360, 100%, 100%, 1)"
     234"hsla(10rad 20% 30% / 40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     235"HSLA(10rad 20% 30% / 40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     236"hsla( 10rad  20%  30% / 40% )" resolves to "hsla(360, 20%, 30%, 0.4)"
     237"hsla(999rad 999% 999% / 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     238"hsl(10grad,20%,30%)" resolves to "hsl(9, 20%, 30%)"
     239"HSL(10grad,20%,30%)" resolves to "hsl(9, 20%, 30%)"
     240"hsl( 10grad , 20% , 30% )" resolves to "hsl(9, 20%, 30%)"
     241"hsl(999grad, 999%, 999%)" resolves to "hsl(360, 100%, 100%)"
     242"hsl(10grad 20% 30%)" resolves to "hsl(9, 20%, 30%)"
     243"HSL(10grad 20% 30%)" resolves to "hsl(9, 20%, 30%)"
     244"hsl( 10grad  20%  30% )" resolves to "hsl(9, 20%, 30%)"
     245"hsl(999grad 999% 999%)" resolves to "hsl(360, 100%, 100%)"
     246"hsl(10grad,20%,30%,40)" resolves to "hsla(9, 20%, 30%, 1)"
     247"HSL(10grad,20%,30%,40)" resolves to "hsla(9, 20%, 30%, 1)"
     248"hsl( 10grad , 20% , 30% , 40 )" resolves to "hsla(9, 20%, 30%, 1)"
     249"hsl(999grad, 999%, 999%, 999)" resolves to "hsla(360, 100%, 100%, 1)"
     250"hsl(10grad,20%,30%,40%)" resolves to "hsla(9, 20%, 30%, 0.4)"
     251"HSL(10grad,20%,30%,40%)" resolves to "hsla(9, 20%, 30%, 0.4)"
     252"hsl( 10grad , 20% , 30% , 40% )" resolves to "hsla(9, 20%, 30%, 0.4)"
     253"hsl(999grad, 999%, 999%, 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     254"hsl(10grad 20% 30% / 40)" resolves to "hsla(9, 20%, 30%, 1)"
     255"HSL(10grad 20% 30% / 40)" resolves to "hsla(9, 20%, 30%, 1)"
     256"hsl( 10grad  20%  30% / 40 )" resolves to "hsla(9, 20%, 30%, 1)"
     257"hsl(999grad 999% 999% / 999)" resolves to "hsla(360, 100%, 100%, 1)"
     258"hsl(10grad 20% 30% / 40%)" resolves to "hsla(9, 20%, 30%, 0.4)"
     259"HSL(10grad 20% 30% / 40%)" resolves to "hsla(9, 20%, 30%, 0.4)"
     260"hsl( 10grad  20%  30% / 40% )" resolves to "hsla(9, 20%, 30%, 0.4)"
     261"hsl(999grad 999% 999% / 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     262"hsl(10grad,20%,30%,40)" resolves to "hsla(9, 20%, 30%, 1)"
     263"HSL(10grad,20%,30%,40)" resolves to "hsla(9, 20%, 30%, 1)"
     264"hsl( 10grad , 20% , 30% , 40 )" resolves to "hsla(9, 20%, 30%, 1)"
     265"hsl(999grad, 999%, 999%, 999)" resolves to "hsla(360, 100%, 100%, 1)"
     266"hsl(10grad,20%,30%,40%)" resolves to "hsla(9, 20%, 30%, 0.4)"
     267"HSL(10grad,20%,30%,40%)" resolves to "hsla(9, 20%, 30%, 0.4)"
     268"hsl( 10grad , 20% , 30% , 40% )" resolves to "hsla(9, 20%, 30%, 0.4)"
     269"hsl(999grad, 999%, 999%, 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     270"hsla(10grad,20%,30%,40)" resolves to "hsla(9, 20%, 30%, 1)"
     271"HSLA(10grad,20%,30%,40)" resolves to "hsla(9, 20%, 30%, 1)"
     272"hsla( 10grad , 0% , 50% , 40 )" resolves to "hsla(9, 0%, 50%, 1)"
     273"hsla(999grad, 999%, 999%, 999)" resolves to "hsla(360, 100%, 100%, 1)"
     274"hsla(10grad,20%,30%,40%)" resolves to "hsla(9, 20%, 30%, 0.4)"
     275"HSLA(10grad,20%,30%,40%)" resolves to "hsla(9, 20%, 30%, 0.4)"
     276"hsla( 10grad , 20% , 30% , 40% )" resolves to "hsla(9, 20%, 30%, 0.4)"
     277"hsla(999grad, 999%, 999%, 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     278"hsla(10grad 20% 30% / 40)" resolves to "hsla(9, 20%, 30%, 1)"
     279"HSLA(10grad 20% 30% / 40)" resolves to "hsla(9, 20%, 30%, 1)"
     280"hsla( 10grad  20%  30% / 40 )" resolves to "hsla(9, 20%, 30%, 1)"
     281"hsla(999grad 999% 999% / 999)" resolves to "hsla(360, 100%, 100%, 1)"
     282"hsla(10grad 20% 30% / 40%)" resolves to "hsla(9, 20%, 30%, 0.4)"
     283"HSLA(10grad 20% 30% / 40%)" resolves to "hsla(9, 20%, 30%, 0.4)"
     284"hsla( 10grad  20%  30% / 40% )" resolves to "hsla(9, 20%, 30%, 0.4)"
     285"hsla(999grad 999% 999% / 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     286"hsl(10turn,20%,30%)" resolves to "hsl(360, 20%, 30%)"
     287"HSL(10turn,20%,30%)" resolves to "hsl(360, 20%, 30%)"
     288"hsl( 10turn , 20% , 30% )" resolves to "hsl(360, 20%, 30%)"
     289"hsl(999turn, 999%, 999%)" resolves to "hsl(360, 100%, 100%)"
     290"hsl(10turn 20% 30%)" resolves to "hsl(360, 20%, 30%)"
     291"HSL(10turn 20% 30%)" resolves to "hsl(360, 20%, 30%)"
     292"hsl( 10turn  20%  30% )" resolves to "hsl(360, 20%, 30%)"
     293"hsl(999turn 999% 999%)" resolves to "hsl(360, 100%, 100%)"
     294"hsl(10turn,20%,30%,40)" resolves to "hsla(360, 20%, 30%, 1)"
     295"HSL(10turn,20%,30%,40)" resolves to "hsla(360, 20%, 30%, 1)"
     296"hsl( 10turn , 20% , 30% , 40 )" resolves to "hsla(360, 20%, 30%, 1)"
     297"hsl(999turn, 999%, 999%, 999)" resolves to "hsla(360, 100%, 100%, 1)"
     298"hsl(10turn,20%,30%,40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     299"HSL(10turn,20%,30%,40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     300"hsl( 10turn , 20% , 30% , 40% )" resolves to "hsla(360, 20%, 30%, 0.4)"
     301"hsl(999turn, 999%, 999%, 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     302"hsl(10turn 20% 30% / 40)" resolves to "hsla(360, 20%, 30%, 1)"
     303"HSL(10turn 20% 30% / 40)" resolves to "hsla(360, 20%, 30%, 1)"
     304"hsl( 10turn  20%  30% / 40 )" resolves to "hsla(360, 20%, 30%, 1)"
     305"hsl(999turn 999% 999% / 999)" resolves to "hsla(360, 100%, 100%, 1)"
     306"hsl(10turn 20% 30% / 40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     307"HSL(10turn 20% 30% / 40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     308"hsl( 10turn  20%  30% / 40% )" resolves to "hsla(360, 20%, 30%, 0.4)"
     309"hsl(999turn 999% 999% / 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     310"hsl(10turn,20%,30%,40)" resolves to "hsla(360, 20%, 30%, 1)"
     311"HSL(10turn,20%,30%,40)" resolves to "hsla(360, 20%, 30%, 1)"
     312"hsl( 10turn , 20% , 30% , 40 )" resolves to "hsla(360, 20%, 30%, 1)"
     313"hsl(999turn, 999%, 999%, 999)" resolves to "hsla(360, 100%, 100%, 1)"
     314"hsl(10turn,20%,30%,40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     315"HSL(10turn,20%,30%,40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     316"hsl( 10turn , 20% , 30% , 40% )" resolves to "hsla(360, 20%, 30%, 0.4)"
     317"hsl(999turn, 999%, 999%, 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     318"hsla(10turn,20%,30%,40)" resolves to "hsla(360, 20%, 30%, 1)"
     319"HSLA(10turn,20%,30%,40)" resolves to "hsla(360, 20%, 30%, 1)"
     320"hsla( 10turn , 0% , 50% , 40 )" resolves to "hsla(360, 0%, 50%, 1)"
     321"hsla(999turn, 999%, 999%, 999)" resolves to "hsla(360, 100%, 100%, 1)"
     322"hsla(10turn,20%,30%,40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     323"HSLA(10turn,20%,30%,40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     324"hsla( 10turn , 20% , 30% , 40% )" resolves to "hsla(360, 20%, 30%, 0.4)"
     325"hsla(999turn, 999%, 999%, 999%)" resolves to "hsla(360, 100%, 100%, 1)"
     326"hsla(10turn 20% 30% / 40)" resolves to "hsla(360, 20%, 30%, 1)"
     327"HSLA(10turn 20% 30% / 40)" resolves to "hsla(360, 20%, 30%, 1)"
     328"hsla( 10turn  20%  30% / 40 )" resolves to "hsla(360, 20%, 30%, 1)"
     329"hsla(999turn 999% 999% / 999)" resolves to "hsla(360, 100%, 100%, 1)"
     330"hsla(10turn 20% 30% / 40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     331"HSLA(10turn 20% 30% / 40%)" resolves to "hsla(360, 20%, 30%, 0.4)"
     332"hsla( 10turn  20%  30% / 40% )" resolves to "hsla(360, 20%, 30%, 0.4)"
     333"hsla(999turn 999% 999% / 999%)" resolves to "hsla(360, 100%, 100%, 1)"
    66334
    67335PASS: ' #000 ' should not be detected
     
    72340PASS: '#1234567' should not be detected
    73341PASS: '#123456789' should not be detected
    74 PASS: 'rgb(255, 255, 255, 0.5)' should not be detected
     342PASS: 'rgb(255, 255, 255, 0.5, 1)' should not be detected
    75343PASS: 'rgba(255, 255, 255, 0.5, 1)' should not be detected
    76 PASS: 'hsl(0, 0%, 50%, 1)' should not be detected
     344PASS: 'hsl(0, 0%, 50%, 1, 2)' should not be detected
    77345PASS: 'hsla(0, 0%, 50%, 1, 2)' should not be detected
    78346PASS: 'superblue' should not be detected
  • trunk/LayoutTests/inspector/model/color.html

    r239597 r240550  
    4141            function testGood(string, expectedFormat) {
    4242                let color = WI.Color.fromString(string);
    43                 InspectorTest.expectThat(color instanceof WI.Color, `'${string}' should be detected`);
    44                 InspectorTest.expectThat(color && color.format === expectedFormat, `'${string}' was the expected '${formatToString(expectedFormat)}' format`);
     43                InspectorTest.assert(color instanceof WI.Color, `'${string}' should be detected`);
     44                InspectorTest.assert(color.format === expectedFormat, `'${string}' was the expected '${formatToString(expectedFormat)}' format`);
     45                InspectorTest.log(`"${string}" resolves to "${color.toString()}"`);
    4546            }
    4647
    4748            function testBad(string) {
    4849                let color = WI.Color.fromString(string);
    49                 InspectorTest.expectThat(color === null, `'${string}' should not be detected`);
    50                 if (color) InspectorTest.log(`'${string}' detected with format '${formatToString(color.format)}'`);
     50                InspectorTest.expectNull(color, `'${string}' should not be detected`);
     51                if (color)
     52                    InspectorTest.log(`'${string}' detected with format '${formatToString(color.format)}'`);
    5153            }
    5254
     
    6163            testGood("#a0Aa0Aff", WI.Color.Format.HEXAlpha);
    6264
    63             testGood("rgb(1,2,3)", WI.Color.Format.RGB);
    64             testGood("RGB(1,2,3)", WI.Color.Format.RGB);
     65            testGood("rgb(10,20,30)", WI.Color.Format.RGB);
     66            testGood("RGB(10,20,30)", WI.Color.Format.RGB);
     67            testGood("rgb( 10 , 20 , 30 )", WI.Color.Format.RGB);
    6568            testGood("rgb(999, 999, 999)", WI.Color.Format.RGB);
    66             testGood("rgb( 1 , 1 , 1 )", WI.Color.Format.RGB);
    67 
    68             testGood("rgba(1,2,3,0)", WI.Color.Format.RGBA);
    69             testGood("RGBA(1,2,3,0)", WI.Color.Format.RGBA);
     69
     70            testGood("rgb(10 20 30)", WI.Color.Format.RGB);
     71            testGood("RGB(10 20 30)", WI.Color.Format.RGB);
     72            testGood("rgb( 10 20 30 )", WI.Color.Format.RGB);
     73            testGood("rgb(999 999 999)", WI.Color.Format.RGB);
     74
     75            testGood("rgb(10,20,30,40)", WI.Color.Format.RGBA);
     76            testGood("RGB(10,20,30,40)", WI.Color.Format.RGBA);
     77            testGood("rgb( 10 , 20 , 30 , 40 )", WI.Color.Format.RGBA);
     78            testGood("rgb(999, 999, 999, 999)", WI.Color.Format.RGBA);
     79
     80            testGood("rgb(10,20,30,40%)", WI.Color.Format.RGBA);
     81            testGood("RGB(10,20,30,40%)", WI.Color.Format.RGBA);
     82            testGood("rgb( 10 , 20 , 30 , 40% )", WI.Color.Format.RGBA);
     83            testGood("rgb(999, 999, 999, 999%)", WI.Color.Format.RGBA);
     84
     85            testGood("rgb(10 20 30 / 40)", WI.Color.Format.RGBA);
     86            testGood("RGB(10 20 30 / 40)", WI.Color.Format.RGBA);
     87            testGood("rgb( 10  20  30 / 40 )", WI.Color.Format.RGBA);
     88            testGood("rgb(999 999 999 / 999)", WI.Color.Format.RGBA);
     89
     90            testGood("rgb(10 20 30 / 40%)", WI.Color.Format.RGBA);
     91            testGood("RGB(10 20 30 / 40%)", WI.Color.Format.RGBA);
     92            testGood("rgb( 10  20  30 / 40% )", WI.Color.Format.RGBA);
     93            testGood("rgb(999 999 999 / 999%)", WI.Color.Format.RGBA);
     94
     95            testGood("rgba(10,20,30,40)", WI.Color.Format.RGBA);
     96            testGood("RGBA(10,20,30,40)", WI.Color.Format.RGBA);
     97            testGood("rgba( 10 , 20 , 30 , 40 )", WI.Color.Format.RGBA);
    7098            testGood("rgba(999, 999, 999, 999)", WI.Color.Format.RGBA);
    71             testGood("rgba( 1 , 1 , 1 , 0.5 )", WI.Color.Format.RGBA);
    72 
    73             testGood("hsl(0, 0%, 50%)", WI.Color.Format.HSL);
    74             testGood("HSL(0, 0%, 50%)", WI.Color.Format.HSL);
    75             testGood("hsl(999, 999%, 999%)", WI.Color.Format.HSL);
    76             testGood("hsl( 0 , 0% , 50% )", WI.Color.Format.HSL);
    77            
    78             testGood("hsla(0, 0%, 50%, 0)", WI.Color.Format.HSLA);
    79             testGood("HSLA(0, 0%, 50%, 0)", WI.Color.Format.HSLA);
    80             testGood("hsla(999, 999%, 999%, 999)", WI.Color.Format.HSLA);
    81             testGood("hsla( 0 , 0% , 50% , 0.5 )", WI.Color.Format.HSLA);
    82 
    83             testGood("blue", WI.Color.Format.Keyword);
    84             testGood("BLuE", WI.Color.Format.Keyword);
    85             testGood("midnightblue", WI.Color.Format.Keyword);
    86             testGood("royalblue", WI.Color.Format.Keyword);
    87             testGood("steelblue", WI.Color.Format.Keyword);
    88             testGood("transparent", WI.Color.Format.Keyword);
     99
     100            testGood("rgba(10,20,30,40%)", WI.Color.Format.RGBA);
     101            testGood("RGBA(10,20,30,40%)", WI.Color.Format.RGBA);
     102            testGood("rgba( 10 , 20 , 30 , 40% )", WI.Color.Format.RGBA);
     103            testGood("rgba(999, 999, 999, 999%)", WI.Color.Format.RGBA);
     104
     105            testGood("rgba(10 20 30 / 40)", WI.Color.Format.RGBA);
     106            testGood("RGBA(10 20 30 / 40)", WI.Color.Format.RGBA);
     107            testGood("rgba( 10  20  30 / 40 )", WI.Color.Format.RGBA);
     108            testGood("rgba(999 999 999 / 999)", WI.Color.Format.RGBA);
     109
     110            testGood("rgba(10 20 30 / 40%)", WI.Color.Format.RGBA);
     111            testGood("RGBA(10 20 30 / 40%)", WI.Color.Format.RGBA);
     112            testGood("rgba( 10  20  30 / 40% )", WI.Color.Format.RGBA);
     113            testGood("rgba(999 999 999 / 999%)", WI.Color.Format.RGBA);
     114
     115            testGood("rgb(10%,20%,30%)", WI.Color.Format.RGB);
     116            testGood("RGB(10%,20%,30%)", WI.Color.Format.RGB);
     117            testGood("rgb( 10% , 20% , 30% )", WI.Color.Format.RGB);
     118            testGood("rgb(999%, 999%, 999%)", WI.Color.Format.RGB);
     119
     120            testGood("rgb(10% 20% 30%)", WI.Color.Format.RGB);
     121            testGood("RGB(10% 20% 30%)", WI.Color.Format.RGB);
     122            testGood("rgb( 10%  20%  30% )", WI.Color.Format.RGB);
     123            testGood("rgb(999% 999% 999%)", WI.Color.Format.RGB);
     124
     125            testGood("rgb(10%,20%,30%,40)", WI.Color.Format.RGBA);
     126            testGood("RGB(10%,20%,30%,40)", WI.Color.Format.RGBA);
     127            testGood("rgb( 10% , 20% , 30% , 40 )", WI.Color.Format.RGBA);
     128            testGood("rgb(999%, 999%, 999%, 999%)", WI.Color.Format.RGBA);
     129
     130            testGood("rgb(10%,20%,30%,40%)", WI.Color.Format.RGBA);
     131            testGood("RGB(10%,20%,30%,40%)", WI.Color.Format.RGBA);
     132            testGood("rgb( 10% , 20% , 30% , 40% )", WI.Color.Format.RGBA);
     133            testGood("rgb(999%, 999%, 999%, 999%)", WI.Color.Format.RGBA);
     134
     135            testGood("rgb(10% 20% 30% / 40)", WI.Color.Format.RGBA);
     136            testGood("RGB(10% 20% 30% / 40)", WI.Color.Format.RGBA);
     137            testGood("rgb( 10%  20%  30% / 40 )", WI.Color.Format.RGBA);
     138            testGood("rgb(999% 999% 999% / 999%)", WI.Color.Format.RGBA);
     139
     140            testGood("rgb(10% 20% 30% / 40%)", WI.Color.Format.RGBA);
     141            testGood("RGB(10% 20% 30% / 40%)", WI.Color.Format.RGBA);
     142            testGood("rgb( 10%  20%  30% / 40% )", WI.Color.Format.RGBA);
     143            testGood("rgb(999% 999% 999% / 999%)", WI.Color.Format.RGBA);
     144
     145            testGood("rgba(10%,20%,30%,40)", WI.Color.Format.RGBA);
     146            testGood("RGBA(10%,20%,30%,40)", WI.Color.Format.RGBA);
     147            testGood("rgba( 10% , 20% , 30% , 40 )", WI.Color.Format.RGBA);
     148            testGood("rgba(999%, 999%, 999%, 999%)", WI.Color.Format.RGBA);
     149
     150            testGood("rgba(10%,20%,30%,40%)", WI.Color.Format.RGBA);
     151            testGood("RGBA(10%,20%,30%,40%)", WI.Color.Format.RGBA);
     152            testGood("rgba( 10% , 20% , 30% , 40% )", WI.Color.Format.RGBA);
     153            testGood("rgba(999%, 999%, 999%, 999%)", WI.Color.Format.RGBA);
     154
     155            testGood("rgba(10% 20% 30% / 40)", WI.Color.Format.RGBA);
     156            testGood("RGBA(10% 20% 30% / 40)", WI.Color.Format.RGBA);
     157            testGood("rgba( 10%  20%  30% / 40 )", WI.Color.Format.RGBA);
     158            testGood("rgba(999% 999% 999% / 999%)", WI.Color.Format.RGBA);
     159
     160            testGood("rgba(10% 20% 30% / 40%)", WI.Color.Format.RGBA);
     161            testGood("RGBA(10% 20% 30% / 40%)", WI.Color.Format.RGBA);
     162            testGood("rgba( 10%  20%  30% / 40% )", WI.Color.Format.RGBA);
     163            testGood("rgba(999% 999% 999% / 999%)", WI.Color.Format.RGBA);
     164
     165            for (let unit of ["", "deg", "rad", "grad", "turn"]) {
     166                testGood(`hsl(10${unit},20%,30%)`, WI.Color.Format.HSL);
     167                testGood(`HSL(10${unit},20%,30%)`, WI.Color.Format.HSL);
     168                testGood(`hsl( 10${unit} , 20% , 30% )`, WI.Color.Format.HSL);
     169                testGood(`hsl(999${unit}, 999%, 999%)`, WI.Color.Format.HSL);
     170
     171                testGood(`hsl(10${unit} 20% 30%)`, WI.Color.Format.HSL);
     172                testGood(`HSL(10${unit} 20% 30%)`, WI.Color.Format.HSL);
     173                testGood(`hsl( 10${unit}  20%  30% )`, WI.Color.Format.HSL);
     174                testGood(`hsl(999${unit} 999% 999%)`, WI.Color.Format.HSL);
     175
     176                testGood(`hsl(10${unit},20%,30%,40)`, WI.Color.Format.HSLA);
     177                testGood(`HSL(10${unit},20%,30%,40)`, WI.Color.Format.HSLA);
     178                testGood(`hsl( 10${unit} , 20% , 30% , 40 )`, WI.Color.Format.HSLA);
     179                testGood(`hsl(999${unit}, 999%, 999%, 999)`, WI.Color.Format.HSLA);
     180
     181                testGood(`hsl(10${unit},20%,30%,40%)`, WI.Color.Format.HSLA);
     182                testGood(`HSL(10${unit},20%,30%,40%)`, WI.Color.Format.HSLA);
     183                testGood(`hsl( 10${unit} , 20% , 30% , 40% )`, WI.Color.Format.HSLA);
     184                testGood(`hsl(999${unit}, 999%, 999%, 999%)`, WI.Color.Format.HSLA);
     185
     186                testGood(`hsl(10${unit} 20% 30% / 40)`, WI.Color.Format.HSLA);
     187                testGood(`HSL(10${unit} 20% 30% / 40)`, WI.Color.Format.HSLA);
     188                testGood(`hsl( 10${unit}  20%  30% / 40 )`, WI.Color.Format.HSLA);
     189                testGood(`hsl(999${unit} 999% 999% / 999)`, WI.Color.Format.HSLA);
     190
     191                testGood(`hsl(10${unit} 20% 30% / 40%)`, WI.Color.Format.HSLA);
     192                testGood(`HSL(10${unit} 20% 30% / 40%)`, WI.Color.Format.HSLA);
     193                testGood(`hsl( 10${unit}  20%  30% / 40% )`, WI.Color.Format.HSLA);
     194                testGood(`hsl(999${unit} 999% 999% / 999%)`, WI.Color.Format.HSLA);
     195
     196                testGood(`hsl(10${unit},20%,30%,40)`, WI.Color.Format.HSLA);
     197                testGood(`HSL(10${unit},20%,30%,40)`, WI.Color.Format.HSLA);
     198                testGood(`hsl( 10${unit} , 20% , 30% , 40 )`, WI.Color.Format.HSLA);
     199                testGood(`hsl(999${unit}, 999%, 999%, 999)`, WI.Color.Format.HSLA);
     200
     201                testGood(`hsl(10${unit},20%,30%,40%)`, WI.Color.Format.HSLA);
     202                testGood(`HSL(10${unit},20%,30%,40%)`, WI.Color.Format.HSLA);
     203                testGood(`hsl( 10${unit} , 20% , 30% , 40% )`, WI.Color.Format.HSLA);
     204                testGood(`hsl(999${unit}, 999%, 999%, 999%)`, WI.Color.Format.HSLA);
     205
     206                testGood(`hsla(10${unit},20%,30%,40)`, WI.Color.Format.HSLA);
     207                testGood(`HSLA(10${unit},20%,30%,40)`, WI.Color.Format.HSLA);
     208                testGood(`hsla( 10${unit} , 0% , 50% , 40 )`, WI.Color.Format.HSLA);
     209                testGood(`hsla(999${unit}, 999%, 999%, 999)`, WI.Color.Format.HSLA);
     210
     211                testGood(`hsla(10${unit},20%,30%,40%)`, WI.Color.Format.HSLA);
     212                testGood(`HSLA(10${unit},20%,30%,40%)`, WI.Color.Format.HSLA);
     213                testGood(`hsla( 10${unit} , 20% , 30% , 40% )`, WI.Color.Format.HSLA);
     214                testGood(`hsla(999${unit}, 999%, 999%, 999%)`, WI.Color.Format.HSLA);
     215
     216                testGood(`hsla(10${unit} 20% 30% / 40)`, WI.Color.Format.HSLA);
     217                testGood(`HSLA(10${unit} 20% 30% / 40)`, WI.Color.Format.HSLA);
     218                testGood(`hsla( 10${unit}  20%  30% / 40 )`, WI.Color.Format.HSLA);
     219                testGood(`hsla(999${unit} 999% 999% / 999)`, WI.Color.Format.HSLA);
     220
     221                testGood(`hsla(10${unit} 20% 30% / 40%)`, WI.Color.Format.HSLA);
     222                testGood(`HSLA(10${unit} 20% 30% / 40%)`, WI.Color.Format.HSLA);
     223                testGood(`hsla( 10${unit}  20%  30% / 40% )`, WI.Color.Format.HSLA);
     224                testGood(`hsla(999${unit} 999% 999% / 999%)`, WI.Color.Format.HSLA);
     225            }
    89226
    90227            InspectorTest.log("");
     
    97234            testBad("#1234567"); // 7
    98235            testBad("#123456789"); // 9
    99             testBad("rgb(255, 255, 255, 0.5)"); // extra values
     236            testBad("rgb(255, 255, 255, 0.5, 1)"); // extra values
    100237            testBad("rgba(255, 255, 255, 0.5, 1)"); // extra values
    101             testBad("hsl(0, 0%, 50%, 1)"); // extra value
     238            testBad("hsl(0, 0%, 50%, 1, 2)"); // extra value
    102239            testBad("hsla(0, 0%, 50%, 1, 2)"); // extra values
    103240            testBad("superblue"); // not a keyword
  • trunk/Source/WebInspectorUI/ChangeLog

    r240549 r240550  
     12019-01-26  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: handle CSS Color 4 color syntaxes
     4        https://bugs.webkit.org/show_bug.cgi?id=193166
     5        <rdar://problem/47062403>
     6
     7        Reviewed by Simon Fraser.
     8
     9        * UserInterface/Models/Color.js:
     10        (WI.Color.fromString):
     11        (WI.Color.fromString.splitFunctionString): Added.
     12        (WI.Color.fromString.parseFunctionAlpha): Added.
     13        (WI.Color.fromString.parseFunctionComponent): Added.
     14        (WI.Color.fromString.parseHueComponent): Added.
     15        (WI.Color.fromString.parsePercentageComponent): Added.
     16
    1172019-01-26  Devin Rousso  <drousso@apple.com>
    218
  • trunk/Source/WebInspectorUI/UserInterface/Models/Color.js

    r239597 r240550  
    4949    static fromString(colorString)
    5050    {
    51         let value = colorString.toLowerCase().replace(/%|\s+/g, "");
    52         let transparentKeywords = ["transparent", "rgba(0,0,0,0)", "hsla(0,0,0,0)"];
    53         if (transparentKeywords.includes(value)) {
    54             let color = new WI.Color(WI.Color.Format.Keyword, [0, 0, 0, 0]);
    55             color.keyword = "transparent";
     51        const matchRegExp = /^(?:#(?<hex>[0-9a-f]{3,8})|rgba?\((?<rgb>[^)]+)\)|(?<keyword>\w+)|hsla?\((?<hsl>[^)]+)\))$/i;
     52        let match = colorString.match(matchRegExp);
     53        if (!match)
     54            return null;
     55
     56        if (match.groups.hex) {
     57            let hex = match.groups.hex.toUpperCase();
     58            switch (hex.length) {
     59            case 3:
     60                return new WI.Color(WI.Color.Format.ShortHEX, [
     61                    parseInt(hex.charAt(0) + hex.charAt(0), 16),
     62                    parseInt(hex.charAt(1) + hex.charAt(1), 16),
     63                    parseInt(hex.charAt(2) + hex.charAt(2), 16),
     64                    1
     65                ]);
     66
     67            case 6:
     68                return new WI.Color(WI.Color.Format.HEX, [
     69                    parseInt(hex.substring(0, 2), 16),
     70                    parseInt(hex.substring(2, 4), 16),
     71                    parseInt(hex.substring(4, 6), 16),
     72                    1
     73                ]);
     74
     75            case 4:
     76                return new WI.Color(WI.Color.Format.ShortHEXAlpha, [
     77                    parseInt(hex.charAt(0) + hex.charAt(0), 16),
     78                    parseInt(hex.charAt(1) + hex.charAt(1), 16),
     79                    parseInt(hex.charAt(2) + hex.charAt(2), 16),
     80                    parseInt(hex.charAt(3) + hex.charAt(3), 16) / 255
     81                ]);
     82
     83            case 8:
     84                return new WI.Color(WI.Color.Format.HEXAlpha, [
     85                    parseInt(hex.substring(0, 2), 16),
     86                    parseInt(hex.substring(2, 4), 16),
     87                    parseInt(hex.substring(4, 6), 16),
     88                    parseInt(hex.substring(6, 8), 16) / 255
     89                ]);
     90            }
     91
     92            return null;
     93        }
     94
     95        if (match.groups.keyword) {
     96            let keyword = match.groups.keyword.toLowerCase();
     97            if (!WI.Color.Keywords.hasOwnProperty(keyword))
     98                return null;
     99            let color = new WI.Color(WI.Color.Format.Keyword, WI.Color.Keywords[keyword].slice());
     100            color.keyword = keyword;
    56101            color.original = colorString;
    57102            return color;
    58103        }
    59104
    60         // Simple - #hex, rgb(), keyword, hsl()
    61         let simple = /^(?:#(?<hex>[0-9a-f]{3,8})|rgb\((?<rgb>[^)]+)\)|(?<keyword>\w+)|hsl\((?<hsl>[^)]+)\))$/i;
    62         let match = colorString.match(simple);
    63         if (match) {
    64             if (match.groups.hex) {
    65                 let hex = match.groups.hex.toUpperCase();
    66                 let len = hex.length;
    67                 if (len === 3) {
    68                     return new WI.Color(WI.Color.Format.ShortHEX, [
    69                         parseInt(hex.charAt(0) + hex.charAt(0), 16),
    70                         parseInt(hex.charAt(1) + hex.charAt(1), 16),
    71                         parseInt(hex.charAt(2) + hex.charAt(2), 16),
    72                         1
    73                     ]);
    74                 } else if (len === 6) {
    75                     return new WI.Color(WI.Color.Format.HEX, [
    76                         parseInt(hex.substring(0, 2), 16),
    77                         parseInt(hex.substring(2, 4), 16),
    78                         parseInt(hex.substring(4, 6), 16),
    79                         1
    80                     ]);
    81                 } else if (len === 4) {
    82                     return new WI.Color(WI.Color.Format.ShortHEXAlpha, [
    83                         parseInt(hex.charAt(0) + hex.charAt(0), 16),
    84                         parseInt(hex.charAt(1) + hex.charAt(1), 16),
    85                         parseInt(hex.charAt(2) + hex.charAt(2), 16),
    86                         parseInt(hex.charAt(3) + hex.charAt(3), 16) / 255
    87                     ]);
    88                 } else if (len === 8) {
    89                     return new WI.Color(WI.Color.Format.HEXAlpha, [
    90                         parseInt(hex.substring(0, 2), 16),
    91                         parseInt(hex.substring(2, 4), 16),
    92                         parseInt(hex.substring(4, 6), 16),
    93                         parseInt(hex.substring(6, 8), 16) / 255
    94                     ]);
    95                 } else
    96                     return null;
    97             } else if (match.groups.rgb) {
    98                 let rgb = match.groups.rgb.split(/\s*,\s*/);
    99                 if (rgb.length !== 3)
    100                     return null;
    101                 return new WI.Color(WI.Color.Format.RGB, [
    102                     parseInt(rgb[0]),
    103                     parseInt(rgb[1]),
    104                     parseInt(rgb[2]),
    105                     1
    106                 ]);
    107             } else if (match.groups.keyword) {
    108                 let keyword = match.groups.keyword.toLowerCase();
    109                 if (!WI.Color.Keywords.hasOwnProperty(keyword))
    110                     return null;
    111                 let color = new WI.Color(WI.Color.Format.Keyword, WI.Color.Keywords[keyword].concat(1));
    112                 color.keyword = keyword;
    113                 color.original = colorString;
    114                 return color;
    115             } else if (match.groups.hsl) {
    116                 let hsl = match.groups.hsl.replace(/%/g, "").split(/\s*,\s*/);
    117                 if (hsl.length !== 3)
    118                     return null;
    119                 return new WI.Color(WI.Color.Format.HSL, [
    120                     parseInt(hsl[0]),
    121                     parseInt(hsl[1]),
    122                     parseInt(hsl[2]),
    123                     1
    124                 ]);
     105        function splitFunctionString(string) {
     106            return string.trim().replace(/(\s*(,|\/)\s*|\s+)/g, "|").split("|");
     107        }
     108
     109        function parseFunctionAlpha(alpha) {
     110            let value = parseFloat(alpha);
     111            if (alpha.includes("%"))
     112                value /= 100;
     113            return Number.constrain(value, 0, 1);
     114        }
     115
     116        if (match.groups.rgb) {
     117            let rgb = splitFunctionString(match.groups.rgb);
     118            if (rgb.length !== 3 && rgb.length !== 4)
     119                return null;
     120
     121            function parseFunctionComponent(component) {
     122                let value = parseFloat(component);
     123                if (component.includes("%"))
     124                    value = value * 255 / 100;
     125                return Number.constrain(value, 0, 255);
    125126            }
    126         }
    127 
    128         // Advanced - rgba(), hsla()
    129         let advanced = /^(?:rgba\((?<rgba>[^)]+)\)|hsla\((?<hsla>[^)]+)\))$/i;
    130         match = colorString.match(advanced);
    131         if (match) {
    132             if (match.groups.rgba) {
    133                 let rgba = match.groups.rgba.split(/\s*,\s*/);
    134                 if (rgba.length !== 4)
    135                     return null;
    136                 return new WI.Color(WI.Color.Format.RGBA, [
    137                     parseInt(rgba[0]),
    138                     parseInt(rgba[1]),
    139                     parseInt(rgba[2]),
    140                     Number.constrain(parseFloat(rgba[3]), 0, 1)
    141                 ]);
    142             } else if (match.groups.hsla) {
    143                 let hsla = match.groups.hsla.replace(/%/g, "").split(/\s*,\s*/);
    144                 if (hsla.length !== 4)
    145                     return null;
    146                 return new WI.Color(WI.Color.Format.HSLA, [
    147                     parseInt(hsla[0]),
    148                     parseInt(hsla[1]),
    149                     parseInt(hsla[2]),
    150                     Number.constrain(parseFloat(hsla[3]), 0, 1)
    151                 ]);
     127
     128            let alpha = 1;
     129            if (rgb.length === 4)
     130                alpha = parseFunctionAlpha(rgb[3]);
     131
     132            return new WI.Color(rgb.length === 4 ? WI.Color.Format.RGBA : WI.Color.Format.RGB, [
     133                parseFunctionComponent(rgb[0]),
     134                parseFunctionComponent(rgb[1]),
     135                parseFunctionComponent(rgb[2]),
     136                alpha,
     137            ]);
     138        }
     139
     140        if (match.groups.hsl) {
     141            let hsl = splitFunctionString(match.groups.hsl);
     142            if (hsl.length !== 3 && hsl.length !== 4)
     143                return null;
     144
     145            let alpha = 1;
     146            if (hsl.length === 4)
     147                alpha = parseFunctionAlpha(hsl[3]);
     148
     149            function parseHueComponent(hue) {
     150                let value = parseFloat(hue);
     151                if (/(\b|\d)rad\b/.test(hue))
     152                    value = value * 180 / Math.PI;
     153                else if (/(\b|\d)grad\b/.test(hue))
     154                    value = value * 360 / 400;
     155                else if (/(\b|\d)turn\b/.test(hue))
     156                    value = value * 360;
     157                return Number.constrain(value, 0, 360);
    152158            }
     159
     160            function parsePercentageComponent(component) {
     161                let value = parseFloat(component);
     162                return Number.constrain(value, 0, 100);
     163            }
     164
     165            return new WI.Color(hsl.length === 4 ? WI.Color.Format.HSLA : WI.Color.Format.HSL, [
     166                parseHueComponent(hsl[0]),
     167                parsePercentageComponent(hsl[1]),
     168                parsePercentageComponent(hsl[2]),
     169                alpha,
     170            ]);
    153171        }
    154172
     
    596614
    597615WI.Color.Keywords = {
    598     "aliceblue": [240, 248, 255],
    599     "antiquewhite": [250, 235, 215],
    600     "aquamarine": [127, 255, 212],
    601     "azure": [240, 255, 255],
    602     "beige": [245, 245, 220],
    603     "bisque": [255, 228, 196],
    604     "black": [0, 0, 0],
    605     "blanchedalmond": [255, 235, 205],
    606     "blue": [0, 0, 255],
    607     "blueviolet": [138, 43, 226],
    608     "brown": [165, 42, 42],
    609     "burlywood": [222, 184, 135],
    610     "cadetblue": [95, 158, 160],
    611     "chartreuse": [127, 255, 0],
    612     "chocolate": [210, 105, 30],
    613     "coral": [255, 127, 80],
    614     "cornflowerblue": [100, 149, 237],
    615     "cornsilk": [255, 248, 220],
    616     "crimson": [237, 164, 61],
    617     "cyan": [0, 255, 255],
    618     "darkblue": [0, 0, 139],
    619     "darkcyan": [0, 139, 139],
    620     "darkgoldenrod": [184, 134, 11],
    621     "darkgray": [169, 169, 169],
    622     "darkgreen": [0, 100, 0],
    623     "darkgrey": [169, 169, 169],
    624     "darkkhaki": [189, 183, 107],
    625     "darkmagenta": [139, 0, 139],
    626     "darkolivegreen": [85, 107, 47],
    627     "darkorange": [255, 140, 0],
    628     "darkorchid": [153, 50, 204],
    629     "darkred": [139, 0, 0],
    630     "darksalmon": [233, 150, 122],
    631     "darkseagreen": [143, 188, 143],
    632     "darkslateblue": [72, 61, 139],
    633     "darkslategray": [47, 79, 79],
    634     "darkslategrey": [47, 79, 79],
    635     "darkturquoise": [0, 206, 209],
    636     "darkviolet": [148, 0, 211],
    637     "deeppink": [255, 20, 147],
    638     "deepskyblue": [0, 191, 255],
    639     "dimgray": [105, 105, 105],
    640     "dimgrey": [105, 105, 105],
    641     "dodgerblue": [30, 144, 255],
    642     "firebrick": [178, 34, 34],
    643     "floralwhite": [255, 250, 240],
    644     "forestgreen": [34, 139, 34],
    645     "gainsboro": [220, 220, 220],
    646     "ghostwhite": [248, 248, 255],
    647     "gold": [255, 215, 0],
    648     "goldenrod": [218, 165, 32],
    649     "gray": [128, 128, 128],
    650     "green": [0, 128, 0],
    651     "greenyellow": [173, 255, 47],
    652     "grey": [128, 128, 128],
    653     "honeydew": [240, 255, 240],
    654     "hotpink": [255, 105, 180],
    655     "indianred": [205, 92, 92],
    656     "indigo": [75, 0, 130],
    657     "ivory": [255, 255, 240],
    658     "khaki": [240, 230, 140],
    659     "lavender": [230, 230, 250],
    660     "lavenderblush": [255, 240, 245],
    661     "lawngreen": [124, 252, 0],
    662     "lemonchiffon": [255, 250, 205],
    663     "lightblue": [173, 216, 230],
    664     "lightcoral": [240, 128, 128],
    665     "lightcyan": [224, 255, 255],
    666     "lightgoldenrodyellow": [250, 250, 210],
    667     "lightgray": [211, 211, 211],
    668     "lightgreen": [144, 238, 144],
    669     "lightgrey": [211, 211, 211],
    670     "lightpink": [255, 182, 193],
    671     "lightsalmon": [255, 160, 122],
    672     "lightseagreen": [32, 178, 170],
    673     "lightskyblue": [135, 206, 250],
    674     "lightslategray": [119, 136, 153],
    675     "lightslategrey": [119, 136, 153],
    676     "lightsteelblue": [176, 196, 222],
    677     "lightyellow": [255, 255, 224],
    678     "lime": [0, 255, 0],
    679     "limegreen": [50, 205, 50],
    680     "linen": [250, 240, 230],
    681     "magenta": [255, 0, 255],
    682     "maroon": [128, 0, 0],
    683     "mediumaquamarine": [102, 205, 170],
    684     "mediumblue": [0, 0, 205],
    685     "mediumorchid": [186, 85, 211],
    686     "mediumpurple": [147, 112, 219],
    687     "mediumseagreen": [60, 179, 113],
    688     "mediumslateblue": [123, 104, 238],
    689     "mediumspringgreen": [0, 250, 154],
    690     "mediumturquoise": [72, 209, 204],
    691     "mediumvioletred": [199, 21, 133],
    692     "midnightblue": [25, 25, 112],
    693     "mintcream": [245, 255, 250],
    694     "mistyrose": [255, 228, 225],
    695     "moccasin": [255, 228, 181],
    696     "navajowhite": [255, 222, 173],
    697     "navy": [0, 0, 128],
    698     "oldlace": [253, 245, 230],
    699     "olive": [128, 128, 0],
    700     "olivedrab": [107, 142, 35],
    701     "orange": [255, 165, 0],
    702     "orangered": [255, 69, 0],
    703     "orchid": [218, 112, 214],
    704     "palegoldenrod": [238, 232, 170],
    705     "palegreen": [152, 251, 152],
    706     "paleturquoise": [175, 238, 238],
    707     "palevioletred": [219, 112, 147],
    708     "papayawhip": [255, 239, 213],
    709     "peachpuff": [255, 218, 185],
    710     "peru": [205, 133, 63],
    711     "pink": [255, 192, 203],
    712     "plum": [221, 160, 221],
    713     "powderblue": [176, 224, 230],
    714     "purple": [128, 0, 128],
    715     "rebeccapurple": [102, 51, 153],
    716     "red": [255, 0, 0],
    717     "rosybrown": [188, 143, 143],
    718     "royalblue": [65, 105, 225],
    719     "saddlebrown": [139, 69, 19],
    720     "salmon": [250, 128, 114],
    721     "sandybrown": [244, 164, 96],
    722     "seagreen": [46, 139, 87],
    723     "seashell": [255, 245, 238],
    724     "sienna": [160, 82, 45],
    725     "silver": [192, 192, 192],
    726     "skyblue": [135, 206, 235],
    727     "slateblue": [106, 90, 205],
    728     "slategray": [112, 128, 144],
    729     "slategrey": [112, 128, 144],
    730     "snow": [255, 250, 250],
    731     "springgreen": [0, 255, 127],
    732     "steelblue": [70, 130, 180],
    733     "tan": [210, 180, 140],
    734     "teal": [0, 128, 128],
    735     "thistle": [216, 191, 216],
    736     "tomato": [255, 99, 71],
    737     "turquoise": [64, 224, 208],
    738     "violet": [238, 130, 238],
    739     "wheat": [245, 222, 179],
    740     "white": [255, 255, 255],
    741     "whitesmoke": [245, 245, 245],
    742     "yellow": [255, 255, 0],
    743     "yellowgreen": [154, 205, 50]
     616    "aliceblue": [240, 248, 255, 1],
     617    "antiquewhite": [250, 235, 215, 1],
     618    "aquamarine": [127, 255, 212, 1],
     619    "azure": [240, 255, 255, 1],
     620    "beige": [245, 245, 220, 1],
     621    "bisque": [255, 228, 196, 1],
     622    "black": [0, 0, 0, 1],
     623    "blanchedalmond": [255, 235, 205, 1],
     624    "blue": [0, 0, 255, 1],
     625    "blueviolet": [138, 43, 226, 1],
     626    "brown": [165, 42, 42, 1],
     627    "burlywood": [222, 184, 135, 1],
     628    "cadetblue": [95, 158, 160, 1],
     629    "chartreuse": [127, 255, 0, 1],
     630    "chocolate": [210, 105, 30, 1],
     631    "coral": [255, 127, 80, 1],
     632    "cornflowerblue": [100, 149, 237, 1],
     633    "cornsilk": [255, 248, 220, 1],
     634    "crimson": [237, 164, 61, 1],
     635    "cyan": [0, 255, 255, 1],
     636    "darkblue": [0, 0, 139, 1],
     637    "darkcyan": [0, 139, 139, 1],
     638    "darkgoldenrod": [184, 134, 11, 1],
     639    "darkgray": [169, 169, 169, 1],
     640    "darkgreen": [0, 100, 0, 1],
     641    "darkgrey": [169, 169, 169, 1],
     642    "darkkhaki": [189, 183, 107, 1],
     643    "darkmagenta": [139, 0, 139, 1],
     644    "darkolivegreen": [85, 107, 47, 1],
     645    "darkorange": [255, 140, 0, 1],
     646    "darkorchid": [153, 50, 204, 1],
     647    "darkred": [139, 0, 0, 1],
     648    "darksalmon": [233, 150, 122, 1],
     649    "darkseagreen": [143, 188, 143, 1],
     650    "darkslateblue": [72, 61, 139, 1],
     651    "darkslategray": [47, 79, 79, 1],
     652    "darkslategrey": [47, 79, 79, 1],
     653    "darkturquoise": [0, 206, 209, 1],
     654    "darkviolet": [148, 0, 211, 1],
     655    "deeppink": [255, 20, 147, 1],
     656    "deepskyblue": [0, 191, 255, 1],
     657    "dimgray": [105, 105, 105, 1],
     658    "dimgrey": [105, 105, 105, 1],
     659    "dodgerblue": [30, 144, 255, 1],
     660    "firebrick": [178, 34, 34, 1],
     661    "floralwhite": [255, 250, 240, 1],
     662    "forestgreen": [34, 139, 34, 1],
     663    "gainsboro": [220, 220, 220, 1],
     664    "ghostwhite": [248, 248, 255, 1],
     665    "gold": [255, 215, 0, 1],
     666    "goldenrod": [218, 165, 32, 1],
     667    "gray": [128, 128, 128, 1],
     668    "green": [0, 128, 0, 1],
     669    "greenyellow": [173, 255, 47, 1],
     670    "grey": [128, 128, 128, 1],
     671    "honeydew": [240, 255, 240, 1],
     672    "hotpink": [255, 105, 180, 1],
     673    "indianred": [205, 92, 92, 1],
     674    "indigo": [75, 0, 130, 1],
     675    "ivory": [255, 255, 240, 1],
     676    "khaki": [240, 230, 140, 1],
     677    "lavender": [230, 230, 250, 1],
     678    "lavenderblush": [255, 240, 245, 1],
     679    "lawngreen": [124, 252, 0, 1],
     680    "lemonchiffon": [255, 250, 205, 1],
     681    "lightblue": [173, 216, 230, 1],
     682    "lightcoral": [240, 128, 128, 1],
     683    "lightcyan": [224, 255, 255, 1],
     684    "lightgoldenrodyellow": [250, 250, 210, 1],
     685    "lightgray": [211, 211, 211, 1],
     686    "lightgreen": [144, 238, 144, 1],
     687    "lightgrey": [211, 211, 211, 1],
     688    "lightpink": [255, 182, 193, 1],
     689    "lightsalmon": [255, 160, 122, 1],
     690    "lightseagreen": [32, 178, 170, 1],
     691    "lightskyblue": [135, 206, 250, 1],
     692    "lightslategray": [119, 136, 153, 1],
     693    "lightslategrey": [119, 136, 153, 1],
     694    "lightsteelblue": [176, 196, 222, 1],
     695    "lightyellow": [255, 255, 224, 1],
     696    "lime": [0, 255, 0, 1],
     697    "limegreen": [50, 205, 50, 1],
     698    "linen": [250, 240, 230, 1],
     699    "magenta": [255, 0, 255, 1],
     700    "maroon": [128, 0, 0, 1],
     701    "mediumaquamarine": [102, 205, 170, 1],
     702    "mediumblue": [0, 0, 205, 1],
     703    "mediumorchid": [186, 85, 211, 1],
     704    "mediumpurple": [147, 112, 219, 1],
     705    "mediumseagreen": [60, 179, 113, 1],
     706    "mediumslateblue": [123, 104, 238, 1],
     707    "mediumspringgreen": [0, 250, 154, 1],
     708    "mediumturquoise": [72, 209, 204, 1],
     709    "mediumvioletred": [199, 21, 133, 1],
     710    "midnightblue": [25, 25, 112, 1],
     711    "mintcream": [245, 255, 250, 1],
     712    "mistyrose": [255, 228, 225, 1],
     713    "moccasin": [255, 228, 181, 1],
     714    "navajowhite": [255, 222, 173, 1],
     715    "navy": [0, 0, 128, 1],
     716    "oldlace": [253, 245, 230, 1],
     717    "olive": [128, 128, 0, 1],
     718    "olivedrab": [107, 142, 35, 1],
     719    "orange": [255, 165, 0, 1],
     720    "orangered": [255, 69, 0, 1],
     721    "orchid": [218, 112, 214, 1],
     722    "palegoldenrod": [238, 232, 170, 1],
     723    "palegreen": [152, 251, 152, 1],
     724    "paleturquoise": [175, 238, 238, 1],
     725    "palevioletred": [219, 112, 147, 1],
     726    "papayawhip": [255, 239, 213, 1],
     727    "peachpuff": [255, 218, 185, 1],
     728    "peru": [205, 133, 63, 1],
     729    "pink": [255, 192, 203, 1],
     730    "plum": [221, 160, 221, 1],
     731    "powderblue": [176, 224, 230, 1],
     732    "purple": [128, 0, 128, 1],
     733    "rebeccapurple": [102, 51, 153, 1],
     734    "red": [255, 0, 0, 1],
     735    "rosybrown": [188, 143, 143, 1],
     736    "royalblue": [65, 105, 225, 1],
     737    "saddlebrown": [139, 69, 19, 1],
     738    "salmon": [250, 128, 114, 1],
     739    "sandybrown": [244, 164, 96, 1],
     740    "seagreen": [46, 139, 87, 1],
     741    "seashell": [255, 245, 238, 1],
     742    "sienna": [160, 82, 45, 1],
     743    "silver": [192, 192, 192, 1],
     744    "skyblue": [135, 206, 235, 1],
     745    "slateblue": [106, 90, 205, 1],
     746    "slategray": [112, 128, 144, 1],
     747    "slategrey": [112, 128, 144, 1],
     748    "snow": [255, 250, 250, 1],
     749    "springgreen": [0, 255, 127, 1],
     750    "steelblue": [70, 130, 180, 1],
     751    "tan": [210, 180, 140, 1],
     752    "teal": [0, 128, 128, 1],
     753    "thistle": [216, 191, 216, 1],
     754    "tomato": [255, 99, 71, 1],
     755    "transparent": [0, 0, 0, 0],
     756    "turquoise": [64, 224, 208, 1],
     757    "violet": [238, 130, 238, 1],
     758    "wheat": [245, 222, 179, 1],
     759    "white": [255, 255, 255, 1],
     760    "whitesmoke": [245, 245, 245, 1],
     761    "yellow": [255, 255, 0, 1],
     762    "yellowgreen": [154, 205, 50, 1],
    744763};
Note: See TracChangeset for help on using the changeset viewer.