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.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
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
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.
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.
35 * @param {!Array.<!{name: string, longhands: !Array.<string>}|string>} properties
37 WebInspector.CSSMetadata = function(properties)
39 this._values = /** !Array.<string> */ ([]);
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);
48 var propertyName = property.name;
49 this._values.push(propertyName);
51 var longhands = properties[i].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];
59 this._shorthands[longhandName] = shorthands;
61 shorthands.push(propertyName);
69 * @type {!WebInspector.CSSMetadata}
71 WebInspector.CSSMetadata.cssPropertiesMetainfo = new WebInspector.CSSMetadata([]);
73 WebInspector.CSSMetadata.isColorAwareProperty = function(propertyName)
75 return WebInspector.CSSMetadata._colorAwareProperties[propertyName] === true;
78 WebInspector.CSSMetadata.colors = function()
80 if (!WebInspector.CSSMetadata._colorsKeySet)
81 WebInspector.CSSMetadata._colorsKeySet = WebInspector.CSSMetadata._colors.keySet();
82 return WebInspector.CSSMetadata._colorsKeySet;
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"
95 // These non-standard Blink-specific properties augment the InheritedProperties.
96 WebInspector.CSSMetadata.NonStandardInheritedProperties = [
97 "-webkit-font-smoothing"
101 * @param {string} name
104 WebInspector.CSSMetadata.canonicalPropertyName = function(name)
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();
117 * @param {string} propertyName
120 WebInspector.CSSMetadata.isPropertyInherited = function(propertyName)
122 return !!(WebInspector.CSSMetadata.InheritedProperties[WebInspector.CSSMetadata.canonicalPropertyName(propertyName)]
123 || WebInspector.CSSMetadata.NonStandardInheritedProperties[propertyName.toLowerCase()]);
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"
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"
155 WebInspector.CSSMetadata._propertyDataMap = {
156 "table-layout": { values: [
159 "visibility": { values: [
160 "hidden", "visible", "collapse"
162 "background-repeat": { values: [
163 "repeat", "repeat-x", "repeat-y", "no-repeat", "space", "round"
165 "content": { values: [
166 "list-item", "close-quote", "no-close-quote", "no-open-quote", "open-quote"
168 "list-style-image": { values: [
172 "none", "left", "right", "both"
174 "text-underline-mode": { values: [
175 "continuous", "skip-white-space"
177 "overflow-x": { values: [
178 "hidden", "auto", "visible", "overlay", "scroll"
180 "stroke-linejoin": { values: [
181 "round", "miter", "bevel"
183 "baseline-shift": { values: [
184 "baseline", "sub", "super"
186 "border-bottom-width": { values: [
187 "medium", "thick", "thin"
189 "marquee-speed": { values: [
190 "normal", "slow", "fast"
192 "margin-top-collapse": { values: [
193 "collapse", "separate", "discard"
195 "max-height": { values: [
198 "box-orient": { values: [
199 "horizontal", "vertical", "inline-axis", "block-axis"
201 "font-stretch": { values: [
202 "normal", "wider", "narrower", "ultra-condensed", "extra-condensed", "condensed", "semi-condensed",
203 "semi-expanded", "expanded", "extra-expanded", "ultra-expanded"
205 "text-underline-style": { values: [
206 "none", "dotted", "dashed", "solid", "double", "dot-dash", "dot-dot-dash", "wave"
208 "text-overline-mode": { values: [
209 "continuous", "skip-white-space"
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"
215 "border-left-width": { values: [
216 "medium", "thick", "thin"
218 "box-shadow": { values: [
221 "-webkit-writing-mode": { values: [
222 "lr", "rl", "tb", "lr-tb", "rl-tb", "tb-rl", "horizontal-tb", "vertical-rl", "vertical-lr", "horizontal-bt"
224 "text-line-through-mode": { values: [
225 "continuous", "skip-white-space"
227 "border-collapse": { values: [
228 "collapse", "separate"
230 "page-break-inside": { values: [
233 "border-top-width": { values: [
234 "medium", "thick", "thin"
236 "outline-color": { values: [
239 "text-line-through-style": { values: [
240 "none", "dotted", "dashed", "solid", "double", "dot-dash", "dot-dot-dash", "wave"
242 "outline-style": { values: [
243 "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
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",
252 "border-width": { values: [
253 "medium", "thick", "thin"
255 "border-style": { values: [
256 "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
259 "a3", "a4", "a5", "b4", "b5", "landscape", "ledger", "legal", "letter", "portrait"
261 "background-size": { values: [
264 "direction": { values: [
267 "marquee-direction": { values: [
268 "left", "right", "auto", "reverse", "forwards", "backwards", "ahead", "up", "down"
270 "enable-background": { values: [
274 "none", "left", "right"
276 "overflow-y": { values: [
277 "hidden", "auto", "visible", "overlay", "scroll"
279 "margin-bottom-collapse": { values: [
280 "collapse", "separate", "discard"
282 "box-reflect": { values: [
283 "left", "right", "above", "below"
285 "overflow": { values: [
286 "hidden", "auto", "visible", "overlay", "scroll"
288 "text-rendering": { values: [
289 "auto", "optimizeSpeed", "optimizeLegibility", "geometricPrecision"
291 "text-align": { values: [
292 "-webkit-auto", "start", "end", "left", "right", "center", "justify", "-webkit-left", "-webkit-right", "-webkit-center"
294 "list-style-position": { values: [
295 "outside", "inside", "hanging"
297 "margin-bottom": { values: [
300 "color-interpolation": { values: [
303 "background-origin": { values: [
304 "border-box", "content-box", "padding-box"
306 "word-wrap": { values: [
307 "normal", "break-word"
309 "font-weight": { values: [
310 "normal", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900"
312 "margin-before-collapse": { values: [
313 "collapse", "separate", "discard"
315 "text-overline-width": { values: [
316 "normal", "medium", "auto", "thick", "thin"
318 "text-transform": { values: [
319 "none", "capitalize", "uppercase", "lowercase"
321 "border-right-style": { values: [
322 "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
324 "border-left-style": { values: [
325 "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
327 "-webkit-text-emphasis": { values: [
328 "circle", "filled", "open", "dot", "double-circle", "triangle", "sesame"
330 "font-style": { values: [
331 "italic", "oblique", "normal"
334 "none", "normal", "spell-out", "digits", "literal-punctuation", "no-punctuation"
336 "color-rendering": { values: [
337 "auto", "optimizeSpeed", "optimizeQuality"
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",
354 "-webkit-text-combine": { values: [
357 "outline": { values: [
358 "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
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"
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"
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"
377 "-webkit-text-emphasis-position": { values: [
380 "image-rendering": { values: [
381 "auto", "optimizeSpeed", "optimizeQuality"
383 "alignment-baseline": { values: [
384 "baseline", "middle", "auto", "before-edge", "after-edge", "central", "text-before-edge", "text-after-edge",
385 "ideographic", "alphabetic", "hanging", "mathematical"
387 "outline-width": { values: [
388 "medium", "thick", "thin"
390 "text-line-through-width": { values: [
391 "normal", "medium", "auto", "thick", "thin"
393 "box-align": { values: [
394 "baseline", "center", "stretch", "start", "end"
396 "border-right-width": { values: [
397 "medium", "thick", "thin"
399 "border-top-style": { values: [
400 "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
402 "line-height": { values: [
405 "text-overflow": { values: [
408 "overflow-wrap": { values: [
409 "normal", "break-word"
411 "box-direction": { values: [
414 "margin-after-collapse": { values: [
415 "collapse", "separate", "discard"
417 "page-break-before": { values: [
418 "left", "right", "auto", "always", "avoid"
420 "border-image": { values: [
423 "text-decoration": { values: [
424 "blink", "line-through", "overline", "underline"
426 "position": { values: [
427 "absolute", "fixed", "relative", "static"
429 "font-family": { values: [
430 "serif", "sans-serif", "cursive", "fantasy", "monospace", "-webkit-body", "-webkit-pictograph"
432 "text-overflow-mode": { values: [
435 "border-bottom-style": { values: [
436 "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
438 "unicode-bidi": { values: [
439 "normal", "bidi-override", "embed", "isolate", "isolate-override", "plaintext"
441 "clip-rule": { values: [
444 "margin-left": { values: [
447 "margin-top": { values: [
451 "normal", "document", "reset"
453 "text-overline-style": { values: [
454 "none", "dotted", "dashed", "solid", "double", "dot-dash", "dot-dot-dash", "wave"
456 "max-width": { values: [
459 "caption-side": { values: [
462 "empty-cells": { values: [
465 "pointer-events": { values: [
466 "none", "all", "auto", "visible", "visiblepainted", "visiblefill", "visiblestroke", "painted", "fill", "stroke", "bounding-box"
468 "letter-spacing": { values: [
471 "background-clip": { values: [
472 "border-box", "content-box", "padding-box"
474 "-webkit-font-smoothing": { values: [
475 "none", "auto", "antialiased", "subpixel-antialiased"
477 "border": { values: [
478 "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
480 "font-size": { values: [
481 "xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "-webkit-xxx-large", "smaller",
484 "font-variant": { values: [
485 "small-caps", "normal"
487 "vertical-align": { values: [
488 "baseline", "middle", "sub", "super", "text-top", "text-bottom", "top", "bottom", "-webkit-baseline-middle"
490 "marquee-style": { values: [
491 "none", "scroll", "slide", "alternate"
493 "white-space": { values: [
494 "normal", "nowrap", "pre", "pre-line", "pre-wrap"
496 "text-underline-width": { values: [
497 "normal", "medium", "auto", "thick", "thin"
499 "box-lines": { values: [
502 "page-break-after": { values: [
503 "left", "right", "auto", "always", "avoid"
505 "clip-path": { values: [
508 "margin": { values: [
511 "marquee-repetition": { values: [
514 "margin-right": { values: [
517 "word-break": { values: [
518 "normal", "break-all", "break-word"
520 "word-spacing": { values: [
523 "-webkit-text-emphasis-style": { values: [
524 "circle", "filled", "open", "dot", "double-circle", "triangle", "sesame"
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"
530 "image-resolution": { values: [
533 "box-sizing": { values: [
534 "content-box", "padding-box", "border-box"
539 "resize": { values: [
540 "none", "both", "horizontal", "vertical"
542 "align-content": { values: [
543 "flex-start", "flex-end", "center", "space-between", "space-around", "stretch"
545 "align-items": { values: [
546 "flex-start", "flex-end", "center", "baseline", "stretch"
548 "align-self": { values: [
549 "auto", "flex-start", "flex-end", "center", "baseline", "stretch"
551 "flex-direction": { values: [
552 "row", "row-reverse", "column", "column-reverse"
554 "justify-content": { values: [
555 "flex-start", "flex-end", "center", "space-between", "space-around"
557 "flex-wrap": { values: [
558 "nowrap", "wrap", "wrap-reverse"
560 "-webkit-animation-timing-function": { values: [
561 "ease", "linear", "ease-in", "ease-out", "ease-in-out", "step-start", "step-end", "steps", "cubic-bezier"
563 "-webkit-animation-direction": { values: [
564 "normal", "reverse", "alternate", "alternate-reverse"
566 "-webkit-animation-play-state": { values: [
569 "-webkit-animation-fill-mode": { values: [
570 "none", "forwards", "backwards", "both"
572 "-webkit-backface-visibility": { values: [
575 "-webkit-box-decoration-break": { values: [
578 "-webkit-column-break-after": { values: [
579 "auto", "always", "avoid", "left", "right", "page", "column", "avoid-page", "avoid-column"
581 "-webkit-column-break-before": { values: [
582 "auto", "always", "avoid", "left", "right", "page", "column", "avoid-page", "avoid-column"
584 "-webkit-column-break-inside": { values: [
585 "auto", "avoid", "avoid-page", "avoid-column"
587 "-webkit-column-span": { values: [
590 "-webkit-column-count": { values: [
593 "-webkit-column-gap": { values: [
596 "-webkit-line-break": { values: [
597 "auto", "loose", "normal", "strict"
599 "-webkit-perspective": { values: [
602 "-webkit-perspective-origin": { values: [
603 "left", "center", "right", "top", "bottom"
605 "text-align-last": { values: [
606 "auto", "start", "end", "left", "right", "center", "justify"
608 "-webkit-text-decoration-line": { values: [
609 "none", "underline", "overline", "line-through", "blink"
611 "-webkit-text-decoration-style": { values: [
612 "solid", "double", "dotted", "dashed", "wavy"
614 "-webkit-text-decoration-skip": { values: [
615 "none", "objects", "spaces", "ink", "edges", "box-decoration"
617 "-webkit-transform-origin": { values: [
618 "left", "center", "right", "top", "bottom"
620 "-webkit-transform-style": { values: [
621 "flat", "preserve-3d"
623 "-webkit-transition-timing-function": { values: [
624 "ease", "linear", "ease-in", "ease-out", "ease-in-out", "step-start", "step-end", "steps", "cubic-bezier"
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" }
698 * @param {string} propertyName
699 * @return {!WebInspector.CSSMetadata}
701 WebInspector.CSSMetadata.keywordsForProperty = function(propertyName)
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);
713 * @param {string} propertyName
716 WebInspector.CSSMetadata.descriptor = function(propertyName)
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;
727 WebInspector.CSSMetadata.initializeWithSupportedProperties = function(properties)
729 WebInspector.CSSMetadata.cssPropertiesMetainfo = new WebInspector.CSSMetadata(properties);
732 WebInspector.CSSMetadata.cssPropertiesMetainfoKeySet = function()
734 if (!WebInspector.CSSMetadata._cssPropertiesMetainfoKeySet)
735 WebInspector.CSSMetadata._cssPropertiesMetainfoKeySet = WebInspector.CSSMetadata.cssPropertiesMetainfo.keySet();
736 return WebInspector.CSSMetadata._cssPropertiesMetainfoKeySet;
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,
759 "background-attachment": 144,
760 "background-clip": 143,
761 "background-color": 222,
762 "background-image": 201,
763 "background-origin": 142,
764 "background-size": 25,
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,
774 "border-left-color": 95,
775 "border-left-style": 89,
776 "border-left-width": 94,
779 "border-right-color": 93,
780 "border-right-style": 88,
781 "border-right-width": 93,
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,
809 "list-style-image": 8,
810 "list-style-position": 8,
811 "list-style-type": 17,
813 "margin-bottom": 226,
830 "padding-bottom": 208,
832 "padding-right": 206,
841 "text-decoration": 53,
849 "vertical-align": 37,
859 WebInspector.CSSMetadata.prototype = {
861 * @param {string} prefix
862 * @return {!Array.<string>}
864 startsWith: function(prefix)
866 var firstIndex = this._firstIndexOfPrefix(prefix);
867 if (firstIndex === -1)
871 while (firstIndex < this._values.length && this._values[firstIndex].startsWith(prefix))
872 results.push(this._values[firstIndex++]);
877 * @param {!Array.<string>} properties
880 mostUsedOf: function(properties)
884 for (var i = 0; i < properties.length; i++) {
885 var weight = WebInspector.CSSMetadata.Weight[properties[i]];
887 weight = WebInspector.CSSMetadata.Weight[WebInspector.CSSMetadata.canonicalPropertyName(properties[i])];
888 if (weight > maxWeight) {
896 _firstIndexOfPrefix: function(prefix)
898 if (!this._values.length)
903 var maxIndex = this._values.length - 1;
908 var middleIndex = (maxIndex + minIndex) >> 1;
909 if (this._values[middleIndex].startsWith(prefix)) {
910 foundIndex = middleIndex;
913 if (this._values[middleIndex] < prefix)
914 minIndex = middleIndex + 1;
916 maxIndex = middleIndex - 1;
917 } while (minIndex <= maxIndex);
919 if (foundIndex === undefined)
922 while (foundIndex && this._values[foundIndex - 1].startsWith(prefix))
929 * @return {!Object.<string, boolean>}
934 this._keySet = this._values.keySet();
939 * @param {string} str
940 * @param {string} prefix
943 next: function(str, prefix)
945 return this._closest(str, prefix, 1);
949 * @param {string} str
950 * @param {string} prefix
953 previous: function(str, prefix)
955 return this._closest(str, prefix, -1);
959 * @param {string} str
960 * @param {string} prefix
961 * @param {number} shift
964 _closest: function(str, prefix, shift)
969 var index = this._values.indexOf(str);
974 index = (index + this._values.length + shift) % this._values.length;
975 return this._values[index];
978 var propertiesWithPrefix = this.startsWith(prefix);
979 var j = propertiesWithPrefix.indexOf(str);
980 j = (j + propertiesWithPrefix.length + shift) % propertiesWithPrefix.length;
981 return propertiesWithPrefix[j];
985 * @param {string} shorthand
986 * @return {?Array.<string>}
988 longhands: function(shorthand)
990 return this._longhands[shorthand];
994 * @param {string} longhand
995 * @return {?Array.<string>}
997 shorthands: function(longhand)
999 return this._shorthands[longhand];
1003 WebInspector.CSSMetadata.initializeWithSupportedProperties([]);