Page MenuHomePhabricator

Bug 1445682: Make Shadow DOM account for stylesheet applicableness correctly. r=xidorn
ClosedPublic

Authored by emilio on Mar 16 2018, 10:02 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sep 20 2024, 10:13 PM
Unknown Object (File)
Aug 13 2024, 3:56 PM
Unknown Object (File)
Jan 7 2024, 5:36 PM
Unknown Object (File)
Jan 4 2024, 4:49 PM
Unknown Object (File)
Jan 4 2024, 4:16 PM
Unknown Object (File)
Jan 3 2024, 11:53 PM
Unknown Object (File)
May 1 2023, 6:56 PM
Unknown Object (File)
May 1 2023, 6:52 PM
Subscribers
None

Details

Summary

Also, make stuff sound in presence of CSSOM and what not.

The dirty: false thing is reverting an accidental change that landed in the
de-XBL stuff, which was harmless, but now wouldn't let me assert stuff properly.

Diff Detail

Repository
rMOZILLACENTRAL mozilla-central
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

phab-bot changed the visibility from "secure-revision (Project)" to "Public (No Login Required)".Mar 16 2018, 10:02 PM
phab-bot changed the edit policy from "secure-revision (Project)" to "All Users".

Brought back context, sorry.

xidorn requested changes to this revision.Mar 19 2018, 6:18 AM
xidorn added inline comments.
dom/base/ShadowRoot.cpp
321–335 ↗(On Diff #1913)

You are inserting this unconditionally... Don't you need to check whether the sheet is applicable first?

344 ↗(On Diff #1913)

In all other places you call this function after changing the servo styles. I understand that this function doesn't need to see the changes as it just marks things dirty. But I would prefer we keep it consistent that we invoke it only after we apply the changes.

Just move this to the end of the function and add an additional call before the return should be enough.

dom/base/ShadowRoot.h
206 ↗(On Diff #1913)

Please add a note here that for shadow root, we don't add non-applicable sheets into the style rule map, which is different than what we do for style set.

Or you can just change the handling here to match what we do in style set, since it doesn't really have any problem to add non-applicable sheet into it, given they are not dangling.

layout/style/StyleSheet.cpp
215–219 ↗(On Diff #1913)

Maybe just

c++
if (!mDisabled) {
  ApplicableStateChanged(true);
}
testing/web-platform/tests/css/css-scoping/shadow-disabled-sheet-001.html
3 ↗(On Diff #1913)

In general we have title="Your Name" in the author link element as well.

14 ↗(On Diff #1913)

It doesn't seem to me <style> element may have disabled attribute. Neither MDN nor the HTML spec says so. And according to my test, we don't support it either, actually...

You can still disable a <style> element via giving it a non-empty title attribute and [setting the default style via <meta>](https://html.spec.whatwg.org/multipage/semantics.html#attr-meta-http-equiv-default-style) to something different.

This revision now requires changes to proceed.Mar 19 2018, 6:18 AM
emilio added inline comments.
dom/base/ShadowRoot.cpp
321–335 ↗(On Diff #1913)

AppendSheet and InsertSheetAt will check it.

In particular, they need to add to mStyleSheets unconditionally, but to the author styles only conditionally.

344 ↗(On Diff #1913)

Yeah, I also had to do the RuleMap thing, but sure will do.

dom/base/ShadowRoot.h
206 ↗(On Diff #1913)

We don't add non-applicable style sheets to the style set either. Non-applicable sheets are not in stylesets.

testing/web-platform/tests/css/css-scoping/shadow-disabled-sheet-001.html
14 ↗(On Diff #1913)

Welp, totally brainfarted here.

I'll remove the test for now, title should be ignored in shadow trees, see the "in a document tree" bit in https://html.spec.whatwg.org/multipage/semantics.html#attr-style-title.

dom/base/ShadowRoot.cpp
344 ↗(On Diff #1913)

Actually I think I prefer to leave it here instead, I think it's nicer to leave the call near the rule map stuff. I can add a comment if you think it's worth it.

OK, r=me with the comment in ApplicableRulesChanged added.

dom/base/ShadowRoot.cpp
344 ↗(On Diff #1913)

I think it's definitely worth a comment here and in ApplicableRulesChanged mentioning that when the function is invoked, the styles may or may not have been changed, so it should not rely on that.

dom/base/ShadowRoot.h
206 ↗(On Diff #1913)

Oh, okay, I see. We assert that all stylesheets we add to stylesets are applicable.

This revision is now accepted and ready to land.Mar 19 2018, 11:42 AM