| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Nikita Vasilyev. All rights reserved. | 2 * Copyright (C) 2010 Nikita Vasilyev. All rights reserved. |
| 3 * Copyright (C) 2010 Joseph Pecoraro. All rights reserved. | 3 * Copyright (C) 2010 Joseph Pecoraro. All rights reserved. |
| 4 * Copyright (C) 2010 Google Inc. All rights reserved. | 4 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
| 8 * met: | 8 * met: |
| 9 * | 9 * |
| 10 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 */ | 31 */ |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * @constructor | 34 * @constructor |
| 35 * @param {!Array.<!{name: string, longhands: !Array.<string>}>} properties | 35 * @param {!Array.<!{name: string, longhands: !Array.<string>}>} properties |
| 36 */ | 36 */ |
| 37 WebInspector.CSSMetadata = function(properties) | 37 WebInspector.CSSMetadata = function(properties) |
| 38 { | 38 { |
| 39 this._values = /** !Array.<string> */ ([]); | 39 this._values = /** !Array.<string> */ ([]); |
| 40 this._longhands = {}; | 40 /** @type {!Map<string, !Array<string>>} */ |
| 41 this._shorthands = {}; | 41 this._longhands = new Map(); |
| 42 /** @type {!Map<string, !Array<string>>} */ |
| 43 this._shorthands = new Map(); |
| 44 /** @type {!Set<string>} */ |
| 45 this._inherited = new Set(); |
| 42 for (var i = 0; i < properties.length; ++i) { | 46 for (var i = 0; i < properties.length; ++i) { |
| 43 var property = properties[i]; | 47 var property = properties[i]; |
| 44 var propertyName = property.name; | 48 var propertyName = property.name; |
| 45 if (!CSS.supports(propertyName, "initial")) | 49 if (!CSS.supports(propertyName, "initial")) |
| 46 continue; | 50 continue; |
| 47 this._values.push(propertyName); | 51 this._values.push(propertyName); |
| 48 | 52 |
| 53 if (property.inherited) |
| 54 this._inherited.add(propertyName); |
| 55 |
| 49 var longhands = properties[i].longhands; | 56 var longhands = properties[i].longhands; |
| 50 if (longhands) { | 57 if (longhands) { |
| 51 this._longhands[propertyName] = longhands; | 58 this._longhands.set(propertyName, longhands); |
| 52 for (var j = 0; j < longhands.length; ++j) { | 59 for (var j = 0; j < longhands.length; ++j) { |
| 53 var longhandName = longhands[j]; | 60 var longhandName = longhands[j]; |
| 54 var shorthands = this._shorthands[longhandName]; | 61 var shorthands = this._shorthands.get(longhandName); |
| 55 if (!shorthands) { | 62 if (!shorthands) { |
| 56 shorthands = []; | 63 shorthands = []; |
| 57 this._shorthands[longhandName] = shorthands; | 64 this._shorthands.set(longhandName, shorthands); |
| 58 } | 65 } |
| 59 shorthands.push(propertyName); | 66 shorthands.push(propertyName); |
| 60 } | 67 } |
| 61 } | 68 } |
| 62 } | 69 } |
| 63 this._values.sort(); | 70 this._values.sort(); |
| 64 } | 71 } |
| 65 | 72 |
| 66 /** | 73 /** |
| 67 * @param {string} propertyName | 74 * @param {string} propertyName |
| (...skipping 28 matching lines...) Expand all Loading... |
| 96 | 103 |
| 97 /** | 104 /** |
| 98 * @param {string} propertyName | 105 * @param {string} propertyName |
| 99 * @return {boolean} | 106 * @return {boolean} |
| 100 */ | 107 */ |
| 101 WebInspector.CSSMetadata.isCustomProperty = function(propertyName) | 108 WebInspector.CSSMetadata.isCustomProperty = function(propertyName) |
| 102 { | 109 { |
| 103 return propertyName.startsWith("--"); | 110 return propertyName.startsWith("--"); |
| 104 } | 111 } |
| 105 | 112 |
| 106 // Originally taken from http://www.w3.org/TR/CSS21/propidx.html and augmented. | |
| 107 WebInspector.CSSMetadata.InheritedProperties = [ | |
| 108 "azimuth", "border-collapse", "border-spacing", "caption-side", "color", "cu
rsor", "direction", "elevation", | |
| 109 "empty-cells", "font-family", "font-size", "font-style", "font-variant", "fo
nt-weight", "font", "letter-spacing", | |
| 110 "line-height", "list-style-image", "list-style-position", "list-style-type",
"list-style", "orphans", "overflow-wrap", "pitch-range", | |
| 111 "pitch", "quotes", "resize", "richness", "speak-header", "speak-numeral", "s
peak-punctuation", "speak", "speech-rate", "stress", | |
| 112 "text-align", "text-indent", "text-transform", "text-shadow", "-webkit-user-
select", "visibility", "voice-family", "volume", "white-space", "widows", | |
| 113 "word-spacing", "word-wrap", "zoom" | |
| 114 ].keySet(); | |
| 115 | |
| 116 // These non-standard Blink-specific properties augment the InheritedProperties. | |
| 117 WebInspector.CSSMetadata.NonStandardInheritedProperties = [ | |
| 118 "-webkit-font-smoothing" | |
| 119 ].keySet(); | |
| 120 | |
| 121 /** | 113 /** |
| 122 * @param {string} name | 114 * @param {string} name |
| 123 * @return {string} | 115 * @return {string} |
| 124 */ | 116 */ |
| 125 WebInspector.CSSMetadata.canonicalPropertyName = function(name) | 117 WebInspector.CSSMetadata.canonicalPropertyName = function(name) |
| 126 { | 118 { |
| 127 if (!name || name.length < 9 || name.charAt(0) !== "-") | 119 if (!name || name.length < 9 || name.charAt(0) !== "-") |
| 128 return name.toLowerCase(); | 120 return name.toLowerCase(); |
| 129 var match = name.match(/(?:-webkit-)(.+)/); | 121 var match = name.match(/(?:-webkit-)(.+)/); |
| 130 if (!match || !WebInspector.CSSMetadata.cssPropertiesMetainfo.hasProperty(ma
tch[1].toLowerCase())) | 122 if (!match || !WebInspector.CSSMetadata.cssPropertiesMetainfo.hasProperty(ma
tch[1].toLowerCase())) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 143 return true; | 135 return true; |
| 144 return WebInspector.CSSMetadata.cssPropertiesMetainfo.hasProperty(propertyNa
me); | 136 return WebInspector.CSSMetadata.cssPropertiesMetainfo.hasProperty(propertyNa
me); |
| 145 } | 137 } |
| 146 | 138 |
| 147 /** | 139 /** |
| 148 * @param {string} propertyName | 140 * @param {string} propertyName |
| 149 * @return {boolean} | 141 * @return {boolean} |
| 150 */ | 142 */ |
| 151 WebInspector.CSSMetadata.isPropertyInherited = function(propertyName) | 143 WebInspector.CSSMetadata.isPropertyInherited = function(propertyName) |
| 152 { | 144 { |
| 153 return !!(WebInspector.CSSMetadata.InheritedProperties[WebInspector.CSSMetad
ata.canonicalPropertyName(propertyName)] | 145 var metadata = WebInspector.CSSMetadata.cssPropertiesMetainfo; |
| 154 || WebInspector.CSSMetadata.NonStandardInheritedProperties[propertyN
ame.toLowerCase()]); | 146 return metadata.inherited(WebInspector.CSSMetadata.canonicalPropertyName(pro
pertyName)) || metadata.inherited(propertyName.toLowerCase()); |
| 155 } | 147 } |
| 156 | 148 |
| 157 WebInspector.CSSMetadata._distanceProperties = [ | 149 WebInspector.CSSMetadata._distanceProperties = [ |
| 158 "background-position", "border-spacing", "bottom", "font-size", "height", "l
eft", "letter-spacing", "max-height", "max-width", "min-height", | 150 "background-position", "border-spacing", "bottom", "font-size", "height", "l
eft", "letter-spacing", "max-height", "max-width", "min-height", |
| 159 "min-width", "right", "text-indent", "top", "width", "word-spacing" | 151 "min-width", "right", "text-indent", "top", "width", "word-spacing" |
| 160 ]; | 152 ]; |
| 161 | 153 |
| 162 WebInspector.CSSMetadata._bezierAwareProperties = [ | 154 WebInspector.CSSMetadata._bezierAwareProperties = [ |
| 163 "animation", "animation-timing-function", "transition", "transition-timing-f
unction", "-webkit-animation", "-webkit-animation-timing-function", | 155 "animation", "animation-timing-function", "transition", "transition-timing-f
unction", "-webkit-animation", "-webkit-animation-timing-function", |
| 164 "-webkit-transition", "-webkit-transition-timing-function" | 156 "-webkit-transition", "-webkit-transition-timing-function" |
| (...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 this._valuesSet = new Set(this._values); | 949 this._valuesSet = new Set(this._values); |
| 958 return this._valuesSet.has(propertyName); | 950 return this._valuesSet.has(propertyName); |
| 959 }, | 951 }, |
| 960 | 952 |
| 961 /** | 953 /** |
| 962 * @param {string} shorthand | 954 * @param {string} shorthand |
| 963 * @return {?Array.<string>} | 955 * @return {?Array.<string>} |
| 964 */ | 956 */ |
| 965 longhands: function(shorthand) | 957 longhands: function(shorthand) |
| 966 { | 958 { |
| 967 return this._longhands[shorthand]; | 959 return this._longhands.get(shorthand); |
| 968 }, | 960 }, |
| 969 | 961 |
| 970 /** | 962 /** |
| 971 * @param {string} longhand | 963 * @param {string} longhand |
| 972 * @return {?Array.<string>} | 964 * @return {?Array.<string>} |
| 973 */ | 965 */ |
| 974 shorthands: function(longhand) | 966 shorthands: function(longhand) |
| 975 { | 967 { |
| 976 return this._shorthands[longhand]; | 968 return this._shorthands.get(longhand); |
| 969 }, |
| 970 |
| 971 /** |
| 972 * @param {string} propertyName |
| 973 * @return {boolean} |
| 974 */ |
| 975 inherited: function(propertyName) |
| 976 { |
| 977 return this._inherited.has(propertyName); |
| 977 } | 978 } |
| 978 } | 979 } |
| 979 | 980 |
| 980 WebInspector.CSSMetadata.initializeWithSupportedProperties([]); | 981 WebInspector.CSSMetadata.initializeWithSupportedProperties([]); |
| OLD | NEW |