Bug 146866

Summary: Web Inspector: Improve runtime of pseudo-element sidebar style ordering
Product: WebKit Reporter: Devin Rousso <hi>
Component: Web InspectorAssignee: Devin Rousso <hi>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, graouts, joepeck, jonowells, mattbaker, nvasilyev, timothy, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Patch
none
Patch none

Description Devin Rousso 2015-07-10 18:55:21 PDT
Currently, the algorithm determining where the pseudo-element styles appear in the sidebar has a runtime of O(n^2).  This can be improved to O(n) by getting the most specific selector for each rule when that rule is created.
Comment 1 Radar WebKit Bug Importer 2015-07-10 18:55:53 PDT
<rdar://problem/21778637>
Comment 2 Devin Rousso 2015-07-10 18:58:29 PDT
Created attachment 256636 [details]
Patch
Comment 3 Timothy Hatcher 2015-07-10 19:55:44 PDT
Comment on attachment 256636 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=256636&action=review

> Source/WebInspectorUI/UserInterface/Models/CSSRule.js:83
> +        this._mostSpecificSelector = this._determineMostSpecificSelector();

This could be in the getter and called when !this._mostSpecificSelector. That way it is as lazy as possible.

> Source/WebInspectorUI/UserInterface/Models/CSSRule.js:193
> +        if (!this._mostSpecificSelector)

This would need to use the getter if you make it lazy.

> Source/WebInspectorUI/UserInterface/Models/CSSRule.js:196
> +        return this._mostSpecificSelector.isGreaterThan(otherSelector);

Ditto.

> Source/WebInspectorUI/UserInterface/Models/CSSRule.js:211
> +            return;

This should be: return null;
Comment 4 Devin Rousso 2015-07-11 00:02:29 PDT
Created attachment 256651 [details]
Patch
Comment 5 Timothy Hatcher 2015-07-11 00:58:55 PDT
Comment on attachment 256651 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=256651&action=review

> Source/WebInspectorUI/UserInterface/Models/CSSRule.js:199
> +            return;

return false; or return true;?
Comment 6 Devin Rousso 2015-07-11 12:18:00 PDT
Comment on attachment 256651 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=256651&action=review

>> Source/WebInspectorUI/UserInterface/Models/CSSRule.js:199
>> +            return;
> 
> return false; or return true;?

This is meant to be "return false;".  Is it necessary to specify false (since undefined is falsy)?
Comment 7 Timothy Hatcher 2015-07-11 12:21:17 PDT
Comment on attachment 256651 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=256651&action=review

>>> Source/WebInspectorUI/UserInterface/Models/CSSRule.js:199
>>> +            return;
>> 
>> return false; or return true;?
> 
> This is meant to be "return false;".  Is it necessary to specify false (since undefined is falsy)?

The JIT is happier when types don't change in the flow. We also like to be explicit.
Comment 8 Devin Rousso 2015-07-11 14:33:50 PDT
Created attachment 256667 [details]
Patch
Comment 9 WebKit Commit Bot 2015-07-11 15:31:04 PDT
Comment on attachment 256667 [details]
Patch

Clearing flags on attachment: 256667

Committed r186717: <http://trac.webkit.org/changeset/186717>
Comment 10 WebKit Commit Bot 2015-07-11 15:31:08 PDT
All reviewed patches have been landed.  Closing bug.