Commit Graph

927 Commits

Author SHA1 Message Date
Narfinger
ffae45327c script: Use UnrootedSimpleNodeIterator in delete_cell_or_row (#43476)
This uses UnrootedSimpleNodeIterator in a couple of places, namely
- delete_cell_or_row
- children_changed
- move_fn

More importantly this implements upcast and downcast for `UnrootedDom`.
These methods work the same as the DomRoot methods except that they
carry the no_gc and, hence,
keep the lifetime.

Testing: WPT tests will see if this breaks something.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2026-03-20 12:52:17 +00:00
Tim van der Lippe
2dd5c38c8e script: Pass &mut JSContext in remaining parts of Trusted Types (#43365)
These are the remaining arguments of `CanGc`.

Part of #40600

Testing: it compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-18 09:15:31 +00:00
Gae24
026d679783 script: Pass &mut JSContext to Element::create (#43348)
Pass `&mut JSContext` to `Element::create` and `create_html_element`

Testing: No functionality changes, covered by existing tests.
Part of #40600

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-17 13:03:33 +00:00
Martin Robinson
8555464648 script: Do not fire simulated click on spacebar/enter in non-state-changing elements (#43343)
Servo has for years implemented a behavior where spacebar or enter click
on a focused element will trigger a click. That behavior used to be
unspecified, but now it is. The specification says that this should only
happen on state-changing elements. This change makes this happen using
activatable elements as a heuristic (as state-changing elements are not
defined in the specification). In addition, the behavior is integrated
into the default keyboard event handler code.

Testing: This change adds a Servo-specific test due to the ambiguities
in the specification.
Fixes: #39028.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-03-17 10:13: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
Martin Robinson
4c6dbd59cb script: Only trigger one default event handler for form controls (#43247)
There is a `handle_event` virtual method on `Node` that triggers the
default event handler. Typically the "superclass" virtual method is
called and then the specific type runs its default event handler. This
isn't good for form controls, because typically the event handler should
prevent further event handlers from running. This badness can be
observed by pressing down in a text input, which will both move the
cursor as well as scroll the page. 🙃

This change makes it so that the default form control event handler
consistently calls the `Event::mark_as_handled` method and triggers the
"superclass" event handler *after* running its own. In addition, the
scrolling default event handler on `Node` now doesn't run if the `Event`
was already handled.

Finally, a little bit of dead event handling code is removed.

Testing: This change adds a Servo-specific test for this behavior.
Fixes: #40785

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-03-13 16:27:22 +00:00
Gae24
048612fe84 script: Pass &mut JSContext to children_changed and adopting_steps (#43219)
Switch `VirtualMethods::children_changed` and
`VirtualMethods::adopting_steps` to `&mut JSContext`.

Testing: No behaviour change, a successful build is enough.
Part of #40600

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-13 13:40:40 +00:00
Martin Robinson
c80bdd9c92 prefs: Remove Opts::nonincremental_layout (#43207)
This setting is used to control whether or not incremental legacy layout
was enabled. Nowadays incremental layout is always enabled as it is a
fundamental feature of how layout works. The setting also controls
whether or not nodes are traversed in Style, but that's also something
that's much less interesting today. This change just removes this
setting as it just controls the Stylo setting. A corresponding change in
Stylo will also remove the setting there.

Testing: This just removes a setting so existing tests should suffice.
Fixes: This is part of #34967.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-03-12 16:03:43 +00:00
Tim van der Lippe
c1c5e9373c script: Complete basic implementation of delete command (#43082)
While we are not there yet, this is the majority of the implementation
of the delete command.

What's missing:
1. Handling of style attributes (most of the test failures)
2. Handling of lists

Since these are quite complicated on their own, deferring that to their
own PR.

Also added more assertions regarding parent nodes, which should always
exist in the spec. By adding those, discovered that the logic for
`is_visible` was wrong where its display value wasn't checked for
`"none"`.

Part of #25005

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-11 06:06:51 +00:00
Gae24
4ef22ed227 script: Pass &mut JSContext to VirtualMethods::cloning_steps and Node::clone (#43130)
Continuation of #43108, two new `temp_cx()` calls were required:
- inside `maybe_clone_an_option_into_selectedcontent` since it's part of
a markup5ever trait
- inside `serialize_and_cache_subtree` replacing a `CanGc::note()` call,
propagating it inside reflow code will require even more effort.

Testing: No behaviour change, a successful build is enough.
Part of #40600

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-10 17:05:34 +00:00
Luke Warlow
62e72b027f script: Implement node.moveBefore() (#41238)
Implement node.moveBefore()

This implements the atomic move method for DOM nodes. This allows moving
elements within the DOM without running the full remove and insertion
steps, allowing more seamless behaviour such as CSS transitions
continuing from where they are rather than restarting.

Spec: https://dom.spec.whatwg.org/#dom-parentnode-movebefore

Testing: Existing WPTs

---------

Signed-off-by: Luke Warlow <lwarlow@igalia.com>
2026-03-09 16:39:56 +00:00
Narfinger
9062952bf9 script: Add UnrootedSimpleNodeIterator (#42978)
In the same vein as https://github.com/servo/servo/pull/42781 we
implement a UnrootedSimpleNodeIterator that takes a no_gc and does not
root the required nodes.

We include an example usage in 'dom/text.rs' WholeText.

This requires https://github.com/servo/servo/pull/42781 to be merged
first.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2026-03-09 12:28:07 +00:00
Gae24
fa86bbedbe script: Pass &mut JSContext to DOM apis that call Element::create (#43108)
Testing: No behaviour change, a successful build is enough.
Part of #40600

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-09 10:07:13 +00:00
Martin Robinson
401d327b96 script: Clean up attribute access a little bit in Element (#43064)
- Use modern Rust conveniences such as `unwrap_or_default`
 - Unabbreviate `attr`
- Unify the lowercase ASCII name assertion and make it a debug assertion
 - Use `unreachable!` instead of panic
- Expose two attribute getters that follow the behavior of two
specification concepts and what we expect internally in Servo:
- One that takes a namespace, but does not require lowercase attribute
names. ([specification
concept](https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace>))
- One that does not take a namespace, but does require lowercase
attribute names. ([specification
concept](https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name))
Testing: This should not really change behavior so should be covered by
existing tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-03-06 20:02:37 +00:00
Martin Robinson
291e9e57cb script: Readily accept all event names as Atoms (#43066)
Accepting the name of the event as a `DOMString` means that when events
are constructed from within Servo (for instance via input event
handling), the static strings are converted to an owned `String`
wrapped in a `DOMString` and then finally converted to an `Atom` in
`Event`. This makes it so that all non-generated `Event` constructors
accept `Atom`, which can avoid a conversion entirely when the atom
already exists on the Stylo atoms list and eliminate one in-memory copy
in the case that it isn't on the atom list.

Eventually, all event names can be on the atom list and we can eliminate
all copies. This is a tiny optimization, but also makes the code much
friendlier everywhere.

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

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-03-06 19:25:33 +00:00
Narfinger
11d47b62b9 script: Implement efficient TreeIterator without rooting when possible (#42781)
This implements an two types:
- Efficient Tree Iterator that can be used without rooting when
possible.
- UnrootedDom that can be used while not rooting while capturing a NoGC.

We:
- introduce new methods in 'script/dom/node.rs' to get the correct
iterator.
- introduce methods in 'script/dom/node.rs' to get the unrooted children
in an 'UnrootedDom' container.

We use the new TreeIterator in 'script/dom/document.rs' Open.

Testing: WPT tests should catch this but careful review is required.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2026-03-06 05:21:01 +00:00
Simon Wülker
69e2894923 script: Unify naming of LayoutDom conversion functions to {to, from}_layout_dom (#43032)
As requested during the review of
https://github.com/servo/servo/pull/42991. These functions are currently
called `{to, from}_layout_js` or sometimes `get_jsmanaged` - this change
unifies them as `{to, from}_layout_dom` for clarity.

Testing: Covered by existing tests

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2026-03-05 12:32:31 +00:00
Steven Novaryo
a672397f2d layout: Add a query for getting the effective overflow of an element and use it in script (#42251)
In layout calculation within script, Instead of relying on the computed
values for overflow, query the overflow from layout for its used value
to accurately reflect whether an element establish a scroll container.
This query will be used for `IntersectionObserver` as well.

Testing: There are new `IntersectionObserver` WPT failures:
- `intersection-observer/isIntersecting-change-events.html`
- `intersection-observer/containing-block.html`

The failures are more than likely a false positive because intersection
observation steps wasn't supposed to trigger a reflow, but it was
before. It could be caused by the implementation of
`IntersectionObserver` in major UAs being a little bit different from
the spec in the calculation of `threshold` and `isIntersecting` .

---------

Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2026-03-05 11:35:32 +00:00
Martin Robinson
b47b39f974 script: Distinguish between sequential (keyboard) and click focusability (#43019)
This changes makes it so that keyboard and click focusability are two
separate concepts in `script`. Some elements may be focusable only by
the keyboard and some only by the click events.

In addition, the `SEQUENTIALLY_FOCUSABLE` `Node` flag is removed in
favor of a
more specification-aligned approach of checking lazily if an element is
a focusable area. This allows moving the focus fixup steps to their
correct place, asynchronously during "update the rendering" and
synchronously during `unbind_from_tree`.

Testing: This causes some WPT tests to start passing and some to start
failing:
- Two subtests tests in
`tests/wpt/meta/css/css-conditional/container-queries/` because
we do not implement support for container queries. These are legitimate
failures
   and they are compensated by a good subtest pass in the same file.
- A few subtests in `/html/interaction/focus/tabindex-focus-flag.html`
because now
we do not allow focusing non-rendering elements. The failures are HTML
elements with
`<svg>` which we do not rendering and `<summary>` elements of
`<details>` which
   need special handling we do not implement yet.
- `html/semantics/forms/the-fieldset-element/disabled-003.html`: Some of
these tests
start to fail, but they are not spec compliant and browser properly
implementing
   the asynchronous focus fixup rule also fail them. 

Fixes: #31870.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2026-03-05 08:58:59 +00:00
Simon Wülker
78efa1860d script: Use stylo dom apis for querySelector/querySelectorAll (#42991)
Stylo has ready-to-use apis for `Node::querySelector` and
`Node::querySelectorAll`. We currently instead set up our own selector
queries, which is neither as correct nor as performant, so this change
makes servo use the stylo interfaces instead.

This change contains a fair amount of unsafe code - review with caution!

Notably, this makes the tab component from the astro framework work
correctly in servo (https://starlight.astro.build/components/tabs/).
I've seen that (broken) component on multiple websites.

Fixes https://github.com/servo/servo/issues/41105
Testing: New tests start to pass

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2026-03-04 14:18:48 +00:00
Josh Matthews
f206571869 layout: Prevent DomRefCell::borrow from being used in layout code (#42976)
DomRefCell::borrow inside of layout code is risky because it leads to
memory races if the code is ever called from layout worker threads. This
can be caught via TSAN, but we can also catch it deterministically in CI
by using our existing thread state debug assertions correctly.

Testing: Existing WPT test coverage is sufficient.
Fixes: #42962

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2026-03-04 06:44:39 +00:00
Martin Robinson
1d9d440b22 script: Add basic support for tab navigation (#42952)
This change adds very basic support for tab navigation, but without
support for focus scopes. Followup changes will refine the behavior of
this implementation to follow the specification around focus scopes,
shadow DOM, and slots. In particular `delegatesFocus` is not supported
here yet.

Testing: This causes quite a few WPT tests to start passing.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2026-03-02 20:42:25 +00:00
Simon Wülker
ea8375beaf script: Remember which nodes the devtools know about (#42785)
Currently, `script` and `devtools` use a node's unique id to identify it
across requests. The unique ID is part of a node's rare data field and
is really only meant for debugging. Instantiating it on a node causes
it's memory usage to go up significantly. Now, when the devtools ask for
information about a specific `Node` then they send the unique ID to
`script`, and the script thread then walks the whole DOM tree searching
for that specific ID. This happens here:

6d0b651218/components/script/devtools.rs (L142-L153)

So, in the worst case, all of the nodes in the tree now have a unique
ID. That's not great!

Also, when `script` notifies `devtools` about changes to a DOM node then
`devtools` expects a `NodeActor` to exist for that Node. The actor might
not exist if the inspector doesn't know about that node yet - that
happens when the user hasn't expanded their parent yet.
That is an oversight from https://github.com/servo/servo/pull/42601 and
causes problems now(https://github.com/servo/servo/issues/42784) because
for the longest time, `devtools` was mostly the one sending requests. Of
course, we could make `devtools` simply ignore updates for nodes that it
doesn't know about, but ideally we shouldn't send these updates in the
first place.

This change implements a lookup map on the `ScriptThread` that contains
all nodes that have been sent to the devtools inspector. The map allows
us to efficiently resolve a unique ID to a `Node` in O(1), without
creating unique IDs for the whole tree. It also allows us to only send
DOM updates for nodes that the inspector cares about.

For now, entries from the cache are not evicted unless the relevant
pipeline is closed. That reflects reality, because the inspector also
keeps using them forever.
In the future we will tell the inspector when nodes are removed from the
tree - then it can't interact with them anymore, and we can remove them
from the script-side map.

This is change is not all that complicated but it involves moving a lot
of code around, so feel free to ask for clarification when something is
unclear!





Testing: This change adds a test
Fixes part of https://github.com/servo/servo/issues/42784

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2026-02-25 12:35:52 +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
Tim van der Lippe
32936858df script: Implement canonicalize whitespace (#42704)
What I thought would be a small algorithm turns out required tons of
other implementations of various definitions, most of it around nodes.

Therefore, to keep things manageable, it only implements this algorithm
and relevant parts, but leaves the other parts of the delete command
untouched. For now, it is good if tests keep on working without
crashing. Later, once the full delete command is implemented, more tests
should be passing.

Part of #25005

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-02-20 18:42:50 +00:00
Gae24
8a3738dc43 script: pass down &mut JSContext in post_connection_steps (#42679)
Pass down `&mut JSContext` in `post_connection_steps` 

Testing: No functionality change, a successful build is enough
Part of #40600

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-02-17 13:20:52 +00:00
Tim van der Lippe
92e2d00083 script: Implement check for supported and enabled commands (#42634)
The first step of `execCommand` commands is to figure out
if they are supported and enabled. Therefore, implement
these two pieces with only 1 command: delete.

The implementation of `delete` is currently mostly dummy,
to have at least something going. But the main part of
this change is to setup the infrastructure to figure out
when commands are supported and enabled.

For the first part, its simply the list of commands we
currently have implemented, which is only delete.

For the second part, we need to consider the active range
of the current selection and do various checks, as well as
check the presence of `contenteditable`.

Part of #25005

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-02-17 13:19:41 +00:00
Tim van der Lippe
e23c14aabd script: Implement support for contenteditable (#42633)
This is required for `document.execCommand`, since it needs to check the
active range of the selection whether it has the attribute or not.

It also turns on the relevant WPT tests, with 1
pre-existing failure for absolute positioned pseudo elements. These
currently do not render correctly, regardless of the existence of
contenteditable.

Fixes #12776

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-02-16 18:55:42 +00:00
Simon Wülker
929e275fcd devtools: Show attached event listeners in inspector tab (#42355)
This change makes the devtools inspector show any event listeners that
are attached to a node. The primary motivation is making the devtools
more useful for debugging real-world websites.

<img width="536" height="268" alt="image"
src="https://github.com/user-attachments/assets/5ba13e41-14b4-4202-b994-eadff5d1c6b5"
/>

You can also click on the event listener to show some more info, though
most of that (everything except the event type and the event phase) is
currently just placeholder text:

<img width="1360" height="456" alt="image"
src="https://github.com/user-attachments/assets/ec025847-43fc-489c-8b26-46afb6dada64"
/>


Testing: This change adds a new test

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2026-02-11 13:31:25 +00:00
webbeef
86403fa4e5 layout: get rid of some collect() calls (#42327)
Profiling a speedometer run showed significant time spent in some layout
function in vector allocations. The main change is to switch the result
of `query_box_areas()` from a Vec<T> to and iterator.

Testing: refactoring with no expected test changes

Signed-off-by: webbeef <me@webbeef.org>
2026-02-06 09:38:49 +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
TIN TUN AUNG
17f7c87088 script: add force option for assign-slottables for a tree (#42250)
In the case of node removal, if the subtree of the removed node contains
`<slot>` element, force traverse down to each `<slot>` element is needed
to reset the assignment of the slottables that currently being assigned
to the `<slot>` element. This changes add this force option to
`assign_slottables_for_a_tree`, and only set true to node removal.

Testing: Should be covered by current WPT test, [try
run](https://github.com/rayguo17/servo/actions/runs/21504337658)
Fixes: https://github.com/servo/servo/issues/35188
https://github.com/servo/servo/issues/42182

cc @TimvdLippe @simonwuelker @xiaochengh

---------

Signed-off-by: rayguo17 <tin.tun.aung1@huawei.com>
Signed-off-by: rayguo17 <rayguo17@gmail.com>
2026-02-02 07:25:13 +00:00
Martin Robinson
1900ebc447 script: Do not consider a node an ancestor of itself in Node::is_ancestor_of (#42263)
This change fixes a crash in options collections due to the fact that a
`<select>` element was being considered an ancestor of itself. This
regression likely introduced in #40776.

This change also fills in the specification text for
`HTMLOptionCollect::Add`.

Testing: This change adds a WPT crash test.
Fixes: #41080.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-01-31 10:22:23 +00:00
webbeef
58b56edf97 dom: reduce traversal in CompareDocumentPosition (#42260)
We can avoid doing 2 traversals and stop at the first matching child we
find. This ensures we are never doing the longest iteration.

Testing: covered by WPT

Signed-off-by: webbeef <me@webbeef.org>
2026-01-31 01:18:30 +00:00
Martin Robinson
d6197ee2f0 script: Clear layout data on shadow root during attachShadow (#42237)
When a node has `attachShadow()` successfully called on it, its
descendants are no longer in the flat tree. This change makes it so that
the layout data of these descendants is cleared during `attachShadow()`
so that the node is no longer considered to have a layout box.

Testing: This change includes a new WPT crash test.
Fixes: #42215.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-01-29 13:08:39 +00:00
Tim van der Lippe
c0b55a2c34 script: Add about_base_url (#42104)
We populate the required field for all relevant entrypoints
and set it to `document.base_url` when the url is `about:blank`
or `about:srcdoc`. In all other cases, it uses
`document.about_base_url`.

Testing: WPT
Fixes #41836

---------

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-01-27 18:09:01 +00:00
Martin Robinson
5d0db1fa6a layout: Add unit types to most layout queries (#42002)
This change makes it so that the euclid types returned from layout
queries use the `CSSPixel` unit type when appropriate. The minimal set
of changes are also made to avoid having to convert these types to the
`UnknownUnit` in other places. There is still some casting that has to
happen to deal with the difference between Stylo's `CSSPixel` and
WebRender's `LayoutPixel`, but a followup changes will try to switch to
using one or the other.

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

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-01-23 15:38:57 +00:00
Martin Robinson
4a9c95ac8e layout: Handle selection during display list construction (#41963)
Instead of handling selection in text input during box tree / fragment
tree construction, fully handle it during display list construction.
This means that when the selection changes in script, it updates
automatically in the `FragmentTree` and only a new display list is
necessary. This avoids a layout while changing the selection in text
fields.

Testing: This fixes a few rendering issues, but these are very hard
to isolate and test for. It causes one test to start failing, but this
is
because a cursor that wasn't rendered properly now starts showing
up.
Fixes: #41920.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2026-01-21 08:04:15 +00:00
Rod Borovyk
eacdbd9a34 layout: Accept lengths in arbitrary units for SVG width and height (#40761)
Previously it was only possible to set width and height of SVG elements
in pixels. These changes allow parsing other units like em using a CSS
parser in SVGSVGElement and resolving them to computed values in the
layout code.

Testing: Tested manually
Fixes: -

---------

Signed-off-by: Rodion Borovyk <rodion.borovyk@gmail.com>
2026-01-19 13:31:27 +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
Martin Robinson
cbb23c72af script: Implement all user agent widgets for form controls with shadow DOM (#41760)
This change makes it so that all form controls are implemented with
shadow DOM, completely removing the legacy text content and selection
code paths for form controls. The motivation for this change is:

- to allow properly hit testing against the text nodes of `<textarea>`
  and other widgets. This is important for implementing mouse-based
  selection on the page.
- to simplify the way that form controls are implemented in general and
  to prepare the way for proper implementations of the user interface of
  other controls.

Testing: This should not change observable behavior at the moment,so
should be covered by existing WPT tests.

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2026-01-09 01:11:20 +00:00
Sam
89067e5450 script: Pass &mut JSContext to tasks (#41756)
This change is reviewable per commits:
In first commit we added `&mut JSContext` to `run_box` (it is very hard
to bring `&mut JSContext` to `remove_script_and_layout_blocker`).
In second commit we pass `&mut JSContext` to `run_once`.
In third commit we added support for accepting `&mut JSContext` in
closures of `task!` macro and lastly we demo new macro invocations (to
ensure they actually compile)

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

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-01-08 07:49:27 +00:00
Tim van der Lippe
5b6509f279 script: Implement customElementRegistry support for document.importNode (#41385)
This method now allows you to pass in a custom registry. The registry
isn't used yet for callers, since we don't support scoped registries.
However, as we now pass in the registry to `Node::clone`, we set the
registry when creating elements and cloning them.

As such, various tests start passing where we set the registry. Some
tests started failing, but they rely on scoped registries which we don't
support yet. These tests thus flipped: those that were erroneously
failing are now passing and vice versa.

Part of #34319

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-12-19 09:01:08 +00:00
webbeef
f81c19226f script: set a bloom filter when creating a MatchingContext (#41368)
Uses bloom filters in `MatchingContext` to make selector matching more
efficient. This seems to improve Speedometer score a bit.

Testing: no new test for that small optimization.

Signed-off-by: webbeef <me@webbeef.org>
2025-12-19 03:21:28 +00:00
Simon Wülker
581723c338 script: Remove redundant call to Node::adopt in Node::replace_all (#41373)
All the new nodes will be `adopt`-ed inside the respective calls to
`Node::insert` anyways.

Testing: Hopefully no regressions?

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-12-18 12:03:41 +00:00
webbeef
d7354191d2 dom: avoid short lived rooting in Node::is_ancestor_of (#40776)
When using the iterator nodes are rooted but they are dropped
immediately.

Testing: Green wpt run:
https://github.com/webbeef/servo/actions/runs/19560383039/job/56012660243

Signed-off-by: webbeef <me@webbeef.org>
2025-11-28 07:40:49 +00:00
webbeef
135bc7de36 script: Optimize Node::insert (#40742)
- Change how the static node list is built to prevent a second iteration
of new_nodes
- Memoize some invariants of the parent


Testing: No wpt regressions:
https://github.com/webbeef/servo/actions/runs/19493174678

This improves the `parseFromString()` benchmark by ~7% on my machine.

Signed-off-by: webbeef <me@webbeef.org>
2025-11-20 05:25:53 +00:00
d-kraus
adf840a7c4 script: Add message to Dom exception Error::NotSupported (#40745)
Adding an optional message to Error::NotSupported. Unblocks
https://github.com/servo/servo/issues/39050.

The enum definition of NotSupported is now
`NotSupported(Option<String>)`.

Testing: Just a refactor
Fixes: Partially https://github.com/servo/servo/issues/39053

Signed-off-by: Dennis Kraus <kraus@posteo.de>
2025-11-20 01:31:33 +00:00
Martin Robinson
8939240ed8 script: Trigger reflow properly for pseudo-elements with content: attr() (#40698)
When a Node with a pseudo-element style that uses `content: attr()`
has one of its attributes mutated, trigger a reflow starting at that
node. This is a crude implementation, because we currently aren't taking
into account what attributes changed, but at least it works.

Testing: This doesn't have any test changes, but should fix the test
situation described in #40419.

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-11-17 23:18:41 +00:00