Bug 145979 - Web Inspector: Pseudo Styles Ordering and Media Queries
Summary: Web Inspector: Pseudo Styles Ordering and Media Queries
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All OS X 10.10
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-06-15 10:16 PDT by Chris Chiera
Modified: 2015-07-04 14:45 PDT (History)
9 users (show)

See Also:


Attachments
Comparing same file's style rules in chrome and safari (238.97 KB, image/png)
2015-06-15 10:16 PDT, Chris Chiera
no flags Details
Patch (5.00 KB, patch)
2015-07-02 21:48 PDT, Devin Rousso
no flags Details | Formatted Diff | Diff
Patch (5.12 KB, patch)
2015-07-02 21:54 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 Chris Chiera 2015-06-15 10:16:21 PDT
Created attachment 254882 [details]
Comparing same file's style rules in chrome and safari

This is in regards to Safari 8.1 on 10.11. Filed a bug report with Apple but also posting here. If there is a separate Webkit forum for 8.1 let me know.

In the attachment I compared Chrome style web inspector vs Safari 8.1 showing the same style from the same page. Chrome properly shows all the relevant styles without needing to scroll. Where is in Safari, (while aesthetically pretty), the actual first relevant style, section.products .img-pro h3" is at the very bottom. Chrome properly puts those :after/:before at the bottom of the list since it's least relevant. Chrome also shows why there is two by highlighting :after in the first style and highlighting :before in the second style unlike Safari which simply lists the rules twice without any visual difference. Also Chrome is showing the properly media query relevant information where is Safari is not at all.
Comment 1 Radar WebKit Bug Importer 2015-06-15 10:16:43 PDT
<rdar://problem/21384292>
Comment 2 Timothy Hatcher 2015-06-15 12:06:57 PDT
We should do this. Reset rules night is here. Perhaps we should interleave pseudo-styles with other rules. We might be able to use specificity for that ordering.
Comment 3 Timothy Hatcher 2015-06-18 10:31:40 PDT
"Reset rules night is here." -> "Reset rules get us here."
Comment 4 Devin Rousso 2015-07-02 21:48:17 PDT
Created attachment 256071 [details]
Patch
Comment 5 Devin Rousso 2015-07-02 21:54:57 PDT
Created attachment 256072 [details]
Patch
Comment 6 Timothy Hatcher 2015-07-03 16:22:38 PDT
Comment on attachment 256072 [details]
Patch

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

> Source/WebInspectorUI/UserInterface/Views/RulesStyleDetailsPanel.js:278
> +                    if (style.ownerRule.selectorText.includes(pseudoElement.selectorText))

Do you really want includes? Or should this be a prefix or suffix match?

Comparing selectors might fail in some cases, like selectors with commas or implicit * (like :before is the same as *:before).

The lastMatchingSelector part is confusing to me. Can you explain it more, maybe with a comment.
Comment 7 Devin Rousso 2015-07-04 10:16:23 PDT
I was using includes to allow proper matching with selectors that had commas in them.  For example, so div::after would match with body, div, p.

I can definitely see that there are a lot of edge cases I haven't taken into account, which is why I made it so that if any pseudo-selector rules are left by the time the first User Agent or inherited rule is listed, all the remaining pseudo-selector rules are printed out.

The lastMatchingSelector part is for when multiple rules have the same selector.  In this case, the pseudo-selector rule should go after the last rule and not after the first one.
Comment 8 WebKit Commit Bot 2015-07-04 14:45:47 PDT
Comment on attachment 256072 [details]
Patch

Clearing flags on attachment: 256072

Committed r186282: <http://trac.webkit.org/changeset/186282>
Comment 9 WebKit Commit Bot 2015-07-04 14:45:50 PDT
All reviewed patches have been landed.  Closing bug.