Closed Bug 926717 Opened 11 years ago Closed 9 years ago

"Assertion failure: !node->IsScopedStyleRoot()" with root-scoped stylesheet

Categories

(Core :: CSS Parsing and Computation, defect)

x86_64
macOS
defect
Not set
critical

Tracking

()

RESOLVED DUPLICATE of bug 1223694

People

(Reporter: jruderman, Assigned: heycam)

References

Details

(Keywords: assertion, regression, testcase)

Attachments

(2 files)

Attached file testcase
Assertion failure: !node->IsScopedStyleRoot(), at layout/style/nsRuleProcessorData.h:189

This assertion was added a few days ago in bug 899808.
Attached file stack
Cameron, could you have a look?
Flags: needinfo?(cam)
Assignee: nobody → cam
Flags: needinfo?(cam)
There is an anonymous <xul:scrollbar> child of the root element, which we're styling, and it is not marked as being in a style scope despite its parent node being marked as a style scope root.  Since we don't traverse into anonymous children when updating the "is in a style scope" bits, and thus don't make scoped styles apply to anonymous children, we should change the AssertHasAllStyleScopes to stop when it reaches an anonymous root.
Or maybe we should make scoped styles apply to anonymous children.  David?
Flags: needinfo?(dbaron)
I tend to think we should probably do whatever we're supposed to do for Web Components, which might involved some research.  (Though it's possible the Web Components authors haven't really considered it, and we should figure out what we think is right.)  I don't think I have a strong opinion; maybe bz does?
Flags: needinfo?(dbaron) → needinfo?(bzbarsky)
I don't think we should apply scoped styles to _native_ anonymous children, no matter what, just like we don't apply normal document styles.  That will address the scrollbar case.
Flags: needinfo?(bzbarsky)
Oh, as for anonymous children via web components/XBL, I think the behavior should be whatever it is for full-page stylesheets.  I believe a component can select whether those styles apply to its content or not, in general, and we should honor that for scoped styles.

Given that, I'd think that a scoped stylesheet that applies to a node X should also apply to the roots of the anonymous content of any binding/component attached to X and to their non-anonymous descendants.  And hence transitively to any roots of anonymous content of bindings/components attached to those descendants, etc.
My latest patch in bug 927734 will avoid the assertion in this bug.

Regarding the styling of anonymous content: what is the mechanism that prevents native anonymous content from having the normal document styles being applied to it?  I want to check that indeed scoped styles don't manage to apply here either.

For non-native anonymous children, would it make sense to propagate the "in a style scope" bits to all children, regardless of whether the binding/component has opted in to styles from the outer thing applying to it?  I think that's going to be easier to manage, as long as we do manage to skip applying the styles where appropriate.  What is the mechanism that selectively causes styles to apply to the non-native anonymous children for XBL and for Web Components (if the implementation of the latter is far enough along for this to work)?
Flags: needinfo?(bzbarsky)
> what is the mechanism that prevents native anonymous content from having the normal
> document styles being applied to it? 

http://mxr.mozilla.org/mozilla-central/source/layout/style/nsStyleSet.cpp?rev=829d7bef8b0a&mark=967-968,987-987#935 (and similar code in WalkRuleProcessors so we don't restyle native anon content based on page rules).  Looks like the scoped styles also get skipped in FileRules if skipUserStyles, so things are good on that front, I would think.

Note that this code as written will also skip applying a scoped stylesheet from inside the native anonymous subtree to stuff in that subtree; I think that's OK because we shouldn't be putting stylesheets in native anonymous subtrees.  ;)

> What is the mechanism that selectively causes styles to apply to the non-native
> anonymous children for XBL

That's the cutOffInheritance boolean in the linked-to code above.  Or rather it being set to false.  Web Components are not far enough yet for there to be anything related to them here.
Flags: needinfo?(bzbarsky)
> would it make sense to propagate the "in a style scope" bits to all children

I think that would be fine, yes.
(In reply to Boris Zbarsky [:bz] from comment #9)
> http://mxr.mozilla.org/mozilla-central/source/layout/style/nsStyleSet.
> cpp?rev=829d7bef8b0a&mark=967-968,987-987#935 (and similar code in
> WalkRuleProcessors so we don't restyle native anon content based on page
> rules).  Looks like the scoped styles also get skipped in FileRules if
> skipUserStyles, so things are good on that front, I would think.

Obvious now that you pointed out the marked code. :)

> Note that this code as written will also skip applying a scoped stylesheet
> from inside the native anonymous subtree to stuff in that subtree; I think
> that's OK because we shouldn't be putting stylesheets in native anonymous
> subtrees.  ;)

Yes let's assume that's the case for the moment. ;)  Although note that the new colour picker control puts style="" attributes on native anonymous content, so it's not too much of a stretch that someone wants to do it one day.

> > What is the mechanism that selectively causes styles to apply to the non-native
> > anonymous children for XBL
> 
> That's the cutOffInheritance boolean in the linked-to code above.  Or rather
> it being set to false.  Web Components are not far enough yet for there to
> be anything related to them here.

OK good.

(In reply to Boris Zbarsky [:bz] from comment #10)
> > would it make sense to propagate the "in a style scope" bits to all children
> 
> I think that would be fine, yes.

Will do this in a followup.  Thanks!
> so it's not too much of a stretch that someone wants to do it one day.

When they do, they'll have to hack document.styleSheets to not include the sheets and a bunch of other changes...  Scary stuff.  :(
(In reply to Boris Zbarsky [:bz] from comment #6)
> I don't think we should apply scoped styles to _native_ anonymous children,
> no matter what, just like we don't apply normal document styles.  That will
> address the scrollbar case.

(In reply to Cameron McCormack (:heycam) (away Nov 23 – Dec 4) from comment #8)
> My latest patch in bug 927734 will avoid the assertion in this bug.

It didn't, but the patch in bug 1223694 does.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: