2015-07-11 Devin Rousso <drousso@apple.com>
+ Web Inspector: Improve runtime of pseudo-element sidebar style ordering
+ https://bugs.webkit.org/show_bug.cgi?id=146866
+
+ Reviewed by Timothy Hatcher.
+
+ * UserInterface/Models/CSSRule.js:
+ (WebInspector.CSSRule.prototype.update): Determines the most specific selector and saves it to a variable.
+ (WebInspector.CSSRule.prototype.get mostSpecificSelector): Returns the most specific selector.
+ (WebInspector.CSSRule.prototype.selectorIsGreater): Compares the most specific selector to a given selector.
+ (WebInspector.CSSRule.prototype._determineMostSpecificSelector):
+ Searches through the selector list to find and return the selector that is the most specific.
+ (WebInspector.CSSRule):
+ * UserInterface/Views/RulesStyleDetailsPanel.js:
+ (WebInspector.RulesStyleDetailsPanel.prototype.refresh):
+
+2015-07-11 Devin Rousso <drousso@apple.com>
+
Web Inspector: Warning icon tooltip for numbers with no units could be improved
https://bugs.webkit.org/show_bug.cgi?id=146859
this._selectorText = selectorText;
this._selectors = selectors;
this._matchedSelectorIndices = matchedSelectorIndices;
+ this._mostSpecificSelector = null;
this._style = style;
this._mediaList = mediaList;
return Object.shallowEqual(this._id, rule.id);
}
- selectorIsGreater(otherSelectors)
+ get mostSpecificSelector()
{
- if (!otherSelectors || !otherSelectors.length)
- return true;
+ if (!this._mostSpecificSelector)
+ this._mostSpecificSelector = this._determineMostSpecificSelector();
- var selectorIsGreater = true;
-
- var selectors = this.matchedSelectors;
- if (!selectors.length)
- selectors = this._selectors;
-
- for (var selector of selectors) {
- for (var otherSelector of otherSelectors) {
- if (selector.isGreaterThan(otherSelector))
- continue;
+ return this._mostSpecificSelector;
+ }
- selectorIsGreater = false;
- }
+ selectorIsGreater(otherSelector)
+ {
+ var mostSpecificSelector = this.mostSpecificSelector;
- if (selectorIsGreater)
- return true;
- }
+ if (!mostSpecificSelector)
+ return false;
- return false;
+ return mostSpecificSelector.isGreaterThan(otherSelector);
}
// Protected
{
return this._nodeStyles;
}
+
+ // Private
+
+ _determineMostSpecificSelector()
+ {
+ if (!this._selectors || !this._selectors.length)
+ return null;
+
+ var selectors = this.matchedSelectors;
+
+ if (!selectors.length)
+ selectors = this._selectors;
+
+ var specificSelector = selectors[0];
+
+ for (var selector of selectors) {
+ if (selector.isGreaterThan(specificSelector))
+ specificSelector = selector;
+ }
+
+ return specificSelector;
+ }
};
WebInspector.CSSRule.Event = {