Title: [193004] branches/safari-601-branch/Source/WebInspectorUI

Diff

Modified: branches/safari-601-branch/Source/WebInspectorUI/ChangeLog (193003 => 193004)


--- branches/safari-601-branch/Source/WebInspectorUI/ChangeLog	2015-12-03 18:29:45 UTC (rev 193003)
+++ branches/safari-601-branch/Source/WebInspectorUI/ChangeLog	2015-12-03 18:29:52 UTC (rev 193004)
@@ -1,5 +1,26 @@
 2015-12-01  Timothy Hatcher  <[email protected]>
 
+        Merge r186717. rdar://problem/23221163
+
+    2015-07-11  Devin Rousso  <[email protected]>
+
+            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-12-01  Timothy Hatcher  <[email protected]>
+
         Merge r186708. rdar://problem/23221163
 
     2015-07-11  Devin Rousso  <[email protected]>

Modified: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/CSSRule.js (193003 => 193004)


--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/CSSRule.js	2015-12-03 18:29:45 UTC (rev 193003)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Models/CSSRule.js	2015-12-03 18:29:52 UTC (rev 193004)
@@ -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: branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js (193003 => 193004)


--- branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js	2015-12-03 18:29:45 UTC (rev 193003)
+++ branches/safari-601-branch/Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js	2015-12-03 18:29:52 UTC (rev 193004)
@@ -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
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to