-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
script: Implement DocumentOrShadowDOM.adoptedStylesheet
with FrozenArray
#38163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🔨 Triggering try run (#16366690888) for Linux (WPT) |
Test results for linux-wpt from try job (#16366690888): Flaky unexpected result (11)
Stable unexpected results that are known to be intermittent (22)
Stable unexpected results (8)
|
|
08249d3
to
628030a
Compare
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
628030a
to
f76e235
Compare
🔨 Triggering try run (#16370133621) for Linux (WPT) |
Test results for linux-wpt from try job (#16370133621): Flaky unexpected result (20)
Stable unexpected results that are known to be intermittent (20)
|
✨ Try run (#16370133621) succeeded. |
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
19cf9bc
to
3bfeb66
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in general! There are some more detailed comments.
// The idea is that this case is rare, so we pay the price of removing the | ||
// old sheet from the styles and append it later rather than the other way | ||
// around. | ||
owner.remove_stylesheet( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should deduplicate sheets here. There are cases where:
- The sheet list is [A, B, A]
- We should keep both A. If we keep only one of them, the cascade result is wrong
Example here: https://github.com/web-platform-tests/wpt/blob/master/css/css-cascade/layer-stylesheet-sharing.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIU the case is a little bit different. For this case, we are having two different Stylesheet parsed from a same Stylesheet
.
Not sure what is the full implication, but Stylo is preventing us from having duplicate Stylesheet
inside a StylesheetSet
. I believe it would be fine as long as we are keeping the last occurrence duplicates here, which is what Gecko does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried to replicate it with adoptedStylesheets
. It seems that Blink is keeping the first one while Gecko is keeping the last one, and both are wrong.
- https://jsfiddle.net/d8hxyn5c/1/ Chrome is red, FF is green
- https://jsfiddle.net/d8hxyn5c/2/ Chrome is green, FF is red
So to make things correct, we must keep both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what is the full implication, but Stylo is preventing us from having duplicate Stylesheet inside a StylesheetSet.
Hmm, this sounds tricky. Let's file a bug to Stylo and add a TODO to this part then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this sounds tricky. Let's file a bug to Stylo and add a TODO to this part then.
Added a TODO here. I am looking for relevant issues, as it was a design used by Gecko, it should be filed to Bugzilla as well.
The concern could be handled other PRs, step by step. As it was a preference gated feature.
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
3fe0b08
to
0301d21
Compare
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
0301d21
to
3e0c7fb
Compare
🔨 Triggering try run (#16413847402) for Linux (WPT) |
Test results for linux-wpt from try job (#16413847402): Flaky unexpected result (19)
Stable unexpected results that are known to be intermittent (19)
|
✨ Try run (#16413847402) succeeded. |
DocumentOrShadorDOM.adoptedStylesheet
with FrozenArray
DocumentOrShadorDOM.adoptedStylesheet
with FrozenArray
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
DocumentOrShadorDOM.adoptedStylesheet
with FrozenArray
DocumentOrShadowDOM.adoptedStylesheet
with FrozenArray
Spec: https://drafts.csswg.org/cssom/#dom-documentorshadowroot-adoptedstylesheets
Implement
DocumentOrShadowDOM.adoptedStylesheet
. Due toObservableArray
being a massive issue on its own, it will be as it was aFrozenArray
at first. This approach is similar to how Gecko implement adopted stylesheet. See https://phabricator.services.mozilla.com/D144547#change-IXyOzxxFn8sU.All of the changes will be gated behind a preference
dom_adoptedstylesheet_enabled
.Adopted stylesheet is implemented by adding the setter and getter of it. While the getter works like a normal attribute getter, the setter need to consider the inner working of document and shadow root StylesheetSet, specifically the ordering and the invalidations. Particularly for setter, we will clear all of the adopted stylesheet within the StylesheetSet and readd them. Possible optimization exist, but the focus should be directed to implementing
ObservableArray
.More context about the implementations https://hackmd.io/vtJAn4UyS_O0Idvk5dCO_w.
Testing: Existing WPT Coverage
Fixes: #37561