Title: [186717] trunk/Source/WebInspectorUI
- Revision
- 186717
- Author
- drou...@apple.com
- Date
- 2015-07-11 15:29:55 -0700 (Sat, 11 Jul 2015)
Log Message
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):
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (186716 => 186717)
--- trunk/Source/WebInspectorUI/ChangeLog 2015-07-11 21:30:33 UTC (rev 186716)
+++ trunk/Source/WebInspectorUI/ChangeLog 2015-07-11 22:29:55 UTC (rev 186717)
@@ -1,5 +1,22 @@
2015-07-11 Devin Rousso <drou...@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 <drou...@apple.com>
+
Web Inspector: Warning icon tooltip for numbers with no units could be improved
https://bugs.webkit.org/show_bug.cgi?id=146859
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/CSSRule.js (186716 => 186717)
--- trunk/Source/WebInspectorUI/UserInterface/Models/CSSRule.js 2015-07-11 21:30:33 UTC (rev 186716)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/CSSRule.js 2015-07-11 22:29:55 UTC (rev 186717)
@@ -80,6 +80,7 @@
this._selectorText = selectorText;
this._selectors = selectors;
this._matchedSelectorIndices = matchedSelectorIndices;
+ this._mostSpecificSelector = null;
this._style = style;
this._mediaList = mediaList;
@@ -182,30 +183,22 @@
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;
+ return this._mostSpecificSelector;
+ }
- var selectors = this.matchedSelectors;
- if (!selectors.length)
- selectors = this._selectors;
+ selectorIsGreater(otherSelector)
+ {
+ var mostSpecificSelector = this.mostSpecificSelector;
- for (var selector of selectors) {
- for (var otherSelector of otherSelectors) {
- if (selector.isGreaterThan(otherSelector))
- continue;
+ if (!mostSpecificSelector)
+ return false;
- selectorIsGreater = false;
- }
-
- if (selectorIsGreater)
- return true;
- }
-
- return false;
+ return mostSpecificSelector.isGreaterThan(otherSelector);
}
// Protected
@@ -214,6 +207,28 @@
{
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 = {
Modified: trunk/Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js (186716 => 186717)
--- trunk/Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js 2015-07-11 21:30:33 UTC (rev 186716)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js 2015-07-11 22:29:55 UTC (rev 186717)
@@ -279,7 +279,7 @@
continue;
}
- if (matchedSelectorText.includes(pseudoElement.selectorText) || !ownerRule.selectorIsGreater(pseudoElement.style.ownerRule.selectors))
+ if (matchedSelectorText.includes(pseudoElement.selectorText) || !ownerRule.selectorIsGreater(pseudoElement.style.ownerRule.mostSpecificSelector))
pseudoElement.lastMatchingSelector = matchedSelectorText;
}
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes