Closed Bug 881339 Opened 11 years ago Closed 11 years ago

CSS child selectors do not match when used in style tags with scoped attribute

Categories

(Core :: CSS Parsing and Computation, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla24

People

(Reporter: bryanrsmith, Assigned: heycam)

References

Details

Attachments

(2 files)

Attached file scoped.html
User Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.37 Safari/537.36

Steps to reproduce:

Inside a style tag with the HTML5 scoped attribute, use a child selector (>) that does not include the right-most portion of the selector. Eg: .a>.b .c


Actual results:

The selector does not match when the scoped attribute is present on the style tag. Removing the scoped attribute causes the selector to match as expected. The bug does not reproduce when using a child selector that includes the right-most portion. Eg: .a .b>.c


Expected results:

The selector should match.

Chrome's implementation of the scoped attribute does not reproduce this issue (Chrome behaves as expected). The issue tracking the implementation of the scoped attribute (https://bugzilla.mozilla.org/show_bug.cgi?id=508725#c3) does mention that Chrome's implementation behaves incorrectly in some cases, and I'm unsure if this issue is one of those differences. Attached is a simple HTML document that demonstrates the problem.
Attachment #760466 - Attachment mime type: text/plain → text/html
Cameron, can you take a look please?  Looks like a bug at first glance...
Assignee: nobody → cam
Blocks: 508725
Status: UNCONFIRMED → NEW
Ever confirmed: true
Flags: needinfo?(cam)
It looks like the issue is that in aTreeMatchContext.PopStyleScopeForSelectorMatching, we call aTreeMatchContext.PopStyleScopeForSelectorMatching() when we move up the tree, but when we fail a recursive call to SelectorMatchesTree (for a descendant selector) we don't restore the state of whether we're still in the style scope.  So we think we've left the style scope when we haven't.
Flags: needinfo?(cam)
(In reply to Cameron McCormack (:heycam) from comment #2)
> It looks like the issue is that in
> aTreeMatchContext.PopStyleScopeForSelectorMatching, we call ...

*in SelectorMatchesTree
Attached patch patchSplinter Review
I don't believe we'll ever be in nsCSSRuleProcessor::HasStateDependentStyle or nsCSSRuleProcessor::SelectorListMatches when mForScopedStyle = true, so I've asserted and not done the save/restore of mCurrentScopedStyle in them.

Try run in progress: https://tbpl.mozilla.org/?tree=Try&rev=c71c0f2264d9
Attachment #760726 - Flags: review?(bzbarsky)
Comment on attachment 760726 [details] [diff] [review]
patch

r=me
Attachment #760726 - Flags: review?(bzbarsky) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/266dcd22cc6e
Status: NEW → ASSIGNED
OS: Windows 8 → All
Hardware: x86_64 → All
Version: 21 Branch → Trunk
https://hg.mozilla.org/mozilla-central/rev/266dcd22cc6e
Status: ASSIGNED → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: