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

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

Issue 2571713002: DevTools: [SSP] do not autocomplete SVG properties for non-svg nodes (Closed)
Patch Set: addres comments Created 4 years 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 17 matching lines...) Expand all
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 SDK.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>, inherited: bool ean, svg: boolean}>} 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>} */
47 this._inherited = new Set(); 47 this._inherited = new Set();
48 /** @type {!Set<string>} */
49 this._svgProperties = new Set();
48 for (var i = 0; i < properties.length; ++i) { 50 for (var i = 0; i < properties.length; ++i) {
49 var property = properties[i]; 51 var property = properties[i];
50 var propertyName = property.name; 52 var propertyName = property.name;
51 if (!CSS.supports(propertyName, 'initial')) 53 if (!CSS.supports(propertyName, 'initial'))
52 continue; 54 continue;
53 this._values.push(propertyName); 55 this._values.push(propertyName);
54 56
55 if (property.inherited) 57 if (property.inherited)
56 this._inherited.add(propertyName); 58 this._inherited.add(propertyName);
59 if (property.svg)
60 this._svgProperties.add(propertyName);
57 61
58 var longhands = properties[i].longhands; 62 var longhands = properties[i].longhands;
59 if (longhands) { 63 if (longhands) {
60 this._longhands.set(propertyName, longhands); 64 this._longhands.set(propertyName, longhands);
61 for (var j = 0; j < longhands.length; ++j) { 65 for (var j = 0; j < longhands.length; ++j) {
62 var longhandName = longhands[j]; 66 var longhandName = longhands[j];
63 var shorthands = this._shorthands.get(longhandName); 67 var shorthands = this._shorthands.get(longhandName);
64 if (!shorthands) { 68 if (!shorthands) {
65 shorthands = []; 69 shorthands = [];
66 this._shorthands.set(longhandName, shorthands); 70 this._shorthands.set(longhandName, shorthands);
67 } 71 }
68 shorthands.push(propertyName); 72 shorthands.push(propertyName);
69 } 73 }
70 } 74 }
71 } 75 }
72 this._values.sort(); 76 this._values.sort();
73 this._valuesSet = new Set(this._values); 77 this._valuesSet = new Set(this._values);
74 } 78 }
75 79
76 /** 80 /**
77 * @return {!Array<string>} 81 * @return {!Array<string>}
78 */ 82 */
79 allProperties() { 83 allProperties() {
80 return this._values; 84 return this._values;
81 } 85 }
82 86
83 /** 87 /**
88 * @param {string} name
89 * @return {boolean}
90 */
91 isSVGProperty(name) {
92 name = name.toLowerCase();
93 return this._svgProperties.has(name);
94 }
95
96 /**
84 * @param {string} shorthand 97 * @param {string} shorthand
85 * @return {?Array.<string>} 98 * @return {?Array.<string>}
86 */ 99 */
87 longhands(shorthand) { 100 longhands(shorthand) {
88 return this._longhands.get(shorthand) || null; 101 return this._longhands.get(shorthand) || null;
89 } 102 }
90 103
91 /** 104 /**
92 * @param {string} longhand 105 * @param {string} longhand
93 * @return {?Array.<string>} 106 * @return {?Array.<string>}
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 'widows': 115, 949 'widows': 115,
937 'width': 268, 950 'width': 268,
938 'will-change': 74, 951 'will-change': 74,
939 'word-break': 166, 952 'word-break': 166,
940 'word-spacing': 157, 953 'word-spacing': 157,
941 'word-wrap': 197, 954 'word-wrap': 197,
942 'writing-mode': 41, 955 'writing-mode': 41,
943 'z-index': 239, 956 'z-index': 239,
944 'zoom': 200 957 'zoom': 200
945 }; 958 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698