Commit Graph

173 Commits

Author SHA1 Message Date
Josh Matthews
c6f2fc2eb5 script: Capitalize Content-Type key in formdata. (#41722)
The tests were performing exact string matching on the contents of the
request body, so this change allows them to match.

Testing: Newly passing tests.

---------

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2026-01-07 06:05:41 +00:00
Martin Robinson
2efa7d5d96 script: Add a Rope type and use it for TextInput (#41650)
`TextInput` internally stores a rope of text content, one segment for
each line. This change separates out the rope into a separate `Rope`
data structure that can be shared with other parts of Servo.

`TextInput` needs to move through text content in a variety of ways,
depending on the keys pressed when interacting with a text area. This
change provides a unified movement API in both `Rope` and in
`TextInput` ensuring that selection is handled consistently (apart from
a few minor quirks [^1]). This simplifies the code an improves
interactive behavior.

[^1]: One of these quirks is that the edit point will move to
directional end of the motion when collapsing a selection, but only when
moving by grapheme or word (and not by line). These quirks existed in an
undocumented way previously and they are preserved with code comments.

Testing: This is covered by existing unit tests (updated for the new
API) and
the WPT suite.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-01-06 14:52:08 +00:00
Tim van der Lippe
d44c38998c net: Keep track of size of keep-alive records (#41457)
These keep-alive records live on the `CoreResourceManager` since the vec
of records must be modified by the fetch thread. The script thread
sometimes
requires this information as well, which is why it can send a message to
obtain the total size.

The keep-alive records must be tracked per global. That's why all code
needs
to specify the `pipeline_id`. Requests optionally have this field, which
is why
the code expects it to be present. The relevant information is added to
the
navigator request to ensure it can compute it.

Fixes #41230

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-01-05 18:22: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
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
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
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
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
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
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
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
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
Tim van der Lippe
b02465bc53 script: Mark beacon requests as keepalive (#41405)
This is checked if the body is a stream, but the payload calculation
needs to be in a follow-up PR.

Part of #38302

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-12-19 09:01:36 +00:00
Tim van der Lippe
5b6509f279 script: Implement customElementRegistry support for document.importNode (#41385)
This method now allows you to pass in a custom registry. The registry
isn't used yet for callers, since we don't support scoped registries.
However, as we now pass in the registry to `Node::clone`, we set the
registry when creating elements and cloning them.

As such, various tests start passing where we set the registry. Some
tests started failing, but they rely on scoped registries which we don't
support yet. These tests thus flipped: those that were erroneously
failing are now passing and vice versa.

Part of #34319

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-12-19 09:01:08 +00:00
Tim van der Lippe
d8bf293828 script: Remove Drop implementation of FetchCanceller (#41384)
Instead, we now explicitly call `.terminate()` and introduce relevant
methods to FetchCanceller.

Follow-up from review in #41345

---------

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
Signed-off-by: Tim van der Lippe <TimvdLippe@users.noreply.github.com>
Co-authored-by: Josh Matthews <josh@joshmatthews.net>
2025-12-19 08:31:09 +00:00
Tim van der Lippe
e35a4c81d7 script: Implement destroying of documents (#41346)
The specification has a dedicated method for destroying
documents. Parts of that method were scattered around
various parts of Servo machinery.

This patch consolidates these steps and follow the spec.
Additionally, it now correctly unloads iframes when
they are removed from a parent document.

As a result, the fetch-later WPT test now passes, as
it relies on the correct ordering of iframe unloading
to verify the fetch-later requests are sent.

Part of #31973

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-12-19 07:12:46 +00:00
Narfinger
1b0bd11e11 Use GenericSender and GenericReceiver for WebDriver (#40987)
- Use the generic channel for webdriver.
- Implement try_receive_timeout for GenericReceiver.

Testing: WPT should still work.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2025-12-19 03:22:02 +00:00
Tim van der Lippe
3ac02bc6ac script: Mark fetch-later requests as keep-alive (#41345)
This implements the required plumbing for the keep-alive flag on
requests. The flag already exists on the request object, but now also
exists on the builder itself.

The flag is then passed into a canceller. While we could make canceller
optional, in many cases it isn't and would require a whole lot more
changes. To follow the spec more closely, opted to put the keep_alive
flag on the canceller as well.

Note that this doesn't pass any extra fetch-later tests since we are not
correctly unloading iframe documents. That will be fixed in a follow-up
PR.

Part of #41230

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2025-12-18 19:49:13 +00:00
Simon Wülker
9cbb522606 script: Support legacy "background" presentational hint on more elements (#41272)
Testing: New tests start to pass
Fixes https://github.com/servo/servo/issues/41269

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-12-16 04:22:42 +00:00
Luke Warlow
803743a920 Fire toggle events for dialog methods (#40412)
Fire toggle events for dialog methods

Testing: Existing WPTs

Depends on #40405

Signed-off-by: Luke Warlow <lwarlow@igalia.com>
2025-12-13 08:46:36 +00:00
Josh Matthews
fac1067ec7 script: Add newlines after each value in formdata body. (#41199)
Fixes logging in to lichess.org, since our request body now matches what
other browsers send.

Testing: Newly passing WPT tests.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2025-12-11 11:08:22 +00:00
Gae24
f4d8c4569e script: Bring creating and running classic scripts closer to spec (#40938)
Use the algorithms introduced in #41109 in more places.
Follow more closely the spec when executing classic scripts, introducing
the concepts of rethrowing and muting errors.
Muting errors is not actually implemented, and will be done in a
followup.

Testing: More tests start passing 
Fixes #34199
Fixes #27260
Fixes #15188

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2025-12-10 18:14:34 +00:00
Martin Robinson
824f551f03 Rename IOCompositor to Paint (#41176)
For a long time, the "Compositor" hasn't done any compositing. This is
handled by WebRender. In addition the "Compositor" does many other
tasks. This change renames `IOCompositor` to `Paint`.

`Paint` is Servo's paint subsystem and contains multiple `Painter`s.
This change does not rename the crate; that will be done in a
followup change.

Testing: This just renames types and updates comments, so no new tests
are necessary.

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-12-10 15:09:49 +00:00
Andrei Volykhin
807979b40a script: Decouple ownership of the media element from IPC router callback (#41131)
Added new invocation struct `HTMLMediaElementEventHandler` that allows
to decouple ownership of the `HTMLMediaElement` from the IPC router
callback (break cyclic reference dependency) by replacing a `Trusted`
wrapper with more suitable `WeakRef`.
Note that `WeakRef` is not thread-safe and MUST be rooted and/or deleted
on the script thread.
    
Testing: Regressions in the following tests caused by overly aggressive
GC on document activity change to `Inactive` and will be follow up in
https://github.com/servo/servo/issues/41138
-
html/semantics/embedded-content/media-elements/autoplay-allowed-by-feature-policy.https.sub.html
-
html/semantics/embedded-content/media-elements/autoplay-default-feature-policy.https.sub.html
-
html/semantics/embedded-content/media-elements/autoplay-disabled-by-feature-policy.https.sub.html

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

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-12-10 14:41:42 +00:00
Gae24
3b205ad8f2 script: Implement creating and running classic scripts according to spec (#41109)
Implemented spec algorithms [create a classic
script](https://html.spec.whatwg.org/multipage/#creating-a-classic-script)
and [run a classic
script](https://html.spec.whatwg.org/multipage/#run-a-classic-script).
Classic script now gets unminified on creation.

Testing: Behaviour hasn't changed much, but we pass a new test instead
of crashing.

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2025-12-07 19:06:41 +00:00
webbeef
c217cbb5a6 dom: Avoid crashing on empty favicon href attribute (#41056)
Add a check to handle_favicon_url() similar to the ones done in similar
functions: handle_stylesheet_url() and fetch_and_process_prefetch_link()

Testing: Check that loading http://chiptune.com/  doesn't crash anymore.
Fixes: https://github.com/servo/servo/issues/41047

Signed-off-by: webbeef <me@webbeef.org>
2025-12-06 20:00:23 +00:00
Taym Haddadi
d10d481016 Guard MediaElementAudioSourceNode against closed contexts and add crash test (#41092)
Guard MediaElementAudioSourceNode against closed contexts and add crash
test

Testing: Added crash test.
Fixes: #41083

---------

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-12-06 16:39:36 +00:00
Anonmiraj
b207be05d9 change some allows to expects (#41040)
Changed some allow to expects and removed the unfulfilled expectations.

Testing: Refactor
Part of: #40383

Signed-off-by: anonmiraj <nabilmalek48@gmail.com>
2025-12-05 07:23:32 +00:00
Andrei Volykhin
9a1d86cc88 html: Change the play state of the media player if the old is opposite (#41027)
It's important to check the media player's `paused` state to avoid
unnecessary changes to its internal state (via `play`, `pause`),
including configuration the `playback rate` and `volume` properties.

Depends on https://github.com/servo/media/pull/467

Testing: The expected test results are unchanged because it is the
implicit performance improvements of the media stack, with the exception
of the following test, which is affected by the `playback rate` state
caching mechanism (the `seek` position is not overridden for default
playback rate (1.0)).
- html/semantics/embedded-content/media-elements/preserves-pitch.html

See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4762

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-12-04 12:19:48 +00:00
Andrei Volykhin
f935174981 html: Enhance image update the image data, environment changes algorithms (#41046)
The following image processing algorithms were updated (with
description)
- https://html.spec.whatwg.org/multipage/#update-the-image-data
- https://html.spec.whatwg.org/multipage/#img-environment-changes

Added missing `image request phase` switching cases and non-spec
handling of the `last selected source`.

Testing: Improvements in the following tests
-
html/semantics/embedded-content/the-img-element/current-pixel-density/error.html
-
html/semantics/embedded-content/the-img-element/environment-changes/viewport-change.html

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

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-12-04 12:18:41 +00:00
Andrei Volykhin
d539ac8cf3 html: Track the script/UA initiated media seek request (#40981)
The low-level media `seek` request could be initiated by script (DOM
method call or setting of an IDL attribute), by the user agent (seeking
data) or by the media engine itself (e.g. gst_play_set_rate()).
And to distinguish between them we will use the latest seek position (in
seconds) to be able abort processing the `seek` algorithm steps (13-17)
for a `seek` request initiated by the media engine.

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

If the `seeking` is in progress, any callback which affects the current
playback position (`position changed`, `end of the playback`) shouldn't
be processed (event marshalling over IPC router is non-state
conditional).

Testing: Regression in the following test causes by gstreamer issue when
the `gst_play_set_rate()` overrides the latest seek requested position
unconditionally and the user agent receives the `seek completion` event
with the unexpected seek position (0.5+ instead of 0.0).
- html/semantics/embedded-content/media-elements/preserves-pitch.html

See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4762

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

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-12-02 11:27:21 +00:00
Oriol Brufau
02ed2af193 script: Don't dirty with ContentOrHeritage damage when changing state (#40902)
When for example changing the hover state of an element, we were
dirtying it with ContentOrHeritage damage, which forced it to be laid
out again.

This was added in #39102 in order to fix #38989, but for the most part
it's no longer needed.

However, we will now dirty when a `<textarea>` or `<input>` which can be
selected gets or loses focus. This is to ensure that the caret or
selections get correctly updated.

Testing: Manually tested that #38989 is not regressing

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-12-02 10:19:50 +00:00
Andrei Volykhin
155dc71a65 script: Fire the video resize event in the expected order (#40940)
Queuing a media element task given the media element to fire an event
named `resize` at the media element shoud be done:
- upon the initial `metadata` event from the media engine

https://html.spec.whatwg.org/multipage/#loading-the-media-resource:event-media-resize
- whenever the video dimensions are changed (readyState is not
`HAVE_NOTHING`)

https://html.spec.whatwg.org/multipage/#the-video-element:event-media-resize

See https://html.spec.whatwg.org/multipage/#event-media-resize

Testing: Added new test to confirm `resize` event ordering
-
html/semantics/embedded-content/media-elements/event_order_durationchange_resize_loadedmetadata.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-12-01 08:17:35 +00:00
Ignacio Casal Quinteiro
b00a76427a Fix various typos throughout the code base (#40934)
Signed-off-by: Ignacio Casal Quinteiro <qignacio@amazon.com>
2025-11-28 15:00:56 +00:00
Andrei Volykhin
a516b74ffa html: Update the media player state without delays (#40898)
Currently the sequence order of the DOM method calls and the media
player API calls is mismatched because some media player operations (*)
posted to media task with delayed processing (while should be processed
immediately).
- DOM (script): pause -> seek -> play
- Media: seek -> pause* -> play*

Also the associated queued media events can be fired and processed by
script somehow (e.g. by calling `seek` in event listener handler) even
before the calling of the media player `play/pause` API.

To handle it the application will try to update media state (by calling
media player API) on each DOM `play, pause` method calls and on some
`ready state` changes with checking if the media element can be
potencially playing.

See https://html.spec.whatwg.org/multipage/#potentially-playing

Testing: No expected testing results changes because there are
unexpected `seek completion` signals from the media engine with invalid
time positions which are affecting passing test score (by masking false
positive results).
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4762

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-27 20:06:40 +00:00
Andrei Volykhin
87e8e1ac50 html: Add new media tracks when receiving the initial media metadata event (#40917)
The new audio/video tracks should be added to the media element from the
initial `metadata` event from the media engine because there are
possibility of the multiple `metadata` events without any associated
`media track` state changes and previously the application added new
tracks into lists unconditionally.

The registered issue to handle possible dynamic `media track` state
changes from the media engine gracefully.
https://github.com/servo/media/issues/473

Testing: Improvements in the following tests
-
html/semantics/embedded-content/the-video-element/video_size_preserved_after_ended.html

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

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-27 07:45:59 +00:00
Andrei Volykhin
a5a475cfd8 html: Fix handling of the media playback EnoughData event (#40881)
The media engine signals with the `PlayerEvent::EnoughData` event that
the media source has enough data and the application should stop pushing
more data to avoid excessive buffer queueing and wait
`PlayerEvent::NeedData` event to continue.

Note that the source buffer size - MAX_SRC_QUEUE_SIZE (50MB).

This event is reflecting the state of the media source so the
application shouldn't change the media element ready state somehow.

Testing: No expected testing results changes

Fixes (partially): https://github.com/servo/servo/issues/40740

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-25 16:14:26 +00:00
Yerkebulan Tulibergenov
d0ce02a860 script: add CanGc as argument to methods in HTMLOptionElement (#40873)
script: add CanGc as argument to methods in HTMLOptionElement

Testing: These changes do not require tests because they are a refactor.
Addresses part of https://github.com/servo/servo/issues/34573

Signed-off-by: Yerkebulan Tulibergenov <yerkebulan@gmail.com>
2025-11-25 04:41:39 +00:00
Andrei Volykhin
2937300a9e html: Update MediaSession setPositionState method (#40793)
The MediaSession `setPositionState` method should only update the
position state and propagate it to the platform media session UI
controller and shouldn't change somehow the properties of the media
element directly (duration, playback rate or position).
    
See
https://w3c.github.io/mediasession/#dom-mediasession-setpositionstate
    
Testing: Improvements in the following tests
- /mediasession/positionstate.html
    
The media session UI functionality is implemented for Android and didn't
test due lack of testing sample.

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-24 16:47:36 +00:00
Mukilan Thiyagarajan
90595e3570 compositing: Support per-Painter operations and message handling (#40788)
Currently, only the first `Painter` is used for all operations in the
`Compositor`. This change modifies the compositor API and message
handling to allow routing the operations to the correct `Painter` via a
provided `PainterId` or `WebViewId`.

This change is to enable support for per-`WebView`s `RenderingContext`s.

Testing: This change shouldn't change behavior, so existing WPT tests
should cover it.

---------

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-11-21 13:15:55 +00:00
Jonathan Schwender
f76ce4c64d Prefer log over (e)println! (#40764)
Switches to log methods over eprintln in cases where it makes sense.
stdout / stderr output may be difficult to view on devices like android
/ ohos, and has no filter options, so we should prefer log methods.
This PR avoids prints, which are controlled by a debugging option.

Testing: Only changes logging, no functional behavior change.

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2025-11-20 15:15:30 +00:00
Andrei Volykhin
bc9e8d2949 html: The queued <media> volumechange event should be cancellable (#40763)
Following the HTML specification, on the `volume` or `mute` attrubute
changes the user agent must queue a media element task given the media
element to fire an event named `volumechange` at the media element (the
`generation_id` value will be captured to allow cancel this task -
`media-element-load-algorithm` steps 3-5)

See https://html.spec.whatwg.org/multipage/#event-media-volumechange
See https://html.spec.whatwg.org/multipage/#media-element-load-algorithm

Changed the naming of the `playbackRate` and `defaultPlaybackRate`
members to match Rust naming conventions (`snake_case`).

Testing: Added the `cancellable` subtest to `event_volumechange` test
- html/semantics/embedded-content/media-elements/event_volumechange.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-20 13:41:17 +00:00
Ashwin Naren
e0eb23ce18 script: Finish converting all error message enum variants to Option<String> (#40750)
I used find and replace to finish the job. All this PR does is replace
all `Error::<error_name>` occurrences with `Error::<error_name>(None)`.

Testing: Refactor
Fixes: #39053

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
2025-11-20 06:20:47 +00:00
d-kraus
adf840a7c4 script: Add message to Dom exception Error::NotSupported (#40745)
Adding an optional message to Error::NotSupported. Unblocks
https://github.com/servo/servo/issues/39050.

The enum definition of NotSupported is now
`NotSupported(Option<String>)`.

Testing: Just a refactor
Fixes: Partially https://github.com/servo/servo/issues/39053

Signed-off-by: Dennis Kraus <kraus@posteo.de>
2025-11-20 01:31:33 +00:00
Taym Haddadi
66a50ad687 Fix RefCell already borrowed panic in HTMLMediaElement::set_audio_renderer (#40729)
Fix RefCell already borrowed panic in
HTMLMediaElement::set_audio_renderer

Testing: new crash test should pass.
Fixes: #40720

Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2025-11-19 00:34:15 +00:00
Martin Robinson
5494995e01 libservo: Add ContextMenuElementInformation to for the context menu API (#40607)
This new data structure allows passing more information when popping up
context menus. It's possible in the future that it will be adapted into
a more generic "hit test result" type API ala WebKit, but for now, this
is probably
enough.

Testing: This change includes new API test assertions.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-17 15:53:43 +00:00