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([]);
74 * @param {string} propertyName
77 WebInspector.CSSMetadata.isColorAwareProperty = function(propertyName)
79 return !!WebInspector.CSSMetadata._colorAwareProperties[propertyName.toLowerCase()];
83 * @return {!Object.<string, boolean>}
85 WebInspector.CSSMetadata.colors = function()
87 if (!WebInspector.CSSMetadata._colorsKeySet)
88 WebInspector.CSSMetadata._colorsKeySet = WebInspector.CSSMetadata._colors.keySet();
89 return WebInspector.CSSMetadata._colorsKeySet;
93 * @param {string} propertyName
96 WebInspector.CSSMetadata.isLengthProperty = function(propertyName)
98 if (propertyName === "line-height")
100 if (!WebInspector.CSSMetadata._distancePropertiesKeySet)
101 WebInspector.CSSMetadata._distancePropertiesKeySet = WebInspector.CSSMetadata._distanceProperties.keySet();
102 return WebInspector.CSSMetadata._distancePropertiesKeySet[propertyName] || propertyName.startsWith("margin") || propertyName.startsWith("padding") || propertyName.indexOf("width") !== -1 || propertyName.indexOf("height") !== -1;
105 // Originally taken from http://www.w3.org/TR/CSS21/propidx.html and augmented.
106 WebInspector.CSSMetadata.InheritedProperties = [
107 "azimuth", "border-collapse", "border-spacing", "caption-side", "color", "cursor", "direction", "elevation",
108 "empty-cells", "font-family", "font-size", "font-style", "font-variant", "font-weight", "font", "letter-spacing",
109 "line-height", "list-style-image", "list-style-position", "list-style-type", "list-style", "orphans", "overflow-wrap", "pitch-range",
110 "pitch", "quotes", "resize", "richness", "speak-header", "speak-numeral", "speak-punctuation", "speak", "speech-rate", "stress",
111 "text-align", "text-indent", "text-transform", "text-shadow", "-webkit-user-select", "visibility", "voice-family", "volume", "white-space", "widows",
112 "word-spacing", "word-wrap", "zoom"
115 // These non-standard Blink-specific properties augment the InheritedProperties.
116 WebInspector.CSSMetadata.NonStandardInheritedProperties = [
117 "-webkit-font-smoothing"
121 * @param {string} name
124 WebInspector.CSSMetadata.canonicalPropertyName = function(name)
126 if (!name || name.length < 9 || name.charAt(0) !== "-")
127 return name.toLowerCase();
128 var match = name.match(/(?:-webkit-)(.+)/);
129 var propertiesSet = WebInspector.CSSMetadata.cssPropertiesMetainfoKeySet();
130 var hasSupportedProperties = WebInspector.CSSMetadata.cssPropertiesMetainfo._values.length > 0;
131 if (!match || (hasSupportedProperties && !propertiesSet.hasOwnProperty(match[1].toLowerCase())))
132 return name.toLowerCase();
133 return match[1].toLowerCase();
137 * @param {string} propertyName
140 WebInspector.CSSMetadata.isPropertyInherited = function(propertyName)
142 return !!(WebInspector.CSSMetadata.InheritedProperties[WebInspector.CSSMetadata.canonicalPropertyName(propertyName)]
143 || WebInspector.CSSMetadata.NonStandardInheritedProperties[propertyName.toLowerCase()]);
146 WebInspector.CSSMetadata._colors = [
147 "aqua", "black", "blue", "fuchsia", "gray", "green", "lime", "maroon", "navy", "olive", "orange", "purple", "red",
148 "silver", "teal", "white", "yellow", "transparent", "currentcolor", "grey", "aliceblue", "antiquewhite",
149 "aquamarine", "azure", "beige", "bisque", "blanchedalmond", "blueviolet", "brown", "burlywood", "cadetblue",
150 "chartreuse", "chocolate", "coral", "cornflowerblue", "cornsilk", "crimson", "cyan", "darkblue", "darkcyan",
151 "darkgoldenrod", "darkgray", "darkgreen", "darkgrey", "darkkhaki", "darkmagenta", "darkolivegreen", "darkorange",
152 "darkorchid", "darkred", "darksalmon", "darkseagreen", "darkslateblue", "darkslategray", "darkslategrey",
153 "darkturquoise", "darkviolet", "deeppink", "deepskyblue", "dimgray", "dimgrey", "dodgerblue", "firebrick",
154 "floralwhite", "forestgreen", "gainsboro", "ghostwhite", "gold", "goldenrod", "greenyellow", "honeydew", "hotpink",
155 "indianred", "indigo", "ivory", "khaki", "lavender", "lavenderblush", "lawngreen", "lemonchiffon", "lightblue",
156 "lightcoral", "lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightgrey", "lightpink",
157 "lightsalmon", "lightseagreen", "lightskyblue", "lightslategray", "lightslategrey", "lightsteelblue", "lightyellow",
158 "limegreen", "linen", "magenta", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple", "mediumseagreen",
159 "mediumslateblue", "mediumspringgreen", "mediumturquoise", "mediumvioletred", "midnightblue", "mintcream",
160 "mistyrose", "moccasin", "navajowhite", "oldlace", "olivedrab", "orangered", "orchid", "palegoldenrod", "palegreen",
161 "paleturquoise", "palevioletred", "papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue", "rosybrown",
162 "royalblue", "saddlebrown", "salmon", "sandybrown", "seagreen", "seashell", "sienna", "skyblue", "slateblue",
163 "slategray", "slategrey", "snow", "springgreen", "steelblue", "tan", "thistle", "tomato", "turquoise", "violet",
164 "wheat", "whitesmoke", "yellowgreen"
167 WebInspector.CSSMetadata._distanceProperties = [
168 'background-position', 'border-spacing', 'bottom', 'font-size', 'height', 'left', 'letter-spacing', 'max-height', 'max-width', 'min-height',
169 'min-width', 'right', 'text-indent', 'top', 'width', 'word-spacing'
172 WebInspector.CSSMetadata._colorAwareProperties = [
173 "background", "background-color", "background-image", "border", "border-color", "border-top", "border-right", "border-bottom",
174 "border-left", "border-top-color", "border-right-color", "border-bottom-color", "border-left-color", "box-shadow", "color",
175 "fill", "outline", "outline-color", "stroke", "text-shadow", "-webkit-box-shadow", "-webkit-column-rule-color",
176 "-webkit-text-decoration-color", "-webkit-text-emphasis", "-webkit-text-emphasis-color"
179 WebInspector.CSSMetadata._propertyDataMap = {
180 "table-layout": { values: [
183 "visibility": { values: [
184 "hidden", "visible", "collapse"
186 "background-repeat": { values: [
187 "repeat", "repeat-x", "repeat-y", "no-repeat", "space", "round"
189 "content": { values: [
190 "list-item", "close-quote", "no-close-quote", "no-open-quote", "open-quote"
192 "list-style-image": { values: [
196 "none", "left", "right", "both"
198 "overflow-x": { values: [
199 "hidden", "auto", "visible", "overlay", "scroll"
201 "stroke-linejoin": { values: [
202 "round", "miter", "bevel"
204 "baseline-shift": { values: [
205 "baseline", "sub", "super"
207 "border-bottom-width": { values: [
208 "medium", "thick", "thin"
210 "margin-top-collapse": { values: [
211 "collapse", "separate", "discard"
213 "max-height": { values: [
216 "box-orient": { values: [
217 "horizontal", "vertical", "inline-axis", "block-axis"
219 "font-stretch": { values: [
220 "normal", "wider", "narrower", "ultra-condensed", "extra-condensed", "condensed", "semi-condensed",
221 "semi-expanded", "expanded", "extra-expanded", "ultra-expanded"
223 "-webkit-background-composite": { values: [
224 "highlight", "clear", "copy", "source-over", "source-in", "source-out", "source-atop", "destination-over",
225 "destination-in", "destination-out", "destination-atop", "xor", "plus-darker", "plus-lighter"
227 "border-left-width": { values: [
228 "medium", "thick", "thin"
230 "box-shadow": { values: [
233 "-webkit-writing-mode": { values: [
234 "lr", "rl", "tb", "lr-tb", "rl-tb", "tb-rl", "horizontal-tb", "vertical-rl", "vertical-lr", "horizontal-bt"
236 "border-collapse": { values: [
237 "collapse", "separate"
239 "page-break-inside": { values: [
242 "border-top-width": { values: [
243 "medium", "thick", "thin"
245 "outline-color": { values: [
248 "outline-style": { values: [
249 "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
251 "cursor": { values: [
252 "none", "copy", "auto", "crosshair", "default", "pointer", "move", "vertical-text", "cell", "context-menu",
253 "alias", "progress", "no-drop", "not-allowed", "-webkit-zoom-in", "-webkit-zoom-out", "e-resize", "ne-resize",
254 "nw-resize", "n-resize", "se-resize", "sw-resize", "s-resize", "w-resize", "ew-resize", "ns-resize",
255 "nesw-resize", "nwse-resize", "col-resize", "row-resize", "text", "wait", "help", "all-scroll", "-webkit-grab",
258 "border-width": { values: [
259 "medium", "thick", "thin"
261 "border-style": { values: [
262 "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
265 "a3", "a4", "a5", "b4", "b5", "landscape", "ledger", "legal", "letter", "portrait"
267 "background-size": { values: [
270 "direction": { values: [
273 "enable-background": { values: [
277 "none", "left", "right"
279 "overflow-y": { values: [
280 "hidden", "auto", "visible", "overlay", "scroll"
282 "margin-bottom-collapse": { values: [
283 "collapse", "separate", "discard"
285 "box-reflect": { values: [
286 "left", "right", "above", "below"
288 "overflow": { values: [
289 "hidden", "auto", "visible", "overlay", "scroll"
291 "text-rendering": { values: [
292 "auto", "optimizeSpeed", "optimizeLegibility", "geometricPrecision"
294 "text-align": { values: [
295 "-webkit-auto", "start", "end", "left", "right", "center", "justify", "-webkit-left", "-webkit-right", "-webkit-center"
297 "list-style-position": { values: [
298 "outside", "inside", "hanging"
300 "margin-bottom": { values: [
303 "color-interpolation": { values: [
306 "background-origin": { values: [
307 "border-box", "content-box", "padding-box"
309 "word-wrap": { values: [
310 "normal", "break-word"
312 "font-weight": { values: [
313 "normal", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900"
315 "margin-before-collapse": { values: [
316 "collapse", "separate", "discard"
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 "box-align": { values: [
391 "baseline", "center", "stretch", "start", "end"
393 "border-right-width": { values: [
394 "medium", "thick", "thin"
396 "border-top-style": { values: [
397 "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
399 "line-height": { values: [
402 "text-overflow": { values: [
405 "overflow-wrap": { values: [
406 "normal", "break-word"
408 "box-direction": { values: [
411 "margin-after-collapse": { values: [
412 "collapse", "separate", "discard"
414 "page-break-before": { values: [
415 "left", "right", "auto", "always", "avoid"
417 "border-image": { values: [
420 "text-decoration": { values: [
421 "blink", "line-through", "overline", "underline"
423 "position": { values: [
424 "absolute", "fixed", "relative", "static"
426 "font-family": { values: [
427 "serif", "sans-serif", "cursive", "fantasy", "monospace", "-webkit-body", "-webkit-pictograph"
429 "text-overflow-mode": { values: [
432 "border-bottom-style": { values: [
433 "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
435 "unicode-bidi": { values: [
436 "normal", "bidi-override", "embed", "isolate", "isolate-override", "plaintext"
438 "clip-rule": { values: [
441 "margin-left": { values: [
444 "margin-top": { values: [
448 "normal", "document", "reset"
450 "max-width": { values: [
453 "caption-side": { values: [
456 "empty-cells": { values: [
459 "pointer-events": { values: [
460 "none", "all", "auto", "visible", "visiblepainted", "visiblefill", "visiblestroke", "painted", "fill", "stroke", "bounding-box"
462 "letter-spacing": { values: [
465 "background-clip": { values: [
466 "border-box", "content-box", "padding-box"
468 "-webkit-font-smoothing": { values: [
469 "none", "auto", "antialiased", "subpixel-antialiased"
471 "border": { values: [
472 "none", "hidden", "inset", "groove", "ridge", "outset", "dotted", "dashed", "solid", "double"
474 "font-size": { values: [
475 "xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "-webkit-xxx-large", "smaller",
478 "font-variant": { values: [
479 "small-caps", "normal"
481 "vertical-align": { values: [
482 "baseline", "middle", "sub", "super", "text-top", "text-bottom", "top", "bottom", "-webkit-baseline-middle"
484 "white-space": { values: [
485 "normal", "nowrap", "pre", "pre-line", "pre-wrap"
487 "box-lines": { values: [
490 "page-break-after": { values: [
491 "left", "right", "auto", "always", "avoid"
493 "clip-path": { values: [
496 "margin": { values: [
499 "margin-right": { values: [
502 "word-break": { values: [
503 "normal", "break-all", "break-word"
505 "word-spacing": { values: [
508 "-webkit-text-emphasis-style": { values: [
509 "circle", "filled", "open", "dot", "double-circle", "triangle", "sesame"
511 "transform": { values: [
512 "scale", "scaleX", "scaleY", "scale3d", "rotate", "rotateX", "rotateY", "rotateZ", "rotate3d", "skew", "skewX", "skewY",
513 "translate", "translateX", "translateY", "translateZ", "translate3d", "matrix", "matrix3d", "perspective"
515 "image-resolution": { values: [
518 "box-sizing": { values: [
519 "content-box", "border-box"
524 "resize": { values: [
525 "none", "both", "horizontal", "vertical"
527 "align-content": { values: [
528 "flex-start", "flex-end", "center", "space-between", "space-around", "stretch"
530 "align-items": { values: [
531 "flex-start", "flex-end", "center", "baseline", "stretch"
533 "align-self": { values: [
534 "auto", "flex-start", "flex-end", "center", "baseline", "stretch"
536 "flex-direction": { values: [
537 "row", "row-reverse", "column", "column-reverse"
539 "justify-content": { values: [
540 "flex-start", "flex-end", "center", "space-between", "space-around"
542 "flex-wrap": { values: [
543 "nowrap", "wrap", "wrap-reverse"
545 "-webkit-animation-timing-function": { values: [
546 "ease", "linear", "ease-in", "ease-out", "ease-in-out", "step-start", "step-end", "steps", "cubic-bezier"
548 "-webkit-animation-direction": { values: [
549 "normal", "reverse", "alternate", "alternate-reverse"
551 "-webkit-animation-play-state": { values: [
554 "-webkit-animation-fill-mode": { values: [
555 "none", "forwards", "backwards", "both"
557 "-webkit-backface-visibility": { values: [
560 "-webkit-box-decoration-break": { values: [
563 "-webkit-column-break-after": { values: [
564 "auto", "always", "avoid", "left", "right", "page", "column", "avoid-page", "avoid-column"
566 "-webkit-column-break-before": { values: [
567 "auto", "always", "avoid", "left", "right", "page", "column", "avoid-page", "avoid-column"
569 "-webkit-column-break-inside": { values: [
570 "auto", "avoid", "avoid-page", "avoid-column"
572 "-webkit-column-span": { values: [
575 "-webkit-column-count": { values: [
578 "-webkit-column-gap": { values: [
581 "-webkit-line-break": { values: [
582 "auto", "loose", "normal", "strict"
584 "-webkit-perspective": { values: [
587 "-webkit-perspective-origin": { values: [
588 "left", "center", "right", "top", "bottom"
590 "text-align-last": { values: [
591 "auto", "start", "end", "left", "right", "center", "justify"
593 "-webkit-text-decoration-line": { values: [
594 "none", "underline", "overline", "line-through", "blink"
596 "-webkit-text-decoration-style": { values: [
597 "solid", "double", "dotted", "dashed", "wavy"
599 "-webkit-text-decoration-skip": { values: [
600 "none", "objects", "spaces", "ink", "edges", "box-decoration"
602 "-webkit-transform-origin": { values: [
603 "left", "center", "right", "top", "bottom"
605 "-webkit-transform-style": { values: [
606 "flat", "preserve-3d"
608 "-webkit-transition-timing-function": { values: [
609 "ease", "linear", "ease-in", "ease-out", "ease-in-out", "step-start", "step-end", "steps", "cubic-bezier"
612 "-webkit-flex": { m: "flexbox" },
613 "-webkit-flex-basis": { m: "flexbox" },
614 "-webkit-flex-flow": { m: "flexbox" },
615 "-webkit-flex-grow": { m: "flexbox" },
616 "-webkit-flex-shrink": { m: "flexbox" },
617 "-webkit-animation": { m: "animations" },
618 "-webkit-animation-delay": { m: "animations" },
619 "-webkit-animation-duration": { m: "animations" },
620 "-webkit-animation-iteration-count": { m: "animations" },
621 "-webkit-animation-name": { m: "animations" },
622 "-webkit-column-rule": { m: "multicol" },
623 "-webkit-column-rule-color": { m: "multicol", a: "crc" },
624 "-webkit-column-rule-style": { m: "multicol", a: "crs" },
625 "-webkit-column-rule-width": { m: "multicol", a: "crw" },
626 "-webkit-column-width": { m: "multicol", a: "cw" },
627 "-webkit-columns": { m: "multicol" },
628 "-webkit-order": { m: "flexbox" },
629 "-webkit-text-decoration-color": { m: "text-decor" },
630 "-webkit-text-emphasis-color": { m: "text-decor" },
631 "-webkit-transition": { m: "transitions" },
632 "-webkit-transition-delay": { m: "transitions" },
633 "-webkit-transition-duration": { m: "transitions" },
634 "-webkit-transition-property": { m: "transitions" },
635 "background": { m: "background" },
636 "background-attachment": { m: "background" },
637 "background-color": { m: "background" },
638 "background-image": { m: "background" },
639 "background-position": { m: "background" },
640 "background-position-x": { m: "background" },
641 "background-position-y": { m: "background" },
642 "background-repeat-x": { m: "background" },
643 "background-repeat-y": { m: "background" },
644 "border-top": { m: "background" },
645 "border-right": { m: "background" },
646 "border-bottom": { m: "background" },
647 "border-left": { m: "background" },
648 "border-radius": { m: "background" },
649 "bottom": { m: "visuren" },
650 "color": { m: "color", a: "foreground" },
651 "counter-increment": { m: "generate" },
652 "counter-reset": { m: "generate" },
653 "grid-template-columns": { m: "grid" },
654 "grid-template-rows": { m: "grid" },
655 "height": { m: "box" },
656 "image-orientation": { m: "images" },
657 "left": { m: "visuren" },
658 "list-style": { m: "lists" },
659 "min-height": { m: "box" },
660 "min-width": { m: "box" },
661 "opacity": { m: "color", a: "transparency" },
662 "orphans": { m: "page" },
663 "outline-offset": { m: "ui" },
664 "padding": { m: "box", a: "padding1" },
665 "padding-bottom": { m: "box" },
666 "padding-left": { m: "box" },
667 "padding-right": { m: "box" },
668 "padding-top": { m: "box" },
669 "page": { m: "page" },
670 "quotes": { m: "generate" },
671 "right": { m: "visuren" },
672 "tab-size": { m: "text" },
673 "text-indent": { m: "text" },
674 "text-shadow": { m: "text-decor" },
675 "top": { m: "visuren" },
676 "unicode-range": { m: "fonts", a: "descdef-unicode-range" },
677 "widows": { m: "page" },
678 "width": { m: "box" },
679 "z-index": { m: "visuren" }
683 * @param {string} propertyName
684 * @return {!WebInspector.CSSMetadata}
686 WebInspector.CSSMetadata.keywordsForProperty = function(propertyName)
688 var acceptedKeywords = ["inherit", "initial"];
689 var descriptor = WebInspector.CSSMetadata.descriptor(propertyName);
690 if (descriptor && descriptor.values)
691 acceptedKeywords.push.apply(acceptedKeywords, descriptor.values);
692 if (WebInspector.CSSMetadata.isColorAwareProperty(propertyName))
693 acceptedKeywords.push.apply(acceptedKeywords, WebInspector.CSSMetadata._colors);
694 return new WebInspector.CSSMetadata(acceptedKeywords);
698 * @param {string} propertyName
701 WebInspector.CSSMetadata.descriptor = function(propertyName)
705 var unprefixedName = propertyName.replace(/^-webkit-/, "");
706 propertyName = propertyName.toLowerCase();
707 var entry = WebInspector.CSSMetadata._propertyDataMap[propertyName];
708 if (!entry && unprefixedName !== propertyName)
709 entry = WebInspector.CSSMetadata._propertyDataMap[unprefixedName];
710 return entry || null;
713 WebInspector.CSSMetadata.initializeWithSupportedProperties = function(properties)
715 WebInspector.CSSMetadata.cssPropertiesMetainfo = new WebInspector.CSSMetadata(properties);
719 * @return {!Object.<string, boolean>}
721 WebInspector.CSSMetadata.cssPropertiesMetainfoKeySet = function()
723 if (!WebInspector.CSSMetadata._cssPropertiesMetainfoKeySet)
724 WebInspector.CSSMetadata._cssPropertiesMetainfoKeySet = WebInspector.CSSMetadata.cssPropertiesMetainfo.keySet();
725 return WebInspector.CSSMetadata._cssPropertiesMetainfoKeySet;
728 // Weight of CSS properties based on their usage on a few popular websites: https://gist.github.com/3751436
729 WebInspector.CSSMetadata.Weight = {
730 "-webkit-animation": 1,
731 "-webkit-animation-duration": 1,
732 "-webkit-animation-iteration-count": 1,
733 "-webkit-animation-name": 1,
734 "-webkit-animation-timing-function": 1,
735 "-webkit-appearance": 1,
736 "-webkit-background-clip": 2,
737 "-webkit-border-horizontal-spacing": 1,
738 "-webkit-border-vertical-spacing": 1,
739 "-webkit-box-shadow": 24,
740 "-webkit-font-smoothing": 2,
741 "-webkit-transition": 8,
742 "-webkit-transition-delay": 7,
743 "-webkit-transition-duration": 7,
744 "-webkit-transition-property": 7,
745 "-webkit-transition-timing-function": 6,
746 "-webkit-user-select": 1,
748 "background-attachment": 144,
749 "background-clip": 143,
750 "background-color": 222,
751 "background-image": 201,
752 "background-origin": 142,
753 "background-size": 25,
755 "border-bottom": 121,
756 "border-bottom-color": 121,
757 "border-bottom-left-radius": 50,
758 "border-bottom-right-radius": 50,
759 "border-bottom-style": 114,
760 "border-bottom-width": 120,
761 "border-collapse": 3,
763 "border-left-color": 95,
764 "border-left-style": 89,
765 "border-left-width": 94,
768 "border-right-color": 93,
769 "border-right-style": 88,
770 "border-right-width": 93,
772 "border-top-color": 111,
773 "border-top-left-radius": 49,
774 "border-top-right-radius": 49,
775 "border-top-style": 104,
776 "border-top-width": 109,
798 "list-style-image": 8,
799 "list-style-position": 8,
800 "list-style-type": 17,
802 "margin-bottom": 226,
819 "padding-bottom": 208,
821 "padding-right": 206,
830 "text-decoration": 53,
838 "vertical-align": 37,
848 WebInspector.CSSMetadata.prototype = {
850 * @param {string} prefix
851 * @return {!Array.<string>}
853 startsWith: function(prefix)
855 var firstIndex = this._firstIndexOfPrefix(prefix);
856 if (firstIndex === -1)
860 while (firstIndex < this._values.length && this._values[firstIndex].startsWith(prefix))
861 results.push(this._values[firstIndex++]);
866 * @param {!Array.<string>} properties
869 mostUsedOf: function(properties)
873 for (var i = 0; i < properties.length; i++) {
874 var weight = WebInspector.CSSMetadata.Weight[properties[i]];
876 weight = WebInspector.CSSMetadata.Weight[WebInspector.CSSMetadata.canonicalPropertyName(properties[i])];
877 if (weight > maxWeight) {
885 _firstIndexOfPrefix: function(prefix)
887 if (!this._values.length)
892 var maxIndex = this._values.length - 1;
897 var middleIndex = (maxIndex + minIndex) >> 1;
898 if (this._values[middleIndex].startsWith(prefix)) {
899 foundIndex = middleIndex;
902 if (this._values[middleIndex] < prefix)
903 minIndex = middleIndex + 1;
905 maxIndex = middleIndex - 1;
906 } while (minIndex <= maxIndex);
908 if (foundIndex === undefined)
911 while (foundIndex && this._values[foundIndex - 1].startsWith(prefix))
918 * @return {!Object.<string, boolean>}
923 this._keySet = this._values.keySet();
928 * @param {string} str
929 * @param {string} prefix
932 next: function(str, prefix)
934 return this._closest(str, prefix, 1);
938 * @param {string} str
939 * @param {string} prefix
942 previous: function(str, prefix)
944 return this._closest(str, prefix, -1);
948 * @param {string} str
949 * @param {string} prefix
950 * @param {number} shift
953 _closest: function(str, prefix, shift)
958 var index = this._values.indexOf(str);
963 index = (index + this._values.length + shift) % this._values.length;
964 return this._values[index];
967 var propertiesWithPrefix = this.startsWith(prefix);
968 var j = propertiesWithPrefix.indexOf(str);
969 j = (j + propertiesWithPrefix.length + shift) % propertiesWithPrefix.length;
970 return propertiesWithPrefix[j];
974 * @param {string} shorthand
975 * @return {?Array.<string>}
977 longhands: function(shorthand)
979 return this._longhands[shorthand];
983 * @param {string} longhand
984 * @return {?Array.<string>}
986 shorthands: function(longhand)
988 return this._shorthands[longhand];
992 WebInspector.CSSMetadata.initializeWithSupportedProperties([]);