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

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

Issue 2220473002: DevTools: generate information about property inheritance. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kill-2
Patch Set: Created 4 years, 4 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/scripts/generate_supported_css.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/sdk/CSSMetadata.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/CSSMetadata.js b/third_party/WebKit/Source/devtools/front_end/sdk/CSSMetadata.js
index 2ce9adb7bb5e0cf62458541bbbc1d075256bd6af..d21f873bec2426e1fc4f00d2bd221d75bdfdba89 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/CSSMetadata.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/CSSMetadata.js
@@ -37,8 +37,12 @@
WebInspector.CSSMetadata = function(properties)
{
this._values = /** !Array.<string> */ ([]);
- this._longhands = {};
- this._shorthands = {};
+ /** @type {!Map<string, !Array<string>>} */
+ this._longhands = new Map();
+ /** @type {!Map<string, !Array<string>>} */
+ this._shorthands = new Map();
+ /** @type {!Set<string>} */
+ this._inherited = new Set();
for (var i = 0; i < properties.length; ++i) {
var property = properties[i];
var propertyName = property.name;
@@ -46,15 +50,18 @@ WebInspector.CSSMetadata = function(properties)
continue;
this._values.push(propertyName);
+ if (property.inherited)
+ this._inherited.add(propertyName);
+
var longhands = properties[i].longhands;
if (longhands) {
- this._longhands[propertyName] = longhands;
+ this._longhands.set(propertyName, longhands);
for (var j = 0; j < longhands.length; ++j) {
var longhandName = longhands[j];
- var shorthands = this._shorthands[longhandName];
+ var shorthands = this._shorthands.get(longhandName);
if (!shorthands) {
shorthands = [];
- this._shorthands[longhandName] = shorthands;
+ this._shorthands.set(longhandName, shorthands);
}
shorthands.push(propertyName);
}
@@ -103,21 +110,6 @@ WebInspector.CSSMetadata.isCustomProperty = function(propertyName)
return propertyName.startsWith("--");
}
-// Originally taken from http://www.w3.org/TR/CSS21/propidx.html and augmented.
-WebInspector.CSSMetadata.InheritedProperties = [
- "azimuth", "border-collapse", "border-spacing", "caption-side", "color", "cursor", "direction", "elevation",
- "empty-cells", "font-family", "font-size", "font-style", "font-variant", "font-weight", "font", "letter-spacing",
- "line-height", "list-style-image", "list-style-position", "list-style-type", "list-style", "orphans", "overflow-wrap", "pitch-range",
- "pitch", "quotes", "resize", "richness", "speak-header", "speak-numeral", "speak-punctuation", "speak", "speech-rate", "stress",
- "text-align", "text-indent", "text-transform", "text-shadow", "-webkit-user-select", "visibility", "voice-family", "volume", "white-space", "widows",
- "word-spacing", "word-wrap", "zoom"
-].keySet();
-
-// These non-standard Blink-specific properties augment the InheritedProperties.
-WebInspector.CSSMetadata.NonStandardInheritedProperties = [
- "-webkit-font-smoothing"
-].keySet();
-
/**
* @param {string} name
* @return {string}
@@ -150,8 +142,8 @@ WebInspector.CSSMetadata.isCSSPropertyName = function(propertyName)
*/
WebInspector.CSSMetadata.isPropertyInherited = function(propertyName)
{
- return !!(WebInspector.CSSMetadata.InheritedProperties[WebInspector.CSSMetadata.canonicalPropertyName(propertyName)]
- || WebInspector.CSSMetadata.NonStandardInheritedProperties[propertyName.toLowerCase()]);
+ var metadata = WebInspector.CSSMetadata.cssPropertiesMetainfo;
+ return metadata.inherited(WebInspector.CSSMetadata.canonicalPropertyName(propertyName)) || metadata.inherited(propertyName.toLowerCase());
}
WebInspector.CSSMetadata._distanceProperties = [
@@ -964,7 +956,7 @@ WebInspector.CSSMetadata.prototype = {
*/
longhands: function(shorthand)
{
- return this._longhands[shorthand];
+ return this._longhands.get(shorthand);
},
/**
@@ -973,7 +965,16 @@ WebInspector.CSSMetadata.prototype = {
*/
shorthands: function(longhand)
{
- return this._shorthands[longhand];
+ return this._shorthands.get(longhand);
+ },
+
+ /**
+ * @param {string} propertyName
+ * @return {boolean}
+ */
+ inherited: function(propertyName)
+ {
+ return this._inherited.has(propertyName);
}
}
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/scripts/generate_supported_css.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698