Commit graph

11673 commits

Author SHA1 Message Date
sagudev
b799f27817
canvas: Use stored transform instead of querying canvas paint thread (#38097)
We already store transform in context state, so let's just use this when
querying instead of using IPC to ask canvas paint thread.

Testing: Existing WPT tests
work towards #38022

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

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-16 14:59:10 +00:00
Gregory Terzian
b821377771
script: further use of safe to jsval (#38099)
Remove size bound from safe to jsval trait, apply to script/dom, with
the exception of windowproxy.

Second part of https://github.com/servo/servo/issues/37951

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>

*Describe the changes that this pull request makes here. This will be
the commit message.*

Testing: *Describe how this pull request is tested or why it doesn't
require tests*
Fixes: *Link to an issue this pull requests fixes or remove this line if
there is no issue*
2025-07-16 14:46:10 +00:00
Ashwin Naren
71e7019d45
[IndexedDB] Adhere better to the specification for idb object store related operations (#37682)
Many object store related operations require the transaction to be
checked: to ensure it is still active, and, if the operation is a write,
that the transaction is not read-only. I've added the
`check_transaction` method to perform these checks.

Additionally `Clear` was still half-implemented, so I went ahead and
implemented that.

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-07-16 02:11:06 +00:00
webbeef
30b6e289e0
Refactor constellation broadcast channel (#38077)
- Move the 2 hash maps used to manage channels in their own struct.
- The constellation is still in charge of origin checks since it holds
the pipeline information required.
- BroadcastMsg is renamed to BroadcastChannelMsg for consistency.


Testing: covered by existing tests.
Fixes: #38060

Signed-off-by: webbeef <me@webbeef.org>
2025-07-15 13:57:05 +00:00
Andrei Volykhin
c817d7b9ce
canvas: Add initial support of ImageBitmapRenderingContext (#37998)
Add support of the ImageBitmapRenderingContext as "bitmaprenderer"
canvas context mode to RenderingContext/OffscreenRenderingContext
https://html.spec.whatwg.org/multipage/#imagebitmaprenderingcontext

It is initial implementation with public interface API but without
any display presentation support for HTMLCanvasElement.

Testing: Improvements in the following tests:
-
html/canvas/element/manual/imagebitmap/createImageBitmap-origin.sub.html
- html/canvas/offscreen/manual/text/canvas.2d.offscreen*
-
html/canvas/offscreen/manual/the-offscreen-canvas/offscreencanvas.transfer.to.imagebitmap.nocrash.html
- imagebitmap-renderingcontext/*

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-07-15 08:03:49 +00:00
batu_hoang
f155c95e1b
webdriver: Element click waits for navigation complete (#37935)
Step 11 in https://w3c.github.io/webdriver/#dfn-element-click

> [Try](https://w3c.github.io/webdriver/#dfn-try) to [wait for
navigation to
complete](https://w3c.github.io/webdriver/#dfn-wait-for-navigation-to-complete)
with session.

This fixes issue in which element_click triggers navigation, but
incoming commands still interact with old page.

Testing:
https://github.com/longvatrong111/servo/actions/runs/16175767947
https://github.com/longvatrong111/servo/actions/runs/16175770044

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
2025-07-15 06:51:05 +00:00
batu_hoang
aa098ba2a3
webdriver: Allow script thread to fail to send response for ExecuteScript (#38054)
When script thread executes script sent from webdriver, if an alert
appears, webdriver can stop waiting for the script response and process
the next command.

This PR allows script thread to fail to send response for
`ExecuteScript` if the channel is closed.

cc: @xiaochengh

Signed-off-by: batu_hoang <hoang.binh.trong@huawei.com>
2025-07-15 04:14:03 +00:00
Josh Matthews
312985faff
IndexedDB: communicate transaction errors and async response data more precisely (#38027)
Digging into several crashing tests revealed that committing
transactions is a fallible operation. Propagating those errors led to
exposing many new errors caused by the IDBRequest implementation
assuming that all successful responses contained a structured clone. The
end result is a bunch of new test failures that were previously hidden.

Testing: Existing test coverage is sufficient.

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-07-15 02:04:28 +00:00
Gregory Terzian
027954dbad
script: introduce safe wrappers for js val conversions (#38004)
Introduce a safe wrapper trait for the unsafe `ToJSValConvertible`, and
use it in `script/dom` where the default `T` implementation works.

Part of https://github.com/servo/servo/issues/37951

---------

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
2025-07-15 01:57:15 +00:00
Josh Matthews
9e2ee0029a
script: Reduce usage of Trusted in Node::insert. (#37762)
These changes introduce a new kind of task that uses a variation of the
`task!` syntax. Existing `task!` usages create task structs that have a
`Send` bound, which requires the use of `Trusted<T>` to reference a DOM
object T inside of the task closure. The new syntax replaces the `Send`
bound with a `JSTraceable` bound, which requires explicit capture
clauses with types. This looks like:
```rust
task!(ScriptPrepare: {script: DomRoot<HTMLScriptElement>} |script| {
    script.prepare(CanGc::note());
}),
```

The capture clauses must list every value that will be referenced from
the closure's environment—these values are moved into fields in the
generated task structure, which allows them to be traced by the GC as
part of a generated JSTraceable implementation. Since the closure itself
is not a `move` closure, any attempts to reference values not explicitly
captured will generate a borrow checker error since the closure requires
the `'static` lifetime.

Testing: Existing WPT tests exercise these code paths. I also attempted
to write incorrect tasks that capture references or use values not
explicitly captured, and the compiler correctly errors out.
Fixes: part of #35517

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-07-15 01:11:12 +00:00
Euclid Ye
8877adccf2
script: Improve webdriver_handler::get_element_in_view_center_point (#38058)
1. Some rounding was wrongly used which can be a source of inaccuracy. 
2. Use `window.InnerWidth` instead of `body.ClientWidth` according to
spec.

Testing: Many new passing cases.
Fixes: Part of #38042.

---------

Signed-off-by: Euclid Ye <euclid.ye@huawei.com>
2025-07-15 00:14:17 +00:00
JoeDow
f6b98d5c56
layout: dirty parent node with NodeDamage::ContentOrHeritage when text content changed (#38057)
This change aims to reduce the scope of incremental box tree
construction. Previously, when text content changed, the parent node
would always be marked as requiring box tree reconstruction; now, it is
adjusted to only mark the parent 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-14 11:21:45 +00:00
Euclid Ye
d38ffb82b2
script: Get the screen metrics from the WebViewDelegate instead of via the compositor (#38020)
Similar to #37960, previously, `AvailHeight`, `AvailWidth`, `Height`,
`Width` ask compositor for screen metrics. This PR moves the request to
embedder.

This simplifies code, and reduces workload of compositor, which is
busier most of time.

Testing: No behaviour change. Updated some tests. `Width/Height` matches
other browsers.

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-07-12 16:07:39 +00:00
Josh Matthews
d0a93a8b02
script: Minimize layout queries for window scroll offsets. (#38018)
These changes reduce the number of times we need to query layout for the
same information when creating mouse/pointer events.

Testing: No new tests required for maintaining existing behaviour.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-07-12 14:17:55 +00:00
Josh Matthews
6dbd64e72d
net: Split read-only and read-write IndexedDB operations into separate enums (#37575)
This change allows the compiler to recognize if any read-only operations
are missing an implementation when processing a readonly transaction.

Testing: The existing behaviour is unchanged, so current tests suffice.
The new code is unused and cannot be tested.
Fixes: part of #6963

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-07-12 11:29:36 +00:00
Tim van der Lippe
2c116f4011
Fix reporting when only the report-only CSP header is present (#38002)
This was a bit confusing at first, but the report-only only
had an effect if it was used in conjunction with the regular
CSP header. This is incorrect, as the report-only header
can be present on its own.

Additionally, there was double-logic for parsing the CSP list
values, since we can only concatenate CSP lists if we have
an initial value, which requires a concrete policy value.

Therefore, abstract that way by looping over both headers and
handling the case where initially it is `None` and, if the
CSP header is not present, still `None` when we parse
the `report-only` header.

Additionally, update a WPT test. It was expecting the image
to load, yet was showing the fail image.

Part of #4577

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-07-12 10:38:30 +00:00
sagudev
9b5b26386c
canvas: Use wrapped kurbo::BezPath for path everywhere (#37967)
This PR removes existing path(segment) abstractions in favor of
`kurbo::BezPath`, well actually wrapped `kurbo::BezPath`, to ensure
building of valid paths. This allows us better Path2D building in script
and doing all validation and segmentation there and also allows us
remove blocking is_point_in_path on Path2D as we can now do this in
script. Current path is still done on canvas thread side as it will be
harder to move to script (will be done as a follow up), but it now uses
this new path abstraction.

Using kurbo also allows us to ditch our manual svgpath parser with the
one provided by kurbo.

Same code is stolen from: https://github.com/servo/servo/pull/36821.

Testing: Existing WPT tests
Fixes: #37904

wpt run: https://github.com/sagudev/servo/actions/runs/16172191716

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-12 10:37:47 +00:00
Jay Wang
204af81d2c
script: Add a Constraint DOMException for IndexedDB (#37605)
Add Constraint DOMException to handle the name conflict error in
`IDBDatabase::createObjectStore` method.

Testing: `./mach test-wpt tests/wpt/tests/IndexedDB/`, but it seems
there are many test failures even in main branch already ([related
comment](https://github.com/servo/servo/pull/37605#issuecomment-2993889163)).
Fixes: #37571

---------

Signed-off-by: iamlockon <xdddxyyyxzzz123@gmail.com>
2025-07-12 10:08:40 +00:00
Euclid Ye
c5aeac3cea
script: Get the window rectangle from the WebViewDelegate instead of via the compositor (#37960)
Previously, `screenX`, `screenY`, `outerHeight`, `outerWidth`, `moveBy`,
`resizeBy` ask compositor for window rectangle, which then return
"inner" rectangle after consulting Embedder.

This PR 
1. removes `GetClientWindowRect` from compositor, and directly let
script ask embedder.
2. add `window_size` to `ScreenGeometry`
3. add a lot of docs to `ScreenGeometry`

Testing: `tests\wpt\mozilla\tests\mozilla\window_resizeTo.html` can now
pass for Headed Window.
Fixes: #37824

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-07-11 18:31:24 +00:00
Martin Robinson
2366a8bf9e
script: Wrapping unsafe code in unsafe blocks for basic DOM types (#37997)
There is a new default cargo clippy lint, `unsafe_op_in_unsafe_fn`,
which requires unsafe code to be wrapped in unsafe blocks, even inside
functions marked as unsafe. The lint is disabled as much of our code
doesn't fulfill this contract. The thing itself is pretty useful in
order to gradually remove unsafety, so this change starts adding
`unsafe` blocks so we can eventually enable this lint.

Testing: This doesn't change behavior so existings tests should suffice.
Fixes: This is part of #35955.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-07-11 11:38:02 +00:00
Narfinger
a13cc1b25a
Do not duplicate console messages on OHOS/Android (#37994)
Console messages on OHOS/Android targets were duplicated.
Originally messages were on the debug level directed to stdout and then
redirected to the logger. https://github.com/servo/servo/pull/37912
changed this behavior recently.


Testing: Tested by looking at the debug log of certain things.
ohos-speedometer for example.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-07-11 11:08:39 +00:00
Tim van der Lippe
8edc6ba1b2
Return correct source position for element CSP violations (#37970)
The scripted_caller only has information if the context is coming
from a script. If an element fetch listener processes CSP
violations, then this information doesn't exist. Instead, we should
use the global URL and the line number. WPT tests don't appear
to expect a column number, as they are all zero. Not all elements
are updated, as I am not actually sure all of them need it.

The source position remains an Option, since there are also code
paths that don't correspond to element or script sources. Maybe
in the future we can always determine the source position, but
let's take small steps towards that.

Part of #4577

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2025-07-11 08:42:51 +00:00
webbeef
3c1bc1a92d
Avoid rooting/unrooting in Node::rev_version (#37885)
The iterator produced by Node::inclusive_ancestors roots the items but
rev_version just drop and unroot them right away. This patch makes it
possible to work on the Node references instead to avoid rooting.

*Describe the changes that this pull request makes here. This will be
the commit message.*

Testing: *Describe how this pull request is tested or why it doesn't
require tests*
Fixes: *Link to an issue this pull requests fixes or remove this line if
there is no issue*

Signed-off-by: webbeef <me@webbeef.org>
2025-07-11 07:46:23 +00:00
batu_hoang
edfacec9c8
script_thread: handle_unfocus_msg ignores unfocus request of top-level document (#37955)
`ScriptThread::handle_unfocus_msg` ignores unfocus request of top-level
document
Fix errors in webdriver navigation commands, which may request unfocus
on top-level documents.

Testing: 
`tests/wpt/meta/webdriver/tests/classic/back/back.py`
`tests/wpt/meta/webdriver/tests/classic/forward/forward.py`

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
2025-07-11 07:13:16 +00:00
Kingsley Yung
464d71ecfc
Implement cookie expiry date parsing algorithm (#37715)
The cookie-rs library parses the cookie expiry date based on the format
from RFC 2616 (for HTTP/1.1), which is stricter than the format from RFC
6265 (for HTTP cookie).

This patch implements the cookie expiry date algorithm from RFC 6265.
When Cookie::parse fails in parsing the expiry date, we try to parse the
expiry again with this algorithm, to provide extra compatibility with
legacy systems.

Testing: Pass a WPT test that was expected to fail before, and add a
unit test.
Fixes: #36452

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-07-11 05:18:11 +00:00
minghuaw
5b507dc871
script: Update name validation for attribute, element, and doctype (#37747)
A recent update in the spec (https://github.com/whatwg/dom/pull/1079)
introduced new rules for name validation of attribute, element, and
doctype. This PR implements the new name validation rules in
`components/script/dom/bindings/domname.rs`. The old XML name validation
rules are not fully removed because there remains a few usage of it in
`ProcessingInstructions` and `xpath`.

Testing: Covered by WPT tests
Fixes: #37746

---------

Signed-off-by: minghuaw <michael.wu1107@gmail.com>
Signed-off-by: Minghua Wu <michael.wu1107@gmail.com>
Co-authored-by: Xiaocheng Hu <xiaochengh.work@gmail.com>
2025-07-11 02:45:52 +00:00
Ashwin Naren
6ad57a343e
[IndexedDB] Key ranges implementation (#37684)
Improves the implementation of keys to a point where key ranges can be
implemented as well.

Due to me making branching mistakes I'll have to cherry-pick out the
first commit (it's from #37682)

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-07-10 18:33:23 +00:00
Tim van der Lippe
70c57c6136
Add support for Reporting-Endpoints (#37965)
Does not yet handle failures of endpoints, which requires us to update
metadata. I don't see that metadata being used anywhere, so I am not
sure if there is WPT coverage for it.

Part of #37238

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-07-09 19:07:29 +00:00
Martin Robinson
436c9072c4
layout: Skip box tree construction when possible (#37957)
When a style change does not chang the structure of the box tree, it is
possible to skip box tree rebuilding for an element. This change adds
support for reusing old box trees when no element has that type of
damage. In order to make this happen, there needs to be a type of
"empty" `LayoutDamage` that just indicates that a fragment tree layout
is necessary.

This is the first step toward incremental fragment tree layout.

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

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-07-09 17:33:09 +00:00
Steven Novaryo
378c4648e4
script: Use an implemented pseudo-element to fortype=color ::color-swatch (#37427)
Implement internal pseudo element, which would be resolved as a
"Implemented Pseudo Element" within style computation. This is an
concrete element that would has a primary style after the style
computation, but could match and style resolved like an pseudo element.
Therefore, it would have a different behavior compared to how does
`pseudo`s that `ServoLayoutNode` had. Where they would not have a
concrete element behind it. Note that, due to the nature of these pseudo
elements residing inside a UA widget, these pseudo elements would
therefore not be accessible in JavaScript by default.

This kind of element is required in order to implement the [form control
pseudo element](https://drafts.csswg.org/css-forms-1/#pseudo-elements)
like `::placeholder`, `::color-swatch`, `::field-text`, etc.
 
See [this docs](https://hackmd.io/@ChaKweTiau/BJ3zRdLQlg) for more
details of the implementation.

Then, the implemented pseudo element is utilized to implement style
matching for input `type=text`.

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

Testing: No WPT regression.

---------

Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
2025-07-09 15:36:58 +00:00
Andrei Volykhin
26f4da8249
script: Propagate a pending JS exception on structured cloning (#37964)
During the object (de)serialization steps on structured cloning
https://html.spec.whatwg.org/multipage/#safe-passing-of-structured-data
it is possible to throw a JS exception.

`self.postMessage({ get whatever() { throw customError } }));`

Require to propagate a pending JS exception and not throw the default
"DataCloneError" DOM exception.

Testing: Improvements in the following tests
- html/infrastructure/safe-passing-of-structured-data/*
- html/webappapis/structured-clone/structured-clone.any.js*
- wasm/serialization/arraybuffer/transfer.window.js
- webmessaging/without-ports/026.html
- workers/semantics/structured-clone/dedicated.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-07-09 14:47:55 +00:00
Ngo Iok Ui (Wu Yu Wei)
34c31ee418
WebGL2: support TexImage3D (#37718)
Add TexImage3D method to WebGL2RenderingContext

Testing: conformance2 should pass. Also it should get
http://webglsamples.org/WebGL2Samples/#texture_2d_array and
http://webglsamples.org/WebGL2Samples/#texture_3d running.
Fixes: #26511

Now Servo can run texture_2d_array and texture_3d samples!

![圖片](https://github.com/user-attachments/assets/41b87563-08b8-4db3-b503-12f3a61dbed7)

![圖片](https://github.com/user-attachments/assets/3c62a4de-35ea-488d-b2e5-00e3aed52090)

And it can now run three.js too!

![圖片](https://github.com/user-attachments/assets/d880aa92-a154-4895-aa06-b7919d1fc869)

---------

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>
2025-07-09 14:22:03 +00:00
Andrei Volykhin
a5b02047f9
script: Allow to throw a custom exception on structured cloning (#37948)
The structured cloning with transfer list
https://html.spec.whatwg.org/multipage/#structuredserializewithtransfer
throws a "DataCloneError" DOM expection by default if
serialization/transferral
is not possible, but a platform object can throw a custom excepton on
its serialization/transfer steps.

One example is OffscreenCanvas, which can throw
an "InvalidStateError" exception if the context mode is not none on
transfer steps.

https://html.spec.whatwg.org/multipage/#the-offscreencanvas-interface:transfer-steps

Testing: Improvements in the following tests
-
html/canvas/offscreen/manual/the-offscreen-canvas/offscreencanvas.transferrable*

Fixes: #37919

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-07-09 11:43:09 +00:00
sagudev
e64bc6d282
script: join compositor_requested_update_the_rendering into should_trigger_script_thread_animation_tick (#37889)
This will help us make "update the rendering" a proper task.

Testing: Existing WPT tests.

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

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-08 15:26:32 +00:00
Andrei Volykhin
4054f9a5a0
canvas: Make OffscreenCanvas transferable (without placeholder) (#37872)
Follow the specification and make OffscreenCanvas objects are
transferable,
but not in case if there are a weak reference to placeholder canvas
element.
To handle it properly need to implement dedicated frame
provider/dispatcher
between canvas element (script thread) and offscreen canvas (dedicated
worker thread).

https://html.spec.whatwg.org/multipage/#the-offscreencanvas-interface:transferable-objects

Testing: Improvements in the following tests
-
html/canvas/element/drawing-images-to-the-canvas/2d.drawImage.detachedcanvas.html
-
html/canvas/offscreen/manual/convert-to-blob/offscreencanvas.convert.to.blob*
-
html/canvas/offscreen/manual/the-offscreen-canvas/offscreencanvas.transfer*
-
html/infrastructure/safe-passing-of-structured-data/transfer-errors.window.js

Part of #24276

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-07-08 14:47:29 +00:00
Tim van der Lippe
fcb2a4cd95
Implement initial version of ReportingObserver (#37905)
The specification moved around lately with how it defines its reports
and report bodies. They became dictionaries, but are currently missing
some fields [1].

Most tests won't be passing yet, since the `Reporting-Endpoints` header
isn't used yet. In fact, the specification leaves it up to the browser
to figure out when to run this task [2]. I am not sure if there some
background scheduling we can do here.

Confirmed with content-security-policy/reporting-api/
report-to-directive-allowed-in-meta.https.sub.html that the callback is
invoked. The test doesn't pass, since
the `describe_scripted_caller` is empty for HTML elements. Thus the
`source_file` is empty, whereas it should be equivalent to the current
document URL.

Part of #37328

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>

[1]: https://github.com/w3c/reporting/issues/286
[2]: https://w3c.github.io/reporting/#report-delivery
2025-07-07 10:43:30 +00:00
Abdelrahman Hossam
3d4868592a
Differentiate console message behavior based on target OS (#37912)
Printing using log macro for Android and OhOS, while retaining original
stderr behavior for other platforms.

Fixes: #37877

Signed-off-by: abdelrahman1234567 <boudyalex321@gmail.com>
2025-07-07 09:14:12 +00:00
sagudev
48cf50309f
script: Also update canvas contents when laying out right after / during long parsing (#37899)
Before #37703 we were actually doing update rendering of canvases/images
as part of `allow_layout_if_necessary` so let's keep doing that until we
fix this properly as this will be much more involved and we want usable
canvases in the mean time.

Testing: Manual testing + WPT tests
Fixes: #37891

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-05 18:09:22 +00:00
Usman Yahaya Baba
2ad5b24225
Send WillNavigate earlier during navigation startup (#37778)
The will-navigate message tells the devtools client to expect a
navigation for a browsing context. This makes the network monitor clear
any previous entries and show the requests for the new page that is
loaded. In order to support this correctly, we need to send the
navigation notification from the constellation instead of the script
thread, otherwise we silently ignore navigations triggered by the
browser URL bar.




Testing: Ran servo in devtools mode , now the requests appear for new
loaded page
Fixes: https://github.com/servo/servo/issues/37334

---------

Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
2025-07-05 11:35:37 +00:00
sagudev
e1a891ea96
canvas: Use snapshot in canvas backends (#37863)
This removes assumption about pixel format from backend abstraction to
actual backend implementation. This is important for vello.

Testing: WPT tests

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-07-04 20:22:20 +00:00
Andrei Volykhin
9bd8d4f026
canvas: Add OffscreenCanvas 'transferToImageBitmap' method (#37880)
Follow the HTML speficication and add missing 'transferToImageBitmap'
method to OffscreenCanvas interface.

https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-transfertoimagebitmap

Testing: Improvements in the following tests
- html/canvas/offscreen/compositing/2d.composite.grid*
- html/canvas/offscreen/fill-and-stroke-styles/2d.gradient*
- html/canvas/offscreen/manual/the-offscreen-canvas/offscreencanvas*
- html/canvas/offscreen/reset/2d.reset*
- html/canvas/offscreen/text/2d.text*

Fixes (partially): #34111

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-07-04 16:25:36 +00:00
Fuguo
fe7aa91235
compositor|script: Update script's active_touch_points when hit tests on compositor fail (#37779)
[RootCause]:Tochdown executes normally, but touchup fails during hittest
and does not send a touchup event to the script, causing the script to
save an incorrect number of active_touch_points. The application
receives an incorrect event.touches.length, causing a logic error and
preventing the carousel from sliding.
[Solution]:
When hit test on compositor fails, we also need to send the
EmbedderToConstellationMessage::ForwardInputEvent message to
constellation. In the script's handle_touch_event, if it exits early, we
also need to update active_touch_points.

Testing: 
Fixes: #37763

---------

Signed-off-by: kongbai1996 <1782765876@qq.com>
2025-07-04 09:57:24 +00:00
Jan Varga
934b3341d7
storage: Isolate sessionStorage per top-level browsing context and copy sessionStorage when creating a new auxiliary browsing context (#37803)
This pull request introduces changes to the storage subsystem to:
- Isolate sessionStorage per top-level browsing context (WebViewId), in
  addition to origin.
- Copy sessionStorage when creating a new auxiliary browsing context
without
  noopener, as required by the corresponding spec
 
These changes bring Servo closer to spec compliance, matching expected
browser
behavior.

Testing: This work affects observable behavior. As a result, some
previously
failing WPT tests now pass. No new tests are added, since the behavior
is
already covered by existing web-platform-tests.

Fixes: #21291

---------

Signed-off-by: Jan Varga <jan.varga@gmail.com>
2025-07-04 09:15:12 +00:00
Kenzie Raditya Tirtarahardja
a990ff82b9
Webdriver: Implement calculate the absolute position for Get Element Rect (#37847)
Implementing [calculate the absolute
position](https://w3c.github.io/webdriver/#dfn-calculate-the-absolute-position)
and make [Get Element
Rect](https://w3c.github.io/webdriver/#get-element-rect) conforms the
spec .

Testing: Covered in webdriver WPT, especially for pointer test that
needs to find the element rect.

Signed-off-by: PotatoCP <kenzieradityatirtarahardja18@gmail.com>
2025-07-04 07:22:29 +00:00
Simon Wülker
13eeb29878
Don't explicitly handle dirty roots that are shadow roots (#37862)
Dirty roots are never shadow roots, since we use the flat tree for
invalidation. The flat tree does not contain shadow roots.

Reverts https://github.com/servo/servo/pull/35132. When that patch was
submitted we used the DOM tree for invalidation, so it was possible to
encounter shadow roots.

Testing: Covered by
`shadow-dom/untriaged/events/event-dispatch/test-003.html`

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-07-04 07:11:04 +00:00
Simon Wülker
a6b27c5078
Don't increment node revision twice when attaching shadow root to element (#37865)
`Node::dirty` already increments the version. `Node::rev_version`
traverses all ancestors, so it can end up being fairly expensive.

Testing: I'm not sure about WPT coverage but I think this change is
trivial enough to merge without tests.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-07-04 07:10:06 +00:00
Andrei Volykhin
6ba54e4d79
canvas: Add OffscreenCanvas 'convertToBlob' method (#37786)
Follow the HTML speficication and add missing 'convertToBlob' method
to OffscreenCanvas interface.

https://html.spec.whatwg.org/multipage/#dom-offscreencanvas-converttoblob

Testing: Improvements in the following tests
-
html/canvas/offscreen/manual/convert-to-blob/offscreencanvas.convert.to.blob*
-
html/canvas/offscreen/manual/wide-gamut-canvas/2d.color.space.p3.convertToBlobp3.canvas.html

Fixes: #24272

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-07-04 06:58:12 +00:00
sagudev
a631b42e60
pixels: Ensure expected formats when accesing bytes of snapshot (#37767)
I introduced snapshot in #36119 to pack raw bytes and metadata together,
now we take the next step and require for user to always specify what
kind of byte data they want when calling `as_bytes` or `to_vec`
(basically joining transform and data). There are also valid usages when
one might require just one property of bytes (textures can generally
handle both RGBA and BGRA). There are also valid usages of using just
raw bytes (when cropping). This PR tries to make such usages more
obvious.

This will make it easier to fix stuff around 2d canvas (we do not want
to assume any bytes properties in abstraction).

Testing: Code is covered by WPT tests.

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-07-03 15:02:41 +00:00
Narfinger
ca47cc2fa3
Add a basic caching mechanism for ImageKeys. (#37369)
This creates a new method in shared/compositing/lib to generate image
keys that are send over the webview. This does not immediately return
the keys but goes over the constellation to receive the keys from the
IOCompositor. To make this more efficient, we now cache the keys in
image_cache in a simple FIFO order. The old blocking method stays intact
for now but got renamed to make the blocking clear.
The blocking calls that are left are in:
- `components/canvas/canvas_data.rs`
- `components/script/dom/htmlmediaelement.rs`

Testing: WPT tests should cover this as this doesn't change any
functionality.
Fixes: Was mentioned in
https://github.com/servo/servo/issues/37161#issuecomment-2915750051 and
part of https://github.com/servo/servo/issues/37086

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
Co-authored-by: gterzian <2792687+gterzian@users.noreply.github.com>
2025-07-03 13:16:43 +00:00
Martin Robinson
6dafeb7a59
layout: Add a first pass at incremental box tree construction (#37751)
This change:

- Adds a new type of LayoutDamage that signifies that a box needs its
  children recollected, because one or more of them need to be rebuilt.
- During restyle damage propagation, propagate this new damage upward in
  the tree. Then box tree construction should be able to preserve any
  still-valid box tree nodes from box slots.
- During BlockLevelBox job finalization, if a box slot is valid and
  there is not LayoutDamage to the element, use the old box slot,
  ensuring that its fragment cache is invalidated.

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

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: coding-joedow <ibluegalaxy_taoj@163.com>
2025-07-03 08:13:20 +00:00