Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / devtools / front_end / sdk / CSSMetadata.js
1 /*
2  * Copyright (C) 2010 Nikita Vasilyev. All rights reserved.
3  * Copyright (C) 2010 Joseph Pecoraro. All rights reserved.
4  * Copyright (C) 2010 Google Inc. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  *     * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *     * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  *     * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 /**
34  * @constructor
35  * @param {!Array.<!{name: string, longhands: !Array.<string>}|string>} properties
36  */
37 WebInspector.CSSMetadata = function(properties)
38 {
39     this._values = /** !Array.<string> */ ([]);
40     this._longhands = {};
41     this._shorthands = {};
42     for (var i = 0; i < properties.length; ++i) {
43         var property = properties[i];
44         if (typeof property === "string") {
45             this._values.push(property);
46             continue;
47         }
48         var propertyName = property.name;
49         this._values.push(propertyName);
50
51         var longhands = properties[i].longhands;
52         if (longhands) {
53             this._longhands[propertyName] = longhands;
54             for (var j = 0; j < longhands.length; ++j) {
55                 var longhandName = longhands[j];
56                 var shorthands = this._shorthands[longhandName];
57                 if (!shorthands) {
58                     shorthands = [];
59                     this._shorthands[longhandName] = shorthands;
60                 }
61                 shorthands.push(propertyName);
62             }
63         }
64     }
65     this._values.sort();
66 }
67
68 /**
69  * @type {!WebInspector.CSSMetadata}
70  */
71 WebInspector.CSSMetadata.cssPropertiesMetainfo = new WebInspector.CSSMetadata([]);
72
73 WebInspector.CSSMetadata.isColorAwareProperty = function(propertyName)
74 {
75     return WebInspector.CSSMetadata._colorAwareProperties[propertyName] === true;
76 }
77
78 WebInspector.CSSMetadata.colors = function()
79 {
80     if (!WebInspector.CSSMetadata._colorsKeySet)
81         WebInspector.CSSMetadata._colorsKeySet = WebInspector.CSSMetadata._colors.keySet();
82     return WebInspector.CSSMetadata._colorsKeySet;
83 }
84
85 // Taken from http://www.w3.org/TR/CSS21/propidx.html.
86 WebInspector.CSSMetadata.InheritedProperties = [
87     "azimuth", "border-collapse", "border-spacing", "caption-side", "color", "cursor", "direction", "elevation",
88     "empty-cells", "font-family", "font-size", "font-style", "font-variant", "font-weight", "font", "letter-spacing",
89     "line-height", "list-style-image", "list-style-position", "list-style-type", "list-style", "orphans", "pitch-range",
90     "pitch", "quotes", "resize", "richness", "speak-header", "speak-numeral", "speak-punctuation", "speak", "speech-rate", "stress",
91     "text-align", "text-indent", "text-transform", "text-shadow", "visibility", "voice-family", "volume", "white-space", "widows",
92     "word-spacing", "zoom"
93 ].keySet();
94
95 // These non-standard Blink-specific properties augment the InheritedProperties.
96 WebInspector.CSSMetadata.NonStandardInheritedProperties = [
97     "-webkit-font-smoothing"
98 ].keySet();
99
100 /**
101  * @param {string} name
102  * @return {string}
103  */
104 WebInspector.CSSMetadata.canonicalPropertyName = function(name)
105 {
106     if (!name || name.length < 9 || name.charAt(0) !== "-")
107         return name.toLowerCase();
108     var match = name.match(/(?:-webkit-)(.+)/);
109     var propertiesSet = WebInspector.CSSMetadata.cssPropertiesMetainfoKeySet();
110     var hasSupportedProperties = WebInspector.CSSMetadata.cssPropertiesMetainfo._values.length > 0;
111     if (!match || (hasSupportedProperties && !propertiesSet.hasOwnProperty(match[1].toLowerCase())))
112         return name.toLowerCase();
113     return match[1].toLowerCase();
114 }
115
116 /**
117  * @param {string} propertyName
118  * @return {boolean}
119  */
120 WebInspector.CSSMetadata.isPropertyInherited = function(propertyName)
121 {
122     return !!(WebInspector.CSSMetadata.InheritedProperties[WebInspector.CSSMetadata.canonicalPropertyName(propertyName)]
123             || WebInspector.CSSMetadata.NonStandardInheritedProperties[propertyName.toLowerCase()]);
124 }
125
126 WebInspector.CSSMetadata._colors = [
127     "aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red",
128     "silver", "teal", "white", "yellow", "transparent", "currentcolor", "grey", "aliceblue", "antiquewhite",
129     "aquamarine", "azure", "beige", "bisque", "blanchedalmond", "blueviolet", "brown", "burlywood", "cadetblue",
130     "chartreuse", "chocolate", "coral", "cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue", "darkcyan",
131     "darkgoldenrod", "darkgray", "darkgreen", "darkgrey", "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange",
132     "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue", "darkslategray", "darkslategrey",
133     "darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dimgrey", "dodgerblue", "firebrick",
134     "floralwhite", "forestgreen", "gainsboro", "ghostwhite", "gold", "goldenrod", "greenyellow", "honeydew", "hotpink",
135     "indianred", "indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue",
136     "lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey", "lightpink",
137     "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightslategrey", "lightsteelblue", "lightyellow",
138     "limegreen", "linen", "magenta", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen",
139     "mediumslateblue", "mediumspringgreen", "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream",
140     "mistyrose", "moccasin", "navajowhite", "oldlace", "olivedrab", "orangered", "orchid", "palegoldenrod", "palegreen",
141     "paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", "rosybrown",
142     "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen", "seashell", "sienna", "skyblue", "slateblue",
143     "slategray", "slategrey", "snow", "springgreen", "steelblue", "tan", "thistle", "tomato", "turquoise", "violet",
144     "wheat", "whitesmoke", "yellowgreen"
145 ];
146
147 WebInspector.CSSMetadata._colorAwareProperties = [
148     "background", "background-color", "background-image", "border", "border-color", "border-top", "border-right", "border-bottom",
149     "border-left", "border-top-color", "border-right-color", "border-bottom-color", "border-left-color", "box-shadow", "color",
150     "fill", "outline", "outline-color", "stroke", "text-line-through-color", "text-overline-color",
151     "text-shadow", "text-underline-color", "-webkit-box-shadow", "-webkit-column-rule-color",
152     "-webkit-text-decoration-color", "-webkit-text-emphasis", "-webkit-text-emphasis-color"
153 ].keySet();
154
155 WebInspector.CSSMetadata._propertyDataMap = {
156     "table-layout": { values: [
157         "auto", "fixed"
158     ] },
159     "visibility": { values: [
160         "hidden", "visible", "collapse"
161     ] },
162     "background-repeat": { values: [
163         "repeat", "repeat-x", "repeat-y", "no-repeat", "space", "round"
164     ] },
165     "content": { values: [
166         "list-item", "close-quote", "no-close-quote", "no-open-quote", "open-quote"
167     ] },
168     "list-style-image": { values: [
169         "none"
170     ] },
171     "clear": { values: [
172         "none", "left", "right", "both"
173     ] },
174     "text-underline-mode": { values: [
175         "continuous", "skip-white-space"
176     ] },
177     "overflow-x": { values: [
178         "hidden", "auto", "visible", "overlay", "scroll"
179     ] },
180     "stroke-linejoin": { values: [
181         "round", "miter", "bevel"
182     ] },
183     "baseline-shift": { values: [
184         "baseline", "sub", "super"
185     ] },
186     "border-bottom-width": { values: [
187         "medium", "thick", "thin"
188     ] },
189     "marquee-speed": { values: [
190         "normal", "slow", "fast"
191     ] },
192     "margin-top-collapse": { values: [
193         "collapse", "separate", "discard"
194     ] },
195     "max-height": { values: [
196         "none"
197     ] },
198     "box-orient": { values: [
199         "horizontal", "vertical", "inline-axis", "block-axis"
200     ], },
201     "font-stretch": { values: [
202         "normal", "wider", "narrower", "ultra-condensed", "extra-condensed", "condensed", "semi-condensed",
203         "semi-expanded", "expanded", "extra-expanded", "ultra-expanded"
204     ] },
205     "text-underline-style": { values: [
206         "none", "dotted", "dashed", "solid", "double", "dot-dash", "dot-dot-dash", "wave"
207     ] },
208     "text-overline-mode": { values: [
209         "continuous", "skip-white-space"
210     ] },
211     "-webkit-background-composite": { values: [
212         "highlight", "clear", "copy", "source-over", "source-in", "source-out", "source-atop", "destination-over",
213         "destination-in", "destination-out", "destination-atop", "xor", "plus-darker", "plus-lighter"
214     ] },
215     "border-left-width": { values: [
216         "medium", "thick", "thin"
217     ] },
218     "box-shadow": { values: [
219         "inset", "none"
220     ] },
221     "-webkit-writing-mode": { values: [
222         "lr", "rl", "tb", "lr-tb", "rl-tb", "tb-rl", "horizontal-tb", "vertical-rl", "vertical-lr", "horizontal-bt"
223     ] },
224     "text-line-through-mode": { values: [
225         "continuous", "skip-white-space"
226     ] },
227     "border-collapse": { values: [
228         "collapse", "separate"
229     ] },
230     "page-break-inside": { values: [
231         "auto", "avoid"
232     ] },
233     "border-top-width": { values: [
234         "medium", "thick", "thin"
235     ] },
236     "outline-color": { values: [
237         "invert"
238     ] },
239     "text-line-through-style": { values: [
240         "none", "dotted", "dashed", "solid", "double", "dot-dash", "dot-dot-dash", "wave"
241     ] },
242     "outline-style": { values: [
243         "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
244     ] },
245     "cursor": { values: [
246         "none", "copy", "auto", "crosshair", "default", "pointer", "move", "vertical-text", "cell", "context-menu",
247         "alias", "progress", "no-drop", "not-allowed", "-webkit-zoom-in", "-webkit-zoom-out", "e-resize", "ne-resize",
248         "nw-resize", "n-resize", "se-resize", "sw-resize", "s-resize", "w-resize", "ew-resize", "ns-resize",
249         "nesw-resize", "nwse-resize", "col-resize", "row-resize", "text", "wait", "help", "all-scroll", "-webkit-grab",
250         "-webkit-grabbing"
251     ] },
252     "border-width": { values: [
253         "medium", "thick", "thin"
254     ] },
255     "border-style": { values: [
256         "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
257     ] },
258     "size": { values: [
259         "a3", "a4", "a5", "b4", "b5", "landscape", "ledger", "legal", "letter", "portrait"
260     ] },
261     "background-size": { values: [
262         "contain", "cover"
263     ] },
264     "direction": { values: [
265         "ltr", "rtl"
266     ] },
267     "marquee-direction": { values: [
268         "left", "right", "auto", "reverse", "forwards", "backwards", "ahead", "up", "down"
269     ] },
270     "enable-background": { values: [
271         "accumulate", "new"
272     ] },
273     "float": { values: [
274         "none", "left", "right"
275     ] },
276     "overflow-y": { values: [
277         "hidden", "auto", "visible", "overlay", "scroll"
278     ] },
279     "margin-bottom-collapse": { values: [
280         "collapse",  "separate", "discard"
281     ] },
282     "box-reflect": { values: [
283         "left", "right", "above", "below"
284     ] },
285     "overflow": { values: [
286         "hidden", "auto", "visible", "overlay", "scroll"
287     ] },
288     "text-rendering": { values: [
289         "auto", "optimizeSpeed", "optimizeLegibility", "geometricPrecision"
290     ] },
291     "text-align": { values: [
292         "-webkit-auto", "start", "end", "left", "right", "center", "justify", "-webkit-left", "-webkit-right", "-webkit-center"
293     ] },
294     "list-style-position": { values: [
295         "outside", "inside", "hanging"
296     ] },
297     "margin-bottom": { values: [
298         "auto"
299     ] },
300     "color-interpolation": { values: [
301         "linearrgb"
302     ] },
303     "background-origin": { values: [
304         "border-box", "content-box", "padding-box"
305     ] },
306     "word-wrap": { values: [
307         "normal", "break-word"
308     ] },
309     "font-weight": { values: [
310         "normal", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900"
311     ] },
312     "margin-before-collapse": { values: [
313         "collapse", "separate", "discard"
314     ] },
315     "text-overline-width": { values: [
316         "normal", "medium", "auto", "thick", "thin"
317     ] },
318     "text-transform": { values: [
319         "none", "capitalize", "uppercase", "lowercase"
320     ] },
321     "border-right-style": { values: [
322         "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
323     ] },
324     "border-left-style": { values: [
325         "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
326     ] },
327     "-webkit-text-emphasis": { values: [
328         "circle", "filled", "open", "dot", "double-circle", "triangle", "sesame"
329     ] },
330     "font-style": { values: [
331         "italic", "oblique", "normal"
332     ] },
333     "speak": { values: [
334         "none", "normal", "spell-out", "digits", "literal-punctuation", "no-punctuation"
335     ] },
336     "color-rendering": { values: [
337         "auto", "optimizeSpeed", "optimizeQuality"
338     ] },
339     "list-style-type": { values: [
340         "none", "inline", "disc", "circle", "square", "decimal", "decimal-leading-zero", "arabic-indic", "binary", "bengali",
341         "cambodian", "khmer", "devanagari", "gujarati", "gurmukhi", "kannada", "lower-hexadecimal", "lao", "malayalam",
342         "mongolian", "myanmar", "octal", "oriya", "persian", "urdu", "telugu", "tibetan", "thai", "upper-hexadecimal",
343         "lower-roman", "upper-roman", "lower-greek", "lower-alpha", "lower-latin", "upper-alpha", "upper-latin", "afar",
344         "ethiopic-halehame-aa-et", "ethiopic-halehame-aa-er", "amharic", "ethiopic-halehame-am-et", "amharic-abegede",
345         "ethiopic-abegede-am-et", "cjk-earthly-branch", "cjk-heavenly-stem", "ethiopic", "ethiopic-halehame-gez",
346         "ethiopic-abegede", "ethiopic-abegede-gez", "hangul-consonant", "hangul", "lower-norwegian", "oromo",
347         "ethiopic-halehame-om-et", "sidama", "ethiopic-halehame-sid-et", "somali", "ethiopic-halehame-so-et", "tigre",
348         "ethiopic-halehame-tig", "tigrinya-er", "ethiopic-halehame-ti-er", "tigrinya-er-abegede",
349         "ethiopic-abegede-ti-er", "tigrinya-et", "ethiopic-halehame-ti-et", "tigrinya-et-abegede",
350         "ethiopic-abegede-ti-et", "upper-greek", "upper-norwegian", "asterisks", "footnotes", "hebrew", "armenian",
351         "lower-armenian", "upper-armenian", "georgian", "cjk-ideographic", "hiragana", "katakana", "hiragana-iroha",
352         "katakana-iroha"
353     ] },
354     "-webkit-text-combine": { values: [
355         "none", "horizontal"
356     ] },
357     "outline": { values: [
358         "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
359     ] },
360     "font": { values: [
361         "caption", "icon", "menu", "message-box", "small-caption", "-webkit-mini-control", "-webkit-small-control",
362         "-webkit-control", "status-bar", "italic", "oblique", "small-caps", "normal", "bold", "bolder", "lighter",
363         "100", "200", "300", "400", "500", "600", "700", "800", "900", "xx-small", "x-small", "small", "medium",
364         "large", "x-large", "xx-large", "-webkit-xxx-large", "smaller", "larger", "serif", "sans-serif", "cursive",
365         "fantasy", "monospace", "-webkit-body", "-webkit-pictograph"
366     ] },
367     "dominant-baseline": { values: [
368         "middle", "auto", "central", "text-before-edge", "text-after-edge", "ideographic", "alphabetic", "hanging",
369         "mathematical", "use-script", "no-change", "reset-size"
370     ] },
371     "display": { values: [
372         "none", "inline", "block", "list-item", "run-in", "compact", "inline-block", "table", "inline-table",
373         "table-row-group", "table-header-group", "table-footer-group", "table-row", "table-column-group",
374         "table-column", "table-cell", "table-caption", "-webkit-box", "-webkit-inline-box",
375         "flex", "inline-flex", "grid", "inline-grid"
376     ] },
377     "-webkit-text-emphasis-position": { values: [
378         "over", "under"
379     ] },
380     "image-rendering": { values: [
381         "auto", "optimizeSpeed", "optimizeQuality"
382     ] },
383     "alignment-baseline": { values: [
384         "baseline", "middle", "auto", "before-edge", "after-edge", "central", "text-before-edge", "text-after-edge",
385         "ideographic", "alphabetic", "hanging", "mathematical"
386     ] },
387     "outline-width": { values: [
388         "medium", "thick", "thin"
389     ] },
390     "text-line-through-width": { values: [
391         "normal", "medium", "auto", "thick", "thin"
392     ] },
393     "box-align": { values: [
394         "baseline", "center", "stretch", "start", "end"
395     ] },
396     "border-right-width": { values: [
397         "medium", "thick", "thin"
398     ] },
399     "border-top-style": { values: [
400         "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
401     ] },
402     "line-height": { values: [
403         "normal"
404     ] },
405     "text-overflow": { values: [
406         "clip", "ellipsis"
407     ] },
408     "overflow-wrap": { values: [
409         "normal", "break-word"
410     ] },
411     "box-direction": { values: [
412         "normal", "reverse"
413     ] },
414     "margin-after-collapse": { values: [
415         "collapse", "separate", "discard"
416     ] },
417     "page-break-before": { values: [
418         "left", "right", "auto", "always", "avoid"
419     ] },
420     "border-image": { values: [
421         "repeat", "stretch"
422     ] },
423     "text-decoration": { values: [
424         "blink", "line-through", "overline", "underline"
425     ] },
426     "position": { values: [
427         "absolute", "fixed", "relative", "static"
428     ] },
429     "font-family": { values: [
430         "serif", "sans-serif", "cursive", "fantasy", "monospace", "-webkit-body", "-webkit-pictograph"
431     ] },
432     "text-overflow-mode": { values: [
433         "clip", "ellipsis"
434     ] },
435     "border-bottom-style": { values: [
436         "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
437     ] },
438     "unicode-bidi": { values: [
439         "normal", "bidi-override", "embed", "isolate", "isolate-override", "plaintext"
440     ] },
441     "clip-rule": { values: [
442         "nonzero", "evenodd"
443     ] },
444     "margin-left": { values: [
445         "auto"
446     ] },
447     "margin-top": { values: [
448         "auto"
449     ] },
450     "zoom": { values: [
451         "normal", "document", "reset"
452     ] },
453     "text-overline-style": { values: [
454         "none", "dotted", "dashed", "solid", "double", "dot-dash", "dot-dot-dash", "wave"
455     ] },
456     "max-width": { values: [
457         "none"
458     ] },
459     "caption-side": { values: [
460         "top", "bottom"
461     ] },
462     "empty-cells": { values: [
463         "hide", "show"
464     ] },
465     "pointer-events": { values: [
466         "none", "all", "auto", "visible", "visiblepainted", "visiblefill", "visiblestroke", "painted", "fill", "stroke", "bounding-box"
467     ] },
468     "letter-spacing": { values: [
469         "normal"
470     ] },
471     "background-clip": { values: [
472         "border-box", "content-box", "padding-box"
473     ] },
474     "-webkit-font-smoothing": { values: [
475         "none", "auto", "antialiased", "subpixel-antialiased"
476     ] },
477     "border": { values: [
478         "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
479     ] },
480     "font-size": { values: [
481         "xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "-webkit-xxx-large", "smaller",
482         "larger"
483     ] },
484     "font-variant": { values: [
485         "small-caps", "normal"
486     ] },
487     "vertical-align": { values: [
488         "baseline", "middle", "sub", "super", "text-top", "text-bottom", "top", "bottom", "-webkit-baseline-middle"
489     ] },
490     "marquee-style": { values: [
491         "none", "scroll", "slide", "alternate"
492     ] },
493     "white-space": { values: [
494         "normal", "nowrap", "pre", "pre-line", "pre-wrap"
495     ] },
496     "text-underline-width": { values: [
497         "normal", "medium", "auto", "thick", "thin"
498     ] },
499     "box-lines": { values: [
500         "single", "multiple"
501     ] },
502     "page-break-after": { values: [
503         "left", "right", "auto", "always", "avoid"
504     ] },
505     "clip-path": { values: [
506         "none"
507     ] },
508     "margin": { values: [
509         "auto"
510     ] },
511     "marquee-repetition": { values: [
512         "infinite"
513     ] },
514     "margin-right": { values: [
515         "auto"
516     ] },
517     "word-break": { values: [
518         "normal", "break-all", "break-word"
519     ] },
520     "word-spacing": { values: [
521         "normal"
522     ] },
523     "-webkit-text-emphasis-style": { values: [
524         "circle", "filled", "open", "dot", "double-circle", "triangle", "sesame"
525     ] },
526     "transform": { values: [
527         "scale", "scaleX", "scaleY", "scale3d", "rotate", "rotateX", "rotateY", "rotateZ", "rotate3d", "skew", "skewX", "skewY",
528         "translate", "translateX", "translateY", "translateZ", "translate3d", "matrix", "matrix3d", "perspective"
529     ] },
530     "image-resolution": { values: [
531         "from-image", "snap"
532     ] },
533     "box-sizing": { values: [
534         "content-box", "padding-box", "border-box"
535     ] },
536     "clip": { values: [
537         "auto"
538     ] },
539     "resize": { values: [
540         "none", "both", "horizontal", "vertical"
541     ] },
542     "align-content": { values: [
543         "flex-start", "flex-end", "center", "space-between", "space-around", "stretch"
544     ] },
545     "align-items": {  values: [
546         "flex-start", "flex-end", "center", "baseline", "stretch"
547     ] },
548     "align-self": {  values: [
549         "auto", "flex-start", "flex-end", "center", "baseline", "stretch"
550     ] },
551     "flex-direction": { values: [
552         "row", "row-reverse", "column", "column-reverse"
553     ] },
554     "justify-content": { values: [
555         "flex-start", "flex-end", "center", "space-between", "space-around"
556     ] },
557     "flex-wrap": { values: [
558         "nowrap", "wrap", "wrap-reverse"
559     ] },
560     "-webkit-animation-timing-function": { values: [
561         "ease", "linear", "ease-in", "ease-out", "ease-in-out", "step-start", "step-end", "steps", "cubic-bezier"
562     ] },
563     "-webkit-animation-direction": { values: [
564         "normal", "reverse", "alternate", "alternate-reverse"
565     ] },
566     "-webkit-animation-play-state": { values: [
567         "running", "paused"
568     ] },
569     "-webkit-animation-fill-mode": { values: [
570         "none", "forwards", "backwards", "both"
571     ] },
572     "-webkit-backface-visibility": { values: [
573         "visible", "hidden"
574     ] },
575     "-webkit-box-decoration-break": { values: [
576         "slice", "clone"
577     ] },
578     "-webkit-column-break-after": { values: [
579         "auto", "always", "avoid", "left", "right", "page", "column", "avoid-page", "avoid-column"
580     ] },
581     "-webkit-column-break-before": { values: [
582         "auto", "always", "avoid", "left", "right", "page", "column", "avoid-page", "avoid-column"
583     ] },
584     "-webkit-column-break-inside": { values: [
585         "auto", "avoid", "avoid-page", "avoid-column"
586     ] },
587     "-webkit-column-span": { values: [
588         "none", "all"
589     ] },
590     "-webkit-column-count": { values: [
591         "auto"
592     ] },
593     "-webkit-column-gap": { values: [
594         "normal"
595     ] },
596     "-webkit-line-break": { values: [
597         "auto", "loose", "normal", "strict"
598     ] },
599     "-webkit-perspective": { values: [
600         "none"
601     ] },
602     "-webkit-perspective-origin": { values: [
603         "left", "center", "right", "top", "bottom"
604     ] },
605     "text-align-last": { values: [
606         "auto", "start", "end", "left", "right", "center", "justify"
607     ] },
608     "-webkit-text-decoration-line": { values: [
609         "none", "underline", "overline", "line-through", "blink"
610     ] },
611     "-webkit-text-decoration-style": { values: [
612         "solid", "double", "dotted", "dashed", "wavy"
613     ] },
614     "-webkit-text-decoration-skip": { values: [
615         "none", "objects", "spaces", "ink", "edges", "box-decoration"
616     ] },
617     "-webkit-transform-origin": { values: [
618         "left", "center", "right", "top", "bottom"
619     ] },
620     "-webkit-transform-style": { values: [
621         "flat", "preserve-3d"
622     ] },
623     "-webkit-transition-timing-function": { values: [
624         "ease", "linear", "ease-in", "ease-out", "ease-in-out", "step-start", "step-end", "steps", "cubic-bezier"
625     ] },
626
627     "-webkit-flex": { m: "flexbox" },
628     "-webkit-flex-basis": { m: "flexbox" },
629     "-webkit-flex-flow": { m: "flexbox" },
630     "-webkit-flex-grow": { m: "flexbox" },
631     "-webkit-flex-shrink": { m: "flexbox" },
632     "-webkit-animation": { m: "animations" },
633     "-webkit-animation-delay": { m: "animations" },
634     "-webkit-animation-duration": { m: "animations" },
635     "-webkit-animation-iteration-count": { m: "animations" },
636     "-webkit-animation-name": { m: "animations" },
637     "-webkit-column-rule": { m: "multicol" },
638     "-webkit-column-rule-color": { m: "multicol", a: "crc" },
639     "-webkit-column-rule-style": { m: "multicol", a: "crs" },
640     "-webkit-column-rule-width": { m: "multicol", a: "crw" },
641     "-webkit-column-width": { m: "multicol", a: "cw" },
642     "-webkit-columns": { m: "multicol" },
643     "-webkit-order": { m: "flexbox" },
644     "-webkit-text-decoration-color": { m: "text-decor" },
645     "-webkit-text-emphasis-color": { m: "text-decor" },
646     "-webkit-transition": { m: "transitions" },
647     "-webkit-transition-delay": { m: "transitions" },
648     "-webkit-transition-duration": { m: "transitions" },
649     "-webkit-transition-property": { m: "transitions" },
650     "background": { m: "background" },
651     "background-attachment": { m: "background" },
652     "background-color": { m: "background" },
653     "background-image": { m: "background" },
654     "background-position": { m: "background" },
655     "background-position-x": { m: "background" },
656     "background-position-y": { m: "background" },
657     "background-repeat-x": { m: "background" },
658     "background-repeat-y": { m: "background" },
659     "border-top": { m: "background" },
660     "border-right": { m: "background" },
661     "border-bottom": { m: "background" },
662     "border-left": { m: "background" },
663     "border-radius": { m: "background" },
664     "bottom": { m: "visuren" },
665     "color": { m: "color", a: "foreground" },
666     "counter-increment": { m: "generate" },
667     "counter-reset": { m: "generate" },
668     "grid-template-columns": { m: "grid" },
669     "grid-template-rows": { m: "grid" },
670     "height": { m: "box" },
671     "image-orientation": { m: "images" },
672     "left": { m: "visuren" },
673     "list-style": { m: "lists" },
674     "min-height": { m: "box" },
675     "min-width": { m: "box" },
676     "opacity": { m: "color", a: "transparency" },
677     "orphans": { m: "page" },
678     "outline-offset": { m: "ui" },
679     "padding": { m: "box", a: "padding1" },
680     "padding-bottom": { m: "box" },
681     "padding-left": { m: "box" },
682     "padding-right": { m: "box" },
683     "padding-top": { m: "box" },
684     "page": { m: "page" },
685     "quotes": { m: "generate" },
686     "right": { m: "visuren" },
687     "tab-size": { m: "text" },
688     "text-indent": { m: "text" },
689     "text-shadow": { m: "text-decor" },
690     "top": { m: "visuren" },
691     "unicode-range": { m: "fonts", a: "descdef-unicode-range" },
692     "widows": { m: "page" },
693     "width": { m: "box" },
694     "z-index": { m: "visuren" }
695 }
696
697 /**
698  * @param {string} propertyName
699  * @return {!WebInspector.CSSMetadata}
700  */
701 WebInspector.CSSMetadata.keywordsForProperty = function(propertyName)
702 {
703     var acceptedKeywords = ["inherit", "initial"];
704     var descriptor = WebInspector.CSSMetadata.descriptor(propertyName);
705     if (descriptor && descriptor.values)
706         acceptedKeywords.push.apply(acceptedKeywords, descriptor.values);
707     if (propertyName in WebInspector.CSSMetadata._colorAwareProperties)
708         acceptedKeywords.push.apply(acceptedKeywords, WebInspector.CSSMetadata._colors);
709     return new WebInspector.CSSMetadata(acceptedKeywords);
710 }
711
712 /**
713  * @param {string} propertyName
714  * @return {?Object}
715  */
716 WebInspector.CSSMetadata.descriptor = function(propertyName)
717 {
718     if (!propertyName)
719         return null;
720     var unprefixedName = propertyName.replace(/^-webkit-/, "");
721     var entry = WebInspector.CSSMetadata._propertyDataMap[propertyName];
722     if (!entry && unprefixedName !== propertyName)
723         entry = WebInspector.CSSMetadata._propertyDataMap[unprefixedName];
724     return entry || null;
725 }
726
727 WebInspector.CSSMetadata.initializeWithSupportedProperties = function(properties)
728 {
729     WebInspector.CSSMetadata.cssPropertiesMetainfo = new WebInspector.CSSMetadata(properties);
730 }
731
732 WebInspector.CSSMetadata.cssPropertiesMetainfoKeySet = function()
733 {
734     if (!WebInspector.CSSMetadata._cssPropertiesMetainfoKeySet)
735         WebInspector.CSSMetadata._cssPropertiesMetainfoKeySet = WebInspector.CSSMetadata.cssPropertiesMetainfo.keySet();
736     return WebInspector.CSSMetadata._cssPropertiesMetainfoKeySet;
737 }
738
739 // Weight of CSS properties based on their usage on a few popular websites: https://gist.github.com/3751436
740 WebInspector.CSSMetadata.Weight = {
741     "-webkit-animation": 1,
742     "-webkit-animation-duration": 1,
743     "-webkit-animation-iteration-count": 1,
744     "-webkit-animation-name": 1,
745     "-webkit-animation-timing-function": 1,
746     "-webkit-appearance": 1,
747     "-webkit-background-clip": 2,
748     "-webkit-border-horizontal-spacing": 1,
749     "-webkit-border-vertical-spacing": 1,
750     "-webkit-box-shadow": 24,
751     "-webkit-font-smoothing": 2,
752     "-webkit-transition": 8,
753     "-webkit-transition-delay": 7,
754     "-webkit-transition-duration": 7,
755     "-webkit-transition-property": 7,
756     "-webkit-transition-timing-function": 6,
757     "-webkit-user-select": 1,
758     "background": 222,
759     "background-attachment": 144,
760     "background-clip": 143,
761     "background-color": 222,
762     "background-image": 201,
763     "background-origin": 142,
764     "background-size": 25,
765     "border": 121,
766     "border-bottom": 121,
767     "border-bottom-color": 121,
768     "border-bottom-left-radius": 50,
769     "border-bottom-right-radius": 50,
770     "border-bottom-style": 114,
771     "border-bottom-width": 120,
772     "border-collapse": 3,
773     "border-left": 95,
774     "border-left-color": 95,
775     "border-left-style": 89,
776     "border-left-width": 94,
777     "border-radius": 50,
778     "border-right": 93,
779     "border-right-color": 93,
780     "border-right-style": 88,
781     "border-right-width": 93,
782     "border-top": 111,
783     "border-top-color": 111,
784     "border-top-left-radius": 49,
785     "border-top-right-radius": 49,
786     "border-top-style": 104,
787     "border-top-width": 109,
788     "bottom": 16,
789     "box-shadow": 25,
790     "box-sizing": 2,
791     "clear": 23,
792     "color": 237,
793     "cursor": 34,
794     "direction": 4,
795     "display": 210,
796     "fill": 2,
797     "filter": 1,
798     "float": 105,
799     "font": 174,
800     "font-family": 25,
801     "font-size": 174,
802     "font-style": 9,
803     "font-weight": 89,
804     "height": 161,
805     "left": 54,
806     "letter-spacing": 3,
807     "line-height": 75,
808     "list-style": 17,
809     "list-style-image": 8,
810     "list-style-position": 8,
811     "list-style-type": 17,
812     "margin": 241,
813     "margin-bottom": 226,
814     "margin-left": 225,
815     "margin-right": 213,
816     "margin-top": 241,
817     "max-height": 5,
818     "max-width": 11,
819     "min-height": 9,
820     "min-width": 6,
821     "opacity": 24,
822     "outline": 10,
823     "outline-color": 10,
824     "outline-style": 10,
825     "outline-width": 10,
826     "overflow": 57,
827     "overflow-x": 56,
828     "overflow-y": 57,
829     "padding": 216,
830     "padding-bottom": 208,
831     "padding-left": 216,
832     "padding-right": 206,
833     "padding-top": 216,
834     "position": 136,
835     "resize": 1,
836     "right": 29,
837     "stroke": 1,
838     "stroke-width": 1,
839     "table-layout": 1,
840     "text-align": 66,
841     "text-decoration": 53,
842     "text-indent": 9,
843     "text-overflow": 8,
844     "text-shadow": 19,
845     "text-transform": 5,
846     "top": 71,
847     "transform": 1,
848     "unicode-bidi": 1,
849     "vertical-align": 37,
850     "visibility": 11,
851     "white-space": 24,
852     "width": 255,
853     "word-wrap": 6,
854     "z-index": 32,
855     "zoom": 10
856 };
857
858
859 WebInspector.CSSMetadata.prototype = {
860     /**
861      * @param {string} prefix
862      * @return {!Array.<string>}
863      */
864     startsWith: function(prefix)
865     {
866         var firstIndex = this._firstIndexOfPrefix(prefix);
867         if (firstIndex === -1)
868             return [];
869
870         var results = [];
871         while (firstIndex < this._values.length && this._values[firstIndex].startsWith(prefix))
872             results.push(this._values[firstIndex++]);
873         return results;
874     },
875
876     /**
877      * @param {!Array.<string>} properties
878      * @return {number}
879      */
880     mostUsedOf: function(properties)
881     {
882         var maxWeight = 0;
883         var index = 0;
884         for (var i = 0; i < properties.length; i++) {
885             var weight = WebInspector.CSSMetadata.Weight[properties[i]];
886             if (!weight)
887                 weight = WebInspector.CSSMetadata.Weight[WebInspector.CSSMetadata.canonicalPropertyName(properties[i])];
888             if (weight > maxWeight) {
889                 maxWeight = weight;
890                 index = i;
891             }
892         }
893         return index;
894     },
895
896     _firstIndexOfPrefix: function(prefix)
897     {
898         if (!this._values.length)
899             return -1;
900         if (!prefix)
901             return 0;
902
903         var maxIndex = this._values.length - 1;
904         var minIndex = 0;
905         var foundIndex;
906
907         do {
908             var middleIndex = (maxIndex + minIndex) >> 1;
909             if (this._values[middleIndex].startsWith(prefix)) {
910                 foundIndex = middleIndex;
911                 break;
912             }
913             if (this._values[middleIndex] < prefix)
914                 minIndex = middleIndex + 1;
915             else
916                 maxIndex = middleIndex - 1;
917         } while (minIndex <= maxIndex);
918
919         if (foundIndex === undefined)
920             return -1;
921
922         while (foundIndex && this._values[foundIndex - 1].startsWith(prefix))
923             foundIndex--;
924
925         return foundIndex;
926     },
927
928     /**
929      * @return {!Object.<string, boolean>}
930      */
931     keySet: function()
932     {
933         if (!this._keySet)
934             this._keySet = this._values.keySet();
935         return this._keySet;
936     },
937
938     /**
939      * @param {string} str
940      * @param {string} prefix
941      * @return {string}
942      */
943     next: function(str, prefix)
944     {
945         return this._closest(str, prefix, 1);
946     },
947
948     /**
949      * @param {string} str
950      * @param {string} prefix
951      * @return {string}
952      */
953     previous: function(str, prefix)
954     {
955         return this._closest(str, prefix, -1);
956     },
957
958     /**
959      * @param {string} str
960      * @param {string} prefix
961      * @param {number} shift
962      * @return {string}
963      */
964     _closest: function(str, prefix, shift)
965     {
966         if (!str)
967             return "";
968
969         var index = this._values.indexOf(str);
970         if (index === -1)
971             return "";
972
973         if (!prefix) {
974             index = (index + this._values.length + shift) % this._values.length;
975             return this._values[index];
976         }
977
978         var propertiesWithPrefix = this.startsWith(prefix);
979         var j = propertiesWithPrefix.indexOf(str);
980         j = (j + propertiesWithPrefix.length + shift) % propertiesWithPrefix.length;
981         return propertiesWithPrefix[j];
982     },
983
984     /**
985      * @param {string} shorthand
986      * @return {?Array.<string>}
987      */
988     longhands: function(shorthand)
989     {
990         return this._longhands[shorthand];
991     },
992
993     /**
994      * @param {string} longhand
995      * @return {?Array.<string>}
996      */
997     shorthands: function(longhand)
998     {
999         return this._shorthands[longhand];
1000     }
1001 }
1002
1003 WebInspector.CSSMetadata.initializeWithSupportedProperties([]);