CSSMetadata.js 35 KB

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