Commit Graph

12501 Commits

Author SHA1 Message Date
Narfinger
94eafd4ef9 script: Store a Weak handle to ScriptThread in both ScriptThread and Window (#40645)
We construct `ScriptThread` in an `Rc` which itself has the given `Weak`
for it. It then can give it to `Window` and other elements in the
future. We currently only use this for the microtask checkpoint function
in `Window`. This is the first step toward eliminating the usage of
thread local storage to access the `ScriptThread`.

Testing: This should not change behavior so is covered by existing
tests.
Fixes: Part of addressing:
https://github.com/servo/servo/issues/37969#issuecomment-3520463442

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2026-01-05 13:20:19 +00:00
Josh Matthews
07714b683a script: Remove pointless rename. (#41680)
There's no naming conflict, and nowhere else the name NetRequestInit.
All it does is increase confusion.

Testing: No runtime changes.

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2026-01-05 06:55:36 +00:00
Kingsley Yung
259b3985ee script: Implement sign and verify operations of ML-DSA (#41676)
Finish adding ML-DSA support to WebCrypto API.

This patch implements the sign and verify operations of ML-DSA, with
`ml-dsa` crate.

Specification:
https://wicg.github.io/webcrypto-modern-algos/#ml-dsa-operations-sign
https://wicg.github.io/webcrypto-modern-algos/#ml-dsa-operations-verify

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

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2026-01-05 06:12:58 +00:00
Tim van der Lippe
de27dc69e5 Implement pending preload responses with futures (#40059)
This implements waiting for pending preloads, where the preload request
is still fetching the result when the second "real" request is started.
It is
implemented by storing responses in the `SharedPreloadedResources`
which is communicated via `PreloadId` send to the `CoreResourceManager`.

Part of #35035

---------

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2026-01-04 12:22:54 +00:00
Kingsley Yung
58070dd692 script: Implement generate key operation of ML-DSA (#41659)
Continue on adding ML-DSA support to WebCrypto API.

This patch implements the generate key operation of ML-DSA, with
`ml-dsa` crate.

Specification:
https://wicg.github.io/webcrypto-modern-algos/#ml-dsa-operations-generate-key

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

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2026-01-04 08:52:23 +00:00
WaterWhisperer
af2370ec5c Retry EventSource after temporary failures using is_permanent_failure (#41651)
add `is_permanent_failure` method in `NetworkError` and call it from the
`EventSource` instead of the current match against the url's scheme

Testing: `./mach test-wpt tests/wpt/tests/eventsource`
Fixes: #41634

---------

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2026-01-04 04:00:33 +00:00
aquaThirsty
d808cc15d0 change #[allow]s to #[expect]s (#41635)
Changed most #[allow]s to #[expect]s, mainly for
clippy::too_many_arguments

Removed unfulfilled expectations

This is my first opensource contribution, so please let me know if
anything should
be done differently.

Testing: Refactor
Part of: #40838

---------

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: TimurBora <timurborisov5561@gmail.com>
Co-authored-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
2026-01-03 10:54:27 +00:00
Kingsley Yung
0c91c3bc81 script: Implement export key operation of ML-DSA (#41647)
Continue on adding ML-DSA support to WebCrypto API.

This patch implements the export key operation of ML-DSA, with `ml-dsa`
crate.

Specification:
https://wicg.github.io/webcrypto-modern-algos/#ml-dsa-operations-export-key

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

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2026-01-03 07:42:55 +00:00
Simon Wülker
9ca7628dbd script: Skip some steps when determining encoding for XML document (#41637)
XML documents do not use the "determine the encoding" algorithm. As far
as I can tell, it is unspecified how they should determine the encoding
instead. We now check the BOM, `Content-Type` header and prescan for an
xml encoding declaration (but don't inherit encodings from iframes or
attempt to determine the encoding from heuristics).

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

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2026-01-02 17:53:11 +00:00
Usman Yahaya Baba
6decaaefa9 Replace NetworkError::Internal with structured enum variants for calls with literal strings (#36599)
Replace NetworkError::Internal with structured enum variants
- Adds
UnsupportedScheme,CorsViolation,ConnectionFailure,Timeout,RedirectError,InvalidMethod,ResourceError,SecurityBlock,MixedContent,CacheError,InvalidPort,
LocalDirectoryError, variants in NetworkError enum.
- Refactored the usage of NetworkError::Internal(String) to use the
appropriate new variant

Testing: Changes does not require test.
Fixes: https://github.com/servo/servo/issues/36434

---------

Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
Signed-off-by: Usman Yahaya Baba <91813795+uthmaniv@users.noreply.github.com>
Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Co-authored-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-01-02 10:28:17 +00:00
Kingsley Yung
df9877a94c script: Implement import key operations of ML-DSA (#41628)
Start adding ML-DSA support to WebCrypto API.

This patch implements the import key operations of ML-DSA, with `ml-dsa`
crate.

Specification:
https://wicg.github.io/webcrypto-modern-algos/#ml-dsa-operations-import-key

Testing:
- Pass some WPT tests that were expected to fail.
- Some new FAIL expectations are added. They were skipped by WPT when
the import key operations of ML-DSA had not been implemented, and
requires other not-yet-implemented operations to pass.

Fixes: Part of #41626

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2026-01-02 09:59:00 +00:00
Kingsley Yung
00792e098e script: Fix alg field of exported ML-KEM key in JWK format (#41627)
We wrongly use the object identifier of ML-KEM for the `alg` field of
exported ML-KEM key in JWK format. We should use the values specified in
Section 8 of [draft-ietf-jose-pqc-kem-01] (Figure 1) instead.

[draft-ietf-jose-pqc-kem-01] (Figure 1):

https://www.ietf.org/archive/id/draft-ietf-jose-pqc-kem-01.html#direct-table

Testing: WPT currently does not have relevant tests for ML-KEM keys in
JWK format since The JWK format for ML-KEM is not standardized yet. We
strive to remain compliant with the current specification.

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2026-01-02 09:33:35 +00:00
Wayne Van Son
5b9263690d Refactor allow to expect (#41586)
Replace `allow` with `expect` lints for `unused`, `unsafe_code`,
`dead_code`, and `non_upper_case_globals`.

Testing: So far just check it compiled on `x86_64-linux` on NixOS. Need
to use the module `system.fontconfig.enable = true;` I think in my NixOS
config.
Part of: #40383 

Searching `allow\(.*\)` for `.rs` files shows the following. for
(total_results:total_files) went from `707:386` to `675:368`, a
reduction of `32:18`.

How many files is too many files per PR? I feel like the 20-30 I have is
too big.

---------

Signed-off-by: Wayne Van Son <waynevanson@gmail.com>
2026-01-01 13:40:20 +00:00
Kingsley Yung
96ddb0bbf0 script: Implement WebCrypto encapsulation and decapsulation with ML-KEM (#41617)
Complete the ML-KEM support in WebCrypto API, with the implementation of
the "encapsulate" and "decapsulate" operations of ML-KEM, as well as
four new methods `encapsulateKey`, `encapsulateBits`, `decapsulateKey`
and `decapsulateBits` of `SubtleCrypto`.

Specification:

https://wicg.github.io/webcrypto-modern-algos/#ml-kem-operations-encapsulate

https://wicg.github.io/webcrypto-modern-algos/#ml-kem-operations-decapsulate

https://wicg.github.io/webcrypto-modern-algos/#SubtleCrypto-method-encapsulateKey

https://wicg.github.io/webcrypto-modern-algos/#SubtleCrypto-method-encapsulateBits

https://wicg.github.io/webcrypto-modern-algos/#SubtleCrypto-method-decapsulateKey

https://wicg.github.io/webcrypto-modern-algos/#SubtleCrypto-method-decapsulateBits

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

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2026-01-01 13:30:04 +00:00
Kingsley Yung
883f8b4a6c script: Implement generate key operation of ML-KEM (#41615)
Continue on adding ML-KEM support to WebCrypto API.
Specification: https://wicg.github.io/webcrypto-modern-algos/#ml-kem

This patch implements generate key operation of ML-KEM, with `ml-kem`
crate.

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

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2026-01-01 08:46:15 +00:00
Kingsley Yung
c7cd8fcef8 script: Implement export key operation of ML-KEM (#41604)
Continue on adding ML-KEM support to WebCrypto API.
Specification: https://wicg.github.io/webcrypto-modern-algos/#ml-kem

This patch implements export key operation of ML-KEM, with `ml-kem`
crate.

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

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-12-31 14:27:47 +00:00
Narfinger
15aa6ee8c0 Base: Rename IpcSharedMemory to GenericSharedMemory (#41198)
In the future, servo components should depend on the generic channels in
base instead of IpcChannels to correctly optimize for multiprocess vs
non-multiprocess mode.
This reexports IpcSharedMemory as GenericSharedMemory in GenericChannel
and changes all dependencies on it.

Currently this is only a type/name change and does not change
functionality. But in the future we would want want to use non-ipc
things for the data.

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

Testing: This changes types and does not need testing.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-12-31 13:07:59 +00:00
Martin Robinson
e4822c9c5d script: More thoroughly convert between UTF-16 and UTF-8 offsets in text inputs (#41588)
DOM APIs for interacting with selection and text in text inputs
`<input type=text>` and `<textarea>` all accept offsets and lengths in
UTF-16 code units. Servo was not converting all of these offsets into
UTF-8 code units. This change makes it so that this conversion is done
more thoroughly and makes it clear when the code is dealing with UTF-8
offsets and UTF-16 offsets.

Helper functions are added for doing this conversion in both directions
as it is necessary. In addition, a `char` iterator is added for
`TextInput` as it is useful for doing this conversion. It will be used
more completely in the future when a `Rope` data structure is extracted
from `TextInput`.

Finally, specification text is added to all of the DOM implementation
touched here.

Testing: This change includes a new WPT crash test as well as a series
of unit
tests to verify conversion between UTF-8 and UTF-16 offsets.
Fixes #36719.
Fixes #20028.
Fixes #39184.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-12-31 09:29:25 +00:00
WaterWhisperer
b974a6685c script: Create CSS parsing helpers to simplify ParserContext setup (#41566)
Creates a new `css.rs` module in `components/script` with helper
functions for CSS value parsing.
Callers no longer need to manually specify document URL, quirks mode,
and error reporter.

Testing: `./mach check`
Fixes: #41541

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-12-31 06:27:52 +00:00
Sam
d1ba789482 script: Obtain &mut JSContext at the start of the script and pass it down to msg handlers (#41564)
At the start of the script we create first (and only[^1]) safe
`JSContext`, from where we should pass it down to every code that needs
the cx. This PR brings it all the way down to message handlers. There is
clear separation between functions that use new model `&mut JSContext`
and the ones that use the old model (usually they take can_gc).

[^1]: Another place of construction are SM hooks (that pass us down raw
JSContext), but to reach that point we already needed to call another
function that takes `&mut JSContext`, so one can look at this case as
reentering/reborrowing (we derive new shorter `&mut JSContext` from the
old one).

Testing: This is just refactor, but should covered by WPT tests.
Part of #40600

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-12-30 18:19:41 +00:00
Tim van der Lippe
0de7b23a7b script: Initialize all requests with clients (#41584)
In preparation for adding preload support for all requests, we need to
add relevant client information to all these entrypoints. Additionally,
for links we now also set the referrer correctly and initialize
documents. All of which are required to start loading preload
information when processing requests.

Part of #35035

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2025-12-30 13:10:29 +00:00
Kingsley Yung
c394c6e65f script: Use SupportedAlgorithm in Subtlecrypto.wrapKey (#41587)
With the new implementation of `supportedAlgorithms` of WebCrypto from
#41563, we can properly check whether a cryptographic algorithm supports
export key operation, based on the algorithm registration.

This refactoring makes our implementation of `Subtlecrypto.wrapKey`
method to use this functionality to avoid hard-coding a list of
unsupported algorithms.

Testing: Refactoring. Existing tests suffice.

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-12-30 12:36:43 +00:00
Kingsley Yung
5d6d2c67bb script: Implement import key operation of ML-KEM (#41585)
Start adding ML-KEM support to WebCrypto API.
Specification: https://wicg.github.io/webcrypto-modern-algos/#ml-kem

This patch implements import key operation of ML-KEM, with `ml-kem`
crate.

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

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-12-30 11:46:10 +00:00
Gae24
6f14742707 script: Pass ModuleTree instead of retrieving it in run_a_module_script (#41571)
Inside `notify_owner_to_finish` we already retrieve the `ModuleTree`
tied to the corresponding `ModuleIdentity`, but we ended up retrieving
it a second time inside of `run_a_module_script` instead of simply
passing it.

Testing: Covered by existing tests, a simple cleanup.

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2025-12-29 23:49:04 +00:00
Tim van der Lippe
9a860baef0 script: Use correct creation_url for workers (#41458)
Instead of the creation URL of the containing global,
it should instead use the URL of the current worker.

Despite the referrer specification stating that we
should use the creation URL, instead browsers use
the current URL. A new WPT test is added to cover that
which we currently fail because of incorrect
serialization of query parameters of a URL. But the
actual redirect and all work now.

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-12-29 21:40:47 +00:00
Tim van der Lippe
551684f3af script: Introduce concept of a fetch group (#41423)
We now keep track of deferred fetches in globalscope
rather than in document loader. This matches what
the spec expects with its concept of a fetchgroup.

Cancellations are still present in a document loader
and don't match yet all places where we perform fetches.
Therefore, these will leave in document loader for now
until we rearranged the fetch record tracking in the
fetch group (which is a separate field from deferred
fetches).

Fixes #41286

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-12-29 12:50:30 +00:00
Sam
ffa4864f49 script: Remove redundant realm entering (#41565)
`spawn_pipeline` does not need realm entered and
`handle_fullscreen_exit` does realm entering on it's own:
133c9b4266/components/script/script_thread.rs (L2503)

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

Signed-off-by: Sam <16504129+sagudev@users.noreply.github.com>
2025-12-29 12:11:09 +00:00
Kingsley Yung
7342ee0627 script: Properly implement supportedAlgorithms of WebCrypto (#41563)
WebCrypto API has an internal object `supportedAlgorithms`
<https://w3c.github.io/webcrypto/#dfn-supportedAlgorithms> that maps the
all supported algorithms and operations to their desired IDL dictionary
types. It is mainly used by the "normalize an algorithm" algorithm
<https://w3c.github.io/webcrypto/#algorithm-normalization-normalize-an-algorithm>.
We currently implement it as a large `match` block in the
`normalize_algorithm` function.

This patch properly implements the internal object `supportedAlgorithms`
as a new enum type `SupportedAlgorithm`.

By doing so, we can reduce a lot of string comparison to enum matching,
which can be done faster. This patch also separates the dictionary
conversion away from the `match` block to make our code cleaner.
Furthermore, the `exportKey()` method can now utilize the new
`SupportedAlgorithm` to properly check against the algorithm
registration, instead of hard-coding an list of unsupported algorithms
by itself.

Testing: Refactoring. Existing tests suffice.

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-12-29 06:22:24 +00:00
WaterWhisperer
84487008ec script: Replace RefCell with DomRefCell in svgsvgelement::cached_serialized_data_url (#41547)
Testing: [WPT
tests](https://github.com/WaterWhisperer/servo/actions/runs/20552524367/job/59033378580)
Fixes: #41539

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-12-28 12:56:20 +00:00
Kingsley Yung
c77cc00474 script: Add helper function for setting JsonWebKey key_ops attribute (#41544)
Add a helper function `JsonWebKey::set_key_ops` for setting JsonWebKey
key_ops attribute to a given list of key usages. This task is very
common in export key operation of different cryptographic algorithms.
Adding this helper function helps simplify our code.

Testing: Refactoring. Existing tests suffice.

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-12-28 05:02:30 +00:00
Kingsley Yung
bb84e0dac3 script: Add helper function to handle JsonWebKey common encoding tasks (#41472)
Companion of #41428, which added helper functions to handle JsonWebKey
common decoding tasks.

This patch adds a helper function `JsonWebKey::encode_string_field` to
handle common base64url encoding tasks across multiple algorithms.

Testing: Refactoring. Existing tests suffice.

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-12-27 17:19:30 +00:00
Sam
d7324d7279 script: Pass &mut CurrentRealm in callbacks (#41536)
Continuation of #41520 to use more safe cx in promises, now by passing
&mut CurrentRealm in callbacks. Most callback implementations still do
conversions to old SafeJSContext, so there are some low hanging stuff
for follow ups.


Testing: Should be covered by existing WPT tests.
try run: https://github.com/sagudev/servo/actions/runs/20540030020
Part of #40600

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-12-27 16:33:26 +00:00
Sam
6e0e50505e script: Use more new JSContext/CurrentRealm in crossorigin codegen (#41537)
reviewable per commit

Testing: Should be covered by WPT tests.
try run: https://github.com/sagudev/servo/actions/runs/20540365373
Part of #40600

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-12-27 15:59:32 +00:00
Sam
600accba82 script: Support new context for promise and add some more helpers to ease migration (#41520)
This PR adds support for using new JSContext/CurrentRealm to promise and
adds some more helpers that will ease migration to new context model.
Second commit has another demo.

Testing: Covered by WPT
Part of #40600

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-12-27 13:11:37 +00:00
Martin Robinson
f418c1272f base: Move Unicode offset types to base (#41521)
This moves the Unicode offset types to the `base` crate and makes them
generally more usable throughout the Servo codebase. In addition, they
are renamed to use Rust naming and to be a bit more consistent:

 - `UTF8Bytes` -> `Utf8CodeUnitLength`
 - `UTF16CodeUnits` -> `Utf16CodeUnitLength`

There is also a bit more documentation explaining their use.

This is preparation for fixing issues with UTF-16 offsets in editable
text fields.

Testing: This does not change behavior so existing WPT tests should
suffice.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-12-25 14:48:40 +00:00
Andreu Botella
f4307334dc script: Make link elements set ElementState::UNVISITED (#41478)
In Servo, the `:link` and `:any-link` pseudo-classes correctly match
link elements when they are part of a compound selector whose last
simple selector does not start with them (e.g. `a:link` or `:link b`),
but they do not match when the last simple selector starts with `:link`.

The reason for this seems to be that Stylo uses two methods to determine
whether an element is an (unvisited) link: to call the `is_link()`
method on the `selectors::Element` trait, and to check if the element's
state has `ElementState::UNVISITED` set.

In a browser like Servo which does not support visited styles, these two
checks should be equivalent. However, they turn out not to be, because
Servo never actually sets `ElementState::UNVISITED`.

Since per the HTML spec the `:link` selector applies to all `<a>` and
`<area>` elements that have an `href` attribute, this patch fixes this
by setting `ElementState::UNVISITED` on such elements when the `href`
attribute is set, and by unsetting it when it is removed.

Testing: There are two invalidation-related WPT tests about the
`:any-link` selector that now pass with this patch.

Fixes: servo/stylo#282

---------

Signed-off-by: Andreu Botella <andreu@andreubotella.com>
2025-12-24 08:00:40 +00:00
Simon Wülker
c8ed7a7269 layout + script: Use Iterator::sum in more places (#41501)
This change replaces a couple calls to `Iterator::fold` with
`Iterator::sum`.

Testing: No tests, this is a small cleanup PR.

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-12-24 07:58:58 +00:00
Martin Robinson
273c1d54b7 Fix build of ./mach test-unit -p base (#41498)
`malloc_size_of` depends on `tendril` having the `encoding_rs` feature
turned on, but this was only turned on transitively via `html5ever` and
`script`/ `script_bindings` `tendril` dependencies. This change makes it
so that `malloc_size_of` depends directly on `tendril` and moves this
dependency to the root `Cargo.toml`.

Testing: This just fixes a particular build configuration.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-12-23 17:44:36 +00:00
atbrakhi
ae6f56f194 Separate console.clear() from ConsoleLogLevel (#41495)
Separate `console.clear()` from `ConsoleLogLevel`. See
https://github.com/servo/servo/pull/41311#discussion_r2622642820

Testing: Tested locally. Unfortunately in DevTools tests we do not cover
console tab

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
2025-12-23 14:27:04 +00:00
Gregory Terzian
9cd480f7ee indexeddb: implement databases concept(detete and databases method) (#41322)
Moves the concept of databases closer to the 3.0 spec, by implementing
the delete functionality, and the method returning current databases to
script.

Testing: WPT tests with new passes
Fixes: The "Implement databases deletion and `databases`" item of
https://github.com/servo/servo/issues/40983

---------

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
2025-12-23 14:09:48 +00:00
Steven Novaryo
b68d277c55 script: Add stub VisualViewport Interface (#41372)
Add placeholder implementation of DOM `VisualViewport` according to the
spec https://drafts.csswg.org/cssom-view/#visualviewport. This is the
first step of implementing the interface and syncing it with the
`PinchZoom` struct that we had in the `Embedder`.

Since this interface's is not accurate and couldn't fulfill it's
purpose, it would be gated behind a preference
`dom_visual_viewport_enabled` and would be open after the interface had
been integrated with `PinchZoom`, viewport resizing, and viewport
scroll.

Testing: Existing WPT Test.
Part of: #41341

---------

Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
2025-12-23 09:56:13 +00:00
Mukilan Thiyagarajan
2ccd9f54ad libservo: Let UserContentManager be per WebView and add basic support for mutations. (#41352)
This change moves the `UserContentManager` abstraction from the
`ServoBuilder` to `WebViewBuilder` so that embedders can inject content
for each `WebView` independently. It also adds basic support for runtime
mutations to the `UserContentManager` API. Only adding new scripts is
currently supported, but future changes will add support for both other
mutations such as removal of scripts and addition & removal of
stylesheets. Future changes could also optimize the way mutations are
propagated to `ScriptThread`s by sending just the "delta" rather than
the whole `UserContents` structure for each mutation.

The `UserContentManager` now becomes just a convenient handle for the
embedders to invoke the mutation API while the actual management of the
manager's content is handled by the Constellation. The mutations are
relayed to the constellation via messages. The change also separates the
serialized version containg the user contents into a new `UserContent`
structure so that the API cannot be misused.

Testing: New unit tests have been added for the different scenarios
involving UserContentManager.

---------

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-12-23 06:15:01 +00:00
Martin Robinson
55c4f579c9 fonts: Refactor the font fallback code a little bit and remove RwLock around FontGroup (#41449)
This change reworks the logic for finding font fallbacks to make it
simpler. I was involved with writing the code for `FontGroupFamily` and
`FontGroupFamilyMember` and I still struggle a bit with understanding
it, so I've chosen to do this. In addition, the change is in preparation
for more flexible font fallback (#41426).

The main changes here are:
 1. Move the logic for creating a new descriptor with variations into
    the Font constructor.
 2. Add some more general methods to `FontGroupFamily` such as a
    template iterator.
 3. Use `OnceLock` to avoid a convoluted code structure because of
    mutability and also having boolean "loaded" members. This is what
    `OnceLock` and `OnceCell` are for!
 4. Rename `FontGroupFamilyMember` to `FontGroupFamilyTemplate` to
    stress that it is one template of a particular `FontGroupFamily`.

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

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-12-22 15:06:25 +00:00
Oriol Brufau
3ee05f7c7d script: Restrict box tree damage from changes in original display (#41475)
When the original display of an absolutely positioned element changes,
the static position can be affected. However, the static position is
only used when both insets in the same axis are `auto`.

Therefore, this patch avoids dirtying the box tree when both axes have a
non-auto inset.

Testing: Not needed, this should have no observable behavior change

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-12-22 12:58:45 +00:00
Kingsley Yung
007f3379c5 script: Add helper functions to handle JsonWebKey common decoding tasks (#41428)
Add several helper functions to JsonWebKey to handle common base64url
decoding tasks across multiple algorithms. Those helper functions
include:

- `JsonWebKey::decode_optional_string_field`: decode optional field
- `JsonWebKey::decode_required_string_field`: decode required field
- `JsonWebKey::decode_primes_from_oth_field`: decode oth field to primes

These help simplify our code for importing keys in JsonWebKey format.

Testing: Refactoring. Existing tests suffice.

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-12-22 04:45:16 +00:00
PaulTreitel
008ffa6965 script: Add remaining AES error messages (#41442)
Fill in the error messages across
`script/dom/subtlecrypto/aes_operations.rs` that were still left as
`None`.

Testing: No tests added as these are just error messages.
Addressing: #40756

---------

Signed-off-by: PaulTreitel <paul.treitel@gmail.com>
2025-12-21 20:55:22 +00:00
WaterWhisperer
6623cc1dbb feat: gamepad feature flag (#41451)
Put the Gamepad API and its supporting infrastructure behind a `gamepad`
feature flag. This allows embedders to opt-out of gamepad support at
compile time to save on binary size and reduce dependencies.

Testing:
1. `./mach build -d` (Gamepad enabled by default)
2. `cargo build -p servoshell --no-default-features --features
"libservo/clipboard,js_jit,max_log_level,webgpu"` (Gamepad Disabled)
3. `cargo build -p servoshell --features "gamepad,webxr,..."` (Gamepad &
WebXR Enabled)

Fixes: #40897

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-12-21 13:18:06 +00:00
Jan Varga
1a6b18937a libservo: Add initial SiteDataManager::site_data API (#41378)
This PR adds an initial `site_data` API to `SiteDataManager`, allowing
embedders to obtain a unified list of sites that have associated site
data.

The implementation introduces supporting infrastructure across storage
and
`SiteDataManager` layers, including a small helper for obtaining
WebStorage
origins and initial support for filtering by storage type. At this
stage,
sites correspond directly to origins, future work will extend this to
higher
level grouping (e.g. domain or eTLD+1).

Testing: Added a new integration test covering site data behavior across
localStorage and sessionStorage.

---------

Signed-off-by: Jan Varga <jvarga@igalia.com>
2025-12-21 12:45:43 +00:00
WaterWhisperer
a45186675a script: Support --local-script-source for module scripts (#41445)
The `substitute_with_local_script` logic has been refactored into a
standalone function to allow reuse in `script_module.rs` when a module
script's source is fetched and decoded.

Testing: Verified manually by running Servo with a local HTTP server and
a module script, confirming that the local file correctly replaces the
remote one when the `--local-script-source` flag is provided.

Fixes: #41433

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-12-21 12:30:22 +00:00
Simon Wülker
b0734b7f2d script: Make same-origin iframes inherit encoding from their container document (#41450)
Testing: new tests start to pass
Part of https://github.com/servo/servo/issues/6414

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-12-21 11:03:30 +00:00