Bug 146576 - Web Inspector: CSS rule with 2 pseudo-selectors appears twice
Summary: Web Inspector: CSS rule with 2 pseudo-selectors appears twice
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P3 Normal
Assignee: Devin Rousso
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-07-02 23:20 PDT by Nikita Vasilyev
Modified: 2015-07-05 11:24 PDT (History)
10 users (show)

See Also:


Attachments
[HTML] Reduction (75 bytes, text/html)
2015-07-02 23:20 PDT, Nikita Vasilyev
no flags Details
Animated GIF of the problem (286.46 KB, image/gif)
2015-07-02 23:21 PDT, Nikita Vasilyev
no flags Details
Patch (2.20 KB, patch)
2015-07-04 17:11 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews104 for mac-mavericks-wk2 (574.62 KB, application/zip)
2015-07-04 17:49 PDT, Build Bot
no flags Details
Patch (2.21 KB, patch)
2015-07-04 17:57 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (2.53 KB, patch)
2015-07-05 00:00 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.