Bug 146576

Summary: Web Inspector: CSS rule with 2 pseudo-selectors appears twice
Product: WebKit Reporter: Nikita Vasilyev <nvasilyev>
Component: Web InspectorAssignee: Devin Rousso <hi>
Status: RESOLVED FIXED    
Severity: Normal CC: buildbot, commit-queue, graouts, joepeck, jonowells, mattbaker, nvasilyev, rniwa, timothy, webkit-bug-importer
Priority: P3 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
See Also: https://bugs.webkit.org/show_bug.cgi?id=145979
Attachments:
Description Flags
[HTML] Reduction
none
Animated GIF of the problem
none
Patch
none
Archive of layout-test-results from ews104 for mac-mavericks-wk2
none
Patch
none
Patch none

Description Nikita Vasilyev 2015-07-02 23:20:11 PDT
Created attachment 256079 [details]
[HTML] Reduction

Originally reported by https://twitter.com/toolmantim.
Animated GIF: https://cloudup.com/idEbO3X5_OS
Comment 1 Radar WebKit Bug Importer 2015-07-02 23:20:32 PDT
<rdar://problem/21666285>
Comment 2 Nikita Vasilyev 2015-07-02 23:21:19 PDT
Created attachment 256080 [details]
Animated GIF of the problem
Comment 3 Devin Rousso 2015-07-04 11:47:38 PDT
I have a fix for this, but it relies upon https://bugs.webkit.org/show_bug.cgi?id=145979, so once that lands I can fix this.
Comment 4 Devin Rousso 2015-07-04 17:11:52 PDT
Created attachment 256161 [details]
Patch
Comment 5 Timothy Hatcher 2015-07-04 17:15:38 PDT
Comment on attachment 256161 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js:183
> +                if (pseudoElementSelectors.length && pseudoElementSelectors.lastValue.selectorText === selectorText)
> +                    continue;

What if the rules have different source locations?
Comment 6 Build Bot 2015-07-04 17:49:32 PDT
Comment on attachment 256161 [details]
Patch

Attachment 256161 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/5429194611752960

New failing tests:
platform/mac-wk2/tiled-drawing/scrolling/scroll-snap/scroll-snap-mandatory-mainframe-slow-vertical.html
Comment 7 Build Bot 2015-07-04 17:49:34 PDT
Created attachment 256163 [details]
Archive of layout-test-results from ews104 for mac-mavericks-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews104  Port: mac-mavericks-wk2  Platform: Mac OS X 10.9.5
Comment 8 Devin Rousso 2015-07-04 17:57:24 PDT
Created attachment 256164 [details]
Patch
Comment 9 Timothy Hatcher 2015-07-04 18:31:18 PDT
Comment on attachment 256164 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js:182
> +                if (pseudoElementSelectors.length && pseudoElementSelectors.lastValue.style.ownerRule.isEqualTo(style.ownerRule))

Wouldn't just preventing duplicates of the same style/ownerRule be enough? Why does the selector need a replace done and compared to others?
Comment 10 Timothy Hatcher 2015-07-04 19:58:03 PDT
Comment on attachment 256164 [details]
Patch

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

>> Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js:182
>> +                if (pseudoElementSelectors.length && pseudoElementSelectors.lastValue.style.ownerRule.isEqualTo(style.ownerRule))
> 
> Wouldn't just preventing duplicates of the same style/ownerRule be enough? Why does the selector need a replace done and compared to others?

Ah-ha, I think I understand now.

Per pseudo element, uniqueOrderedStyles is called and it strips duplicates. But that duplicate matching does not happen across pseudo-elements, in the case of a selector like "*::before, *::after" which applies to two pseudo elements.

Perhaps the same logic as uniqueOrderedStyles, should be used here? Not just adjacent duplicates, but all duplicates are removed.
Comment 11 Timothy Hatcher 2015-07-04 20:03:47 PDT
Comment on attachment 256164 [details]
Patch

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

>>> Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js:182
>>> +                if (pseudoElementSelectors.length && pseudoElementSelectors.lastValue.style.ownerRule.isEqualTo(style.ownerRule))
>> 
>> Wouldn't just preventing duplicates of the same style/ownerRule be enough? Why does the selector need a replace done and compared to others?
> 
> Ah-ha, I think I understand now.
> 
> Per pseudo element, uniqueOrderedStyles is called and it strips duplicates. But that duplicate matching does not happen across pseudo-elements, in the case of a selector like "*::before, *::after" which applies to two pseudo elements.
> 
> Perhaps the same logic as uniqueOrderedStyles, should be used here? Not just adjacent duplicates, but all duplicates are removed.

One way to do this would be to concat all pseudoElement.orderedStyles together, then use uniqueOrderedStyles. Then loop over that uniqueOrderedStyles result and populate pseudoElementSelectors.
Comment 12 Devin Rousso 2015-07-05 00:00:19 PDT
Created attachment 256172 [details]
Patch
Comment 13 Timothy Hatcher 2015-07-05 10:35:26 PDT
Comment on attachment 256172 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js:173
> +        var pseudoElementsStyle = [];

Nit: pseudoElementStyles would be better, since this is an array.
Comment 14 WebKit Commit Bot 2015-07-05 11:24:46 PDT
Comment on attachment 256172 [details]
Patch

Clearing flags on attachment: 256172

Committed r186288: <http://trac.webkit.org/changeset/186288>
Comment 15 WebKit Commit Bot 2015-07-05 11:24:51 PDT
All reviewed patches have been landed.  Closing bug.