Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(133)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/sdk/CSSMetadata.js

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 15 matching lines...) Expand all
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 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. 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33 /** 33 /**
34 * @unrestricted 34 * @unrestricted
35 */ 35 */
36 WebInspector.CSSMetadata = class { 36 SDK.CSSMetadata = class {
37 /** 37 /**
38 * @param {!Array.<!{name: string, longhands: !Array.<string>}>} properties 38 * @param {!Array.<!{name: string, longhands: !Array.<string>}>} properties
39 */ 39 */
40 constructor(properties) { 40 constructor(properties) {
41 this._values = /** !Array.<string> */ ([]); 41 this._values = /** !Array.<string> */ ([]);
42 /** @type {!Map<string, !Array<string>>} */ 42 /** @type {!Map<string, !Array<string>>} */
43 this._longhands = new Map(); 43 this._longhands = new Map();
44 /** @type {!Map<string, !Array<string>>} */ 44 /** @type {!Map<string, !Array<string>>} */
45 this._shorthands = new Map(); 45 this._shorthands = new Map();
46 /** @type {!Set<string>} */ 46 /** @type {!Set<string>} */
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 */ 94 */
95 shorthands(longhand) { 95 shorthands(longhand) {
96 return this._shorthands.get(longhand) || null; 96 return this._shorthands.get(longhand) || null;
97 } 97 }
98 98
99 /** 99 /**
100 * @param {string} propertyName 100 * @param {string} propertyName
101 * @return {boolean} 101 * @return {boolean}
102 */ 102 */
103 isColorAwareProperty(propertyName) { 103 isColorAwareProperty(propertyName) {
104 return !!WebInspector.CSSMetadata._colorAwareProperties.has(propertyName.toL owerCase()) || 104 return !!SDK.CSSMetadata._colorAwareProperties.has(propertyName.toLowerCase( )) ||
105 this.isCustomProperty(propertyName.toLowerCase()); 105 this.isCustomProperty(propertyName.toLowerCase());
106 } 106 }
107 107
108 /** 108 /**
109 * @param {string} propertyName 109 * @param {string} propertyName
110 * @return {boolean} 110 * @return {boolean}
111 */ 111 */
112 isLengthProperty(propertyName) { 112 isLengthProperty(propertyName) {
113 propertyName = propertyName.toLowerCase(); 113 propertyName = propertyName.toLowerCase();
114 if (propertyName === 'line-height') 114 if (propertyName === 'line-height')
115 return false; 115 return false;
116 return WebInspector.CSSMetadata._distanceProperties.has(propertyName) || pro pertyName.startsWith('margin') || 116 return SDK.CSSMetadata._distanceProperties.has(propertyName) || propertyName .startsWith('margin') ||
117 propertyName.startsWith('padding') || propertyName.indexOf('width') !== -1 || 117 propertyName.startsWith('padding') || propertyName.indexOf('width') !== -1 ||
118 propertyName.indexOf('height') !== -1; 118 propertyName.indexOf('height') !== -1;
119 } 119 }
120 120
121 /** 121 /**
122 * @param {string} propertyName 122 * @param {string} propertyName
123 * @return {boolean} 123 * @return {boolean}
124 */ 124 */
125 isBezierAwareProperty(propertyName) { 125 isBezierAwareProperty(propertyName) {
126 propertyName = propertyName.toLowerCase(); 126 propertyName = propertyName.toLowerCase();
127 return !!WebInspector.CSSMetadata._bezierAwareProperties.has(propertyName) | | this.isCustomProperty(propertyName); 127 return !!SDK.CSSMetadata._bezierAwareProperties.has(propertyName) || this.is CustomProperty(propertyName);
128 } 128 }
129 129
130 /** 130 /**
131 * @param {string} propertyName 131 * @param {string} propertyName
132 * @return {boolean} 132 * @return {boolean}
133 */ 133 */
134 isCustomProperty(propertyName) { 134 isCustomProperty(propertyName) {
135 return propertyName.startsWith('--'); 135 return propertyName.startsWith('--');
136 } 136 }
137 137
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 171 }
172 172
173 /** 173 /**
174 * @param {string} propertyName 174 * @param {string} propertyName
175 * @return {!Array<string>} 175 * @return {!Array<string>}
176 */ 176 */
177 propertyValues(propertyName) { 177 propertyValues(propertyName) {
178 var acceptedKeywords = ['inherit', 'initial']; 178 var acceptedKeywords = ['inherit', 'initial'];
179 propertyName = propertyName.toLowerCase(); 179 propertyName = propertyName.toLowerCase();
180 var unprefixedName = propertyName.replace(/^-webkit-/, ''); 180 var unprefixedName = propertyName.replace(/^-webkit-/, '');
181 var entry = WebInspector.CSSMetadata._propertyDataMap[propertyName] || 181 var entry = SDK.CSSMetadata._propertyDataMap[propertyName] ||
182 WebInspector.CSSMetadata._propertyDataMap[unprefixedName]; 182 SDK.CSSMetadata._propertyDataMap[unprefixedName];
183 if (entry && entry.values) 183 if (entry && entry.values)
184 acceptedKeywords.pushAll(entry.values); 184 acceptedKeywords.pushAll(entry.values);
185 if (this.isColorAwareProperty(propertyName)) { 185 if (this.isColorAwareProperty(propertyName)) {
186 acceptedKeywords.push('currentColor'); 186 acceptedKeywords.push('currentColor');
187 for (var color in WebInspector.Color.Nicknames) 187 for (var color in Common.Color.Nicknames)
188 acceptedKeywords.push(color); 188 acceptedKeywords.push(color);
189 } 189 }
190 return acceptedKeywords.sort(); 190 return acceptedKeywords.sort();
191 } 191 }
192 192
193 /** 193 /**
194 * @param {!Array.<string>} properties 194 * @param {!Array.<string>} properties
195 * @return {number} 195 * @return {number}
196 */ 196 */
197 mostUsedProperty(properties) { 197 mostUsedProperty(properties) {
198 var maxWeight = 0; 198 var maxWeight = 0;
199 var index = 0; 199 var index = 0;
200 for (var i = 0; i < properties.length; i++) { 200 for (var i = 0; i < properties.length; i++) {
201 var weight = WebInspector.CSSMetadata.Weight[properties[i]]; 201 var weight = SDK.CSSMetadata.Weight[properties[i]];
202 if (!weight) 202 if (!weight)
203 weight = WebInspector.CSSMetadata.Weight[this.canonicalPropertyName(prop erties[i])]; 203 weight = SDK.CSSMetadata.Weight[this.canonicalPropertyName(properties[i] )];
204 if (weight > maxWeight) { 204 if (weight > maxWeight) {
205 maxWeight = weight; 205 maxWeight = weight;
206 index = i; 206 index = i;
207 } 207 }
208 } 208 }
209 return index; 209 return index;
210 } 210 }
211 }; 211 };
212 212
213 WebInspector.CSSMetadata.VariableRegex = /(var\(--.*?\))/g; 213 SDK.CSSMetadata.VariableRegex = /(var\(--.*?\))/g;
214 WebInspector.CSSMetadata.URLRegex = /url\(\s*('.+?'|".+?"|[^)]+)\s*\)/g; 214 SDK.CSSMetadata.URLRegex = /url\(\s*('.+?'|".+?"|[^)]+)\s*\)/g;
215 215
216 /** 216 /**
217 * @return {!WebInspector.CSSMetadata} 217 * @return {!SDK.CSSMetadata}
218 */ 218 */
219 WebInspector.cssMetadata = function() { 219 SDK.cssMetadata = function() {
220 if (!WebInspector.CSSMetadata._instance) 220 if (!SDK.CSSMetadata._instance)
221 WebInspector.CSSMetadata._instance = 221 SDK.CSSMetadata._instance =
222 new WebInspector.CSSMetadata(WebInspector.CSSMetadata._generatedProperti es || []); 222 new SDK.CSSMetadata(SDK.CSSMetadata._generatedProperties || []);
223 return WebInspector.CSSMetadata._instance; 223 return SDK.CSSMetadata._instance;
224 }; 224 };
225 225
226 WebInspector.CSSMetadata._distanceProperties = new Set([ 226 SDK.CSSMetadata._distanceProperties = new Set([
227 'background-position', 'border-spacing', 'bottom', 'font-size', 'height', 'lef t', 'letter-spacing', 'max-height', 227 'background-position', 'border-spacing', 'bottom', 'font-size', 'height', 'lef t', 'letter-spacing', 'max-height',
228 'max-width', 'min-height', 'min-width', 'right', 'text-indent', 'top', 'width' , 'word-spacing' 228 'max-width', 'min-height', 'min-width', 'right', 'text-indent', 'top', 'width' , 'word-spacing'
229 ]); 229 ]);
230 230
231 WebInspector.CSSMetadata._bezierAwareProperties = new Set([ 231 SDK.CSSMetadata._bezierAwareProperties = new Set([
232 'animation', 'animation-timing-function', 'transition', 'transition-timing-fun ction', '-webkit-animation', 232 'animation', 'animation-timing-function', 'transition', 'transition-timing-fun ction', '-webkit-animation',
233 '-webkit-animation-timing-function', '-webkit-transition', '-webkit-transition -timing-function' 233 '-webkit-animation-timing-function', '-webkit-transition', '-webkit-transition -timing-function'
234 ]); 234 ]);
235 235
236 WebInspector.CSSMetadata._colorAwareProperties = new Set([ 236 SDK.CSSMetadata._colorAwareProperties = new Set([
237 'backdrop-filter', 237 'backdrop-filter',
238 'background', 238 'background',
239 'background-color', 239 'background-color',
240 'background-image', 240 'background-image',
241 'border', 241 'border',
242 'border-color', 242 'border-color',
243 'border-image', 243 'border-image',
244 'border-image-source', 244 'border-image-source',
245 'border-bottom', 245 'border-bottom',
246 'border-bottom-color', 246 'border-bottom-color',
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 '-webkit-mask-image', 280 '-webkit-mask-image',
281 '-webkit-tap-highlight-color', 281 '-webkit-tap-highlight-color',
282 '-webkit-text-decoration-color', 282 '-webkit-text-decoration-color',
283 '-webkit-text-emphasis', 283 '-webkit-text-emphasis',
284 '-webkit-text-emphasis-color', 284 '-webkit-text-emphasis-color',
285 '-webkit-text-fill-color', 285 '-webkit-text-fill-color',
286 '-webkit-text-stroke', 286 '-webkit-text-stroke',
287 '-webkit-text-stroke-color' 287 '-webkit-text-stroke-color'
288 ]); 288 ]);
289 289
290 WebInspector.CSSMetadata._propertyDataMap = { 290 SDK.CSSMetadata._propertyDataMap = {
291 'table-layout': {values: ['auto', 'fixed']}, 291 'table-layout': {values: ['auto', 'fixed']},
292 'visibility': {values: ['hidden', 'visible', 'collapse']}, 292 'visibility': {values: ['hidden', 'visible', 'collapse']},
293 'background-repeat': {values: ['repeat', 'repeat-x', 'repeat-y', 'no-repeat', 'space', 'round']}, 293 'background-repeat': {values: ['repeat', 'repeat-x', 'repeat-y', 'no-repeat', 'space', 'round']},
294 'content': {values: ['list-item', 'close-quote', 'no-close-quote', 'no-open-qu ote', 'open-quote']}, 294 'content': {values: ['list-item', 'close-quote', 'no-close-quote', 'no-open-qu ote', 'open-quote']},
295 'list-style-image': {values: ['none']}, 295 'list-style-image': {values: ['none']},
296 'clear': {values: ['none', 'left', 'right', 'both']}, 296 'clear': {values: ['none', 'left', 'right', 'both']},
297 'overflow-x': {values: ['hidden', 'auto', 'visible', 'overlay', 'scroll']}, 297 'overflow-x': {values: ['hidden', 'auto', 'visible', 'overlay', 'scroll']},
298 'stroke-linejoin': {values: ['round', 'miter', 'bevel']}, 298 'stroke-linejoin': {values: ['round', 'miter', 'bevel']},
299 'baseline-shift': {values: ['baseline', 'sub', 'super']}, 299 'baseline-shift': {values: ['baseline', 'sub', 'super']},
300 'border-bottom-width': {values: ['medium', 'thick', 'thin']}, 300 'border-bottom-width': {values: ['medium', 'thick', 'thin']},
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 }, 693 },
694 'background-blend-mode': { 694 'background-blend-mode': {
695 values: [ 695 values: [
696 'normal', 'multiply', 'screen', 'overlay', 'darken', 'lighten', 'color-dod ge', 'color-burn', 'hard-light', 696 'normal', 'multiply', 'screen', 'overlay', 'darken', 'lighten', 'color-dod ge', 'color-burn', 'hard-light',
697 'soft-light', 'difference', 'exclusion', 'hue', 'saturation', 'color', 'lu minosity', 'unset' 697 'soft-light', 'difference', 'exclusion', 'hue', 'saturation', 'color', 'lu minosity', 'unset'
698 ] 698 ]
699 }, 699 },
700 }; 700 };
701 701
702 // Weight of CSS properties based on their usage from https://www.chromestatus.c om/metrics/css/popularity 702 // Weight of CSS properties based on their usage from https://www.chromestatus.c om/metrics/css/popularity
703 WebInspector.CSSMetadata.Weight = { 703 SDK.CSSMetadata.Weight = {
704 'align-content': 57, 704 'align-content': 57,
705 'align-items': 129, 705 'align-items': 129,
706 'align-self': 55, 706 'align-self': 55,
707 'animation': 175, 707 'animation': 175,
708 'animation-delay': 114, 708 'animation-delay': 114,
709 'animation-direction': 113, 709 'animation-direction': 113,
710 'animation-duration': 137, 710 'animation-duration': 137,
711 'animation-fill-mode': 132, 711 'animation-fill-mode': 132,
712 'animation-iteration-count': 124, 712 'animation-iteration-count': 124,
713 'animation-name': 139, 713 'animation-name': 139,
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 'widows': 115, 949 'widows': 115,
950 'width': 268, 950 'width': 268,
951 'will-change': 74, 951 'will-change': 74,
952 'word-break': 166, 952 'word-break': 166,
953 'word-spacing': 157, 953 'word-spacing': 157,
954 'word-wrap': 197, 954 'word-wrap': 197,
955 'writing-mode': 41, 955 'writing-mode': 41,
956 'z-index': 239, 956 'z-index': 239,
957 'zoom': 200 957 'zoom': 200
958 }; 958 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698