Commit Graph

121 Commits

Author SHA1 Message Date
Martin Robinson
d9b183f39b script: Add support for parsing CSS in parallel (#40639)
This change is a rework of #22478, originally authored by @vimpunk.

It adds parsing of CSS in parallel with the main script thread. The
big idea here is that when the transfer of stylesheet bytes is
finished, the actual parsing is pushed to a worker thread from the Stylo
thread pool. This also applies for subsequent loads triggered by
`@import` statements.

The design is quite similar to the previous PR with a few significant
changes:

 - Error handling works properly. The `CSSErrorReporter` is a crossbeam
   `Sender` and a `PipelineId` so it can be trivially cloned and sent to
   the worker thread.
 - Generation checking is done both before and after parsing, in order
   to both remove the race condition and avoid extra work when the
   generations do not match.
- The design is reworked a bit to avoid code duplication, dropping added
   lines from 345 to 160.
 - Now that `process_response_eof` gives up ownership to the
   `FetchResponseListener`, this change avoids all extra copies.

Testing: This shouldn't change observable behavior, so is covered
by existing tests.
Fixes: #20721
Closes: #22478

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: mandreyel <mandreyel@protonmail.com>
2025-11-15 09:10:27 +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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Martin Robinson
8f6edca4dd net: Simplify FetchResponseListener and move it to script (#40461)
`FetchReponseListener` has traditionally lived in `net` even though it
is only used in `script` currently. Because of the two way dependency,
it has also use a lot of templating to implement something pretty basic
(call methods on a trait object).

This change moves the trait to `script` and removes several levels of
templating, making the code quite a bit shorter and easier to
understand.

This change is preparation for fixing #22550 and implementing
off-the-main-thread CSS parsing.

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

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-06 14:44:01 +00:00
Martin Robinson
bdcae320fd net: Use callbacks instead of IPC channels in the ImageCache API (#40453)
Previously, the `ImageCache` would inform consumers of changes to image
availability by messaging an IPC channel. This isn't great, because it
requires serialization and deserialization. Nowadays, `ImageCache`s are
always owned by the same `Global` that uses them. This change replaces
the IPC channel with callback that implements `Send`.

For the case of normal HTML document images, the results are still sent
over the pre-existing Crossbeam channel that was connected via an IPC
route. A followup change might eliminate that channel entirely.

Testing: This should not change observable behavior so is covered by
existing tests.
Fixes: #24338.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-11-06 12:52:40 +00:00
WaterWhisperer
158bf97e30 script/dom/: Change some #[allow]s to #[expect]s (#40454)
Removes some unneeded lints, especially `#[allow(unsafe_code)]`.

Testing: Refactor
Part of: #40383

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-11-06 11:06:03 +00:00
Martin Robinson
f08460cded script: Handle broken image icon in HTMLImageElement (#40429)
Instead of having the `ImageCache` return the broken image icon for
failed loads, have `HTMLImageElement` explicitly request it. This means
that the image is loaded on demand (reducing the usage of resources) and
also simplifying the interface of the `ImageCache` greatly.

In addition, the display of the broken image icon is improved, more
closely matching other browsers. A test for this display (which was
falsely passing before) is updated to reflect the new display of the
broken image icon.

Testing: There is a Servo-specific test for this change. Some WPT tests
start to fail as well. Before these were not properly loading the broken
image icon so they were failing before, just in a hidden way.

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-11-06 09:36:21 +00:00
Luke Warlow
e3c4655463 Partially implement dialog.showModal() (#40405)
Partially implement dialog.showModal()

Follow-ups will be needed to further implement proper dialog
functionality but this makes a good start.

Testing: Existing WPTs cover this.

---------

Signed-off-by: Luke Warlow <lwarlow@igalia.com>
2025-11-05 15:03:13 +00:00
Andrei Volykhin
66c990e373 html: Support releasing of <media> underlying resources and frames (#40316)
The HTMLMediaElement should stop playback of any previously playing
media resource on running media element loading algorithm or before
attempt to load next source child.

This step will reset media player (including release of the underlying
media resources and media frames from the video renderer).

The closure for marshalling the incoming GLPLayer messages from ROUTER
("router-proxy") thread to script thread will use
`Weak<MediaFrameRenderer>` instead of `Trusted<HTMLMediaElement>` to
break circular references dependency (decouple ownership).

The media frame renderer will track the media player id to be able
ignore async locking render call with new frame after playback of any
previously playing media was stopped.

Testing: No WPT test expectation changes

Fixes (partially): https://github.com/servo/servo/issues/40243
Fixes (partially): https://github.com/servo/servo/issues/40265
Fixes: https://github.com/servo/servo/issues/37173

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-11-05 08:52:43 +00:00
Simon Wülker
46e6d072b7 script: Enforce exclusivity between <details> elements in the same tree (#40314)
Within the same tree, only one `<details>` element with the same name
may be open at a time. Before this change, this invariant was not
enforced.

I've added a `HashMap` to `Document` and `ShadowRoot` which maps from a
name to the a list of details elements with the same name. This map
allows us to find conflicting details elements without having to
traverse the whole tree. Of course this only works when the tree is a
document tree or a shadow tree, so we still have to fall back to
`traverse_preorder` in some cases (which I believe to be uncommon).

This is ready for review, but I'd like to wait until
https://github.com/servo/servo/pull/40271 is merged to not cause
unnecessary merge conflicts.

Testing: New web platform tests start to pass

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-11-04 21:54:21 +00:00
Martin Robinson
9fa6303d26 script: Let HTMLCanvasElement manage the ImageKey for canvases (#40375)
This change makes it so that the `HTMLCanvasElement` is responsible for
managing the `ImageKey` for associated `RenderingContext`s. Only
canvases display their contents into WebRender directly, so this makes
it so that keys are not generated for `OffscreenCanvas`.

The main goal here is that `ImageKey`s are always associated with a
particular `WebView`, which isn't possible in the various canvas
backends yet. This is important because each `WebView` may soon have a
different WebRender instance entirely with its own set of `ImageKey`s.

This also allows for clearing `ImageKey`s when canvases are disconnected
from the DOM in a future change. One tricky thing here is placeholder
canvases, which are meant to be driven from workers.

It seems that the implementation isn't correct for these at the moment
as they need to be updated to the specification. Instead, what is
happening is that any existing context / image is completely lost when
converting to an `OffscreenCanvas`.

Testing: This shouldn't change observable behavior, so is covered by
existing tests.
Fixes: This is part of #40261.

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-11-04 12:18:30 +00:00
Gregory Terzian
f174c53fee script: improve spec compliance of the iframe load event steps (#40100)
Prevent the running of the iframe load event steps for the initial
about:blank document. Part of
https://github.com/servo/servo/issues/31973

Testing:
/html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/iframe-nosrc.html
Fixes: It is expected that the intermittent issue of 34819 will go away,
but I will leave it open so we can close it when we realize it isn't
being mentioned by PR's anymore.

https://github.com/servo/servo/issues/34819

---------

Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
2025-11-03 07:08:37 +00:00
Luke Warlow
8ca4ecba02 script: Implement ToggleEvent and use for <details> element (#40271)
Implement ToggleEvent and use for details element

Testing: Covered by existing WPTs

Signed-off-by: Luke Warlow <lwarlow@igalia.com>
2025-11-02 18:20:18 +00:00
Martin Robinson
f5865c77f9 wpt: Turn on selectFiles and handle asynchronicity in FileAPI test (#40349)
This change fixes the Servo-specific FileAPI tests which need the
special `SelectFiles` API. In addition, file selection is now totally
asynchronous, so update the tests to handle this.

Testing: This change fixes some tests.
Fixes: #40348.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-02 11:07:54 +00:00
Yerkebulan Tulibergenov
1713f0c8f2 script: add CanGc as argument to VirtualMethods.post_connection_steps (#40329)
script: add `CanGc` as argument to
`VirtualMethods.post_connection_steps`

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-01 10:01:15 +00:00
Simon Wülker
c4ae451612 Turn all commented links before functions into doccomments (#40331)
Servo has a lot of comments like this:
```rust
// https://example-spec.com/#do-the-thing
fn do_the_thing() {}
```
and I keep turning these into doc comments whenever I'm working close to
one of them. Doing so allows me to hover over a function call in an IDE
and open its specification without having to jump to the function
definition first. This change fixes all of these comments at once.

This was done using `find components -name '*.rs' -exec perl -i -0777
-pe 's|^([ \t]*)// (https?://.*)\n\1(fn )|\1/// <$2>\n\1$3|mg' {} +`.

Note that these comments should be doc comments even within trait `impl`
blocks, because rustdoc will use them as fallback documentation when the
method definition on the trait does not have documentation.

Testing: Comments only, no testing required
Preparation for https://github.com/servo/servo/pull/39552

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-11-01 05:32:45 +00:00
Yerkebulan Tulibergenov
5cc786a98e script: add CanGc as argument to VirtualMethods::children_changed (#40325)
script: add CanGc as argument to VirtualMethods::children_changed

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-01 00:20:25 +00:00
lumiscosity
41d9c7f07f script: fix defaults on formMethod getters on <input> and <button> (#40310)
Fixes the getters for `formMethod` on `<input>` and `<button>` elements
providing a missing value default when they shouldn't.

Testing: 2 new passing tests in `html/dom/reflection-forms.html`.
Fixes: #8302. (`formEnctype` seems to have already been fixed since that
issue was filed.)

---------

Signed-off-by: lumiscosity <averyrudelphe@gmail.com>
2025-10-31 18:35:00 +00:00
Simon Wülker
2111a122e2 script: Don't unregister slots from their shadow root when the whole shadow tree is being unbound (#40278)
Each shadow root holds a map of slot names to slot elements. Slot
elements dynamically register and unregister themselves at their
respective shadow root when they are bound and unbound from the tree.

Previously, they were doing this too often. When a slot element is
unbound from the tree then it might still be connected to its shadow
root, in case the entire shadow tree is being unbound.

Fixing this requires the slot element to know whether it was in a shadow
tree prior to `bind_to_tree` being called (then it's already registered
and doesn't need to do so again), and whether it will be in a shadow
tree after `unbind_from_tree` is called (then there's no need to
unregister).

Testing: This change adds a new web platform test
Fixes: https://github.com/servo/servo/issues/40242

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-10-30 13:09:35 +00:00
WaterWhisperer
32c0c41d11 script: Move performance DOM interfaces to script/dom/performance/ (#40262)
Moves interfaces defined by the performance spec to the
`script/dom/performance/` module from `script/dom/`.

Testing: Just a refactor shouldn't need any testing
Fixes: Partially #38901

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-10-29 11:41:52 +00:00
WaterWhisperer
d5baab2bfc script: Move CSS DOM interfaces to script/dom/css/ (#40241)
Moves interfaces defined by the CSS spec to the `script/dom/css/` module
from `script/dom/`.

Testing: Just a refactor shouldn't need any testing
Fixes: Partially #38901

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-10-28 17:40:44 +00:00
TIN TUN AUNG
db3ccd9917 Media: Change of Volume of video tag should passed to player (#40203)
When changing the 'volume' attribute of media element, should also call
`set_volume()` api of underlying player if it is valid value.

Testing: No Test is required, as this should not affect any WPT Test
Fixes: N/A

---------

Signed-off-by: rayguo17 <rayguo17@gmail.com>
Signed-off-by: TIN TUN AUNG <62133983+rayguo17@users.noreply.github.com>
Co-authored-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-10-27 04:19:56 +00:00
Yerkebulan Tulibergenov
c2f6a1b89d add CanGc as argument to methods in HTMLImageElement (#40177)
add CanGc as argument to methods in HTMLImageElement

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-10-27 00:06:32 +00:00
Yerkebulan Tulibergenov
d394be3cc5 add CanGc as argument to methods in HTMLLinkElement (#40178)
add CanGc as argument to methods in HTMLLinkElement

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-10-26 23:58:34 +00:00
Simon Wülker
fc908adfd8 script: Return early from "assign_slottables" when assigned slots did not change (#40191)
The remainder of this algorithm updates the slottables assigned slot and
the slots assigned nodes, but neither operation will do anything if the
slottables didn't change. This should be a slight performance
improvement.

Testing: Covered by existing tests

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
2025-10-26 22:26:54 +00:00
Martin Robinson
8be7ec73fd pixels: Split Snapshot into SharedSnapshot and Snapshot (#40136)
This splits `Snapshot` into two structs:

- `Snapshot`: A non-serializable owned image buffer that might contain
  either shared memory or a `Vec<u8>`. When mutated the shared memory
  version is converted into a `Vec<u8>` avoiding a copy of the data
  until absolutely necessary.
- `SharedSnapshot`: A serialzable version of `Snapshot` that contains
  only shared memory and is suitable for sending across IPC channels.
  This version is cheaply convertible from and to owned `Snapshot`s as
  long as the source is also a shared memory `Snapshot`.

In addition, it does copyless conversions of `RasterImage` into
`Snapshot`s (including for frame offsets in animated images). Finally,
there are a few minor changes to try harder not to have to do a
`transform()` operation.

Testing: This should not change observable behavior, so is covered by
existing
tests. It should come with a mild performance improvement and open up
the
opportunity for others.
Fixes: #36594.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-10-26 15:03:30 +00:00
Yerkebulan Tulibergenov
1f6c4f0180 add CanGc as argument to methods in HTMLMediaElement (#40179)
add CanGc as argument to methods in HTMLMediaElement

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-10-26 07:48:57 +00:00
Yerkebulan Tulibergenov
132bd24c6d add CanGc as argument to Validatable.validity_state (#40155)
add CanGc as argument to Validatable.validity_state

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-10-25 06:06:32 +00:00
Andrei Volykhin
45ed17de54 html: Add the 'name' and 'areas' IDL attributes for <map> (#40133)
Follow the HTML specification and add the missing 'name' and 'areas' IDL
attributes to HTMLMapElement.

https://html.spec.whatwg.org/multipage/#htmlmapelement

Testing: Improvements in the following WPT tests
- custom-elements/reactions/customized-builtins/HTMLMapElement.html
- html/dom/idlharness.https.html

Signed-off-by: Andrei Volykhin <andrei.volykhin@gmail.com>
2025-10-24 14:19:24 +00:00