Home | History | Annotate | Download | only in front-end
      1 /*
      2  * Copyright (C) 2009 Apple Inc.  All rights reserved.
      3  * Copyright (C) 2009 Joseph Pecoraro
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  *
      9  * 1.  Redistributions of source code must retain the above copyright
     10  *     notice, this list of conditions and the following disclaimer.
     11  * 2.  Redistributions in binary form must reproduce the above copyright
     12  *     notice, this list of conditions and the following disclaimer in the
     13  *     documentation and/or other materials provided with the distribution.
     14  * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
     15  *     its contributors may be used to endorse or promote products derived
     16  *     from this software without specific prior written permission.
     17  *
     18  * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
     19  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     20  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     21  * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
     22  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     24  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
     25  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28  */
     29 
     30 WebInspector.Color = function(str)
     31 {
     32     this.value = str;
     33     this._parse();
     34 }
     35 
     36 WebInspector.Color.prototype = {
     37     get shorthex()
     38     {
     39         if ("_short" in this)
     40             return this._short;
     41 
     42         if (!this.simple)
     43             return null;
     44 
     45         var hex = this.hex;
     46         if (hex.charAt(0) === hex.charAt(1) && hex.charAt(2) === hex.charAt(3) && hex.charAt(4) === hex.charAt(5))
     47             this._short = hex.charAt(0) + hex.charAt(2) + hex.charAt(4);
     48         else
     49             this._short = hex;
     50 
     51         return this._short;
     52     },
     53 
     54     get hex()
     55     {
     56         if (!this.simple)
     57             return null;
     58 
     59         return this._hex;
     60     },
     61 
     62     set hex(x)
     63     {
     64         this._hex = x;
     65     },
     66 
     67     get rgb()
     68     {
     69         if ("_rgb" in this)
     70             return this._rgb;
     71 
     72         if (this.simple)
     73             this._rgb = this._hexToRGB(this.hex);
     74         else {
     75             var rgba = this.rgba;
     76             this._rgb = [rgba[0], rgba[1], rgba[2]];
     77         }
     78 
     79         return this._rgb;
     80     },
     81 
     82     set rgb(x)
     83     {
     84         this._rgb = x;
     85     },
     86 
     87     get hsl()
     88     {
     89         if ("_hsl" in this)
     90             return this._hsl;
     91 
     92         this._hsl = this._rgbToHSL(this.rgb);
     93         return this._hsl;
     94     },
     95 
     96     set hsl(x)
     97     {
     98         this._hsl = x;
     99     },
    100 
    101     get nickname()
    102     {
    103         if (typeof this._nickname !== "undefined") // would be set on parse if there was a nickname
    104             return this._nickname;
    105         else
    106             return null;
    107     },
    108 
    109     set nickname(x)
    110     {
    111         this._nickname = x;
    112     },
    113 
    114     get rgba()
    115     {
    116         return this._rgba;
    117     },
    118 
    119     set rgba(x)
    120     {
    121         this._rgba = x;
    122     },
    123 
    124     get hsla()
    125     {
    126         return this._hsla;
    127     },
    128 
    129     set hsla(x)
    130     {
    131         this._hsla = x;
    132     },
    133 
    134     hasShortHex: function()
    135     {
    136         var shorthex = this.shorthex;
    137         return (shorthex && shorthex.length === 3);
    138     },
    139 
    140     toString: function(format)
    141     {
    142         if (!format)
    143             format = this.format;
    144 
    145         switch (format) {
    146             case "rgb":
    147                 return "rgb(" + this.rgb.join(", ") + ")";
    148             case "rgba":
    149                 return "rgba(" + this.rgba.join(", ") + ")";
    150             case "hsl":
    151                 var hsl = this.hsl;
    152                 return "hsl(" + hsl[0] + ", " + hsl[1] + "%, " + hsl[2] + "%)";
    153             case "hsla":
    154                 var hsla = this.hsla;
    155                 return "hsla(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%, " + hsla[3] + ")";
    156             case "hex":
    157                 return "#" + this.hex;
    158             case "shorthex":
    159                 return "#" + this.shorthex;
    160             case "nickname":
    161                 return this.nickname;
    162         }
    163 
    164         throw "invalid color format";
    165     },
    166 
    167     _rgbToHex: function(rgb)
    168     {
    169         var r = parseInt(rgb[0]).toString(16);
    170         var g = parseInt(rgb[1]).toString(16);
    171         var b = parseInt(rgb[2]).toString(16);
    172         if (r.length === 1)
    173             r = "0" + r;
    174         if (g.length === 1)
    175             g = "0" + g;
    176         if (b.length === 1)
    177             b = "0" + b;
    178 
    179         return (r + g + b).toUpperCase();
    180     },
    181 
    182     _hexToRGB: function(hex)
    183     {
    184         var r = parseInt(hex.substring(0,2), 16);
    185         var g = parseInt(hex.substring(2,4), 16);
    186         var b = parseInt(hex.substring(4,6), 16);
    187 
    188         return [r, g, b];
    189     },
    190 
    191     _rgbToHSL: function(rgb)
    192     {
    193         var r = parseInt(rgb[0]) / 255;
    194         var g = parseInt(rgb[1]) / 255;
    195         var b = parseInt(rgb[2]) / 255;
    196         var max = Math.max(r, g, b);
    197         var min = Math.min(r, g, b);
    198         var diff = max - min;
    199         var add = max + min;
    200 
    201         if (min === max)
    202             var h = 0;
    203         else if (r === max)
    204             var h = ((60 * (g - b) / diff) + 360) % 360;
    205         else if (g === max)
    206             var h = (60 * (b - r) / diff) + 120;
    207         else
    208             var h = (60 * (r - g) / diff) + 240;
    209 
    210         var l = 0.5 * add;
    211 
    212         if (l === 0)
    213             var s = 0;
    214         else if (l === 1)
    215             var s = 1;
    216         else if (l <= 0.5)
    217             var s = diff / add;
    218         else
    219             var s = diff / (2 - add);
    220 
    221         h = Math.round(h);
    222         s = Math.round(s*100);
    223         l = Math.round(l*100);
    224 
    225         return [h, s, l];
    226     },
    227 
    228     _hslToRGB: function(hsl)
    229     {
    230         var h = parseFloat(hsl[0]) / 360;
    231         var s = parseFloat(hsl[1]) / 100;
    232         var l = parseFloat(hsl[2]) / 100;
    233 
    234         if (l <= 0.5)
    235             var q = l * (1 + s);
    236         else
    237             var q = l + s - (l * s);
    238 
    239         var p = 2 * l - q;
    240 
    241         var tr = h + (1 / 3);
    242         var tg = h;
    243         var tb = h - (1 / 3);
    244 
    245         var r = Math.round(hueToRGB(p, q, tr) * 255);
    246         var g = Math.round(hueToRGB(p, q, tg) * 255);
    247         var b = Math.round(hueToRGB(p, q, tb) * 255);
    248         return [r, g, b];
    249 
    250         function hueToRGB(p, q, h) {
    251             if (h < 0)
    252                 h += 1;
    253             else if (h > 1)
    254                 h -= 1;
    255 
    256             if ((h * 6) < 1)
    257                 return p + (q - p) * h * 6;
    258             else if ((h * 2) < 1)
    259                 return q;
    260             else if ((h * 3) < 2)
    261                 return p + (q - p) * ((2 / 3) - h) * 6;
    262             else
    263                 return p;
    264         }
    265     },
    266 
    267     _rgbaToHSLA: function(rgba)
    268     {
    269         var alpha = rgba[3];
    270         var hsl = this._rgbToHSL(rgba)
    271         hsl.push(alpha);
    272         return hsl;
    273     },
    274 
    275     _hslaToRGBA: function(hsla)
    276     {
    277         var alpha = hsla[3];
    278         var rgb = this._hslToRGB(hsla);
    279         rgb.push(alpha);
    280         return rgb;
    281     },
    282 
    283     _parse: function()
    284     {
    285         // Special Values - Advanced but Must Be Parsed First - transparent
    286         var value = this.value.toLowerCase().replace(/%|\s+/g, "");
    287         if (value in WebInspector.Color.AdvancedNickNames) {
    288             this.format = "nickname";
    289             var set = WebInspector.Color.AdvancedNickNames[value];
    290             this.simple = false;
    291             this.rgba = set[0];
    292             this.hsla = set[1];
    293             this.nickname = set[2];
    294             this.alpha = set[0][3];
    295             return;
    296         }
    297 
    298         // Simple - #hex, rgb(), nickname, hsl()
    299         var simple = /^(?:#([0-9a-f]{3,6})|rgb\(([^)]+)\)|(\w+)|hsl\(([^)]+)\))$/i;
    300         var match = this.value.match(simple);
    301         if (match) {
    302             this.simple = true;
    303 
    304             if (match[1]) { // hex
    305                 var hex = match[1].toUpperCase();
    306                 if (hex.length === 3) {
    307                     this.format = "shorthex";
    308                     this.hex = hex.charAt(0) + hex.charAt(0) + hex.charAt(1) + hex.charAt(1) + hex.charAt(2) + hex.charAt(2);
    309                 } else {
    310                     this.format = "hex";
    311                     this.hex = hex;
    312                 }
    313             } else if (match[2]) { // rgb
    314                 this.format = "rgb";
    315                 var rgb = match[2].split(/\s*,\s*/);
    316                 this.rgb = rgb;
    317                 this.hex = this._rgbToHex(rgb);
    318             } else if (match[3]) { // nickname
    319                 var nickname = match[3].toLowerCase();
    320                 if (nickname in WebInspector.Color.Nicknames) {
    321                     this.format = "nickname";
    322                     this.hex = WebInspector.Color.Nicknames[nickname];
    323                 } else // unknown name
    324                     throw "unknown color name";
    325             } else if (match[4]) { // hsl
    326                 this.format = "hsl";
    327                 var hsl = match[4].replace(/%g/, "").split(/\s*,\s*/);
    328                 this.hsl = hsl;
    329                 this.rgb = this._hslToRGB(hsl);
    330                 this.hex = this._rgbToHex(this.rgb);
    331             }
    332 
    333             // Fill in the values if this is a known hex color
    334             var hex = this.hex;
    335             if (hex && hex in WebInspector.Color.HexTable) {
    336                 var set = WebInspector.Color.HexTable[hex];
    337                 this.rgb = set[0];
    338                 this.hsl = set[1];
    339                 this.nickname = set[2];
    340             }
    341 
    342             return;
    343         }
    344 
    345         // Advanced - rgba(), hsla()
    346         var advanced = /^(?:rgba\(([^)]+)\)|hsla\(([^)]+)\))$/;
    347         match = this.value.match(advanced);
    348         if (match) {
    349             this.simple = false;
    350             if (match[1]) { // rgba
    351                 this.format = "rgba";
    352                 this.rgba = match[1].split(/\s*,\s*/);
    353                 this.hsla = this._rgbaToHSLA(this.rgba);
    354                 this.alpha = this.rgba[3];
    355             } else if (match[2]) { // hsla
    356                 this.format = "hsla";
    357                 this.hsla = match[2].replace(/%/g, "").split(/\s*,\s*/);
    358                 this.rgba = this._hslaToRGBA(this.hsla);
    359                 this.alpha = this.hsla[3];
    360             }
    361 
    362             return;
    363         }
    364 
    365         // Could not parse as a valid color
    366         throw "could not parse color";
    367     }
    368 }
    369 
    370 // Simple Values: [rgb, hsl, nickname]
    371 WebInspector.Color.HexTable = {
    372     "000000": [[0, 0, 0], [0, 0, 0], "black"],
    373     "000080": [[0, 0, 128], [240, 100, 25], "navy"],
    374     "00008B": [[0, 0, 139], [240, 100, 27], "darkBlue"],
    375     "0000CD": [[0, 0, 205], [240, 100, 40], "mediumBlue"],
    376     "0000FF": [[0, 0, 255], [240, 100, 50], "blue"],
    377     "006400": [[0, 100, 0], [120, 100, 20], "darkGreen"],
    378     "008000": [[0, 128, 0], [120, 100, 25], "green"],
    379     "008080": [[0, 128, 128], [180, 100, 25], "teal"],
    380     "008B8B": [[0, 139, 139], [180, 100, 27], "darkCyan"],
    381     "00BFFF": [[0, 191, 255], [195, 100, 50], "deepSkyBlue"],
    382     "00CED1": [[0, 206, 209], [181, 100, 41], "darkTurquoise"],
    383     "00FA9A": [[0, 250, 154], [157, 100, 49], "mediumSpringGreen"],
    384     "00FF00": [[0, 255, 0], [120, 100, 50], "lime"],
    385     "00FF7F": [[0, 255, 127], [150, 100, 50], "springGreen"],
    386     "00FFFF": [[0, 255, 255], [180, 100, 50], "cyan"],
    387     "191970": [[25, 25, 112], [240, 64, 27], "midnightBlue"],
    388     "1E90FF": [[30, 144, 255], [210, 100, 56], "dodgerBlue"],
    389     "20B2AA": [[32, 178, 170], [177, 70, 41], "lightSeaGreen"],
    390     "228B22": [[34, 139, 34], [120, 61, 34], "forestGreen"],
    391     "2E8B57": [[46, 139, 87], [146, 50, 36], "seaGreen"],
    392     "2F4F4F": [[47, 79, 79], [180, 25, 25], "darkSlateGray"],
    393     "32CD32": [[50, 205, 50], [120, 61, 50], "limeGreen"],
    394     "3CB371": [[60, 179, 113], [147, 50, 47], "mediumSeaGreen"],
    395     "40E0D0": [[64, 224, 208], [174, 72, 56], "turquoise"],
    396     "4169E1": [[65, 105, 225], [225, 73, 57], "royalBlue"],
    397     "4682B4": [[70, 130, 180], [207, 44, 49], "steelBlue"],
    398     "483D8B": [[72, 61, 139], [248, 39, 39], "darkSlateBlue"],
    399     "48D1CC": [[72, 209, 204], [178, 60, 55], "mediumTurquoise"],
    400     "4B0082": [[75, 0, 130], [275, 100, 25], "indigo"],
    401     "556B2F": [[85, 107, 47], [82, 39, 30], "darkOliveGreen"],
    402     "5F9EA0": [[95, 158, 160], [182, 25, 50], "cadetBlue"],
    403     "6495ED": [[100, 149, 237], [219, 79, 66], "cornflowerBlue"],
    404     "66CDAA": [[102, 205, 170], [160, 51, 60], "mediumAquaMarine"],
    405     "696969": [[105, 105, 105], [0, 0, 41], "dimGray"],
    406     "6A5ACD": [[106, 90, 205], [248, 53, 58], "slateBlue"],
    407     "6B8E23": [[107, 142, 35], [80, 60, 35], "oliveDrab"],
    408     "708090": [[112, 128, 144], [210, 13, 50], "slateGray"],
    409     "778899": [[119, 136, 153], [210, 14, 53], "lightSlateGray"],
    410     "7B68EE": [[123, 104, 238], [249, 80, 67], "mediumSlateBlue"],
    411     "7CFC00": [[124, 252, 0], [90, 100, 49], "lawnGreen"],
    412     "7FFF00": [[127, 255, 0], [90, 100, 50], "chartreuse"],
    413     "7FFFD4": [[127, 255, 212], [160, 100, 75], "aquamarine"],
    414     "800000": [[128, 0, 0], [0, 100, 25], "maroon"],
    415     "800080": [[128, 0, 128], [300, 100, 25], "purple"],
    416     "808000": [[128, 128, 0], [60, 100, 25], "olive"],
    417     "808080": [[128, 128, 128], [0, 0, 50], "gray"],
    418     "87CEEB": [[135, 206, 235], [197, 71, 73], "skyBlue"],
    419     "87CEFA": [[135, 206, 250], [203, 92, 75], "lightSkyBlue"],
    420     "8A2BE2": [[138, 43, 226], [271, 76, 53], "blueViolet"],
    421     "8B0000": [[139, 0, 0], [0, 100, 27], "darkRed"],
    422     "8B008B": [[139, 0, 139], [300, 100, 27], "darkMagenta"],
    423     "8B4513": [[139, 69, 19], [25, 76, 31], "saddleBrown"],
    424     "8FBC8F": [[143, 188, 143], [120, 25, 65], "darkSeaGreen"],
    425     "90EE90": [[144, 238, 144], [120, 73, 75], "lightGreen"],
    426     "9370D8": [[147, 112, 219], [260, 60, 65], "mediumPurple"],
    427     "9400D3": [[148, 0, 211], [282, 100, 41], "darkViolet"],
    428     "98FB98": [[152, 251, 152], [120, 93, 79], "paleGreen"],
    429     "9932CC": [[153, 50, 204], [280, 61, 50], "darkOrchid"],
    430     "9ACD32": [[154, 205, 50], [80, 61, 50], "yellowGreen"],
    431     "A0522D": [[160, 82, 45], [19, 56, 40], "sienna"],
    432     "A52A2A": [[165, 42, 42], [0, 59, 41], "brown"],
    433     "A9A9A9": [[169, 169, 169], [0, 0, 66], "darkGray"],
    434     "ADD8E6": [[173, 216, 230], [195, 53, 79], "lightBlue"],
    435     "ADFF2F": [[173, 255, 47], [84, 100, 59], "greenYellow"],
    436     "AFEEEE": [[175, 238, 238], [180, 65, 81], "paleTurquoise"],
    437     "B0C4DE": [[176, 196, 222], [214, 41, 78], "lightSteelBlue"],
    438     "B0E0E6": [[176, 224, 230], [187, 52, 80], "powderBlue"],
    439     "B22222": [[178, 34, 34], [0, 68, 42], "fireBrick"],
    440     "B8860B": [[184, 134, 11], [43, 89, 38], "darkGoldenrod"],
    441     "BA55D3": [[186, 85, 211], [288, 59, 58], "mediumOrchid"],
    442     "BC8F8F": [[188, 143, 143], [0, 25, 65], "rosyBrown"],
    443     "BDB76B": [[189, 183, 107], [56, 38, 58], "darkKhaki"],
    444     "C0C0C0": [[192, 192, 192], [0, 0, 75], "silver"],
    445     "C71585": [[199, 21, 133], [322, 81, 43], "mediumVioletRed"],
    446     "CD5C5C": [[205, 92, 92], [0, 53, 58], "indianRed"],
    447     "CD853F": [[205, 133, 63], [30, 59, 53], "peru"],
    448     "D2691E": [[210, 105, 30], [25, 75, 47], "chocolate"],
    449     "D2B48C": [[210, 180, 140], [34, 44, 69], "tan"],
    450     "D3D3D3": [[211, 211, 211], [0, 0, 83], "lightGrey"],
    451     "D87093": [[219, 112, 147], [340, 60, 65], "paleVioletRed"],
    452     "D8BFD8": [[216, 191, 216], [300, 24, 80], "thistle"],
    453     "DA70D6": [[218, 112, 214], [302, 59, 65], "orchid"],
    454     "DAA520": [[218, 165, 32], [43, 74, 49], "goldenrod"],
    455     "DC143C": [[237, 164, 61], [35, 83, 58], "crimson"],
    456     "DCDCDC": [[220, 220, 220], [0, 0, 86], "gainsboro"],
    457     "DDA0DD": [[221, 160, 221], [300, 47, 75], "plum"],
    458     "DEB887": [[222, 184, 135], [34, 57, 70], "burlyWood"],
    459     "E0FFFF": [[224, 255, 255], [180, 100, 94], "lightCyan"],
    460     "E6E6FA": [[230, 230, 250], [240, 67, 94], "lavender"],
    461     "E9967A": [[233, 150, 122], [15, 72, 70], "darkSalmon"],
    462     "EE82EE": [[238, 130, 238], [300, 76, 72], "violet"],
    463     "EEE8AA": [[238, 232, 170], [55, 67, 80], "paleGoldenrod"],
    464     "F08080": [[240, 128, 128], [0, 79, 72], "lightCoral"],
    465     "F0E68C": [[240, 230, 140], [54, 77, 75], "khaki"],
    466     "F0F8FF": [[240, 248, 255], [208, 100, 97], "aliceBlue"],
    467     "F0FFF0": [[240, 255, 240], [120, 100, 97], "honeyDew"],
    468     "F0FFFF": [[240, 255, 255], [180, 100, 97], "azure"],
    469     "F4A460": [[244, 164, 96], [28, 87, 67], "sandyBrown"],
    470     "F5DEB3": [[245, 222, 179], [39, 77, 83], "wheat"],
    471     "F5F5DC": [[245, 245, 220], [60, 56, 91], "beige"],
    472     "F5F5F5": [[245, 245, 245], [0, 0, 96], "whiteSmoke"],
    473     "F5FFFA": [[245, 255, 250], [150, 100, 98], "mintCream"],
    474     "F8F8FF": [[248, 248, 255], [240, 100, 99], "ghostWhite"],
    475     "FA8072": [[250, 128, 114], [6, 93, 71], "salmon"],
    476     "FAEBD7": [[250, 235, 215], [34, 78, 91], "antiqueWhite"],
    477     "FAF0E6": [[250, 240, 230], [30, 67, 94], "linen"],
    478     "FAFAD2": [[250, 250, 210], [60, 80, 90], "lightGoldenrodYellow"],
    479     "FDF5E6": [[253, 245, 230], [39, 85, 95], "oldLace"],
    480     "FF0000": [[255, 0, 0], [0, 100, 50], "red"],
    481     "FF00FF": [[255, 0, 255], [300, 100, 50], "magenta"],
    482     "FF1493": [[255, 20, 147], [328, 100, 54], "deepPink"],
    483     "FF4500": [[255, 69, 0], [16, 100, 50], "orangeRed"],
    484     "FF6347": [[255, 99, 71], [9, 100, 64], "tomato"],
    485     "FF69B4": [[255, 105, 180], [330, 100, 71], "hotPink"],
    486     "FF7F50": [[255, 127, 80], [16, 100, 66], "coral"],
    487     "FF8C00": [[255, 140, 0], [33, 100, 50], "darkOrange"],
    488     "FFA07A": [[255, 160, 122], [17, 100, 74], "lightSalmon"],
    489     "FFA500": [[255, 165, 0], [39, 100, 50], "orange"],
    490     "FFB6C1": [[255, 182, 193], [351, 100, 86], "lightPink"],
    491     "FFC0CB": [[255, 192, 203], [350, 100, 88], "pink"],
    492     "FFD700": [[255, 215, 0], [51, 100, 50], "gold"],
    493     "FFDAB9": [[255, 218, 185], [28, 100, 86], "peachPuff"],
    494     "FFDEAD": [[255, 222, 173], [36, 100, 84], "navajoWhite"],
    495     "FFE4B5": [[255, 228, 181], [38, 100, 85], "moccasin"],
    496     "FFE4C4": [[255, 228, 196], [33, 100, 88], "bisque"],
    497     "FFE4E1": [[255, 228, 225], [6, 100, 94], "mistyRose"],
    498     "FFEBCD": [[255, 235, 205], [36, 100, 90], "blanchedAlmond"],
    499     "FFEFD5": [[255, 239, 213], [37, 100, 92], "papayaWhip"],
    500     "FFF0F5": [[255, 240, 245], [340, 100, 97], "lavenderBlush"],
    501     "FFF5EE": [[255, 245, 238], [25, 100, 97], "seaShell"],
    502     "FFF8DC": [[255, 248, 220], [48, 100, 93], "cornsilk"],
    503     "FFFACD": [[255, 250, 205], [54, 100, 90], "lemonChiffon"],
    504     "FFFAF0": [[255, 250, 240], [40, 100, 97], "floralWhite"],
    505     "FFFAFA": [[255, 250, 250], [0, 100, 99], "snow"],
    506     "FFFF00": [[255, 255, 0], [60, 100, 50], "yellow"],
    507     "FFFFE0": [[255, 255, 224], [60, 100, 94], "lightYellow"],
    508     "FFFFF0": [[255, 255, 240], [60, 100, 97], "ivory"],
    509     "FFFFFF": [[255, 255, 255], [0, 100, 100], "white"]
    510 };
    511 
    512 // Simple Values
    513 WebInspector.Color.Nicknames = {
    514     "aliceblue": "F0F8FF",
    515     "antiquewhite": "FAEBD7",
    516     "aqua": "00FFFF",
    517     "aquamarine": "7FFFD4",
    518     "azure": "F0FFFF",
    519     "beige": "F5F5DC",
    520     "bisque": "FFE4C4",
    521     "black": "000000",
    522     "blanchedalmond": "FFEBCD",
    523     "blue": "0000FF",
    524     "blueviolet": "8A2BE2",
    525     "brown": "A52A2A",
    526     "burlywood": "DEB887",
    527     "cadetblue": "5F9EA0",
    528     "chartreuse": "7FFF00",
    529     "chocolate": "D2691E",
    530     "coral": "FF7F50",
    531     "cornflowerblue": "6495ED",
    532     "cornsilk": "FFF8DC",
    533     "crimson": "DC143C",
    534     "cyan": "00FFFF",
    535     "darkblue": "00008B",
    536     "darkcyan": "008B8B",
    537     "darkgoldenrod": "B8860B",
    538     "darkgray": "A9A9A9",
    539     "darkgreen": "006400",
    540     "darkkhaki": "BDB76B",
    541     "darkmagenta": "8B008B",
    542     "darkolivegreen": "556B2F",
    543     "darkorange": "FF8C00",
    544     "darkorchid": "9932CC",
    545     "darkred": "8B0000",
    546     "darksalmon": "E9967A",
    547     "darkseagreen": "8FBC8F",
    548     "darkslateblue": "483D8B",
    549     "darkslategray": "2F4F4F",
    550     "darkturquoise": "00CED1",
    551     "darkviolet": "9400D3",
    552     "deeppink": "FF1493",
    553     "deepskyblue": "00BFFF",
    554     "dimgray": "696969",
    555     "dodgerblue": "1E90FF",
    556     "firebrick": "B22222",
    557     "floralwhite": "FFFAF0",
    558     "forestgreen": "228B22",
    559     "fuchsia": "FF00FF",
    560     "gainsboro": "DCDCDC",
    561     "ghostwhite": "F8F8FF",
    562     "gold": "FFD700",
    563     "goldenrod": "DAA520",
    564     "gray": "808080",
    565     "green": "008000",
    566     "greenyellow": "ADFF2F",
    567     "honeydew": "F0FFF0",
    568     "hotpink": "FF69B4",
    569     "indianred": "CD5C5C",
    570     "indigo": "4B0082",
    571     "ivory": "FFFFF0",
    572     "khaki": "F0E68C",
    573     "lavender": "E6E6FA",
    574     "lavenderblush": "FFF0F5",
    575     "lawngreen": "7CFC00",
    576     "lemonchiffon": "FFFACD",
    577     "lightblue": "ADD8E6",
    578     "lightcoral": "F08080",
    579     "lightcyan": "E0FFFF",
    580     "lightgoldenrodyellow": "FAFAD2",
    581     "lightgreen": "90EE90",
    582     "lightgrey": "D3D3D3",
    583     "lightpink": "FFB6C1",
    584     "lightsalmon": "FFA07A",
    585     "lightseagreen": "20B2AA",
    586     "lightskyblue": "87CEFA",
    587     "lightslategray": "778899",
    588     "lightsteelblue": "B0C4DE",
    589     "lightyellow": "FFFFE0",
    590     "lime": "00FF00",
    591     "limegreen": "32CD32",
    592     "linen": "FAF0E6",
    593     "magenta": "FF00FF",
    594     "maroon": "800000",
    595     "mediumaquamarine": "66CDAA",
    596     "mediumblue": "0000CD",
    597     "mediumorchid": "BA55D3",
    598     "mediumpurple": "9370D8",
    599     "mediumseagreen": "3CB371",
    600     "mediumslateblue": "7B68EE",
    601     "mediumspringgreen": "00FA9A",
    602     "mediumturquoise": "48D1CC",
    603     "mediumvioletred": "C71585",
    604     "midnightblue": "191970",
    605     "mintcream": "F5FFFA",
    606     "mistyrose": "FFE4E1",
    607     "moccasin": "FFE4B5",
    608     "navajowhite": "FFDEAD",
    609     "navy": "000080",
    610     "oldlace": "FDF5E6",
    611     "olive": "808000",
    612     "olivedrab": "6B8E23",
    613     "orange": "FFA500",
    614     "orangered": "FF4500",
    615     "orchid": "DA70D6",
    616     "palegoldenrod": "EEE8AA",
    617     "palegreen": "98FB98",
    618     "paleturquoise": "AFEEEE",
    619     "palevioletred": "D87093",
    620     "papayawhip": "FFEFD5",
    621     "peachpuff": "FFDAB9",
    622     "peru": "CD853F",
    623     "pink": "FFC0CB",
    624     "plum": "DDA0DD",
    625     "powderblue": "B0E0E6",
    626     "purple": "800080",
    627     "red": "FF0000",
    628     "rosybrown": "BC8F8F",
    629     "royalblue": "4169E1",
    630     "saddlebrown": "8B4513",
    631     "salmon": "FA8072",
    632     "sandybrown": "F4A460",
    633     "seagreen": "2E8B57",
    634     "seashell": "FFF5EE",
    635     "sienna": "A0522D",
    636     "silver": "C0C0C0",
    637     "skyblue": "87CEEB",
    638     "slateblue": "6A5ACD",
    639     "slategray": "708090",
    640     "snow": "FFFAFA",
    641     "springgreen": "00FF7F",
    642     "steelblue": "4682B4",
    643     "tan": "D2B48C",
    644     "teal": "008080",
    645     "thistle": "D8BFD8",
    646     "tomato": "FF6347",
    647     "turquoise": "40E0D0",
    648     "violet": "EE82EE",
    649     "wheat": "F5DEB3",
    650     "white": "FFFFFF",
    651     "whitesmoke": "F5F5F5",
    652     "yellow": "FFFF00",
    653     "yellowgreen": "9ACD32"
    654 };
    655 
    656 // Advanced Values [rgba, hsla, nickname]
    657 WebInspector.Color.AdvancedNickNames = {
    658     "transparent": [[0, 0, 0, 0], [0, 0, 0, 0], "transparent"],
    659     "rgba(0,0,0,0)": [[0, 0, 0, 0], [0, 0, 0, 0], "transparent"],
    660     "hsla(0,0,0,0)": [[0, 0, 0, 0], [0, 0, 0, 0], "transparent"],
    661 };
    662