Index: Source/devtools/front_end/elements/StylesSidebarPane.js |
diff --git a/Source/devtools/front_end/elements/StylesSidebarPane.js b/Source/devtools/front_end/elements/StylesSidebarPane.js |
index 6a42183aada574a0c3fa6d3d8dea608939d737bf..319fa195a0d058f09e26bd1830c1958866805460 100644 |
--- a/Source/devtools/front_end/elements/StylesSidebarPane.js |
+++ b/Source/devtools/front_end/elements/StylesSidebarPane.js |
@@ -133,6 +133,14 @@ WebInspector.StylesSidebarPane._colorFormat = function(color) |
} |
/** |
+ * @return {boolean} |
+ */ |
+WebInspector.StylesSidebarPane._affectsNode = function(styleRule) |
vsevik
2014/11/05 08:04:50
Let's name it _hasMatchingSelectors
lushnikov
2014/11/05 11:02:17
Done.
|
+{ |
+ return styleRule.rule ? styleRule.rule.matchingSelectors.length > 0 : true; |
+} |
+ |
+/** |
* @param {!WebInspector.CSSProperty} property |
*/ |
WebInspector.StylesSidebarPane._ignoreErrorsForProperty = function(property) { |
@@ -631,15 +639,25 @@ WebInspector.StylesSidebarPane.prototype = { |
_innerRefreshUpdate: function(node, computedStyle, editedSection) |
{ |
for (var pseudoId in this.sections) { |
- var styleRules = this._refreshStyleRules(this.sections[pseudoId], computedStyle); |
+ var filteredSections = this.sections[pseudoId] ? this.sections[pseudoId].filter(nonBlankSections) : []; |
+ var styleRules = this._refreshStyleRules(filteredSections, computedStyle); |
var usedProperties = {}; |
this._markUsedProperties(styleRules, usedProperties); |
- this._refreshSectionsForStyleRules(styleRules, usedProperties, editedSection); |
+ this._refreshSectionsForStyleRules(filteredSections, styleRules, usedProperties, editedSection); |
} |
if (computedStyle) |
this.sections[0][0].rebuildComputedTrace(this.sections[0]); |
this._nodeStylesUpdatedForTest(node, false); |
+ |
+ /** |
+ * @param {!WebInspector.PropertiesSection} section |
+ * @return {boolean} |
+ */ |
+ function nonBlankSections(section) |
+ { |
+ return !section.isBlank; |
+ } |
}, |
_innerRebuildUpdate: function(node, styles) |
@@ -691,11 +709,9 @@ WebInspector.StylesSidebarPane.prototype = { |
var styleRules = []; |
for (var i = 0; sections && i < sections.length; ++i) { |
var section = sections[i]; |
- if (section.isBlank) |
- continue; |
if (section.computedStyle) |
section.styleRule.style = nodeComputedStyle; |
- var styleRule = { section: section, style: section.styleRule.style, computedStyle: section.computedStyle, rule: section.rule, editable: !!(section.styleRule.style && section.styleRule.style.styleSheetId), |
+ var styleRule = { style: section.styleRule.style, computedStyle: section.computedStyle, rule: section.rule, editable: !!(section.styleRule.style && section.styleRule.style.styleSheetId), |
isAttribute: section.styleRule.isAttribute, isInherited: section.styleRule.isInherited, parentNode: section.styleRule.parentNode }; |
styleRules.push(styleRule); |
} |
@@ -794,7 +810,7 @@ WebInspector.StylesSidebarPane.prototype = { |
var styleRule = styleRules[i]; |
if (styleRule.computedStyle || styleRule.isStyleSeparator) |
continue; |
- if (styleRule.section && styleRule.section.noAffect) |
+ if (!WebInspector.StylesSidebarPane._affectsNode(styleRule)) |
continue; |
styleRule.usedProperties = {}; |
@@ -837,12 +853,12 @@ WebInspector.StylesSidebarPane.prototype = { |
} |
}, |
- _refreshSectionsForStyleRules: function(styleRules, usedProperties, editedSection) |
+ _refreshSectionsForStyleRules: function(sections, styleRules, usedProperties, editedSection) |
{ |
// Walk the style rules and update the sections with new overloaded and used properties. |
for (var i = 0; i < styleRules.length; ++i) { |
var styleRule = styleRules[i]; |
- var section = styleRule.section; |
+ var section = sections[i]; |
if (styleRule.computedStyle) { |
section._usedProperties = usedProperties; |
section.update(); |
@@ -1432,7 +1448,7 @@ WebInspector.StylePropertiesSection.prototype = { |
*/ |
isPropertyOverloaded: function(propertyName, isShorthand) |
{ |
- if (!this._usedProperties || this.noAffect) |
+ if (!this._usedProperties || !WebInspector.StylesSidebarPane._affectsNode(this.styleRule)) |
return false; |
if (this.isInherited && !WebInspector.CSSMetadata.isPropertyInherited(propertyName)) { |
@@ -1530,13 +1546,11 @@ WebInspector.StylePropertiesSection.prototype = { |
{ |
var style = this.styleRule.style; |
var allProperties = style.allProperties; |
- this.uniqueProperties = []; |
var styleHasEditableSource = this.editable && !!style.range; |
if (styleHasEditableSource) { |
for (var i = 0; i < allProperties.length; ++i) { |
var property = allProperties[i]; |
- this.uniqueProperties.push(property); |
if (property.styleBased) |
continue; |
@@ -1553,7 +1567,6 @@ WebInspector.StylePropertiesSection.prototype = { |
// For style-based properties, generate shorthands with values when possible. |
for (var i = 0; i < allProperties.length; ++i) { |
var property = allProperties[i]; |
- this.uniqueProperties.push(property); |
var isShorthand = !!WebInspector.CSSMetadata.cssPropertiesMetainfo.longhands(property.name); |
// For style-based properties, try generating shorthands. |
@@ -1618,7 +1631,7 @@ WebInspector.StylePropertiesSection.prototype = { |
var matchingSelectors = rule.matchingSelectors; |
// .selector is rendered as non-affecting selector by default. |
- if (this.noAffect || matchingSelectors) |
+ if (!WebInspector.StylesSidebarPane._affectsNode(this.styleRule) || matchingSelectors) |
this._selectorElement.className = "selector"; |
if (!matchingSelectors) |
return; |
@@ -1880,17 +1893,11 @@ WebInspector.StylePropertiesSection.prototype = { |
function successCallback(newRule) |
{ |
var doesAffectSelectedNode = newRule.matchingSelectors.length > 0; |
- if (!doesAffectSelectedNode) { |
- this.noAffect = true; |
- this.element.classList.add("no-affect"); |
- } else { |
- delete this.noAffect; |
- this.element.classList.remove("no-affect"); |
- } |
+ this.element.classList.toggle("no-affect", !doesAffectSelectedNode); |
var oldSelectorRange = this.rule.selectorRange; |
this.rule = newRule; |
- this.styleRule = { section: this, style: newRule.style, selectorText: newRule.selectorText, media: newRule.media, rule: newRule }; |
+ this.styleRule = { style: newRule.style, selectorText: newRule.selectorText, media: newRule.media, rule: newRule }; |
this._parentPane.update(selectedNode); |
this._parentPane._styleSheetRuleEdited(this.rule, oldSelectorRange, this.rule.selectorRange); |
@@ -2055,8 +2062,9 @@ WebInspector.ComputedStylePropertiesSection.prototype = { |
if (section.computedStyle || section.isBlank) |
continue; |
- for (var j = 0; j < section.uniqueProperties.length; ++j) { |
- var property = section.uniqueProperties[j]; |
+ var properties = section.styleRule.style.allProperties; |
+ for (var j = 0; j < properties.length; ++j) { |
+ var property = properties[j]; |
if (property.disabled) |
continue; |
if (section.isInherited && !WebInspector.CSSMetadata.isPropertyInherited(property.name)) |
@@ -2163,13 +2171,11 @@ WebInspector.BlankStylePropertiesSection.prototype = { |
function successCallback(newRule) |
{ |
var doesSelectorAffectSelectedNode = newRule.matchingSelectors.length > 0; |
- var styleRule = { media: newRule.media, section: this, style: newRule.style, selectorText: newRule.selectorText, rule: newRule }; |
+ var styleRule = { media: newRule.media, style: newRule.style, selectorText: newRule.selectorText, rule: newRule }; |
this._makeNormal(styleRule); |
- if (!doesSelectorAffectSelectedNode) { |
- this.noAffect = true; |
+ if (!doesSelectorAffectSelectedNode) |
this.element.classList.add("no-affect"); |
- } |
var ruleTextLines = ruleText.split("\n"); |
var startLine = this._ruleLocation.startLine; |