Commit graph

28974 commits

Author SHA1 Message Date
sagudev
056b1538c0
canvas: Add vello_cpu backend (#38282)
vello_cpu does not have any tests timeouts, because we do not need
download stuff from GPU as all work happens on CPU. So performance wise
it's better then classic vello at least for our usecase. There are some
vello bugs, but I think we will be able to sort them out within
upstream, eventually. Interestingly enough there are no new PASS like
they were with classic vello.

Difference with raqote can be observed here:
https://github.com/sagudev/servo/actions/runs/16549241085/attempts/1#summary-46802486798

## Known vello problems:

- https://github.com/linebender/vello/issues/1119
- https://github.com/linebender/vello/issues/1056
-
`/html/canvas/element/fill-and-stroke-styles/2d.gradient.interpolate.coloralpha.html`
- `kurbo::Cap::Butt` is defect (only visible with big lineWidth)
https://github.com/linebender/vello/issues/1063
  - `/html/canvas/element/line-styles/2d.line.cross.html`
  - `/html/canvas/element/line-styles/2d.line.miter.acute.html`
- other lack of strong correct problems
(https://github.com/linebender/vello/issues/1063#issuecomment-2998084736):
  - `/html/canvas/element/path-objects/2d.path.rect.selfintersect.html`
- `putImageData(getImageData(...), ...)` is lossy (precision problems,
might be due to ImageData being unmultiplied)
-
`/html/canvas/element/pixel-manipulation/2d.imageData.put.unchanged.html`

Testing: Tested using vello_cpu_canvas subsuite

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-27 19:56:38 +00:00
Kingsley Yung
ab6e151c89
script_binding: wrapper of JSAutoStructuredCloneBuffer (#38284)
Instead of using raw pointer of JSAutoStructuredCloneBuffer, use its
wrapper JSAutoStructuredCloneBufferWrapper, which implements the Drop
trait that can prevent leakage when structured cloning fails.

Testing: Refactoring. Existing tests should be enough.
Fixes: #37966

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-07-27 12:41:02 +00:00
Oriol Brufau
9614fb997a
layout: Inline {default,natural}_{inline,block}_size methods (#38276)
They only had one caller.

Testing: Unnecessary (no behavior change)

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-07-26 17:40:01 +00:00
sagudev
bc71fb8c0d
canvas: Respect FillRule (#38294)
We just need to pass user provided FillRule via IPC to canvas paint
thread, then pass it all down to backend, which will handle it.

Testing: Added WPT tests.

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-26 17:20:04 +00:00
Ashwin Naren
4188852963
script: Don't panic on IndexedDB put operation structured clone (#38280)
Fixes panic by rethrowing exceptions.

Testing: Covered by WPT
Fixes: #38075

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-07-26 16:35:10 +00:00
Ashwin Naren
e1bda86861
script: Implement converting values to indexeddb key ranges (#38278)
Implements
https://www.w3.org/TR/IndexedDB-2/#convert-a-value-to-a-key-range. Part
of #38187.

Testing: Currently unused, doesn't change anything
Fixes: None

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-07-26 13:20:52 +00:00
sagudev
f8d6c5646c
canvas: Use bytemuck to remove unsafe from raqote backend (#38283)
This PR changes surface type from `Vec<u8>` to `Vec<u32>` as this is
native type of raqote's backend. We used unsafe for `Vec<u8>` <->
`Vec<u32>` casting that is replaced with bytemuck. Bytemuck is already
in cargo lock.

Testing: Existing WPT tests.

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-26 13:16:16 +00:00
sagudev
daebb5a033
canvas: Move peniko/kurbo conversions in separate file (#38279)
This will allow reusing those conversions in vello_cpu backend.

Testing: Just refactor

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-26 13:14:25 +00:00
Kingsley Yung
4d899ecba5
webdriver: configure Expires and SameSite in handle_add_cookie (#38285)
Handler::handle_add_cookie did not configure the attributes "Expires"
and "SameSite". This patch adds them.

Testing: Passing WPT tests that were expected to fail.
Fixes: https://github.com/servo/servo/pull/37715#issuecomment-3069734014

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-07-26 12:23:24 +00:00
Euclid Ye
a3de3ffa75
webdriver: Implement maximize window for both headless&headed window (#38271)
- Implement [Maximize
Window](https://w3c.github.io/webdriver/#maximize-window)
- Previously, headless window screen size is same as inner size if not
specified in preference. We make it double as required by the test to
not have max window initially.
- Some other random cleanup.

Testing: webdriver Stress test for maximize window (headed + headless).

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
2025-07-26 12:21:17 +00:00
JoeDow
9ef4d0c9d7
layout: Correctly marking box damage when text-related style changed (#38059)
This change aims to supplement the missing incremental box tree
construction when text-related styles change. Since certain text style
adjustments can alter visible text content and typography. Therefore,
the parent nodes of such text are marked as needing to re-collect their
box tree children to ensure the correct display of text.

Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
2025-07-26 11:50:13 +00:00
sagudev
d678901122
canvas: Add vello backend (#36821)
Add vello backend by implementing Backend traits in canvas crate (so
this lives in canvas_paint_thread - embedded process). Current
implementation uses normal wgpu, so we block on GPU work. Vello backend
is gated behind `vello` feature and `dom_canvas_vello_enabled` pref.

Feature-wise this backend is on on par with raqote (sometimes better
sometimes worse), but performance wise it's worse.

## Known vello problems:

- image roundtrip does not work (fixed in
https://github.com/linebender/vello/pull/974)
- https://github.com/linebender/vello/issues/1066 (fixed)
- clip layers are not working properly:
https://github.com/linebender/vello/issues/1061
  - `/html/canvas/element/pixel-manipulation/2d.imageData.put.*`
  - `/html/canvas/element/path-objects/2d.path.clip.intersect.html`
- https://github.com/linebender/vello/issues/1056
-
`/html/canvas/element/fill-and-stroke-styles/2d.gradient.interpolate.coloralpha.html`
- `kurbo::Cap::Butt` is defect (only visible with big lineWidth)
https://github.com/linebender/vello/issues/1063
  - `/html/canvas/element/line-styles/2d.line.cross.html`
  - `/html/canvas/element/line-styles/2d.line.miter.acute.html`
- other lack of strong correct problems
(https://github.com/linebender/vello/issues/1063#issuecomment-2998084736):
  - `/html/canvas/element/path-objects/2d.path.rect.selfintersect.html`
- There is currently no way to do put image properly in vello as we
would need to ignore all clips and other stuff (we try to work around
this on best effort basis)
https://github.com/linebender/vello/issues/1088
  - `/html/canvas/element/pixel-manipulation/2d.imageData.put.*`
- precision problems
  - `/html/canvas/element/path-objects/2d.path.stroke.scale2.html`
  - `/html/canvas/element/path-objects/2d.path.arc.scale.1.html`

## Known servo problems

- bad performance due to blocking on GPU work
  - some get/put intensive tests `TIMEOUT`
- proper shadow support (non-blocker as we already are living without it
now)
- support for rect shadow is there but unimplemented currently as that's
the state in raqote

Testing: `mach try vello` will run normal WPT (with raqote) +
vello_canvas subsuite that runs only on `/html/canvas/element`. All
subsuite expectations are stored separately.
Fixes: #36823
Fixes: #35230

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-26 04:53:10 +00:00
Ashwin Naren
c2ed599eb1
script: implement IDBKeyRange (#38268)
#37684 provided the backend for this change. The key range interface
just wraps a `IndexedDBKeyRange` and exposes the methods from it as per
the spec.

Spec: https://www.w3.org/TR/IndexedDB-2/#keyrange
Testing: WPT tests (some regressions have been exposed, but that's fine)

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2025-07-26 02:59:15 +00:00
sagudev
8b2a5fca54
canvas: Make GetImageData simple and only IPC message to obtain pixels (#38274)
Currently we had `GetImageData` and `SendPixels` to obtain pixels from
script thread. This PR unifies those into single `GetImageData` that
does not need canvas size and has optional rect (for obtaining sub
image).

Testing: Existing WPT tests

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-26 02:28:52 +00:00
sagudev
fc0038743d
canvas: Make pixel obtaining methods take &mut GenericDrawTarget (#38264)
This will be needed for vello_cpu. While we could wrap it in RefCell for
inner mut, but that would be less ergonomic and performant.

Testing: Just refactoring, but the code is covered by WPT tests.

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-25 13:22:41 +00:00
JoeDow
9d29017c0d
layout: optimize the propagation and cleanup of RestyleDamage (#38199)
This change optimizes `RestyleDamage` propagation and cleanup to reduce
unnecessary box reconstruction and relayouts, while preventing damage
from the current reflow affecting subsequent ones. Improvements include:
- For box damage caused by `NodeDamage`, `RestyleDamage::RELAYOUT` is no
longer marked immediately—avoiding erroneous propagation of
`LayoutDamage::RECOLLECT_BOX_TREE_CHILDREN` to descendants during
`RestyleDamage` propagation.
- Clearing damage for nodes whose boxes will be preserved, preventing it
from carrying over to the next reflow and increasing its workload.

Testing: This should not change observable behavior and is thus covered
by existing WPT tests. Although Servo lacks performance test cases,
manual testing shows that this modification reduces reflow time by
nearly 250ms, representing a decrease of approximately 25%.

Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
2025-07-25 12:10:16 +00:00
sagudev
420a5a64a7
canvas: Remove Backend trait (#38262)
After #38214 `Backend` trait is only used as DrawTarget builder and as
type holder. By moving types and DrawTarget creation into
`GenericDrawTarget` trait, we can completely remove `Backend` trait.

Testing: Just refactor, but code is covered by WPT tests.

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-25 12:05:03 +00:00
JoeDow
5cd57f9dba
layout: Add incremental box tree construction for inline boxes (#38084)
This changes extend the incremental box tree construction for inline
boxes. Since an `InlineItem` can be split into multiple `InlineItem`s by
a block element, the reason such an inline item is marked as damaged may
simply be the removal of the block element or the need to reconstruct
its box tree. Therefore, under the current LayoutDamage design,
theoretically, even damaged inline items might still have some of their
splits reusable. However, based on the principle of simplicity and
effectiveness, this PR only considers reusing undamaged inline boxes.

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

Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
2025-07-25 11:49:46 +00:00
Ashwin Naren
3f1e170410
script: Update indexeddb serialization (#38269)
- Dates are now serialized as f64s (like how firefox does it)
- Array buffers are serialized with structured cloning (this is not the
most correct/efficent way to serialize them, however it is currently
better than not supporting array buffers at all)
- Array types are still unimplemented.

Testing: WPT
Fixes: Some panicking

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-07-25 11:11:22 +00:00
Kenzie Raditya Tirtarahardja
165ede59cd
script(webdriver): Send keys set caret at the end of content of text input (#38250)
Remote end step of [element send
keys](https://w3c.github.io/webdriver/#element-send-keys)

> Step 8.2. Set the text insertion caret using [set selection
range](https://w3c.github.io/webdriver/#dfn-set-selection-range) using
current text length for both the start and end parameters.

Also check if the element is already an active element before focusing
(Step 7.7).

Testing:
`./tests/wpt/tests/webdriver/tests/classic/element_send_keys/form_controls.py`

---------

Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
Signed-off-by: Kenzie Raditya Tirtarahardja <kenzieradityatirtarahardja18@gmail.com>
Co-authored-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-07-25 07:24:48 +00:00
Ashwin Naren
ab78a76da6
script: Implement IDBFactory.cmp (#38260)
Implements `IDBFactory.cmp`, most of the work was done by #38123.

Testing: Covered by WPT (lots of flaky results: the appropriate tests
are in tests/wpt/meta/IndexedDB/idlharness.any.js.ini)
Fixes: None

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-07-25 05:29:10 +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
Jo Steven Novaryo
1d896699a4
script: Implement CSSStyleSheet.replace (#38244)
Implement `CSSStyleSheet.replace`
[#dom-cssstylesheet-replace](https://drafts.csswg.org/cssom/#dom-cssstylesheet-replace)
with disallow modification flag
[#concept-css-style-sheet-disallow-modification-flag](https://drafts.csswg.org/cssom/#concept-css-style-sheet-disallow-modification-flag).

Basically it would behave like `replaceSync`, but we are running it
asynchronously.

Testing: Existing WPT coverage.
Part of: https://github.com/servo/servo/issues/36162

---------

Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
2025-07-25 03:05:22 +00:00
sagudev
d39e701b46
canvas: Fully stateless backend (#38214)
I think this simplifies canvas backends greatly. Before there were many
(needless) hoops from abstract to concrete (backend) and back, now we
can do most stuff on abstract types.

Testing: Existing WPT tests
Fixes: #38022 

try run: https://github.com/sagudev/servo/actions/runs/16450978211

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-24 18:11:29 +00:00
Kenzie Raditya Tirtarahardja
4b12ae73fe
webdriver: Implement element clear (#38208)
Initial Implementation of [Element
Clear](https://w3c.github.io/webdriver/#element-clear).

Testing: `tests/wpt/tests/webdriver/tests/classic/element_clear/`

---------

Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
Signed-off-by: Kenzie Raditya Tirtarahardja <kenzieradityatirtarahardja18@gmail.com>
Co-authored-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2025-07-24 17:49:31 +00:00
Jo Steven Novaryo
1fb782bc38
script: Batch scroll event firing (#38222)
The user interaction triggered `scroll` event was initially implemented
in https://github.com/servo/servo/pull/36687.

In triggering the `scroll` event, the event should be batched and
triggered within update the rendering. This serves as a preparatory PR
for the JS API triggered `scroll` event.

Part of: #31665

---------

Signed-off-by: Jo Steven Novaryo <jo.steven.novaryo@huawei.com>
2025-07-24 17:48:12 +00:00
leo030303
5592061474
Add dimension source attribute to HTMLImageElement (#38152)
HTMLImageElement was missing the dimension source attribute, as step 9
from
[here](https://html.spec.whatwg.org/multipage/images.html#updating-the-source-set)
wasn't implemented. This meant that for an element like this:
```html
<picture>
  <source media="(min-width: 1000px)"
    srcset=""
    width="84" height="29">
  <img
    src=""
    width="25" height="25" alt="Wikimedia Foundation" lang="en" loading="lazy">
</picture>
```

The `width` and `height` attributes of the source tag were being
ignored. This broke stuff like these icons on the main page of
Wikipedia.

**Original:**
<img width="2252" height="229" alt="image"
src="https://github.com/user-attachments/assets/fa3fdd9d-5f91-43d4-bc9d-784b0a836d44"
/>


**Fixed:**
<img width="2252" height="229" alt="image"
src="https://github.com/user-attachments/assets/6f4ca4ae-e764-4394-ac31-9a92bbb456ab"
/>


Testing: If there isn't an existing test that covers this I'll make one,
waiting for the github runner to tell me whether this is covered and
then I'll amend the PR

---------

Signed-off-by: Leo Ring <leoring03@gmail.com>
Signed-off-by: Xiaocheng Hu <hu.xiaocheng@huawei.com>
Signed-off-by: Xiaocheng Hu <xiaochengh.work@gmail.com>
Co-authored-by: Xiaocheng Hu <hu.xiaocheng@huawei.com>
Co-authored-by: Xiaocheng Hu <xiaochengh.work@gmail.com>
2025-07-24 13:40:44 +00:00
Josh Matthews
be38bd4636
servo: Track async webview focus operations (#38243)
https://github.com/servo/servo/pull/38160 added a webdriver-specific API
to support waiting on focus operations to complete. These changes
replace that with a generalized pattern, where a unique ID is created
for each focus operation and the embedder can receive notifications
about each focus operation when it is complete, regardless of whether
the focus was actually changed.

Testing: Existing test coverage from
https://github.com/servo/servo/pull/38160/ is unchanged.

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-07-24 06:01:11 +00:00
Euclid Ye
0b8986c8da
servoshell: Consider window decorations when handling resize requests from web content (#38174)
Also fix some docs. This is used by JS `resizeTo`, `resizeBy` and
webdriver [set window
rect](https://w3c.github.io/webdriver/#set-window-rect).

Testing: Can now pass more tests for headed window.
Fixes: Well.. Originally the attempt is to address
https://github.com/servo/servo/issues/38093#issuecomment-3092284104. But
it turns out as a more general problem to be fixed in another PR.

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
2025-07-24 05:42:04 +00:00
Shubham Gupta
f62aa8edc2
Rename viewport_zoom to pinch_zoom (#38194)
This change is in accordance with highlighting the usage of various zoom
options.

`pinch_zoom`: `Mobile-style` zoom using pinch gesture
 `page_zoom`: `Desktop-style` zoom (`Ctrl` + `+`/`-`)

It just renames the variable `viewport_zoom` to `pinch_zoom` for better
clarity

Testing: Testing not required, as it's just renaming of variable .

---------

Signed-off-by: Shubham Gupta <shubham13297@gmail.com>
Signed-off-by: Xiaocheng Hu <xiaochengh.work@gmail.com>
Co-authored-by: Xiaocheng Hu <xiaochengh.work@gmail.com>
2025-07-24 05:29:18 +00:00
Kenzie Raditya Tirtarahardja
d95dd69e3c
script(webdriver): Check if element is keyboard interactable in element send keys (#38235)
Step 7.6 of remote end steps of [Element Send
Keys](https://w3c.github.io/webdriver/#element-send-keys)
> If element is not
[keyboard-interactable](https://w3c.github.io/webdriver/#dfn-keyboard-interactable),
return [error](https://w3c.github.io/webdriver/#dfn-error) with [error
code](https://w3c.github.io/webdriver/#dfn-error-code) [element not
interactable](https://w3c.github.io/webdriver/#dfn-element-not-interactable).

---------

Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
2025-07-24 04:32:46 +00:00
Euclid Ye
f726737f24
Reduce redundancy in servoshell webdriver message forwarding and add log for script::handle_send_keys_non_typeable (#38238)
There was a new commit for after
https://github.com/servo/servo/pull/38189#discussion_r2224805172, but
that does not seem to update/stop MQ.
Also removed `forward_webdriver_command` in servoshell according to
https://github.com/servo/servo/pull/38212#discussion_r2221854327.

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
2025-07-24 04:22:04 +00:00
Narfinger
6ace7ad577
OHOS: Clean up some compile warnings (#38240)
This cleans up some compile warnings about unused functions.

Testing: Does not change functionality, OHOS and Linux still compile
(hopefully the other builds too).

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Co-authored-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2025-07-24 03:29:49 +00:00
Euclid Ye
0e4b2bfef0
cargo: Remove unused dependency (#38239)
Remove unused `Cargo.toml` dependency to reduce binary size.

Testing: Can still compile in different platforms.

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
2025-07-23 13:32:50 +00:00
shuppy
52f53f61e1
script: Add support for creating globals in isolated compartments (#38236)
to use the [SpiderMonkey Debugger
API](https://firefox-source-docs.mozilla.org/js/Debugger/), we need to
call it from an internal debugger script that we will supply. this
script must run in the same runtime as the debuggee(s), but in a
separate
[compartment](https://udn.realityripple.com/docs/Mozilla/Projects/SpiderMonkey/Compartments)
([more
details](https://hacks.mozilla.org/2020/03/future-proofing-firefoxs-javascript-debugger-implementation/)).

when creating two globals in the same runtime, Servo will generally try
to reuse an existing compartment for the second global, and there are
other places in script where we rely on this reuse. but for the debugger
script, we can’t do this.

this patch adds a `use_system_compartment` flag to global object
descriptors, which isolates the global in its own compartment in both
possible directions:
- it forces the global to create a new compartment, preventing the reuse
of any debuggee’s compartment
- it fails the check in select_compartment(), preventing future
debuggees from reusing the global’s compartment

Testing: manually tested working in devtools debugger patch (#37667),
where it will undergo automated tests

---------

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
2025-07-23 11:34:37 +00:00
Kenzie Raditya Tirtarahardja
0970a99b7c
webdriver: Implement element send keys command for non-typeable form control (#38189)
Implement Step 8 of remote end steps of [Element Send
keys](https://w3c.github.io/webdriver/#element-send-keys), specifically
for non-typeable form control.

---------

Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
2025-07-23 09:11:44 +00:00
Jo Steven Novaryo
3cb16eb864
Reland Input type=text Shadow DOM With Performance Improvement (#37483)
Depends on #37427.

In addition to the changes introduced by
https://github.com/servo/servo/pull/37065, there are several performance
improvements and nits as follows:
- Use the internal pseudo element for style matching, this will reduce
the performance regression by ~66%.
- Manual construction of the `Text` node inside a text container. This
is followed by the modification of the inner `Text` node instead of
using `SetTextContent` which is more expensive.
- Use `implemented_pseudo_element` instead of
`text_control_inner_editor` `NodeFlag` to handle the special cases that
these elements should follow, specifically the:
  - focus delegation workaround;
  - selections; and
  - line height resolving.
- More documentation.

Servo's side of: https://github.com/servo/stylo/pull/217

Testing: No new unexpected WPT failure, except for the one introduced by
https://github.com/servo/servo/pull/37065/.
Fixes: #36307 #37205

---------

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
2025-07-23 09:08:24 +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
Euclid Ye
d2e5137201
constellation: Eliminate long-standing inactive code path for WebDriverData (#38221)
Cleaning up some dead code which has been here for 9 years. They are
never detected by Lint because we still initialize them as `None` but
never change afterwards.

Testing: No regression.

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-07-23 06:50:20 +00:00
JoeDow
b8a1df2bc2
script: Use NodeDamage::ContentOrHeritage for slot changes (#38198)
This change aims to reduce the scope of incremental box tree
construction. Previously, when children of slot node changed, the slot
would always be marked as requiring box tree reconstruction; now, it is
adjusted to only mark the slot node as needing to recollect its box tree
children.

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

Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
2025-07-23 03:36:32 +00:00
Euclid Ye
4ff6b1d4a7
Implement setting position through webdriver for headed window (#38209)
Previously, we pretend we are able to set position in response. Now we
can really do it.

Testing: Able to set position accurately when tested locally.
Fixes: Task 5 of #37804.

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
2025-07-22 18:26:37 +00:00
Kenzie Raditya Tirtarahardja
9e29ca2047
WebDriver: Will Send Keys add documentation and modularize input file (#38165)
Add comment for better documentation of `will_send_keys` and extract
file input handling to a function.

Testing: No behaviour change

---------

Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
2025-07-22 17:30:22 +00:00
sagudev
cd340fa8b9
canvas: Make script/canvas thread boundry mostly stateless (#38164)
This PR removes all `Set*` commands as we will send needed options on
each request. This will allow us to remove most of state handling from
canvas paint thread (currently it's still stateful).

Testing: Existing WPT tests
work towards #38022

try run: https://github.com/sagudev/servo/actions/runs/16413823963

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-22 12:30:15 +00:00
JoeDow
8a1cc69717
Layout: minor optimizations and bugfix for non-functional details (#38197)
This change adds some minor optimizations and bugfix for non-functional
details with seperated commits:
- fix the omission that stop use `Rayon` in single-thread mode
- add trace for incremental box tree construction
- fix the bug that failed to skip reflow entirely when there is no need
for `restyle` and a fragment tree has already been built.
- add trace for stylist preparation during reflow. In certain scenarios,
this phase might take up a significant amount of time, such as when
there are a large number of shadow trees.

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

---------

Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
2025-07-22 10:56:52 +00:00
Euclid Ye
57fc569818
Remove Webdriver Server's access to Constellation (#38212)
`WebDriverCommandMsg::TakeScreenshot` was the last thing blocking us
from removing constellation access in webdriver server. Now we can
happily remove it.

Surprisingly, this reduces binary size by 185KB for release profile in
Windows. #37737 removes a net total of 300 lines, but only reduced 98KB.

Testing: No regression after testing.

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
2025-07-22 10:17:19 +00:00
sagudev
61df7ab127
chore: Update kurbo to 0.11.3 (#38210)
Some of the code we wrote is now also in upstream, mainly
`BezPath.current_position` and euclid types conversions.

Testing: Code is covered by existing WPT tests.

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Co-authored-by: Jonathan Schwender <55576758+jschwe@users.noreply.github.com>
2025-07-22 08:23:13 +00:00
Jonathan Schwender
97f544aa20
dom: Optimize IFrameCollection::validate (#38196)
The `IFrameCollection` was previously rebuilt too often. This PR tries
to address the todo, to only rebuild the IFrameCollection when
necessary.

Testing: `CSS Selector Invalidation: :has() invalidation should not be
O(n^2)` wpt-test changed status from timeout to failed.
Fixes: #38131 (IFrameCollection::validate accounts for 30% of script
time in DOM heavy scenarios)


Co-authored-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2025-07-22 03:54:16 +00:00
Euclid Ye
b0a29393a9
WebDriver: Wait focus to complete when switching window (#38160)
Previously the webdriver do not wait for focus to complete, which can
cause some instability.

No matter interact as human or webdriver, the focus chain always goes
as: Embedder forwards -> Constellation (do some updates) -> Embedder (do
some updates).

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
2025-07-21 04:18:21 +00:00
webbeef
7c96084298
Adjust CSP for top-level image documents (#38186)
Allows loading of document images even when they have a sandbox CSP rule
to align with other browsers.

Testing: No wpt failures:
https://github.com/webbeef/servo/actions/runs/16403138806
Fixes: #38180

Signed-off-by: webbeef <me@webbeef.org>
2025-07-20 21:07:47 +00:00
Tim van der Lippe
e24acc5fe5
Add warning for reporting CSP violations (#38181)
This should help debug cases like #38180

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-07-20 16:06:04 +00:00