Commit graph

12013 commits

Author SHA1 Message Date
Narfinger
033da09800
Move signals_slots to ScriptMutationObservers (#39275)
Both places where we access signals_slots already have a reference to
ScriptMutationObserver. This saves us another access to
with_script_thread.


Testing: This does not change functionality.
Fixes: Part of addressing: https://github.com/servo/servo/issues/37969

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-12 18:43:59 +00:00
Kingsley Yung
250c4cda00
indexeddb: Implement openCursor and openKeyCursor for object store (#39080)
Continue on implementing indexeddb's cursor.

This patch focuses on implementing the `openCursor` [1] and
`openKeyCursor` [2] methods of the `IDBObjectStore` interface, which
create and initialize cursors by running the iterate-a-cursor algorithm
[3].

It also adds struct `IndexedDBRecord` to
`components/shared/net/indexeddb_thread.rs`. This struct can later be
used to implement the new `IDBRecord` interface [4].

[1] https://www.w3.org/TR/IndexedDB-2/#dom-idbobjectstore-opencursor
[2] https://www.w3.org/TR/IndexedDB-2/#dom-idbobjectstore-openkeycursor
[3] https://www.w3.org/TR/IndexedDB-2/#iterate-a-cursor
[4] https://w3c.github.io/IndexedDB/#record-interface

Testing: Pass WPT tests that were expected to fail.
Fixes: Part of #38111

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-09-12 16:54:07 +00:00
Euclid Ye
1f63116bdd
webdriver: Add ScrollBehavior::Instant for scroll_into_view (#39265)
There is a recent spec change which adds instant as default scroll
behaviour: https://github.com/w3c/webdriver/pull/1924. This PR reflects
the change.

Testing: No behaviour change as `ScrollBehavior` is ignored right now.

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-09-12 15:49:40 +00:00
Kingsley Yung
a4c6108cbe
script: Check if IndexedDB key path is ECMAScript identifier name (#39255)
From IndexedDB spec, when we check whether a key path is valid, we have
to check whether it is an ECMAScript identifier name. We have not yet
implemented this logic, and always return true.

This patch uses the function `js::rust::wrappers::JS_IsIdentifier` to
achieve this checking.

Testing: Pass WPT tests that were expected to fail.
Fixes: #25324

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-09-12 15:02:28 +00:00
Andrei Volykhin
965e87d006
html: Ignore a parse error on 'srcset' attribute parsing (#39260)
Parsing the 'srcset' attribute of an image element may result in a parse
error
indicating a non-fatal mismatch between the input and the requirements.
https://html.spec.whatwg.org/multipage/#concept-microsyntax-parse-error
https://html.spec.whatwg.org/multipage/#parse-a-srcset-attribute

This error should not be a reason to stop parsing and may be used by the
user agent to signal a syntax error.

Other browsers generally ignore this error, and we do the same.

Testing: Improvements in the following tests
-
html/semantics/embedded-content/the-img-element/srcset/parse-a-srcset-attribute.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-09-12 06:45:01 +00:00
Kenzie Raditya Tirtarahardja
097a69169a
webdriver: Support "scroll into view" for commands (#38508)
Implement scroll into view steps for all WebDriver command that requires
it (element click, element send keys, element clear, and take element
screenshot).

Testing: `element_send_keys/scroll_into_view.py`,
`element_click/scroll_into_view.py`, `element_clear/clear.py`

---------

Signed-off-by: PotatoCP <Kenzie.Raditya.Tirtarahardja@huawei.com>
2025-09-12 06:07:58 +00:00
Shubham Gupta
dfdcba88d4
fixup: Enable viewport <meta> tag support for mobile platforms only (#39207)
1. Adds a pref viewport_meta_enabled.
2. Enable pref for mobile platforms.

Testing: Tested Manually
Fixes: #39157
Fixes: #39002

---------

Signed-off-by: Shubham Gupta <shubham13297@gmail.com>
2025-09-11 17:21:04 +00:00
Ashwin Naren
96592dce44
Invalid return type for key conversion (#39252)
`convert_value_to_key` returns a `ConversionResult` now, so keys can be
considered "Invalid" rather than throwing an exception.

Testing: WPT
Unblocks: #38288

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-09-11 12:48:18 +00:00
Narfinger
19f70dccf6
Combine some access to the thread local variable for script thread. (#38752)
This combines some access to the thread local variable for script
thread.

- We introduce a new UserInteractingScriptGuard which on drop handles
  the resetting of was_interacting to the previous value. Sometimes
throughout the code `ScriptThread::is_user_interacting` was reset to the
previous value while sometimes just set to false. This should
remove this footgun.
- This also reduces the amount of thread local access for
MutationObservers and task queue.

Testing: WPT tests should cover this.
Fixes: This addresses part of
https://github.com/servo/servo/issues/37969 but there is probably still
stuff to be done.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2025-09-11 09:40:32 +00:00
Kingsley Yung
5de041e6ef
script: Unwrap imported key in JWK format after normalizing (#39234)
In our current implementation, the `importKey` method and `unwrapKey`
method of `SubtleCrypto` interface unwrap JsonWebKey before running the
normalized algorithms. Therefore, all cryptography algorithms share the
same unwrapping mechanism. Our current unwrapping mechanism is not
compatible with some cryptography algorithms, which we have not yet
implemented such as Ed25519.

Following the WebCrypto API spec, this patch moves the JsonWebKey
unwrapping mechanism to normalized algorithms so that each cryptography
algorithm can unwrap JsonWebKey in its own way.

This does not introduce behavioral changes, but makes implementing the
unwrap operation for new cryptography algorithms easier in the future.

Remark: Step 8 and 13 of `SubtleCrypto::ImportKey` require the crypto
task source in the script task manager, but we don't have it yet. So,
they're marked as TODO.

Testing: Existing tests should suffice.

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2025-09-11 09:38:21 +00:00
Ashwin Naren
97690b1cba
script: Ensure autoincrement and keypath are passed in correctly from IDBTransaction (#38738)
Previously, the correct autoincremented and keypath parameters were only
being passed if the object store is being created. This PR queries this
info from the backend and passes it onto the constructor in
IDBTransaction. Furthermore it exposes keypath and index_names from
IDBObjectStore, mainly for WPT.

Testing: WPT
Fixes: None

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-09-11 09:13:15 +00:00
Simon Wülker
93ad2cf62a
script: Set validation anchor to target element in ElementInternals::SetValidity when anchor is not given (#39247)
Testing: Covered by existing web platform tests

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-11 01:26:09 +00:00
Narfinger
84465e7768
Removed FnvHash and transformed the rest to FxHashmap (#39233)
This should be the final PR for the Hash Function series that is
trivial.

Of note: I decided to transform `HashMapTracedValues<Atom,..>` to use
FxBuildHasher. This is likely not going to improve performance as Atom's
already have a unique u32 that is used as the Hash but it safes a few
bytes for the RandomState that is normally in the HashMap.

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

Testing: Hash function changes should not change functionality, we
slightly decrease the size and unit tests still work.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-10 13:34:54 +00:00
JasonHonKL
839878c743
script: Make root_from_handle_value a safe function by accepting SafeJSContext (#39193)
Change from unsafe pointer of root_from_handle_value  to SafeJSContext. 

#39131

---------

Signed-off-by: JasonHonKL <j2004nol@gmail.com>
Signed-off-by: Jason <jason@198-61-252-113-on-nets.com>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Jason <jason@198-61-252-113-on-nets.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2025-09-09 19:26:02 +00:00
lumiscosity
721fc01c30
script: Fix building with webgl_backtrace feature (#39231)
I think this is the correct solution? GlobalScope::get_cx() doesn't take
a self parameter anymore.

Testing: WebGL tests should suffice.
Fixes: #39228

Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
2025-09-09 14:09:20 +00:00
Simon Wülker
406eab4ec2
script: Remove three duplicated log functions from webgl (#39227)
We have the standard library at our disposal, let's use it.

Testing: Covered by existing tests

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-09-09 11:31:55 +00:00
Narfinger
177f6d6502
Replace Hash Algorithm in HashMap/Set with FxHashMap/Set for simple types (#39166)
FxHash is faster than FnvHash and SipHash for simple types up to at
least 64 bytes. The cryptographic guarantees are not needed for any
types changed here because they are simple ids.
This changes the types in script and net crates.
In a future PR we will change the remaining Fnv to be also Fx unless
there is a reason to keep them as Fnv.

Testing: Should not change functionality but unit test and wpt will find
it.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-09 08:33:46 +00:00
Sam
1deb7b5957
script: Document need for always sending an image update to compositor (#39210)
I hit this many times while working on #38717

Testing: Not needed because we just update the docs

---------

Signed-off-by: Sam <16504129+sagudev@users.noreply.github.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-09-09 08:19:57 +00:00
lumiscosity
ccecb18a9c
script: Propagate CanGc argument through DictionaryFromJSVal trait (#39223)
Testing: Internal changes only, shouldn't change behaviour.
Fixes: #39206

Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
2025-09-09 06:46:53 +00:00
Sam
1f0f079203
webgpu: Simplify presentation and handle cleared in script (#38717)
There are many important changes here:

- Generalize the presentation buffer into standalone staging buffers
that hold their own state. This allow them to be used by getImage.
- Move all clear handling to the ScriptThread and send the configuration
on each request present/getimage, thus avoiding any recreate/clearing
messages. This means that we prepare staging buffers lazily, on the
first request.

Try run for this change:
https://github.com/sagudev/servo/actions/runs/17341982368
Testing: This is covered by existing WebGPU CTS tests. There are some
bad expectations updates, but they are also on main (presumably from
last update the rendering work) although I think CTS is actually wrong
(see https://github.com/gpuweb/cts/issues/4440).
Fixes: #36820
Fixes: #37705
Fixes: #33368 (we now keep reference alive in hashmap)

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-09-09 03:35:12 +00:00
JoeDow
30d3706a2b
layout: allow only repaint when css background and border image loaded (#39201)
This change allows that only new display list is built when css
background and border image loaded.

Testing: This change should not change any behaviors so covered by
existing WPT tests.

Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
2025-09-08 13:23:11 +00:00
Josh Matthews
e00bfb525b
script: Replace webcrypto-specific macro with trait abstraction. (#39205)
The value_from_js_object macro exists to paper over differences between
dictionary types that require rooting (via `RootedTraceableBox`) and
those that do not. However, I need to read the macro source every time I
look at the code that uses it because I can never remember what it's
doing. These changes replace the macro with a trait abstraction that is
clearer, and should be a code size win as well.

Testing: Existing WPT tests suffice.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-09-08 10:45:40 +00:00
lumiscosity
9584b9e57d
script: Add can_gc to WebIDL dictionary constructors (#39195)
More progress on can_gc!

Testing: Internal change only, shouldn't change behavior.
Fixes: #38708

---------

Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
2025-09-08 09:21:42 +00:00
Martin Robinson
9f4f598f44
script: Use HTMLElement.scrollParent to implement Element.scrollIntoView (#39144)
To find scrolling ancestors, we need to walk up the flat tree and only
consider the elements that are in the chain of containing block
ancestors of an element. `scrollParent` now does this so we can use it
to properly implement `scrollIntoView`.

Testing: There are WPT tests for this change.

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-09-07 21:44:11 +00:00
Tim van der Lippe
a672ffb850
Add resource header for mime sniffing (#39167)
The concept of a "resource header" is not well specced, since it is
unclear what a "resource" is. That said, it most closely matches a
"response" as part of the navigation params.

With this change, we now delay loading the document until either two
things happen:
1. We reached the end of the file
2. We processed 1445 bytes (as defined by spec)

We initially store bytes in the resource header and then after loading
parse the stored bytes. Any subsequent loading will process as before.

Part of #14024

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-07 12:31:57 +00:00
Tim van der Lippe
e3de39893f
Disable scripting when sandbox flag is set (#39163)
While I adding spec comments to the CSP crate, I discovered two issues:
1. We should only use the last sandbox value (WPT test added)
2. We weren't checking for the scripting sandbox flag in document

Also, the autoplay test should have allowed scripts to run, otherwise
the test doesn't run. Since we weren't checking the flag before, the
test ran fine for Servo. However, it wouldn't run for other browsers.

Also realized that an existing test was pointing to a non-existent file
(since it doesn't have `.sub`). Updated that and confirmed that in other
browsers it now properly works (it no longer shows a 404). However,
Servo now fails that test as we don't fire an load event.

Part of #913

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-07 12:31:40 +00:00
lumiscosity
088d16d634
script: Make set_dictionary_property a safe function (#39191)
Makes `set_dictionary_property` safe.

Testing: Changes are internal, this shouldn't affect behavior.
Fixes: #39128

Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
2025-09-07 11:56:20 +00:00
Ashwin Naren
3ac8875697
script: Initial stubs for Credential Management API (#38839)
Stubs `Credential`, `CredentialContainer`, and `PasswordCredential` and
adds the credentials attribute to navigator.

Testing: WPT
Fixes: Partially #38788

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-09-06 19:48:38 +00:00
Sam
643ac08cf0
canvas: Implement strokeText (#39183)
Mostly it's just reusing/copy&edit fillText stuff.

Testing: Existing WPT tests
Fixes: #29973

Try run: https://github.com/sagudev/servo/actions/runs/17511337550

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-09-06 18:01:21 +00:00
Josh Matthews
c490033c52
indexeddb: Support enabling IndexedDB after startup (#39177)
The servodriver harness requires preference-gated web platform features
to be toggleable at any point in the browsing session's lifetime, rather
than at startup. To support toggling IndexedDB, we need to ensure the
IDB manager thread is always started.

Testing: Verified when running `./mach test-wpt /IndexedDB --headless
--product servodriver`. We don't run servodriver in CI yet.
Fixes: #39175

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-09-06 06:55:20 +00:00
Ashwin Naren
b5d6555238
indexeddb: Implement getAll and getAllKeys (#38885)
Implement getAll and getAllKeys for IDBObjectStore.

Testing: WPT & Unit testing
Fixes: Part of #6963.

---------

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-09-06 05:48:11 +00:00
Narfinger
e64c53972a
Switch the majority of fxhash uses to rustc_hash which is maintained (#39168)
fxhash seems to be unmaintained (see
https://github.com/rustsec/advisory-db/issues/2185) so we should move
away from it.
Additionally, the new crate might be slightly faster.

There is still some cases depending on stylo that have the old fxhash
crate.

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

Testing: Changes in Hash should really not show any bugs. And
performance should be comparable.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-06 05:19:47 +00:00
Sebastian C
d3809c1024
fix: Store channel reference in CookieStore to prevent panic on unload (#39171)
CookieStore sets up a route with the resource threads to handle async
communication and needs to later unregister itself when the page
unloads. When attempting to do this in the `Drop` of CookieStore we
panic attempting to retrieve the channel via
`self.global().resource_threads()` because global is already null. This
change stores a reference to the core resource thread in the object to
send the unregister on `Drop`.

Testing: manual testing for crash fix, behavior should be unchanged

Signed-off-by: Sebastian C <sebsebmc@gmail.com>
2025-09-05 18:10:41 +00:00
Sebastian C
7ce0bd8575
script: Remove CookieListItem fields that were removed in the spec (#39170)
The spec removed all fields from CookieListItem except for name and
value

Testing: WPT tests cover this already.

Signed-off-by: Sebastian C <sebsebmc@gmail.com>
2025-09-05 17:47:42 +00:00
Kingsley Yung
b29eab0ffe
script: Re-implement evaluate_key_path_on_value in IndexedDB (#38847)
The current implementation of evaluate_key_path_on_value was translated
from gecko, and it is incomplete. The unimplemented part occurs many
crashes in WPT tests.

This PR re-implements it according to the spec. It should eliminate many
crashed WPT tests, and increase the code readability.

Testing: Update WPT test expectation
Fixes: #38817 partially, and #25325

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-09-05 08:00:07 +00:00
Tim van der Lippe
deb7f802df
Refactor loading methods to align with specification (#39146)
This is in preparation of being able to do mime sniffing on the response
data. For that, we first need to introduce separate methods so that we
can decouple them from process_response. In doing so, we introduce a
NavigationParams which mimics what the spec intents. The spec stores
different data (policy container instead of csp list and response
instead of content-type), but it is similar enough.

Part of #14024

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-05 07:57:36 +00:00
shanehandley
989c0d8994
script: Implement document's active sandboxing flag set (#39079)
Implements document's active sandboxing flags. These are currently
populated only from CSP-derived sandboxing flags for a new document,
when defined in the CSP.

Testing: 1 new pass, and some new wpt's are added to test points in the
spec where these flags influence behaviour.

Signed-off-by: Shane Handley <shanehandley@fastmail.com>
2025-09-05 05:02:23 +00:00
Kingsley Yung
f722419861
webcrypto: Reduce usage of standalone helper functions for JWK format (#39084)
Reduce the reliance on standalone helper functions for handling JWK
format. Instead, those functionalities are now integrated into the
`JsonWebKey` type generated by script_binding, via the local trait
`JsonWebKeyExt`, for internal use.

The `parse_jwk` function remains for now. It will be removed when once
we refactor `SubtleCrypto::ImportKey` to support a more generic approach
across different cryptographic algorithms.

Testing: Refactoring. Existing WPT tests should suffice.

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-09-05 04:08:25 +00:00
Martin Robinson
e5fbb31452
script: Make get_property_jsval a safe function (#39137)
Accept the safe `JSContext` wraper to this function so that it can be
safe. Some callers also become safe as well.

Testing: This does not change behavior and is thus covered by existing
tests.
Fixes: #39129.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-09-04 23:11:15 +00:00
Shubham Gupta
40ced5bb61
Enable viewport <meta> tag support for mobile platforms only (#39133)
Enable viewport `<meta>` tag support for mobile platforms only.

_Reference:_
[web_preferences.h](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/public/common/web_preferences/web_preferences.h;l=158?)
_Todo: Enable for when requested desktop site:_
[web_contents_impl.cc](https://source.chromium.org/chromium/chromium/src/+/main:content/browser/web_contents/web_contents_impl.cc;l=3752?)

Testing: Tested Manually
Fixes: #39002

Signed-off-by: Shubham Gupta <shubham13297@gmail.com>
2025-09-04 19:14:53 +00:00
lumiscosity
c7ca281f44
script: implement setMatrixValue for DOMMatrix (#39148)
Even more progress on the geometry suite. Almost there!

Testing: Covered by WPT (css/geometry).

Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
2025-09-04 19:02:54 +00:00
Kingsley Yung
925b7c5dad
script: Queue a microtask in wait_for_all of promise type (#39108)
In the wait-for-all algorithm of the IDL promise type, we need to queue
a microtask to perform successSteps given « » if total is 0.

This step was previously implemented in a workaround, which perform
successSteps immediately.

This patch properly queue the microtask, and remove the workaround.

Testing: Refactoring only. Existing tests are enough.
Fixes: #37259

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-09-04 13:50:41 +00:00
Martin Robinson
fa7d6d4004
script: Modify Element::determine_scroll_into_view_position to take a ScrollingBox (#39107)
There is no need to separate the two kinds of scrolling boxes into
`Element` and `Viewport` more than once. This also eliminates a
potentially panicking `unwrap()`. 

Testing: This doesn't change behavior and is thus covered by existing
tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-09-04 08:44:57 +00:00
Tim van der Lippe
dab195ca80
Hookup mime classifier to main document loader (#39109)
While we don't perform any sniffing yet, it does now
check all relevant mime types. Before, we would only
check specific versions of specific mime types. However,
the specification is more elaborate, which MimeClassifier
already handles.

There are two new test failures, but they actually fail
in the same way in other browsers. These tests are still
being discussed what the correct behavior should be [1]

Part of #14024

[1]:
https://github.com/whatwg/mimesniff/issues/189#issuecomment-2081559661

---------

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-04 08:30:55 +00:00
lumiscosity
a44b98c358
script: preserve 2D on DOMMatrix invert (#39113)
More small geometry fixes.

Testing: Covered by WPT
(css/geometry/DOMMatrix-invert-preserves-2d.html)

---------

Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
2025-09-04 07:08:37 +00:00
Tim van der Lippe
fc6bee8b81
Move Element::matches_environment to MediaList (#39034)
It more logically matches `MediaList`, and it allows us to
call this method with a document. This is required when
parsing Link headers, as they don't have an associated
element, but they do have a document.

Part of #35035

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-09-04 06:21:01 +00:00
Andrei Volykhin
8a62984c2f
canvas: Use non rooted variant of HTMLCanvasElementOrOffscreenCanvas type (#38970)
Any RenderingContext/OffscreenRenderingContext type has readonly
"canvas" attribute
and associated native-code DOM context objects have reference to target
DOM canvas objects.
https://html.spec.whatwg.org/multipage/canvas.html#renderingcontext
https://html.spec.whatwg.org/multipage/canvas.html#offscreenrenderingcontext

And currently the reference to DOM canvas object is the rooting pointer
on the stack,
which leads to the circular reference problem.

The SpiderMonkey's (SM) garbage collector will not be able to free the
DOM canvas and context
objects (unreacheble from JS) because of the rooting pointer on stack
(see STACK_ROOTS).

And these objects will be stored until the associated script
runtime/thread will be terminated.

SM -> JS Roots -> DOM Canvas* (on heap) -> DOM Context (on heap)
SM -> Rust Roots -> Dom Canvas* (on stack) <- as "canvas" member field

Let's replace the rooting pointer to the traceble pointer (DomRoot ->
Dom)
in the "canvas" member field of DOM context object, which allows to
broke circular referencing problem.

Testing: No changes in existed tests

Signed-off-by: Andrei Volykhin <volykhin.andrei@huawei.com>
Co-authored-by: Andrei Volykhin <volykhin.andrei@huawei.com>
2025-09-03 19:24:48 +00:00
Martin Robinson
2c7866eb24
script/layout: Implement HTMLElement.scrollParent (#39110)
This new API allows getting the element which establishes an element's
scroll container. This will be used to properly implement
`scrollIntoView`. There is still work to do for this API and
`offsetParent` to properly handle ancestors which are
closed-shadow-hidden from the original query element.

In addition, fix an issue where inline boxes were establishing scrolling
containers (they shouldn't do that).

Testing: There are tests for this change.
Fixes: #39096.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
2025-09-03 18:52:15 +00:00
Narfinger
5c7ea4bdee
constellation: Use FnvHashMap for hashmaps that use ids as keys (#39106)
FNV is faster for hashing less than 16 bytes of data and the
cryptographic properties of the default HashMap are not needed for the
various ids.

Testing: This does not change functionality.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-09-03 18:15:19 +00:00
Martin Robinson
0ae9ee28d5
script: More consistently use f32 and have scrolling methods follow the specification more closely (#39104)
This clarifies the units for scrolling:

 - `f32` is used for internal Servo scrolling APIs as that is the unit
   used in WebRender.
 - `f64` is used for the web-exposed scrolling APIs as that is what the
   WebIDL code generator gives us.

Conversions are done consistently at the boundaries of the two APIs.

In addition, web-exposed scrolling methods are refactored a bit to more
closely follow the specification text. In addition, specification text
is added to those methods so that it is clearer that we are following
it.

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

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-09-03 17:29:56 +00:00