Commit Graph

117 Commits

Author SHA1 Message Date
elomscansio
aa7eca43b7 script: propagate VirtualMethods::unbind_from_tree with &mut JSContext (#44422)
Propagate `&mut JSContext` in `VirtualMethods::unbind_from_tree`

Testing: Successful build is enough
Fixes: #42837

---------

Signed-off-by: Emmanuel Paul Elom <elomemmanuel007@gmail.com>
2026-04-23 14:09:11 +00:00
Martin Robinson
5d28862c7b script: Expose a LayoutNode::is_root_of_user_agent_widget method (#44197)
The main goal here is to have layout not depend on `ServoLayoutElement`
directly and instead use the layout DOM interface exposed by
`layout-api`. 

This change allows layout to determine if replaced content
is the root of a user agent widget without having to access
`ServoDangerousStyleShadowRoot` which isn't really safe to use in layout
code. `LayoutElement::shadow_root()` is now no longer exposed to layout.

Testing: This should not change behavior, so should be covered by
existing test.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-04-14 10:35:00 +00:00
Martin Robinson
e0fd559105 script: Simplify the way that layout flushes shadow root stylesheets (#44165)
This change is a minor cleanup of the way that layout flushes the
stylesheets of shadow roots. This avoids exposing so many public methods
in our and gradually to stop using Stylo's `TShadowRoot` in layout
entirely.

Testing: This should not change behavior, so should be covered by
existing tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-04-14 09:15:05 +00:00
Simon Wülker
0fef52f10c script: Remove layout helper traits (#44092)
Servo has lots of `LayoutXYZHelper` traits that are used to define
additional methods on `LayoutDom<XYZ>`. We can replace them with `impl
LayoutDom<XYZ>` blocks, reducing the number of LoC and making it easier
to add or modify methods.

Testing: These should be covered by existing tests

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2026-04-10 18:31:10 +00:00
Tim van der Lippe
c8029ea092 script: Rename CanGc::note() to CanGc::deprecated_note() (#44081)
Per the suggestion in

https://servo.zulipchat.com/#narrow/channel/263398-general/topic/PSA.3A.20avoid.20new.20usages.20of.20CanGc.20whenever.20possible/near/583995807
to mark this method as deprecated and make clear it shouldn't be used
anymore, as alternatives exist.

Part of #40600

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-04-10 06:07:52 +00:00
Euclid Ye
712b4f9bc2 script: Reduce ShadowRoot::bind_to_tree complexity from O(2^N) to O(N) (#44016)
During traversal, exclude shadow roots.

Analysis:
Each shadow root is processed twice:
- via host: Element::bind_to_tree()
-  Via iterator

In total, this would be
```math
\sum_{i=0}^{N-1} 2^i = 2^N - 1
```

Testing: Added a test.
Fixes: https://github.com/servo/servo/issues/43998

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Co-authored-by: webbeef <me@webbeef.org>
2026-04-08 08:20:20 +00:00
Tim van der Lippe
a1c8896eda script: Pass &mut JSContext to reflect_node_with_proto (#43952)
A lot (and I mean, really a lot) depends on these constructors.
Therefore, this is the one spaghetti ball that I could extract and
convert all `can_gc` to `cx`. There are some new introductions of
`temp_cx` in the callbacks of the servo parser, but we already had some
in other callbacks.

Part of #40600

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-04-05 18:07:30 +00:00
Martin Robinson
33f74feffd script: Fully implement DocumentOrShadowRoot#activeElement (#43861)
`DocumentOrShadowRoot#activeElement` should return retargeted results.
What that means is that if the DOM anchor of the `Document`'s focused
focusable area is within a shadow root, `Document#activeElement` should
return the shadow host. This change implements that behavior, properly
returning the `activeElement` from both `Document` and `ShadowRoot`.

Testing: This causes a decent number of WPT tests and subtests to start
passing. One subtest starts to fail, because it uses the `autofocus`
attribute
which we do not yet support.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-04-02 11:12:30 +00:00
Tim van der Lippe
f660fd6d91 script: Pass &mut JSContext to TrustedHTML::get_trusted_type_compliant_string (#43268)
Part of #40600

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-14 19:40:49 +00:00
Gae24
e8b581aaf0 script: Pass &mut JSContext in more places (#43252)
Continuation of #43220, removes many `temp_cx` calls introduced by that.

Testing: No behaviour change, a successful build is enough.
Fixes: #43241 #43240

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-14 10:03:48 +00:00
Gae24
ef97d7e199 script: Pass &mut JSContext to VirtualMethods::bind_to_tree (#43220)
Testing: No behaviour change, a successful build is enough.
Fixes: #42838 #43239

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-14 07:37:47 +00:00
Tim van der Lippe
aae5c4cd97 script: Move Trusted Types interfaces to script/dom/trustedtypes (#43181)
Part of #38901 

Testing: it compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-11 16:26:56 +00:00
Sam
3e2f14c455 script: Pass down &mut JSContext in servoparser and event loop. (#42635)
I only wanted to get `&mut JSContext` in microtask chunk and checkpoint,
but this in turn needed `&mut JSContext` in servoparser, which then
caused need for even more changes in script.

I tried to limit the size by putting some `temp_cx` in:
- drops of `LoadBlocker`, `GenericAutoEntryScript`
- methods of `VirtualMethods`
- methods of `FetchResponseListener`

Testing: Just refactor, but should be covered by WPT tests.
Part of #40600

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-02-25 07:14:23 +00:00
Sam
43bdd3818d script: Pass &mut JSContext to more dom methods (#42751)
split from https://github.com/servo/servo/pull/42635, some dom methods
are also called from other function, which require passing down cx from
many more places :(

Testing: Just refactor, but should be covered by WPT.
Part of #42638

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-02-22 13:22:33 +00:00
Onur Şahin
fb9bef66fd script: Implement DocumentOrShadowRoot.FullscreenDocument (#42401)
Implement
[DocumentOrShadowRoot.FullscreenDocument](https://fullscreen.spec.whatwg.org/#dom-document-fullscreenelement).

## Changes
- Update IDL definition by removing `Document.fullscreenElement` and
declaring it in `DocumentOrShadowRoot` mixin as per the
[spec](https://fullscreen.spec.whatwg.org/#api)
- Implement [fullscreenElement
getter](https://fullscreen.spec.whatwg.org/#dom-document-fullscreenelement)
as a method in `DocumentOrShadowroot.get_fullscreen_element` which is
used by `Document` and `ShadowRoot`.
- Changedbubble and composed flags for fullscreen enter and exit events
to true.
- Delete `shadowroot-fullscreen-element.html.ini` since the test now
passes.

## Testing
Enable `shadowroot-fullscreen-element.html` WPT test.

Passing WPT run: https://github.com/onsah/servo/actions/runs/21872882492

## Fixes
https://github.com/servo/servo/issues/42234

Signed-off-by: Onur Sahin <sahinonur2000@hotmail.com>
2026-02-12 09:55:11 +00:00
Oriol Brufau
2a3f23c78d Upgrade Stylo to 2026-02-02 (#42361)
This continues #41916

Changelog:
- Upstream:
360787fff5...7cd2a178d3
- Servo fixups:
e4d50e905e...d9831d464b

Stylo tracking issue: https://github.com/servo/stylo/issues/305

In particular, this adds support for `alignment-baseline` and
`baseline-shift`, and turns `vertical-align` into a shorthand of them.
This also introduces `vertical-align: center`.

Testing: Various tests improve. Some internal tests are updated because
they were wrong. And some fail because we don't support presentation
attributes on SVG elements.

---------

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2026-02-09 11:16:42 +00:00
Tim van der Lippe
e8aa7d51ba script: Set host for template content (#42276)
A template element should set the host of a DocumentFragment. However,
it didn't have a host yet. That's because ShadowRoot declares a host
attribute which returns Element, but its property is declared on
DocumentFragment.

Therefore, define the host on DocumentFragment instead and use it in all
relevant points for shadow roots. Then, update the pre-insert validity
check to use the correct host-including variant of inclusive ancestors.
Lastly, set the host of the template to wire it all up.

---------

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-02-02 08:25:54 +00:00
minghuaw
611f3ef162 script: Ensure web fonts in shadow root stylesheets are downloaded (#42151)
Added calls to download web font from stylesheet when stylesheets are
added to shadow root.

Testing: Manual testing. Added a new WPT testcase

---------

Signed-off-by: Minghua Wu <michael.wu1107@gmail.com>
2026-01-30 02:14:43 +00:00
WaterWhisperer
2a759ed6de Replace allow(crown::unrooted_must_root) with expect(crown::unrooted_must_root) (#41815)
Testing: `./mach build -d --use-crown` with no warnings
Fixes: #41761

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2026-01-10 08:05:49 +00:00
Josh Matthews
91a73c4f86 script: Reverse retargeting algorithm for ShadowRoot.element[s]FromPoint. (#40975)
This implementation is not actually specified (see #40973 and
https://github.com/w3c/csswg-drafts/issues/556), but the implementation
that we have is backwards. Other retargeting uses that describe
"retarget _something_ against _another thing_" map to
`something.retarget(another_thing)`, but what the current code was doing
for element[s]FromPoint was the equivalent of "retarget _this_ against
each element", which is obviously wrong.

Testing: Newly-passing tests.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-12-01 05:13:55 +00:00
TIN TUN AUNG
6fda77da05 Media: Display User Agent Controls widget for video element. (#40578)
Add Contents::ReplacedWithWidget for video elements with UA control
widget, to allow Traverse into the children of video element during Box
Tree Construction, Generate
IndependentFormattingContextContent::ReplacedWithWidgets, to store both
the `ReplacedContents` and `BlockFormattingContext`. During fragment
tree generation process, first layout the Image Fragment, and then
Layout the Inner Controls BlockFormattingContext. Doing this allow us to
determine the size of Inner Controls widget based on the size of the
Image Fragment. Minor Fix: ::before/::after pseudo elment should be
suppress for replaced element.

Testing: Should show the controls widget for `<video controls></video>`,
and should not affect any existing WPT test. Since how to display UA
widget of Video Element is not defined in the spec, expectedly there has
no existing WPT test that testing this.
Fixes https://github.com/servo/servo/issues/40452
Fixes https://github.com/servo/servo/issues/31414

---------

Signed-off-by: rayguo17 <tin.tun.aung1@huawei.com>
2025-11-18 07:02:13 +00:00
Martin Robinson
99daf8c644 script: Wrap remaining unsafe code and enable unsafe_op_in_unsafe_fn (#40499)
This is last step toward enabling the default rustc
`unsafe_op_in_unsafe_fn` warning for the script crate. It wraps the
remaining unsafe code in `unsafe {}` and removes the line disabling this
warning from `script`'s `Cargo.toml`. In addition, two variables are
renamed from `v` to something slightly more descriptive.

Testing: This should not change behavior so is covered by existing
tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-08 14:27:35 +00:00
WaterWhisperer
158bf97e30 script/dom/: Change some #[allow]s to #[expect]s (#40454)
Removes some unneeded lints, especially `#[allow(unsafe_code)]`.

Testing: Refactor
Part of: #40383

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-11-06 11:06:03 +00:00
Simon Wülker
46e6d072b7 script: Enforce exclusivity between <details> elements in the same tree (#40314)
Within the same tree, only one `<details>` element with the same name
may be open at a time. Before this change, this invariant was not
enforced.

I've added a `HashMap` to `Document` and `ShadowRoot` which maps from a
name to the a list of details elements with the same name. This map
allows us to find conflicting details elements without having to
traverse the whole tree. Of course this only works when the tree is a
document tree or a shadow tree, so we still have to fall back to
`traverse_preorder` in some cases (which I believe to be uncommon).

This is ready for review, but I'd like to wait until
https://github.com/servo/servo/pull/40271 is merged to not cause
unnecessary merge conflicts.

Testing: New web platform tests start to pass

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-11-04 21:54:21 +00:00
Taym Haddadi
6ec242580c Add CanGc argument to SafeFromJSValConvertible::safe_from_jsval (#40404)
Add CanGc argument to SafeFromJSValConvertible::safe_from_jsval
Fixes: #40392

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-11-04 20:43:59 +00:00
Simon Wülker
c4ae451612 Turn all commented links before functions into doccomments (#40331)
Servo has a lot of comments like this:
```rust
// https://example-spec.com/#do-the-thing
fn do_the_thing() {}
```
and I keep turning these into doc comments whenever I'm working close to
one of them. Doing so allows me to hover over a function call in an IDE
and open its specification without having to jump to the function
definition first. This change fixes all of these comments at once.

This was done using `find components -name '*.rs' -exec perl -i -0777
-pe 's|^([ \t]*)// (https?://.*)\n\1(fn )|\1/// <$2>\n\1$3|mg' {} +`.

Note that these comments should be doc comments even within trait `impl`
blocks, because rustdoc will use them as fallback documentation when the
method definition on the trait does not have documentation.

Testing: Comments only, no testing required
Preparation for https://github.com/servo/servo/pull/39552

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-11-01 05:32:45 +00:00
Simon Wülker
2111a122e2 script: Don't unregister slots from their shadow root when the whole shadow tree is being unbound (#40278)
Each shadow root holds a map of slot names to slot elements. Slot
elements dynamically register and unregister themselves at their
respective shadow root when they are bound and unbound from the tree.

Previously, they were doing this too often. When a slot element is
unbound from the tree then it might still be connected to its shadow
root, in case the entire shadow tree is being unbound.

Fixing this requires the slot element to know whether it was in a shadow
tree prior to `bind_to_tree` being called (then it's already registered
and doesn't need to do so again), and whether it will be in a shadow
tree after `unbind_from_tree` is called (then there's no need to
unregister).

Testing: This change adds a new web platform test
Fixes: https://github.com/servo/servo/issues/40242

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-10-30 13:09:35 +00:00
WaterWhisperer
d5baab2bfc script: Move CSS DOM interfaces to script/dom/css/ (#40241)
Moves interfaces defined by the CSS spec to the `script/dom/css/` module
from `script/dom/`.

Testing: Just a refactor shouldn't need any testing
Fixes: Partially #38901

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-10-28 17:40:44 +00:00
Simon Wülker
72555de341 Never disconnect shadow roots from their hosts (#39459)
Regular shadow roots can never be detached once they are created.
However we were specifically detaching shadow roots from media elements
when they were disconnected. This is actually one of the very few
aspects of shadow roots that predate the implementation work I did
earlier this year.

I'm not sure why we ever did this. Maybe its for efficiency reasons,
because keeping the shadow tree around is not necessary when the media
element is not connected. But I can't imagine this yields any benefits,
especially since you would have to reconstruct the shadow tree when the
media element is re-connected (as is the case in the crash we observe).

For simplicities sake, I have completely removed this functionality.
Doing so ends up simplifying the code quite a bit.

Testing: This change adds a new crashtest
Fixes https://github.com/servo/servo/issues/36722

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-24 08:04:56 +00:00
Andrei Volykhin
99fbd36b5d html: Properly count <image>/<source> insertion/removal steps as the relevant mutations (#39452)
Follow the HTML specification and take into account that the HTML
`<image>/<source>` element inserting/removal steps should only be
counted as relevant mutations for `<image>` element if the parent of the
inclusive ancestor that was inserted/removed is the parent `<picture>`
element.

See <https://html.spec.whatwg.org/multipage/#relevant-mutations>.

Testing: Improvements in the following tests
-
html/semantics/embedded-content/the-img-element/relevant-mutations.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-09-23 12:40:03 +00:00
Ashwin Naren
c92cd9e624 script: Move HTML DOM interfaces to script/dom/html/ (#39046)
See #38901.

Testing: Refactor
Fixes: Partially #38901

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-08-31 01:00:09 +00:00
JoeDow
6e6ef513a9 Reuse StylesheetContent for inline style sheets with identical content (#38540)
For duplicate style sheets with identical content, `StylesheetContents`
can be reused to avoid redundant parsing of the inline style sheets.
Since duplicate stylesheets is a common case with web components, this
change will significantly improve performance. Additionally, the cache
hit rate of stylo's `CascadeDataCache` can now be significantly
improved.

When shared `StylesheetContents` is modified, copy-on-write will occur
to avoid affecting other sharers. And then updates the references to
`CssRule` or `PropertyDeclarationBlock` stored in the CSSOMs to ensure
that modifications are made only on the new copy.

Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
2025-08-20 12:31:49 +00:00
JoeDow
ce16fbce75 script: Mark the entire shadow tree for restyle when its stylesheet is invalidated (#38529)
This change fix this bugs: modify stylesheet of shadow tree does not
take effect if there is no other Dom change within the shadow tree
happens.

Fixes: This change fix some bugs reported by this issue #38211. 
Testing: This fixes some subtests in
`/css/cssom/CSSStyleSheet-constructable.html` and
`/css/cssom/CSSStyleSheet-constructable-disallow-import.tentative.html`,
and make some subtest failed in
`/css/cssom/CSSStyleSheet-constructable-baseURL.html`, because the
`BaseUrl` is not yet supported for `CSSStylesheet`.

Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
2025-08-18 12:48:35 +00:00
Martin Robinson
8743a11ba4 tidy: Add a rule ensuring that // comments are followed by a space in Rust (#38698)
This shows up sometimes in code reviews, so it makes sense that tidy
enforces it. `rustfmt` supports this via comment normalization, but it
does many other things and is still an unstable feature (with bugs).

Testing: There are new tidy tests for this change.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-08-18 12:09:09 +00:00
Tim van der Lippe
3976fa77bc Implement Trusted Types for ShadowRoot (#38595)
Also make TrustedHTML work the same as TrustedScript by
only taking 1 `&str` to make things easier.

Part of #36258

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-08-11 13:39:55 +00:00
Mukilan Thiyagarajan
21717158eb script: mark innerHTML as fallible in ShadowRoot (#38565)
This is a follow-up to #38532 which simply defaulted to an empty string
as the spec's WebIDL doesn't mark `innerHTML` as `Throws`. However,
since the absence of `Throws` in the spec doesn't imply no-throw, we can
mark this as fallible in our WebIDL. This makes the `ShadowRoot`'s
implementation match `Element`'s `innerHTML`.

Testing: Same as #38532.

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-08-09 06:45:52 +00:00
Mukilan Thiyagarajan
23c0947072 script: make Node::xml_serialize fallible. (#38532)
Testing: [Try run][1] did not reveal any test failures. There doesn't
seem to be any straightforward failure scenarios that can be triggered
in `xml5ever` that are not IO errors and the xml_serialize method simply
serializes to a String buffer.

[1]:
https://github.com/servo/servo/actions/runs/16824267959/job/47657275606l

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-08-08 11:52:59 +00:00
Martin Robinson
9416251cab script: Unify script-based "update the rendering" and throttle it to 60 FPS (#38431)
Instead of running "update the rendering" at every IPC message, only run
it when a timeout has occured in script. In addition, avoid updating the
rendering if a rendering update isn't necessary. This should greatly
reduce the amount of processing that has to happen in script.

Because we are running many fewer calls to "update the rendering" it is
reasonable now to ensure that these always work the same way. In
particular, we always run rAF and update the animation timeline when
updating the ernder

In addition, pull the following things out of reflow:

 - Code dealing with informing the Constellation that a Pipeline has
   become Idle when waiting for a screenshot.
 - Detecting when it is time to fulfill the `document.fonts.ready`
   promise.

The latter means that reflow can never cause a garbage collection,
making timing of reflows more consistent and simplifying many callsites
that need to do script queries.

Followup changes will seek to simplify the way that ScriptThread-driven
animation timeouts happen even simpler.

Testing: In general, this should not change testable behavior so much,
though it
does seem to fix one test.  The main improvement here should be that
the ScriptThread does less work.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-08-04 16:27:00 +00:00
Jo Steven Novaryo
f523445fc3 script: Implement DocumentOrShadowDOM.adoptedStylesheet with FrozenArray (#38163)
Spec:
https://drafts.csswg.org/cssom/#dom-documentorshadowroot-adoptedstylesheets

Implement `DocumentOrShadowDOM.adoptedStylesheet`. Due to
`ObservableArray` being a massive issue on its own, it will be as it was
a `FrozenArray` 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: https://github.com/servo/servo/issues/37561

---------

Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
2025-07-23 08:16:01 +00:00
Jo Steven Novaryo
bbed6cddcd css: Refactor StyleSheetInDocument owner (#38136)
Refactor `documentotshadowroot::StyleSheetInDocument`, renaming it into
`ServoStylesheetInDocument` to avoid confusion with Stylo's
`StylesheetInDocument` trait.

To support constructed stylesheet. The `ServoStylesheetInDocument.owner`
would contains enum of:
- `Dom<Element>` - for stylesheet parsed from an element.
- `Dom<CSSStylesheet>` - for constructed stylesheet.

Testing: No WPT regression.
Fixes: #38133

---------

Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
2025-07-18 05:39:09 +00:00
JoeDow
bda3e23c74 Fix potential clippy warning for NodeDamage enum variant (#37391)
The default of `enum-variant-name-threshold` is 3, so adding any new
variants will lead to the lint being triggered, reference:

[enum_variant_names](https://rust-lang.github.io/rust-clippy/master/index.html#enum_variant_names).
This PR fix this potential clippy lint warning for facilitate the
addition of new variant in following PR about incremental box tree
update.

Testing: No logic changed, just covered by existing WPT tests
Fixes: None

Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
2025-06-11 09:53:15 +00:00
Kelechi Ebiri
1a3f10bba4 feat: implement ShadowRoot::setHTMLUnsafe (#36240)
Implements #36166

---------

Signed-off-by: TG <ebiritg@gmail.com>
2025-05-01 15:19:41 +00:00
Kunga Derick Abongho
83da63f638 resolve issue #36074 new_js_regex and matches_js_regex need a CanGc argument (#36111)
* new_js_regex and matches_js_regex need a CanGc argument

Signed-off-by: dericko681 <abonghoderick@gmail.com>

* new_js_regex and matches_js_regex need a CanGc argument

Signed-off-by: dericko681 <abonghoderick@gmail.com>

* edit Propagate CanGc arguments through new_js_regex and matches_js_regex

Signed-off-by: dericko681 <abonghoderick@gmail.com>

* Propagate CanGc arguments through new_js_regex and matches_js_regex

Signed-off-by: dericko681 <abonghoderick@gmail.com>

* Propagate CanGc arguments through new_js_regex and matches_js_regex

Signed-off-by: dericko681 <abonghoderick@gmail.com>

* Propagate CanGc arguments through new_js_regex and matches_js_regex

Signed-off-by: dericko681 <abonghoderick@gmail.com>

---------

Signed-off-by: dericko681 <abonghoderick@gmail.com>
2025-03-29 13:09:56 +00:00
Simon Wülker
19d5f5f06f script: Implement Element::GetHTML and ShadowRoot::GetHTML (#36106)
* Serialize html fragments without going through html5ever

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Implement ShadowRoot::GetHtml / Element::GetHtml

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Update WPT expectations

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Propagate CanGc annotations

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-03-23 19:04:23 +00:00
batu_hoang
db74179dc8 Make Element::attach_shadow() and ShadowRoot closer to spec (#36024)
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
2025-03-19 17:58:16 +00:00
batu_hoang
28c8c1df0c Implement declarative shadow dom (#34964)
* Implement declarative shadow dom

Signed-off-by: batu_hoang <longvatrong111@gmail.com>

* Set allowDeclarativeShadowRoots false for innerHTML

Signed-off-by: batu_hoang <longvatrong111@gmail.com>

* Enable allowDeclarativeShadowRoots for Document

Signed-off-by: batu_hoang <longvatrong111@gmail.com>

* Expose HTMLTemplateElement to js

Signed-off-by: batu_hoang <longvatrong111@gmail.com>

* Implemenet setHTMLUnsafe and add more test cases

Signed-off-by: batu_hoang <longvatrong111@gmail.com>

* Declarative shadow dom: minor updates and expected test result update

Signed-off-by: batu_hoang <longvatrong111@gmail.com>

* Shadow-dom: add more test cases

Signed-off-by: batu_hoang <longvatrong111@gmail.com>

* Update comments according to the spec

Signed-off-by: batu_hoang <longvatrong111@gmail.com>

* Bump html5ever version

Signed-off-by: batu_hoang <longvatrong111@gmail.com>

---------

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
2025-03-17 09:41:34 +00:00
Simon Wülker
e627ac5cfd Hide servo internal shadow roots from the inspector by default (#35958)
Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-03-13 13:08:24 +00:00
Simon Wülker
8034216d06 Implement ElementInternals::shadowRoot (#35923)
* Implement ElementInternals::shadowRoot

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

* Update WPT expectations

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-03-12 00:09:32 +00:00
Nico Burns
f527217bdc Use new stylo crate renames (#35898)
Signed-off-by: Nico Burns <nico@nicoburns.com>
2025-03-12 00:02:12 +00:00
Simon Wülker
fd0e2125c6 Keep a list of slot descendants on each shadow root (#35802)
This makes it much faster to traverse over the slot descendants of
a shadow root, which is a fairly costly part of "assign slottables to a tree".

This reduces the time it takes for the results to load on wpt.fyi from
over 3 minutes to about 5 seconds.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-03-10 23:11:20 +00:00