Commit Graph

75 Commits

Author SHA1 Message Date
elomscansio
aa7eca43b7 script: propagate VirtualMethods::unbind_from_tree with &mut JSContext (#44422)
Propagate `&mut JSContext` in `VirtualMethods::unbind_from_tree`

Testing: Successful build is enough
Fixes: #42837

---------

Signed-off-by: Emmanuel Paul Elom <elomemmanuel007@gmail.com>
2026-04-23 14:09:11 +00:00
Tim van der Lippe
c8029ea092 script: Rename CanGc::note() to CanGc::deprecated_note() (#44081)
Per the suggestion in

https://servo.zulipchat.com/#narrow/channel/263398-general/topic/PSA.3A.20avoid.20new.20usages.20of.20CanGc.20whenever.20possible/near/583995807
to mark this method as deprecated and make clear it shouldn't be used
anymore, as alternatives exist.

Part of #40600

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-04-10 06:07:52 +00:00
TIN TUN AUNG
280d984d3b media: Implement Player for ohos backend (#43208)
Implement Player Trait in ohos backend using Harmony OS MediaKit's[
AVPlayer](https://developer.huawei.com/consumer/en/doc/harmonyos-references/capi-avplayer-h).

The modular design of `VideoSink`, `InnerPlayer`, and `MediaSource` is
taken from the GStreamer backend.
Only support HarmonyOS SDK API 21, because the
`OH_AVPlayer_SetDataSource` only started to be exposed on API 21.

Testing: N/A, as there are no platform specific task.
Fixes: N/A, now we can play video on HarmonyOS phone using `<video>`

---------

Signed-off-by: rayguo17 <rayguo17@gmail.com>
2026-04-08 08:48:10 +00:00
Tim van der Lippe
f340042c1d script: Pass &mut JSContext to FetchResponseListener::process_response_chunk (#43657)
Fixes #42841

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-26 18:05:24 +00:00
Euclid Ye
cae0752676 cargo: Rename workspace-local library starting with b to servo_* (#43552)
Follow up of #43526. This addresses Nico's comment:
https://github.com/servo/servo/pull/43526#issuecomment-4104953308

- `bluetooth_traits` -> `servo_bluetooth_traits`
- `base` -> `servo_base`
- `bluetooth` -> `servo_bluetooth`
- `background_hang_monitor` -> `servo_background_hang_monitor`

Testing: This should not change any behaviour.

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2026-03-23 08:26:49 +00:00
Tim van der Lippe
8f699b1f17 script: Pass &mut JSContext to submit_timing_data (#43479)
Part of #40600

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-20 15:31:46 +00:00
Tim van der Lippe
3d4cfa4718 net: Remove process_request_eof (#43477)
This is no longer present in the spec. Instead, the
`process_request_body` is the new way. These two
methods were called right after each other and there was only 1
implementation in `htmlvideoelement`. That implementation is now moved
to `process_request_body` and hence we can remove the unnecessary
method.

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-20 10:51:33 +00:00
Javier Olaechea
eea60b8eb1 script: Pass &mut JSContext to FetchResponseListener::process_response (#43259)
Add the cx parameter to `fn process_response` in the
`FetchResponseListener` trait and the traits that that interface change
requires. Chose to add it as the first parameter, following the same
order that `FetchResponseListener::process_response_eof` uses.

Testing: Checked that servo builds locally as well as `./mach fmt` and
`./mach test-tidy`. I don't think more tests are needed as we are not
introducing new functionality
Fixes: #42840

---------

Signed-off-by: Javier Olaechea <pirata@gmail.com>
2026-03-19 06:22:00 +00:00
Tim van der Lippe
479a9b6be3 script: Pass &mut JSContext to attribute_mutated (#43383)
It pushes the `temp_cx` 1 level up to `element.rs` where the calling
chain begins. Other than that this was purely a mechanical change where
I used regexes to replace all patterns with the new ones.

Part of #42812

Testing: It compiles

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-03-18 11:03:54 +00:00
Gae24
026d679783 script: Pass &mut JSContext to Element::create (#43348)
Pass `&mut JSContext` to `Element::create` and `create_html_element`

Testing: No functionality changes, covered by existing tests.
Part of #40600

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-17 13:03:33 +00:00
Gae24
e8b581aaf0 script: Pass &mut JSContext in more places (#43252)
Continuation of #43220, removes many `temp_cx` calls introduced by that.

Testing: No behaviour change, a successful build is enough.
Fixes: #43241 #43240

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-14 10:03:48 +00:00
Gae24
ef97d7e199 script: Pass &mut JSContext to VirtualMethods::bind_to_tree (#43220)
Testing: No behaviour change, a successful build is enough.
Fixes: #42838 #43239

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-14 07:37:47 +00:00
Gae24
048612fe84 script: Pass &mut JSContext to children_changed and adopting_steps (#43219)
Switch `VirtualMethods::children_changed` and
`VirtualMethods::adopting_steps` to `&mut JSContext`.

Testing: No behaviour change, a successful build is enough.
Part of #40600

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-03-13 13:40:40 +00:00
Simon Wülker
c0ff7c1fc9 Everywhere: Remove instances of clippy::redundant-clone (#43212)
This change fixes all instances where
[`clippy::redundant-clone`](https://rust-lang.github.io/rust-clippy/master/index.html?groups=complexity%2Ccorrectness%2Cnursery%2Csuspicious&levels=allow#redundant_clone)
would trigger. It's allowed by default

I've also changed the lint to warn-by-default for servo.

Testing: Covered by WPT

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2026-03-12 13:28:21 +00:00
Martin Robinson
401d327b96 script: Clean up attribute access a little bit in Element (#43064)
- Use modern Rust conveniences such as `unwrap_or_default`
 - Unabbreviate `attr`
- Unify the lowercase ASCII name assertion and make it a debug assertion
 - Use `unreachable!` instead of panic
- Expose two attribute getters that follow the behavior of two
specification concepts and what we expect internally in Servo:
- One that takes a namespace, but does not require lowercase attribute
names. ([specification
concept](https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace>))
- One that does not take a namespace, but does require lowercase
attribute names. ([specification
concept](https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name))
Testing: This should not really change behavior so should be covered by
existing tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-03-06 20:02:37 +00:00
Narfinger
b55bc205a7 script: jscontext-ify element aria methods and SetCrossOrigin (#42957)
Use &mut JSContext in element aria* methods and SetCrossOrigin methods.

Testing: Compilation is the test as this is part from
https://github.com/servo/servo/issues/40600

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2026-03-02 17:23:33 +00:00
Sam
3e2f14c455 script: Pass down &mut JSContext in servoparser and event loop. (#42635)
I only wanted to get `&mut JSContext` in microtask chunk and checkpoint,
but this in turn needed `&mut JSContext` in servoparser, which then
caused need for even more changes in script.

I tried to limit the size by putting some `temp_cx` in:
- drops of `LoadBlocker`, `GenericAutoEntryScript`
- methods of `VirtualMethods`
- methods of `FetchResponseListener`

Testing: Just refactor, but should be covered by WPT tests.
Part of #40600

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-02-25 07:14:23 +00:00
Sam
43bdd3818d script: Pass &mut JSContext to more dom methods (#42751)
split from https://github.com/servo/servo/pull/42635, some dom methods
are also called from other function, which require passing down cx from
many more places :(

Testing: Just refactor, but should be covered by WPT.
Part of #42638

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-02-22 13:22:33 +00:00
Sam
9f1e5d084e script: Pass &mut JSContext in FetchResponseListener::process_response_eof (#42729)
`process_response_eof` is the only method that needs cx at least right
now. This PR removes one temp_cx and introduces one, removing that one
will is hard (needs VirtualMethods and a lot of work)

Testing: Just refactor
Part of #40600

---------

Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
2026-02-20 16:03:21 +00:00
Narfinger
d41bb930e1 painter: Insert a cache for animation with smarter updates (#41956)
This inserts a cache in painter that keeps data for animating images in
Painter.
We then can send cheap ImageUpdate::UpdateAnimation to just get the
required bytes from the cache.

There are some warts with the current design:
- ImageUpdate::AddImage only adds images in the cache that have the data
in SerializableImageData::Raw. Potentially there could be image
animations in other ways which then for a following
ImageUpdate::UpdateAnimation we do not have the data. We can probably
fix this on the sender side.

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

Testing: Tested on the usecase in
https://github.com/servo/servo/issues/41818 and WPT test here:
https://github.com/Narfinger/servo/actions/runs/21063721427
Fixes: https://github.com/servo/servo/issues/41818

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2026-01-28 14:07:27 +00:00
Martin Robinson
9c9d9c863f Rename compositing and compositing_traits to paint and paint_api (#42066)
This change finishes the big rename associated with the old
`compositing` crates. Long ago, these crates managed a compositor, like
you might find in a traditional web engine. These days, compositing is
done in WebRender so the name has stopped making much sense. Various
structs inside the crates have already been renamed and this is the
final big change necessary for the rename

Testing: This is just a rename so existing tests should cover it.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-01-24 09:17:35 +00:00
Laurent Belmonte
0dc28296e0 script: Some failed requests should record resource timing entries (#41804)
Some failed requests should record resource timing entries

Testing: ./mach test-wpt
tests/wpt/tests/resource-timing/entries-for-network-errors.sub.https.html
Fixes: https://github.com/servo/servo/issues/41667

---------

Signed-off-by: bellau <laurent.belmonte@gmail.com>
2026-01-14 13:20:12 +00:00
WaterWhisperer
2a759ed6de Replace allow(crown::unrooted_must_root) with expect(crown::unrooted_must_root) (#41815)
Testing: `./mach build -d --use-crown` with no warnings
Fixes: #41761

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2026-01-10 08:05:49 +00:00
Tim van der Lippe
e2d62531f5 script: Consolidate global initialization for fetch requests (#41663)
Rather than having each callside specifying the relevant
information from the GlobalScope, do this via a trait instead.
This would have saved us quite a bit of test debugging
since we would often forget to set relevant information
from the global context for a request.

Now, in the future when we need additional information from
the globalscope for a request, we only need to update this
method to make that happen.

Previously it would also sometimes use `document`, but
calling the relevant information on either `document` or
`globalscope` doesn't matter, since the `globalscope`
defers to the value from the `document` anyways.

Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
2026-01-07 13:22:03 +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
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
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
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
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
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
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
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
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
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
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
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
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
Andrei Volykhin
1301dbfcdf html: Run the <media> play seek if loop attribute was set after playback ended (#40688)
The user agent on the `internal play steps` (step 2) must to seek to the
earliest possible position if the playback has ended, but the definition
of the `ended playback` prevents looping when the loop attribute was
added after playback has ended (already registered whatwg html issue).
```
- playback ended (`ended` event)
- loop = true
- play() (no seeking - playback hasn't ended)
```

Currently this edge case if not yet reflected in the HTML specification
so let's do the same as other browsers and ignore the `loop` attribute
for `play` seek.

See https://html.spec.whatwg.org/multipage/#internal-play-steps
See https://github.com/whatwg/html/issues/4487

Testing: Improvements in the following tests
-
html/semantics/embedded-content/media-elements/playing-the-media-resource/loop-from-ended.tentative.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-17 14:41:52 +00:00
Andrei Volykhin
73f8dce99e html: Fire the <media> canplaythrough event in the expected order (#40685)
Follow the HTML specification, queue a media element task to fire
`canplaythrough` event in expected order (after `canplay`) on the
changing the ready state to `HAVE_ENOUGH_DATA` which align the event
ordering for non-autoplay and autoplay media.

See
https://html.spec.whatwg.org/multipage/#ready-states%3Aevent-media-canplaythrough

The associated WPT PR:
https://github.com/web-platform-tests/wpt/pull/56014

Testing: Improvements in the following tests
-
html/semantics/embedded-content/media-elements/ready-states/autoplay.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-17 11:12:11 +00:00
Andrei Volykhin
ac0da57bc1 html: Handle new DurationChanged event by <media> (#40644)
A new event `PlayerEvent::DurationChanged` has been added to the media
engine to simplify handling changes in the duration of a media stream
(sometimes the duration could be inaccurate or even determined by the
media engine with significant delay after the initial metadata was
ready).

This new event eliminates the need to check conditions for two
consecutive `MetadataUpdated` events (the initial metadata and the
metadata with the changed duration) during the loading phase.

servo-media:
- Add new `PlayerEvent::DurationChanged` event
(https://github.com/servo/media/pull/461)

Testing: No expected changes in test results

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

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-14 15:14:13 +00:00
Simon Wülker
a1269e809d Replace calls to ".filter_map()" followed by ".next()" with ".find_map()" (#40612)
The two are semantically equivalent, but `find_map` is more concise.

Testing: Covered by existing tests

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-11-13 14:53:57 +00:00