Commit Graph

881 Commits

Author SHA1 Message Date
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
WaterWhisperer
e4b7962854 script: Fix MutationObserver to use Dom instead of DomRoot (#40608)
converts MutationObserver's record_queue and node_list, as well as
RegisteredObserver's observer field, to use Dom<T> instead.

Testing: `./mach build --use-crown` pass locally
Fixes #40602

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-11-13 19:14:30 +00:00
Simon Wülker
a1269e809d Replace calls to ".filter_map()" followed by ".next()" with ".find_map()" (#40612)
The two are semantically equivalent, but `find_map` is more concise.

Testing: Covered by existing tests

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-11-13 14:53:57 +00:00
Simon Wülker
5ecf09d76a xpath: Fix implementation for preceding::/following:: axes (#40588)
`preceding::` needs to yield all preceding nodes, excluding ancestors.
`following::` needs to yield all following nodes, excluding descendants.

Both `Node::preceding_nodes` and `Node::following_nodes` (which we're
currently using) don't quite match these requirements, so we have to
engineer some xpath-specific iterators.

Testing: New tests start to pass

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-11-12 10:40:36 +00:00
Rod Borovyk
a79d7d700d script: Introduce HtmlSerialize to support extensible node serialization (#40568)
XML and HTML serialization routines relied on a single, shared
implementation of the `markup5ever::Serialize` trait for the DOM Node
type.

These changes introduce the HtmlSerialize type to make it possible to
support XML serialization and fix other issues.

Testing: It does not change any behavior and it builds.
Fixes: #40552

---------

Signed-off-by: Rodion Borovyk <rodion.borovyk@gmail.com>
2025-11-12 10:05:46 +00:00
austinwillis
5896cfd936 script: Add message to HierarchyRequestError (#40366)
Adds an optional error message to HierarchyRequestError

Testing: refactor
Fixes: one item in #39053

---------

Signed-off-by: Austin Willis <austinwillis8@gmail.com>
2025-11-12 07:34:47 +00:00
Andrei Volykhin
9efe79065e dom: Add the attribute mutation reason (#40527)
For some specific cases (one of them see below) where are requirement to
identify the reason of the attribute mutation (by whom/why it was
changed - by cloning, parser or directly), so the following `reason`
parameter was added to `AttributeMutation::Set` option.

Note that for the HTMLMediaElement the internal `muted` state should be
set to true when the element is created and the element has a `muted`
content attribute specified (should be done once on the first attribute
mutation caused by parser or cloning).

See https://html.spec.whatwg.org/multipage/#dom-media-muted

Testing: Improvements in the following tests
-
html/semantics/embedded-content/media-elements/user-interface/muted.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-10 10:09:03 +00:00
WaterWhisperer
401165f154 script: Add message to IndexSizeError (#40463)
Adding an optional message to be attached to a IndexSizeError.

The enum definition of IndexSize is now `IndexSize(Option<String>)`.
Future PRs should probably add more appropriate messages to some of the
`IndexSize(None)`s.

Testing: Just a refactor
Fixes: Partially #39053

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-11-07 01:08:00 +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
Martin Robinson
f08460cded script: Handle broken image icon in HTMLImageElement (#40429)
Instead of having the `ImageCache` return the broken image icon for
failed loads, have `HTMLImageElement` explicitly request it. This means
that the image is loaded on demand (reducing the usage of resources) and
also simplifying the interface of the `ImageCache` greatly.

In addition, the display of the broken image icon is improved, more
closely matching other browsers. A test for this display (which was
falsely passing before) is updated to reflect the new display of the
broken image icon.

Testing: There is a Servo-specific test for this change. Some WPT tests
start to fail as well. Before these were not properly loading the broken
image icon so they were failing before, just in a hidden way.

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-11-06 09:36:21 +00:00
Ashwin Naren
3e97cd2d2c script/dom/: Change some #[allow]s to #[expect]s (#40403)
This removes some unneeded lints, especially `#[allow(unsafe_code)]`.

Testing: Refactor
Part of: #40383

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-11-04 18:29:06 +00:00
Josh Matthews
61f98c510f script: Do not include transforms and inline boxes in ResizeObserver box area queries (#40323)
These changes implement the restrictions for content rects required by
the ResizeObserver specification: inline boxes must return empty rects,
and any transforms must be ignored.

Testing: Newly passing tests.
Fixes: #40259
Fixes: #40258

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-11-03 15:19:34 +00:00
Yerkebulan Tulibergenov
1713f0c8f2 script: add CanGc as argument to VirtualMethods.post_connection_steps (#40329)
script: add `CanGc` as argument to
`VirtualMethods.post_connection_steps`

Testing: These changes do not require tests because they are a refactor.
Addresses part of https://github.com/servo/servo/issues/34573

Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
2025-11-01 10:01:15 +00:00
Yerkebulan Tulibergenov
5cc786a98e script: add CanGc as argument to VirtualMethods::children_changed (#40325)
script: add CanGc as argument to VirtualMethods::children_changed

Testing: These changes do not require tests because they are a refactor.
Addresses part of https://github.com/servo/servo/issues/34573

Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
2025-11-01 00:20:25 +00:00
Josh Matthews
b3868c28e9 script: Report target padding and desired sizes for ResizeObserver notifications (#40254)
We were not following the specification for computing the values of the
content rect. Additionally, any non-content-box observer would get
confused because we never stored the correct size, leading to infinite
notifications when the latest size didn't match the last observed size.

Testing: Various tests now pass.
Fixes: #32549
Fixes: #40107

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-10-31 18:11:34 +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
ZejunYu
a6aa21b068 script: Use new inserted node when performing slot checks (#40251)
https://github.com/servo/servo/blob/main/components/script/dom/node.rs#L2560
The node in this line should be kid.
Step 7.4 If parent is a shadow host whose shadow root’s slot assignment
is "named" and node is a slottable, then assign a slot for node.
The node here should be the node of "for each" rather than the node of
the insert parameter.

Fixes: https://github.com/servo/servo/issues/40250
2025-10-29 07:01:12 +00:00
Tim van der Lippe
1343f3ebf6 Fix updating slottables when slots are removed from a shadowtree (#40188)
We never cleared the containing shadowRoot when unbinding
a node, which meant that slots wouldn't update their
slottables.

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-10-29 06:13:29 +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
WaterWhisperer
3fb59f8e8e script: Move SVG DOM interfaces to script/dom/svg/ (#40206)
Moves interfaces defined by the SVG spec to the `script/dom/svg/` 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-27 06:59:48 +00:00
Simon Wülker
66a6053ae7 script: Don't bail out of "assign slottables for a tree" when the target is a slot element (#40190)
When we are unbinding a slot from the tree then "assign slottables for a
tree" is called with the slot, which unassigns all slottables that are
no longer in the slot. Without this change the slot would keep its
assigned slottables.

cc @TimvdLippe 

Testing: New web platform tests start to pass
Fixes https://github.com/servo/servo/issues/35188

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-10-27 02:20:21 +00:00
Narfinger
423800eec4 Script: Lazily transform the DOMString into Rust String instead of immediately. (#39509)
This implements LazyDOMString (from now on DOMString) as outlined in
https://github.com/servo/servo/issues/39479.
Constructing from a *mut JSString we keep the in a
RootedTraceableBox<Heap<*mut JSString>> and transform
the string into a rust string if necessary via the `make_rust_string`
method.
Methods used in script are implemented on this string. Currently we
transform the string at all times.
But in the future more efficient implementations are possible.

We implement the safety critical sections in a separate module
DOMStringInner which allows simple constructors, `make_rust_string` and
the `bytes` method.
This method returns the new type `EncodedBytes` which contains the
reference to the underlying string in either format.

Testing: WPT tests still seem to work, so this should test this
functionality.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-10-09 18:18:03 +00:00
Martin Robinson
e9151ec744 script: Use CSP sandboxing flags for <iframe> and pass them to child Documents (#39610)
This change makes it so that `<iframe>` sanboxing is equivalent to the
one used for Content Security Policy, which is how the specification is
written. In addition, these sandboxing flags are passed through to
`<iframe>` `Document`s via `LoadData` and stored as
`Document::creation_sandboxing_flag_set`. The flags are used to
calculate the final `Document::active_sandboxing_flag_set` when loading
a `Document`.

This change makes it so that `<iframe>`s actually behave in a sandboxed
way, the same way that `Document`s with CSP configurations do. For
instance, now scripts and popups are blocked by default in `<iframe>`s
with the
`sandbox` attribute.

Testing: This causes many WPT tests to start to pass or to move from
ERROR to TIMEOUT or failing later. Some tests start to fail:
-
`/html/semantics/embedded-content/the-canvas-element/canvas-descendants-focusability-005.html`:
This test uses a combination of `<iframe allow>` and Canvas fallback
content, which we do not support.
-
`/html/semantics/embedded-content/the-iframe-element/iframe_sandbox_navigate_other_frame_popup.sub.html`:
This test is now failing because the iframe is sanboxed but in the
ScriptThread now due to `allow-same-origin`. More implementation is
needed to add support for the "one permitted sandbox navigator concept."

Fixes: This is part of #31973.

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-10-06 17:23:03 +00:00
Excitable Snowball
601ad7e5c6 script: Add message to InvalidStateError (#39535)
Adding an optional message to be attached to an InvalidStateError.

Testing: Only a refactor, no behavior change
Fixes: Partially #39053

Signed-off-by: Excitable Snowball <excitablesnowball@gmail.com>
2025-09-27 19:23:05 +00:00
Narfinger
18a1da0d80 Script: Remove last instances of Deref<str> and DerefMut<str> used for DOMString (#39504)
This removes the last instances of Deref<str> and DerefMut<str> used for
DOMString.
The goal is outlined in https://github.com/servo/servo/issues/39479.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>

Testing: Compilation is the test as it just changes function names
essentially.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-27 01:48:24 +00:00
Rodion Borovyk
9713bb9e1b script: Add message to NotFoundError (#39394)
Adding an optional message to be attached to a NotFoundError.

Testing: Just a refactor
Part of #39053

---------

Signed-off-by: Rodion Borovyk <rodion.borovyk@gmail.com>
2025-09-25 12:16:50 +00:00
shuppy
ac8895c3ae script: Move keyboard scrolling to script (#39371)
Instead of having every single embedder implement keyboard scrolling,
handle it in script in the default key event handler. This allows
properly targeting the scroll events to their scroll containers as well
as appropriately sizing "page up" and "page down" scroll deltas.

This change means that when you use the keyboard to scroll, the focused
or most recently clicked `<iframe>` or overflow scroll container is
scrolled, rather than the main frame.

In addition, when a particular scroll frame is larger than its content
in the axis of the scroll, the scrolling operation is chained to
the parent (as in other browsers). One exception is for `<iframe>`s,
which will be implemented in a followup change.

Testing: automated tests runnable locally with `mach test-wpt --product
servodriver`

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-09-23 20:35:08 +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
Martin Robinson
c63311af02 script: Remove absolute positioning workaround from scrollIntoView implementation (#39441)
This isn't needed as the border box query already takes into account the
containing block chain. Instead, consistently calculate the new
scroll position for a scroller relative to its current scroll offset.

In addition, fix a small bug where the border of a scroll container was
considered part of scrollport.

Testing: A new WPT test is added.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-09-23 10:10:00 +00:00
Simon Wülker
1898a740a8 script: Use xpath ns resolver to resolve namespace prefixes (#39321)
The xpath resolver is a function provided by the user to resolve
namespace prefixes. Previously, we were ignoring the argument.

Testing: New web platform tests start to pass
Part of https://github.com/servo/servo/issues/34527

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-16 17:25:45 +00:00
Narfinger
22dcc8a49d Get the Rc to the custom_reaction_stack outside the loop instead of using the thread_local inside. (#39310)
This uses the ScriptThread::custom_element_reaction_stack to call the
enqueue_callback_reaction on the Rc instead of in the loop.
Potentially saving access to thread_local variables.


Testing: Should not change functionality and should be covered by wpt
tests.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-16 01:51:13 +00:00
Martin Robinson
2fc816d561 script: Make scrollIntoView more similar to the specification (#39094)
Rework the flow of code in `Element:scroll_into_view_with_options` to
more closely follow the specification. This also simplifies the code a
bit and adds some TODOs about future improvements.

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

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-09-02 22:11:02 +00:00
Ashwin Naren
97c8c83cbb script: Add message to SyntaxError (#39056)
Adding an optional message to be attached to a SyntaxError. Unblocks
#39050.

The enum definition of Syntax is now `Syntax(Option<String>)`. Future
PRs should probably add more appropriate messages to some of the
`Syntax(None)`s.

Testing: Just a refactor
Fixes: Partially #39053

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-09-02 05:51:36 +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
Josh Matthews
c97ec1b2fb script: Reduce ScriptThread TLS usage (#38875)
We store a pointer to the ScriptThread singleton for a thread in
thread-local storage. While we don't have yet have profiles pointing to
this TLS access as a hot spot, we can remove a potential performance
footgun without a lot of effort by passing around small pieces of data
that we otherwise need to fetch from the ScriptThread.

Testing: Existing WPT is sufficient
Fixes: part of #37969

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-08-30 16:51:40 +00:00
Euclid Ye
3ac226e841 script: Support decomposing ShadowRoot from mozjs HandleValue (#38984)
- Add `ShadowRoot` to `JSValue` to avoid
`WebDriverJSError::UnknownType`, and
`JavaScriptEvaluationError::SerializationError` when execute JS from
embedder.
- Add unit test.
- Move [is_detached](https://w3c.github.io/webdriver/#dfn-is-detached)
to `fn is_detached` to be reused.
- Other random simplification.

Testing: WebDriver conformance tests.

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
2025-08-28 04:31:06 +00:00
Jo Steven Novaryo
10ca3b6fde layout: Parameterize content box query (#38935)
Parameterize and rename both `Layout::content_box_query` and
`Layout::content_boxes_query` to support the query of rendered padding
area and content area that accounts for transform and scroll. Both of
these query have been misleading for a time since they are using border
box, instead of content box of a Node.

This PR adds a new type `layout_api::BoxAreaType` to be passed from
`ScriptThread` to `LayoutThread` to query the respective area. It is
then used for the query within `IntersectionObserver` to pass several
WPTs.

Testing: Existing WPT Coverage.

---------

Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
2025-08-27 02:27:53 +00:00
Tim van der Lippe
10ac177aa5 Propagate Trusted Types errors for Node.textContent (#38871)
Part of #36258

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-08-22 19:41:50 +00:00
Tim van der Lippe
3c89763b77 Implement trusted types for remaining attribute sinks (#38784)
Additionally, several methods were updated with
spec comments. That's because the "adopt the document
from the element document" step was missing.

By adding these spec comments, I also restructured
some code to avoid duplication of mutation records
and custom element reaction queueing.

Node.textContent doesn't propagate the error yet,
as that method has a lot of separate callers of
elements that wouldn't fail. I will refactor those
in a follow-up PR to keep things manageable.

This implements part of the DOM integration from
https://github.com/whatwg/dom/pull/1268

Part of #36258

---------

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
2025-08-21 05:37:34 +00:00
webbeef
3225d19907 cargo: Bump rustc to 1.89 (#36818)
Update Rustc to 1.89.

Reviewable by commit.

Leftover work:
- #37330 
- #38777

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Co-authored-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-08-19 11:07:53 +00:00
Mukilan Thiyagarajan
4c05758ded script: support inline SVG by serializing the subtree (#38188)
This patch adds support for rendering static inline SVG documents in the
DOM tree by serializing the SVGElement's subtree and leveraging the
existing resvg based SVG stack for rendering. Serialiing the subtree is
necessary as resvg's tree representation (roxmltree) is immutable, so we
can't construct the tree incrementally.

Few other design choices here:
1. The `SVGSVGElement` is now treated as a replaced element and the
   layout code is responsible for plumbing the serialized SVG source
   (encoded as a base64 data: url) into the image cache, much like how
   background images are handled.
2. The serialization is done on the script thread after an initial
   layout pass. This is necessary because the serialization code asserts
that it is invoked from script thread i.e we can't call it from layout
   workers.
3. The serialized SVG data: url is cached to avoid recomputing it on
   subsequent layouts. The cache is invalidated when the SVGSVGElement's
   subtree is mutated.

The original SVGSVGElement code was behind the `dom_svg_enabled` pref.
This patch also removes the preference and make SVG support using resvg
available unconditionally.

Below is the analysis of the new test failures:

These tests use inline SVG but used to pass by accident.
They now fail because they contain SVG with no intrinsic
sizing which is not handled by resvg in a way that would
allows us to distinguish it from the sized case. The same
limitation applies to non-inline SVG.

 - /css/CSS2/positioning/absolute-replaced-width-003a.xht
 - /css/CSS2/positioning/absolute-replaced-width-003b.xht
 - /css/CSS2/positioning/absolute-replaced-width-003c.xht

These tests employ CSS styles in the HTML that
target the elements in inline SVG, which is not currently
supported.

-
/css/compositing/mix-blend-mode/mix-blend-mode-plus-lighter-svg-basic.html
 - /css/compositing/mix-blend-mode/mix-blend-mode-plus-lighter-svg.html

This is a tentative test that uses the unsupported 'border-shape' CSS
property. The ref uses SVG, so it used to pass accidentally. The ref
still doesn't render correctly since it also relies on styling SVG
elements using CSS classes in the HTML (instead of inline in SVG).

 - /css/css-borders/tentative/border-shape/border-shape-stroke.html

These tests use the attribute 'clip-path=circle(...)' in the
test, but this doesn't seem to work in resvg.

 - /css/css-masking/clip-path/clip-path-borderBox-1b.html
 - /css/css-masking/clip-path/clip-path-contentBox-1b.html
 - /css/css-masking/clip-path/clip-path-contentBox-1c.html
 - /css/css-masking/clip-path/clip-path-fillBox-1b.html
 - /css/css-masking/clip-path/clip-path-marginBox-1a.html
 - /css/css-masking/clip-path/clip-path-paddingBox-1b.html
 - /css/css-masking/clip-path/clip-path-strokeBox-1b.html
 - /css/css-masking/clip-path/clip-path-strokeBox-1c.html
 - /css/css-masking/clip-path/clip-path-viewBox-1a.html
 - /css/css-masking/clip-path/clip-path-viewBox-1b.html
 - /css/css-masking/clip-path/clip-path-viewBox-1d.html
 - /css/css-masking/clip-path/svg-clip-path-circle-offset.html
 - /css/css-masking/clip-path/svg-clip-path-ellipse-offset.html

Additionally, the below two tests use a `foreignObject` SVG element
which
embeds a html div fragment. This is also not supported by resvg.

 - /css/css-masking/clip-path/clip-path-viewBox-1d.html
 - /css/css-masking/clip-path/clip-path-fillBox-1b.html

The following test fails because of apparent pixel differences
between a circle rendered purely using CSS clip-path vs a circle
rendered in SVG using resvg.

 - /css/css-masking/clip-path/clip-path-contentBox-1c.html

These tests style the inline SVG elements using CSS in the HTML or
separate stylesheet. This is not supported by this implementation.

 - /css-transforms/document-styles/svg-document-styles-{001..004}.html
 - /css-transforms/document-styles/svg-document-styles-012.html
 - /css-transforms/external-styles/svg-external-styles-{001..004}.html
 - /css-transforms/external-styles/svg-external-styles-014.html

These tests seem like they should pass, but they fail because of what
seems like an anti-aliasing issue in the rendering engine. The
transformed element has a thin outline which is causing pixel difference
with the ref:

 - /css/css-transforms/group/svg-transform-group-008.html
 - /css/css-transforms/group/svg-transform-group-009.html
 - /css/css-transforms/group/svg-transform-nested-009.html
 - /css/css-transforms/group/svg-transform-nested-013.html
 - /css/css-transforms/group/svg-transform-nested-014.html
 - /css/css-transforms/group/svg-transform-nested-018.html
 - /css/css-transforms/group/svg-transform-nested-019.html
 - /css/css-transforms/group/svg-transform-nested-008.html

The below tests fail because resvg is calculating the wrong size for the
'rect' inside the SVG. The dimensions of the SVG are established via the
CSS in the HTML, so it seems resvg is using incorrect coordinates for
the children of the svg when explict width/height are not specified in
the root svg element.

 - /css/css-transforms/group/svg-transform-group-011.html
 - /css/css-transforms/group/svg-transform-nested-021.html
 - /css/css-transforms/group/svg-transform-nested-029.html

All these tests use an SVG that doesn't have width nor height attributes
and this causes resvg to use incorrect coordinates for the SVG's
children. In addition, the following tests use the CSS syntax for
transforms inside the SVG (using style attribute) which is not supported
by resvg (it only supports the SVG 1.1 transform syntax).

 - /css/css-transforms/inline-styles/svg-inline-styles-{001..004}.html
 - /css/css-transforms/inline-styles/svg-inline-styles-012.html

In the case of these four tests, the `style` attribute specifies an
invalid transform, but resvg doesn't fallback to the transform specified
via the `transform`  attribute on the same element.

 - /css/css-transforms/inline-styles/svg-inline-styles-005.html
 - /css/css-transforms/inline-styles/svg-inline-styles-006.html
 - /css/css-transforms/inline-styles/svg-inline-styles-010.html
 - /css/css-transforms/inline-styles/svg-inline-styles-013.html

The following test fails because of the lack of width/height in SVG as
described above but it also exposes gaps in our CSS tranform
implementation.

 - /css/css-transforms/preserve3d-and-filter-with-perspective.html

These tests failure because resvg doesn't handle the SVG without
explicit width and height, but specified via CSS in the HTML. In
addition, there are pixel differences between the ref due to
antialiasing issues.

 - /css/css-transforms/matrix/svg-matrix-{005...008}.html
 - /css/css-transforms/matrix/svg-matrix-010.html
 - /css/css-transforms/matrix/svg-matrix-012.html
 - /css/css-transforms/matrix/svg-matrix-{015..069}.html
 - /css/css-transforms/rotate/svg-rotate-angle-45-001.html
 - /css/css-transforms/rotate/svg-rotate-angle-45-011.html
 - /css/css-transforms/rotate/svg-rotate-angle-45-022.html
 - /css/css-transforms/scale/svg-scale-006.html
 - /css/css-transforms/scale/svg-scale-007.html

These tests seem to be failing due to some sort of antialiasing issue,
where a transformed SVG element has a thin border that causes pixel
differences compared to the solid colored reference.

 - /css/css-transforms/skewX/svg-skewx-001.html
 - /css/css-transforms/skewX/svg-skewx-006.html
 - /css/css-transforms/skewX/svg-skewx-011.html
 - /css/css-transforms/skewX/svg-skewx-016.html
 - /css/css-transforms/skewX/svg-skewx-021.html
 - /css/css-transforms/skewX/svg-skewxy-001.html
 - /css/css-transforms/skewY/svg-skewy-001.html
 - /css/css-transforms/skewY/svg-skewy-006.html
 - /css/css-transforms/skewY/svg-skewy-011.html
 - /css/css-transforms/skewY/svg-skewy-016.html
 - /css/css-transforms/skewY/svg-skewy-021.html

These tests specify several SVG attributes such as transform,
vector-effect etc via CSS in the HTML (rather than inline in SVG). The
current implementation doesn't support this.

 - /css/css-transforms/transform-box/stroke-box-mutation-001.html
 - /css/css-transforms/transform-box/stroke-box-mutation-002.html
 - /css/css-transforms/transform-box/stroke-box-mutation-003.html
 - /css/css-transforms/transform-box/stroke-box-mutation-004.html
 - /css/css-transforms/transform-box/svgbox-stroke-box-002.html
 - /css/css-transforms/transform-box/svgbox-stroke-box-003.html
 - /css/css-transforms/transform-box/svgbox-stroke-box-004.html
 - /css/css-transforms/transform-box/svgbox-stroke-box-005.html

These tests depend on 'transform-origin' specified on an element inside
an SVG, but this transform is influenced by the 'tranform-box' set via
CSS in the HTML itself (not the SVG). The current implementation doesn't
support styling the SVG using document styles, so these tests just fail.

- /css/css-transforms/transform-origin/svg-origin-relative-length-*.html

These tests check the fallback behaviour when invalid syntax is
encountered in the 'transform-origin' value. resvg doesn't correctly
fallback to 0,0 causing the tests to fail.

-
/css/css-transforms/transform-origin/svg-origin-relative-length-invalid-001.html
-
/css/css-transforms/transform-origin/svg-origin-relative-length-invalid-002.html
-
/css/css-transforms/transform-origin/svg-origin-relative-length-invalid-003.html
-
/css/css-transforms/transform-origin/svg-origin-relative-length-invalid-004.html

These tests use unimplemented Canvas APIs like 'beginLayer' and
the 'CanvasFilter' constructor and hence fail at runtime.

-
/html/canvas/element/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.html
-
/html/canvas/element/filters/2d.filter.layers.gaussianBlur.tentative.html
-
/html/canvas/element/layers/2d.layer.anisotropic-blur.isotropic.tentative.html
-
/html/canvas/element/layers/2d.layer.anisotropic-blur.mostly-x.tentative.html
-
/html/canvas/element/layers/2d.layer.anisotropic-blur.mostly-y.tentative.html
-
/html/canvas/element/layers/2d.layer.anisotropic-blur.x-only.tentative.html
-
/html/canvas/element/layers/2d.layer.anisotropic-blur.y-only.tentative.html
-
/html/canvas/element/layers/2d.layer.css-filters.blur-and-shadow.tentative.html
 - /html/canvas/element/layers/2d.layer.css-filters.blur.tentative.html
- /html/canvas/element/layers/2d.layer.css-filters.shadow.tentative.html
 - /html/canvas/element/layers/2d.layer.ctm.layer-filter.tentative.html
-
/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.dropShadow.tentative.html
-
/html/canvas/offscreen/filters/2d.filter.canvasFilterObject.gaussianBlur.tentative.html
-
/html/canvas/offscreen/filters/2d.filter.layers.dropShadow.tentative.html
-
/html/canvas/offscreen/filters/2d.filter.layers.gaussianBlur.tentative.html
-
/html/canvas/offscreen/layers/2d.layer.anisotropic-blur.isotropic.tentative.html
-
/html/canvas/offscreen/layers/2d.layer.anisotropic-blur.mostly-x.tentative.html
-
/html/canvas/offscreen/layers/2d.layer.anisotropic-blur.mostly-y.tentative.html
-
/html/canvas/offscreen/layers/2d.layer.anisotropic-blur.x-only.tentative.html
-
/html/canvas/offscreen/layers/2d.layer.anisotropic-blur.y-only.tentative.html
-
/html/canvas/offscreen/layers/2d.layer.css-filters.blur-and-shadow.tentative.html
- /html/canvas/offscreen/layers/2d.layer.css-filters.blur.tentative.html
-
/html/canvas/offscreen/layers/2d.layer.css-filters.shadow.tentative.html
- /html/canvas/offscreen/layers/2d.layer.ctm.layer-filter.tentative.html

These tests fail because resvg doesn't seem to honour the 'translate'
CSS property specified on an SVG element using an inline 'style'
attribute.

 - /css/css-transforms/translate/svg-translate-with-units.html
-
/css/css-transforms/translate/translate-and-transform-attribute-in-svg.html
-
/css/css-transforms/translate/translate-and-transform-css-property-in-svg.html
 - /css/css-transforms/translate/translate-in-svg.html

These tests seem to fail due to the filter effect implementation in
resvg either not being complete or spec compliant.

 - /css/filter-effects/feconvolve-divisor.html
 - /css/filter-effects/feconvolve-region-001.html
 - /css/filter-effects/feconvolve-region-002.html
 - /css/filter-effects/filter-subregion-01.html
 - /css/filter-effects/svg-feimage-002.html
 - /css/filter-effects/svg-feimage-003.html
 - /css/filter-effects/svg-feimage-004.html
 - /css/filter-effects/svg-feoffset-001.html

The test /css/filter-effects/svg-feimage-004.html should ideally PASS
but currently fails because we don't propagate height/width set using
CSS in HTML element to the root SVG, so resvg uses the wrong dimensions
when rendering the children of the SVG.

These failures are due to deficienies in our current implementation
i.e we don't support styling SVG elements using CSS in HTML.

-
/css/css-transforms/gradientTransform/svg-gradientTransform-combination-001.html
 - /css/selectors/sharing-in-svg-use.html

The below test fails as our current implementation relies on resvg to
tell us the intrinsic ratio of the SVG, but this doesn't always work
correctly.

 - /css/css-sizing/svg-intrinsic-size-005.html

This failure is due to lack of proper fallback to no-op transform in
resvg when the `rotate()` syntax is specified with an invalid list e.g
`rotate(90,)`.

 - /css/css-transforms/rotate/svg-rotate-3args-invalid-002.html

This test only passes in CI and based on the raw log output, it seems
that no text inside the SVG is rendered in the CI. This could be an font
stack related issue.

 - /css/css-display/display-contents-svg-elements.html

This test asserts that the CSP blocks loads triggered using `use`
elements in SVG. It used to TIMEOUT as without inline SVG support, no
CSP violation event was triggered. It fails now since the event is now
triggered for the load of the SVG itself (our current implementation
loads inline SVGs as serialized base64 data: urls). This doesn't match
the blocked URL in the use element though.

 - /content-security-policy/img-src/svg-use-blocked.tentative.html

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-08-11 11:07:59 +00:00
Simon Wülker
4d7a0d3863 script: Tell devtools whether a node is displayed or not (#38575)
Doing so makes the devtools inspector display the nodes in gray, as it
is the case in firefox.
The relevant node parameter already exists but is hardcoded.

Before:
<img width="1108" height="408" alt="image"
src="https://github.com/user-attachments/assets/4a442fc9-92db-4a97-9e70-3b02f994a9d1"
/>


After:
<img width="1169" height="404" alt="image"
src="https://github.com/user-attachments/assets/ec1674a4-c025-4ceb-93c8-0cc3f695ddc7"
/>


Testing: We don't have tests for the devtools inspector.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-08-09 18:12:20 +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
Euclid Ye
56033d844a script: Rename some parent to child (#38498)
I believe there was some code migration but name's not been changed.

Testing: No behaviour change.

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
2025-08-06 17:39:38 +00:00
Martin Robinson
44a11a7c6c script/layout: Ensure a StackingContextTree before IntersectionObserver geometry queries (#38473)
IntersectionObserver needs to be able to query node geometry without
forcing a layout. A previous layout could have run without needing a
`StackingContextTree`. In that case the layout-less query should finish
building the `StackingContextTree` before doing the query.  Add a new
type of layout API which requests that layout finishes building the
StackingContextTree.

This change also slightly simplifies and corrects the naming of
`Element` APIs around client box queries.

Testing: This should fix intermittent failures in WPT tests.
Fixes: #38380.
Fixes: #38390.
Closes: #38400.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-08-06 13:46:43 +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
6cd8578f8b dom: Textual Input UA Shadow Dom (#37527)
Depend on: 
- https://github.com/servo/servo/pull/37427
- https://github.com/servo/servo/pull/37483

Utilize input `type=text` for the display of all textual input. In
which, consist of
https://html.spec.whatwg.org/#the-input-element-as-a-text-entry-widget
and
https://html.spec.whatwg.org/#the-input-element-as-domain-specific-widgets
inputs.

For `password`, `url`, `tel`, and, `email` input, the appearance of
input container is exactly the same as the `text` input. Other types of
textual input simply extends `text` input by adding extra components
inside the container.

Testing: Servo textual input appearance WPT.

---------

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
2025-07-25 04:38:14 +00:00