Changeset 186717 in webkit


Ignore:
Timestamp:
Jul 11, 2015 3:29:55 PM (9 years ago)
Author:
Devin Rousso
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):

Location:
trunk/Source/WebInspectorUI
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r186708 r186717  
     12015-07-11  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: Improve runtime of pseudo-element sidebar style ordering
     4        https://bugs.webkit.org/show_bug.cgi?id=146866
     5
     6        Reviewed by Timothy Hatcher.
     7
     8        * UserInterface/Models/CSSRule.js:
     9        (WebInspector.CSSRule.prototype.update): Determines the most specific selector and saves it to a variable.
     10        (WebInspector.CSSRule.prototype.get mostSpecificSelector): Returns the most specific selector.
     11        (WebInspector.CSSRule.prototype.selectorIsGreater): Compares the most specific selector to a given selector.
     12        (WebInspector.CSSRule.prototype._determineMostSpecificSelector):
     13        Searches through the selector list to find and return the selector that is the most specific.
     14        (WebInspector.CSSRule):
     15        * UserInterface/Views/RulesStyleDetailsPanel.js:
     16        (WebInspector.RulesStyleDetailsPanel.prototype.refresh):
     17
    1182015-07-11  Devin Rousso  <drousso@apple.com>
    219
  • trunk/Source/WebInspectorUI/UserInterface/Models/CSSRule.js

    r186635 r186717  
    8181        this._selectors = selectors;
    8282        this._matchedSelectorIndices = matchedSelectorIndices;
     83        this._mostSpecificSelector = null;
    8384        this._style = style;
    8485        this._mediaList = mediaList;
     
    183184    }
    184185
    185     selectorIsGreater(otherSelectors)
    186     {
    187         if (!otherSelectors || !otherSelectors.length)
    188             return true;
    189 
    190         var selectorIsGreater = true;
     186    get mostSpecificSelector()
     187    {
     188        if (!this._mostSpecificSelector)
     189            this._mostSpecificSelector = this._determineMostSpecificSelector();
     190
     191        return this._mostSpecificSelector;
     192    }
     193
     194    selectorIsGreater(otherSelector)
     195    {
     196        var mostSpecificSelector = this.mostSpecificSelector;
     197
     198        if (!mostSpecificSelector)
     199            return false;
     200
     201        return mostSpecificSelector.isGreaterThan(otherSelector);
     202    }
     203
     204    // Protected
     205
     206    get nodeStyles()
     207    {
     208        return this._nodeStyles;
     209    }
     210
     211    // Private
     212
     213    _determineMostSpecificSelector()
     214    {
     215        if (!this._selectors || !this._selectors.length)
     216            return null;
    191217
    192218        var selectors = this.matchedSelectors;
     219
    193220        if (!selectors.length)
    194221            selectors = this._selectors;
    195222
     223        var specificSelector = selectors[0];
     224
    196225        for (var selector of selectors) {
    197             for (var otherSelector of otherSelectors) {
    198                 if (selector.isGreaterThan(otherSelector))
    199                     continue;
    200 
    201                 selectorIsGreater = false;
    202             }
    203 
    204             if (selectorIsGreater)
    205                 return true;
    206         }
    207 
    208         return false;
    209     }
    210 
    211     // Protected
    212 
    213     get nodeStyles()
    214     {
    215         return this._nodeStyles;
     226            if (selector.isGreaterThan(specificSelector))
     227                specificSelector = selector;
     228        }
     229
     230        return specificSelector;
    216231    }
    217232};
  • trunk/Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js

    r186635 r186717  
    280280                    }
    281281
    282                     if (matchedSelectorText.includes(pseudoElement.selectorText) || !ownerRule.selectorIsGreater(pseudoElement.style.ownerRule.selectors))
     282                    if (matchedSelectorText.includes(pseudoElement.selectorText) || !ownerRule.selectorIsGreater(pseudoElement.style.ownerRule.mostSpecificSelector))
    283283                        pseudoElement.lastMatchingSelector = matchedSelectorText;
    284284                }
Note: See TracChangeset for help on using the changeset viewer.