Commit Graph

12292 Commits

Author SHA1 Message Date
Andrei Volykhin
c19641e3fe html: Add <media> current and official playback positions (#40609)
Follow the HTML specification and split the previous `playback position`
to `current playback position` (a time on the media timeline) and
`official playbac position` (an approximation of the current playback
position that is kept stable while scripts are running) which must be
set to `the current playback position` any time the user agent provides
a stable state.

See https://html.spec.whatwg.org/multipage/#current-playback-position
See https://html.spec.whatwg.org/multipage/#official-playback-position

Note that at this point, there are no difference between the `current`
and `official` playback positions (as the time on the media timeline),
except the `seek` case.

Testing: Improvements in the following tests
-
html/semantics/embedded-content/media-elements/seeking/seek-to-max-value.htm
-
html/semantics/embedded-content/media-elements/seeking/seek-to-negative-time.htm

Fixes: https://github.com/servo/servo/issues/34496

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-13 11:42:41 +00:00
Taym Haddadi
4658fc333a Add AbortSignal garbage collection (#40508)
Add AbortSignal garbage collection

Testing: all AbortSignal should pass.

Fixes: #40481

---------

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-11-13 10:58:55 +00:00
Simon Wülker
c039078ab3 xpath: Apply predicate list before sorting result when evaluating location step expression (#40592)
The result of a predicate can depend on the position of the node in its
set, and this position is dependent on the axis that the node set came
from. This is specified in
https://www.w3.org/TR/1999/REC-xpath-19991116/#predicates.

Additionally, this change fixes a small bug in the implementation of
`preceding::` (https://github.com/servo/servo/pull/40588) where the root
of a subtree would be included twice. That wasn't discovered earlier
because nodes are deduplicated at the end of the evaluation.

Testing: New tests start to pass, this change adds more tests

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-11-13 10:27:06 +00:00
WaterWhisperer
d57d422924 script: servoparser line number pass to CSP (#40597)
takes over the initial work from @zazabap in PR #38675 (Thanks
@zazabap!)

Testing: 
`./mach test-wpt
content-security-policy/securitypolicyviolation/blockeduri-inline.html`
`./mach test-wpt
/css/CSS2/abspos/abspos-containing-block-initial-001.xht`
Fixes #38167  
Closes #38675

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
Co-authored-by: zazabap <sweynan@icloud.com>
2025-11-13 09:48:17 +00:00
Kingsley Yung
b235a35a7c script: Correctly parse spki and pkcs8 of ECDH (#40605)
We parse the `parameter` field of the `algorithm` AlgorithmIdentifier
field of `spki` and `pkcs8` of ECDH keys as an object identifier.
However, according to WebCrypto API specification, we should parse it as
an `ECParameters` ASN.1 type defined in [RFC5480].

```plaintext
ECParameters ::= CHOICE {
  namedCurve         OBJECT IDENTIFIER
  -- implicitCurve   NULL
  -- specifiedCurve  SpecifiedECDomain
}
```

Although our current implementation works fine since `ECParameters` is
defined as a `CHOICE` type with an object identifier as the only option,
it is technically incorrect. This patch fixes this mistake.

Testing: No behavioral change. Existing tests suffice.

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-11-13 09:17:47 +00:00
Andrei Volykhin
6bb012b76b html: Add <media> internal ended_playback method (#40603)
Following the HTML specification, a new internal method,
`ended_playback`, has been added to differentiate it from the `ended`
attribute:
- `ended_playback`: playback has ended for the `forward/backward`
directions
- `ended` attribute: playback has ended for the `forward` direction

See https://html.spec.whatwg.org/multipage/#ended-playback

Added descriptions for the steps of the `Play`, `Pause`,
`internal_play_steps` (new), `internal_pause_steps`,
`notify_about_playing`, `change_ready_state` methods.

Testing: No expected changes in test results.

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-13 08:32:52 +00:00
Andrei Volykhin
59526928af html: Remove canGC argument from <media> internal seek method (#40587)
The `seek` method isn't explicitly exposed in the API, but is called
from various places (`currentTime`, `fastSeek`, by the `media metadata`
event) and doesn't itself create new DOM objects, so the `canGC`
argument can be omitted.

It was previously required because calling the `Seekable` method creates
a new `TimeRanges` object, but it will now be replaced by the internal
`seekable` method to avoid interaction with the JavaScript engine (and
potential garbage collector).

The `earlyest possible position` method has been changed to match the
specification and use `seekable` instead of `played`. See
https://html.spec.whatwg.org/multipage/#earliest-possible-position

Testing: No expected changes in tests

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-12 18:44:15 +00:00
Martin Robinson
0a1061d8d7 script: Use ScriptEventLoopSender for Runtime event loop callbacks (#40590)
Instead of using a task source for SpiderMonkey runtime callbacks, use a
`ScriptEventLoopSender`. Task sources are associated with a particular
Pipeline, but the runtime callback is run indepenently of any particular
Pipeline and could theoretically happen when no Pipeline exists at all.
This reduces the dependency of the `ScriptThread` on the existence of
the first Pipeline.

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

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-12 18:16:59 +00:00
Andrei Volykhin
4d938368cb bump(deps): bump servo-media from 5b788a9 to 8aca9f7 (#40563)
Updated the `PlayerEvent::PositionChanged/SeekDone` events to support
precise position timestamps (u64 -> f64).
    
Also set precise time value (seconds with fractional part) for the
HTMLMediaElement `duration` from media metadata to sync with
`PlayerEvent` changes.

servo-media:
- Pass precise position timestamp within PlayerEvent
(https://github.com/servo/media/pull/460)

Testing: No expected changes in test results

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-12 15:43:34 +00:00
Martin Robinson
ab0f818583 script: Consolidate more logic into ScriptThread::spawn_pipeline (#40586)
Have more of the code follow the same path calling
`ScriptThread::spawn_pipeline`. Somewhat tricky was that the `origin` of
the new Pipeline was being determined in several different places, but
all in a consistent way for different types of page loads. This change
makes it is so that the origin is always determined in the same place.

This change is preparation for splitting out the creation of a new
`ScriptThread` and the spawning of its first pipeline.

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

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-12 15:37:25 +00:00
Kingsley Yung
2f5f40222c script: Implement sign operation of ECDSA (#40591)
Finish adding ECDSA support to WebCrypto API. This patch implements sign
operation of ECDSA, using ECDSA implementation from the crates `ecdsa`
for the operation, `p256`, `p384`, `p521`, and `elliptic_curve` for the
key, and `sha1`, `sha2` and `digest` for digesting messages.

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

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-11-12 12:33:51 +00:00
Simon Wülker
5ecf09d76a xpath: Fix implementation for preceding::/following:: axes (#40588)
`preceding::` needs to yield all preceding nodes, excluding ancestors.
`following::` needs to yield all following nodes, excluding descendants.

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

Testing: New tests start to pass

---------

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

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

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

---------

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

Testing: refactor
Fixes: one item in #39053

---------

Signed-off-by: Austin Willis <austinwillis8@gmail.com>
2025-11-12 07:34:47 +00:00
Martin Robinson
65deada7ef script: Return only a JoinHandle from ScriptThread constructor (#40571)
The `JoinHandle` was added as a newer return value from this
constructor. Both return values accomplish more or less the same thing.
The difference is that the `Sender` return value is triggered right
before the thread ends while the `JoinHandle` is triggered after thread
completion. One was used in multiprocess mode and one in single process
mode. In any case, the `JoinHandle` works fine for both cases.

Testing: Multiprocess isn't tested currently, but I confirmed that the
ScripThread shut down properly in multiprocess mode with this change.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-12 05:40:28 +00:00
Martin Robinson
bfde51c0db script: Have FetchResponseListener::process_response_eof consume the listener (#40556)
The goal of this change is to prevent having to copy so much data out of
listeners when a fetch completes, which will be particularly important
for off-the-main thread parsing of CSS (see #22478). This change has
pros and cons:

Pros:
- This makes the design of the `FetchResponseListener` a great deal
simpler.
They no longer individually store a dummy `ResourceFetchTiming` that is
   only replaced right before `process_response_eof`.
 - The creation of the `Arc<Mutex<FetchResponseListener>>` in the
   `NetworkListener` is abstracted away from clients and now they just
   pass the `FetchResponseListener` to the fetch methods in the global.

Cons:
 - Now each `FetchResponseListener` must explicitly call `submit_timing`
   instead of having the `NetworkListener` do it. This is arguably a bit
   easier to follow in the code.
 - Since the internal data of the `NetworkListener` is now an
   `Arc<Mutex<Option<FetchResponseListener>>>`, when the fetching code
   needs to share state with the `NetworkListener` it either needs to
   share an `Option` or some sort of internal state. In one case I've
   stored the `Option` and in another case, I've stored a new inner
   shared value.

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

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-11 22:30:40 +00:00
Simon Wülker
c23a9594ca script: Choose correct document for xpath queries (#40564)
The result of an xpath query can depend on whether or not the document
is a HTMLDocument. We should always use the document that
`document.evaluate` was called on. Instead, we were using the document
of the relevant window. This makes a difference when a script creates a
document and calls `document.evaluate` on that.

Testing: New tests start to pass

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-11-11 15:45:34 +00:00
Martin Robinson
1e4feeaa0d script: Add context-based context menu options (#40501)
Add context menu options for images, links, and editable text areas. In
addition add the ability to show menu options that are disabled. This
also improves the visual style of the context menu in egui as part of
supporting disabled options.

Testing: This has been manually tested, but we could we should be able
to
easily add unit tests when enriching the API with information about the
active element under context menus.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Rakhi Sharma <atbrakhi@igalia.com>
2025-11-11 11:03:41 +00:00
Oriol Brufau
cb906a6219 script: Pass the right base URI to inline sheets (#40554)
HTMLStyleElement was creating stylesheets using the URI of the document,
ignoring `<base>`.

To avoid having to create the UrlExtraData twice (or clone it), this
inlines the `stylesheetcontents_create_callback`.

Testing: 2 WPT are now passing
Fixes: #40550

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-11-11 09:59:22 +00:00
Kingsley Yung
a094a0bbbc script: Implement verify operation of ECDSA (#40557)
Continue on adding ECDSA support to WebCrypto API. This patch implements
verify operation of ECDSA, using ECDSA implementation from the crates
`ecdsa` for the operation, `p256`, `p384`, `p521`, and `elliptic_curve`
for the key, and `sha1`, `sha2` and `digest` for digesting messages.

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

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-11-11 09:51:26 +00:00
Oriol Brufau
ffd74b9a1c deps: De-duplicate phf (#40555)
Other than upgrading phf, phf_codegen and phf_shared to 0.13, this also
upgrades html5ever, markup5ever and xml5ever to 0.36, string_cache to
0.9, and Stylo to https://github.com/servo/stylo/pull/266.

Testing: Not needed, no behavior change
Fixes: #40533

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-11-11 09:15:29 +00:00
Kingsley Yung
447569a0d7 script: Implement generate key operation of ECDSA (#40553)
Continue on adding ECDSA support to WebCrypto API. This patch implements
generate key operation of ECDSA, using ECDSA implementation from the
crates `p256`, `p384`, `p521` and `elliptic_curve`.

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

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-11-11 05:44:03 +00:00
Oriol Brufau
1d0a8b05fb Upgrade Stylo to 2025-11-01 (#40522)
This continues #39612

Changelog:
- Upstream:
b98470a5cb...d71fd89b78
- Servo fixups:
4714bab122...7481d7f7af

Stylo tracking issue: https://github.com/servo/stylo/issues/264

---------

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
2025-11-11 02:59:38 +00:00
webbeef
29bfb3a7b1 script: improve cookie processing of control characters (#40544)
This implements character set restrictions both for the DOM API and when
getting cookies from http/ws headers. This is a local workaround for
https://github.com/rwf2/cookie-rs/issues/243

We still fail some tests because hyper errors out when parsing headers
with %x1 characters.

This patch also makes a minor change to
'ServoCookie::from_cookie_string()' to avoid some string cloning when
possible.

Testing: wpt tests expectations are updated

Signed-off-by: webbeef <me@webbeef.org>
2025-11-11 00:23:03 +00:00
Narfinger
d8c46f0b15 script_bindings: Small USVString cleanup (#40537)
Some methods for USVString were not needed as they could lead to
inefficient usage
(like in CookieStoreMethod) it is better to remove them. Fixed two
methods that take the String
directly instead of copying it.

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

Testing: No testing necessary as the functionality stays the same.

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-11-10 13:45:56 +00:00
Kingsley Yung
b2e21af948 script: Implement export key operation of ECDSA (#40536)
Continue on adding ECDSA support to WebCrypto API. This patch implements
export key operation of ECDSA, using ECDSA implementation from the
crates `p256`, `p384`, `p521` and `elliptic_curve`.

Testing:
- Pass some WPT tests that were expected to fail.
- The new FAIL expectations are added to
`wrapKey_unwrapKey.https.any.js.ini`, which require the
not-yet-implemented sign/verify operations of ECDSA and RSA-OAEP. These
tests were skipped by WPT when the export key operation of ECDSA had not
been implemented at the time.

Fixes: Part of #39060

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-11-10 12:11:42 +00:00
Andrei Volykhin
de26bfc43a html: Add description for steps of legacy <audio> constructor (#40535)
Add missing description for steps of legacy <audio> constructor with a
small refactoring, avoiding unnecessary `upcast` from `HTMLAudioElement`
to `Element`.

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

Testing: No expected changes in tests (added steps description).

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-10 11:48:55 +00:00
Martin Robinson
b334c9470b constellation: Reuse InitialScriptState and InitialPipelineState in UnprivilegedPipelineContent (#40529)
`UnprivilegedPipelineContent` contains all of the data necessary to
create a new `ScriptThread` with an initial `Pipeline` in a new
process. This change reuses the `InitialScriptState` and
`InitialPipelineState` structs inside `UnprivilegedPipelineContent` and
renames it to `NewScriptEventLoopProcessInfo` to clarify what it does.

In addition, `InitialScriptState` also repeated much of the data of
`NewPipelineInfo`, which is now deduplicated and passed separately to
the `ScriptThreadFactory`.

The overall goal here is to make `ScriptThread` and `Pipeline` creation
separate. A `ScriptThread` contains many `Pipeline`s which come and go,
so it should not depend on a single creation `Pipeline`. This is the
first step toward doing that.

Some inputs to `ScriptThreadFactory` differ based on whether the new
`ScriptThread` is created in a new process or not. This change makes it
so that these input are passed as extra arguments.

Finally these changes have revealed a couple members of data structures
that aren't used. These have been removed.

Testing: This is just a refactor and shouldn't change behavior so is
covered by existing tests.

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

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

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

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

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-10 10:09:03 +00:00
Kingsley Yung
885b404da6 script: Implement import key operation of ECDSA (#40523)
Start adding ECDSA support to WebCrypto API. This patch implements
import key operation of ECDSA, using ECDSA implementation from the
crates `p256`, `p384`, `p521` and `elliptic_curve`.

Testing:
- Pass some WPT tests that were expected to fail.
- Remaining failed tests in `ec_importKey.https.any.js.ini` require the
not-yet-implemented export key operation of ECDSA.
- The new FAIL expectations are added to `ecdsa.https.any.js.ini`, which
require the not-yet-implemented sign/verify operations of ECDSA. These
tests were skipped by WPT because the import key operation had not been
implemented at the time.

Fixes: Part of #39060

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-11-10 07:32:34 +00:00
Taym Haddadi
28dd9f9749 Implement read looping using a read request following the spec (#39510)
Implement read looping using a read request following the spec.

Testing:  current wpt test should pass.
Fixes: #39482

---------

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-11-09 22:05:12 +00:00
Sam
b73b908dbd script: Start preparation to use safer JSContext (#40465)
This PR is companion to https://github.com/servo/mozjs/pull/638,
currently it only make stuff compile. In follwups we will start
passing/using safer JSContext down everywhere.

Testing: Not needed as it's just refactorings.
try run:
https://github.com/sagudev/servo/actions/runs/19196312972/job/54879090390

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2025-11-09 05:17:26 +00:00
Excitable Snowball
a5c3cc3b4e script: Use InputEvent for input events (#39989)
Use `InputEvent` for text input and set appropriate values for the
`composed`, `data`, `isComposing`, and `inputType` attributes. Use a
placeholder for `dataTransfer` attribute and `getTargetRanges` function,
as they are only applicable to contenteditable, which isn't implemented.

Testing: I added two tests under `tests/wpt/mozilla/tests/input-events`
based on the similarly named ones for contenteditable under
`tests/wpt/tests/input-events`.
Fixes: https://github.com/servo/servo/issues/36398

---------

Signed-off-by: Excitable Snowball <excitablesnowball@gmail.com>
2025-11-08 23:04:03 +00:00
Andrei Volykhin
c67ef13d7c html: Render media controls without ready state precondition (#40456)
Follow the specification and allow to render media controls (expose a
user interface to the user) without any HTMLMediaElement `readyState`
precondition.

The media controls be shown for the following examples without specified
media source (e.g. without `src` attribute).
```
<audio controls></audio>
<video controls>/<video>
```

See https://html.spec.whatwg.org/multipage/media.html#user-interface

For media controls UI don't define root `div` element's style `width`
property from the video natural size (`videoWidth/Height` IDL attributes
which return `0` if `readyState` is `HAVE_NOTHING`).

When the `media` element is adopted between different documents need
adopt the media controls id, so media controls UI
will keep access to the whilelist of media controls identifiers via
`document.servoGetMediaControls(id)` API.

Testing: Improvements in the following tests
-
html/rendering/replaced-elements/embedded-content-rendering-rules/audio-controls-00*
-
html/semantics/the-button-element/command-and-commandfor/on-audio-behavior.tentative.html
-
html/semantics/the-button-element/command-and-commandfor/on-audio-invalid-behavior.tentative.html
Note that `Invoker Commands` API is not yet supported so these `command
and commandfor` tests should fail, but due to previous bug with delayed
media controls shown up. The invoker `onClick` function send actions
with mouse events
(move/up/down) to the test driver at the position of the button element
(via getBoundingClientRect), but before test driver
will handle these actions the mediadata is received and media controls
are shown up with "play" button at this position.
So the media control "play" button is clicked instead of the button, and
it triggers media element `pause` state change.
  See https://open-ui.org/components/invokers.explainer/

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-08 19:57:59 +00:00
Josh Matthews
cc1552e8a7 Suppress debug representations of network response bodies (#38789)
Adds a wrapper type for vectors that can contain large response bodies
to prevent flooding debug logs with the contents of those bodies.

Testing: Can't test debug log output.
Fixes: #37769

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-11-08 19:49:17 +00:00
Martin Robinson
99daf8c644 script: Wrap remaining unsafe code and enable unsafe_op_in_unsafe_fn (#40499)
This is last step toward enabling the default rustc
`unsafe_op_in_unsafe_fn` warning for the script crate. It wraps the
remaining unsafe code in `unsafe {}` and removes the line disabling this
warning from `script`'s `Cargo.toml`. In addition, two variables are
renamed from `v` to something slightly more descriptive.

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

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-08 14:27:35 +00:00
Martin Robinson
0c0945c308 script: Handle more ScriptThread messages synchronously (#40490)
Make the handling of more messages to the `ScriptThread` happen
synchronously with the rest of the message handling. Previously these
had to be handled first, but the resiliency of the `ScriptThread` has
increased such that they can be done inline now. This simplifies message
handling.

Testing: This should not change observable behavior and is thus covered
by existing tests. In fact, no tests fail with this change which is
the reason we can do it.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-08 12:46:43 +00:00
Martin Robinson
dfc9819b38 script: Rename ScriptThreadMessage::AttachLayout to ScriptThreadMessage::SpawnPipeline (#40491)
The thing that this message does is to spawn a pipeline in a
`ScriptThread`. I believe that the `AttachLayout` name is a relic of a
different time. The corresponding procedure in the `Constellation` is
already called `Pipeline::spawn`.

Testing: This is just a rename, so existing tests should cover this
change.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-08 11:16:58 +00:00
atbrakhi
ad8c81d634 servoshell: Implement context menu in servoshell (#40434)
This PR adds context menu support with clickable menu items in the
Minibrowser. The menu appears on right click and supports basic
navigation actions (Back, Forward, Reload).


Testing: We already have tests for ContextMenu in WebView API test.

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-11-08 11:11:09 +00:00
Kingsley Yung
11ad3af0ca script: Implement derive bits operation of X25519 (#40497)
Finish adding X25519 support to WebCrypto API. This patch implements
derive bits operation of X25519, using X25519 implementation from the
crate `x25519-dalek`.

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

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-11-08 07:29:21 +00:00
Martin Robinson
65b4e183a4 script: Wrap unsafe code in windowproxy.rs in unsafe {} (#40493)
This is another step on the way toward enabling the default set
of rustc compiler warnings for `script`. This also renames two
functions according to Rust snake case guidelines.

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

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-08 07:26:37 +00:00
Ashwin Naren
435fa2696d Fix some typos in comments across various parts of the codebase (#40492)
Testing: This only updates comments, so should not need new tests.

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-11-08 04:49:04 +00:00
Martin Robinson
8f9f440e98 script: Wrap unsafe code in scriptruntime.rs in unsafe {} (#40494)
This is another step on the way toward enabling the default set
of rustc compiler warnings for `script`. This also renames two
functions according to Rust snake case guidelines.

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

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-07 18:54:55 +00:00
Narfinger
3bfd107686 net: Do not implement Serialize/Deserialize for RasterImage and introduce`SharedRasterImage (#40459)
RasterImage is now not seralizeable and backed by Vec<u8> storage. Add a
new struct `SharedRasterImage` that allows serializeing. This can be
constructed from RasterImage. This introduces some more copying but I
think the tradeoff is ok. Newly introduced copies are for favicon
response to the embedder and EmbedderNotifications.

Testing: Should not change functionality, so covered by existing tests.
Fixes: https://github.com/servo/servo/issues/39626 and related issues.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-11-07 16:49:32 +00:00
Gregory Terzian
933ebe428d script: extend the prevention of the firing of load events to all iframes (#40401)
This extends the preventing of the firing of the load events when there
is a pending navigation from the initial blank document only to all
iframes. Part of https://github.com/servo/servo/issues/31973

Testing: tests/wpt/mozilla/tests/mozilla/FileAPI/file-upload.html
Fixes: This should fix the intermittency of
https://github.com/servo/servo/issues/40348

---------

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
2025-11-07 15:47:36 +00:00
Mukilan Thiyagarajan
e3f6c06fe4 compositor: Allow GenerateFrame to take Vec<WebViewId> (#40482)
This change simply allows `GenerateFrame` to carry a list of
`WebViewId`s and modifies `update_the_rendering` to collect `WebViewId`s
and pass them in the `GenerateFrame` message. The list of `WebViewId`s
is currently not used and that will be handled in a follow-up patch.

Testing: Covered by existing tests.

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-11-07 11:19:30 +00:00
Kingsley Yung
2dbf63e7ee script: Implement generate key operation of X25519 (#40480)
Continue on adding X25519 support to WebCrypto API. This patch
implements generate key operation of X25519, using X25519 implementation
from the crate `x25519-dalek`.

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

---------

Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
2025-11-07 11:12:08 +00:00
webbeef
17db529cb9 Reduce boilerplate in Constellation and ScriptThread (#34960)
The constellation has many cases of early returns in match expressions
that can be rewritten using `if let Some(...) = xyz else { return abc;
}`. Two macros are introduced to help with repetitive code blocks that
can't be extracted as functions.

<!-- Please describe your changes on the following line: -->


---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by
`[X]` when the step is complete, and replace `___` with appropriate
data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors


<!-- Also, please make sure that "Allow edits from maintainers" checkbox
is checked, so that we can help you if you get stuck somewhere along the
way.-->

<!-- Pull requests that do not address these steps are welcome, but they
will require additional verification as part of the review process. -->

Signed-off-by: webbeef <me@webbeef.org>
2025-11-07 08:48:29 +00:00
Shubham Gupta
71196c02ea Add basic IDL implementation for LargestContentfulPaint (#39714)
Add basic `IDL` implementation for `LargestContentfulPaint`

Testing: Tested locally
Fixes: N/A

<img width="800" height="210" alt="Screenshot from 2025-11-06 12-56-37"
src="https://github.com/user-attachments/assets/af453b8d-7605-4300-8c87-c2574feff81f"
/>

---------

Signed-off-by: Shubham Gupta <shubham.gupta@chromium.org>
2025-11-07 02:56:30 +00:00
WaterWhisperer
401165f154 script: Add message to IndexSizeError (#40463)
Adding an optional message to be attached to a IndexSizeError.

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

Testing: Just a refactor
Fixes: Partially #39053

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-11-07 01:08:00 +00:00