Closed Bug 1021572 Opened 10 years ago Closed 7 years ago

<style scoped> elements in shadow trees do not work

Categories

(Core :: CSS Parsing and Computation, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: heycam, Assigned: heycam)

References

Details

Attachments

(7 files)

If a <style scoped> is a child of a ShadowRoot, We don't stick the ElementIsStyleScopeRoot flag on the ShadowRoot, so we don't apply its rules to the elements within the shadow tree.
One question (probably not the only one!): if we have:

  ShadowRoot
   |
   +--span
   |
   +--<style scoped> :scope span { ... } </style>

should that rule match?  The thing we'd want to match :scope against is the ShadowRoot, but that's not an element.  Naively it seems like the rule should match, but on the other hand, :scope should be the same as *:scope, and * is not going to match a ShadowRoot.
Let's handle most of the remaining <style scoped>-in-shadow-trees issues here.
Summary: <style scoped> children of ShadowRoot don't work → <style scoped> elements in shadow trees do not work
Depends on: 1025724
Depends on: 1025725
Assignee: nobody → cam
Status: NEW → ASSIGNED
Attachment #8440484 - Flags: review?(bzbarsky)
Attachment #8440485 - Flags: review?(bzbarsky)
Attachment #8440486 - Flags: review?(bzbarsky)
Attachment #8440487 - Flags: review?(bzbarsky)
Attachment #8440488 - Flags: review?(bzbarsky)
Attachment #8440489 - Flags: review?(bzbarsky)
Attached patch Part 7: Tests. (deleted) β€” β€” Splinter Review
Attachment #8440490 - Flags: review?(bzbarsky)
I'm going to ignore what happens with :scope for now.
https://tbpl.mozilla.org/?tree=Try&rev=8d4eb20de22b
You might want to defer review to someone else as bzbarsky is on vacation
Cameron explicitly told me this was non-urgent.  If it _is_ urgent, I can try to get to it tomorrow...
No, no rush here.
Comment on attachment 8440484 [details] [diff] [review]
Part 1: Allow ShadowRoots to be <style scoped> scope nodes.

>+++ b/content/base/public/nsINode.h
>@@ -1333,21 +1334,22 @@ private:
>+    // Set if the node is in the scope of a scoped style sheet; this flag is
>     // only accurate for elements bound to a document

"or shadow roots of shadow trees attached to them"?

>+  void SetIsInStyleScope(bool aValue) {
>+  void SetIsInStyleScope() {
>+  void ClearIsInStyleScope() {

Can we still assert that we're an element-or-shadowroot in those three?

>+++ b/content/base/src/nsStyleLinkElement.cpp
>+UpdateIsInStyleScopeFlagOnSubtree(FragmentOrElement* aScope)

So this is somewhat preexisting but...

When doing ClearIsInStyleScope on an element, don't we need to check its shadow tree as well to see whether it needs the same treatment?  Followup probably ok here, since it _is_ preexisting.

r=me
Attachment #8440484 - Flags: review?(bzbarsky) → review+
Comment on attachment 8440485 [details] [diff] [review]
Part 2: Give nsBindingManager::WalkRules an argument to control whether rules in <style scoped> style sheets are walked.

Hmm.  Why false in FileRules?
Flags: needinfo?(cam)
Comment on attachment 8440486 [details] [diff] [review]
Part 3: Factor out utility function that gathers rule processors for <style scoped> style sheets.

r=me
Attachment #8440486 - Flags: review?(bzbarsky) → review+
Comment on attachment 8440487 [details] [diff] [review]
Part 4: Create separate rule processors for <style scoped> elements in shadow trees.

r=me
Attachment #8440487 - Flags: review?(bzbarsky) → review+
Comment on attachment 8440488 [details] [diff] [review]
Part 5: Walk <style scoped> sheets from bindings.

r=me
Attachment #8440488 - Flags: review?(bzbarsky) → review+
Comment on attachment 8440489 [details] [diff] [review]
Part 6: Push ShadowRoot style scopes at points during frame construction & restyling where we've recursed down to the ShadowRoot's children.

There's a bunch of copy/paste here.  Can we add a constructor to AutoAncestorPusher, or a subclass of it, that takes an nsIContent* or nsINode* and does all that stuff?

r=me with that

Also, watch out for conflicts in the CSSFC code with bug 907396.
Attachment #8440489 - Flags: review?(bzbarsky) → review+
Comment on attachment 8440490 [details] [diff] [review]
Part 7: Tests.

r=me
Attachment #8440490 - Flags: review?(bzbarsky) → review+
Comment on attachment 8440485 [details] [diff] [review]
Part 2: Give nsBindingManager::WalkRules an argument to control whether rules in <style scoped> style sheets are walked.

Dropping review request pending comment 16 getting answered.
Attachment #8440485 - Flags: review?(bzbarsky)
<style scoped> is gone.
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Flags: needinfo?(cam)
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: