aboutsummaryrefslogtreecommitdiffstats
path: root/components/shared
Commit message (Collapse)AuthorAgeFilesLines
* chore: remove unnecessary `webrender_document` in script (#36648)Jason Tsai16 hours1-3/+1
| | | | | | | | | remove `webrender_document` in script and constellation's pipeline Testing: `webrender_document` in script crate is not being referenced anywhere in the Servo, should be safe to remove. Fixes: https://github.com/servo/servo/issues/36647 Signed-off-by: Jason Tsai <git@pews.dev>
* Reduce indexing boilerplate for serializable/transferrable objects. (#36624)Josh Matthews23 hours1-170/+89
| | | | | | | | | | | | | | | Rather than creating unique types for each pipeline-namespaced index type (eg. MessagePortId, DomExceptionId, etc.), we can create a generic common type that uses a marker to prevent type confusion. This change allows us to reduce the boilerplate code required when implementing serializable/transferable interfaces, since the structured clone implementation can rely on the common type. Testing: Existing WPT tests for serialization and transferring provide coverage. --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* compositing: Rename `WebView` to `WebViewRenderer` (#36574)Martin Robinson40 hours1-1/+1
| | | | | | | | | | | | | | | | | | | | There is a `WebView` in libservo (new) and a `WebView` in compositing (old). Nowadays, the "real" `WebView` is the one in the libservo. The `WebView` in `compositing` is really about rendering the contents of a `WebView` from libservo. In addition there is also a trait exposed by the compositor called `RendererWebView` which is a way for the compositor to talk to libservo without a circular dependency. This changes does some renames to make things clearer and so that there is One Less WebView™: - `compositing::WebView` -> `compositing::WebViewRenderer` (this is the same kind of naming as `ServoRenderer`). - `compositing::RendererWebView` -> `compositing::WebViewTrait` Testing: This is just a couple renames so should be covered by existing tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* constellation: Re-split structured data types into separate files (#36615)Martin Robinson45 hours6-575/+609
| | | | | | | | | | | | | | | | In #36364 I moved both serializable and transferable implementations from the `script_traits` crate into a single file called `message_ports.rs`. Gregory raised the point that this was a bit of a inaccurate grouping. This change attempts to fix it according to the division in the specification. See [the relevant thread on zulip][thread]. [thread]: https://servo.zulipchat.com/#narrow/channel/263398-general/topic/Organizing.20*_traits.20crates/near/510864104. Testing: Covered by existing test as this is just code movement. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Rework `ScriptThread::handle_input_event` for behaviour and performance (#36619)Euclid Ye45 hours1-1/+1
| | | | | | | | | | | | | | Rework `ScriptThread::handle_input_event` for correct behaviour and better performance 1. Only trigger click event with primary button, according to spec 2. Avoid unnecessary clone of `ConstellationInputEvent` This is a follow up of #36413 Testing: Manually tested. Right mouse won't trigger click event now. Fixes: #35666 cc @jdm @xiaochengh Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
* layout: Report memory usage for fragment and box trees. (#36553)Josh Matthews4 days2-2/+5
| | | | | | | | | | | | Add memory reporter integration for the fragment and box trees that are persisted in the layout thread. Testing: Looked at the numbers for https://servo.org and https://html.spec.whatwg.org/. The former was very small, but the latter was 700mb. --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Move click event trigger from embedding layer to `ScriptThread` (#36413)Euclid Ye4 days2-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Move click event trigger from embedding layer to `ScriptThread` 2. Previously, the logic is to trigger click event at same position as `MouseButtonAction::Up` if `MouseButtonAction::Up` is within 10px of `MouseButtonAction::Down`, in embedding layer. This PR ~~removes the condition~~ moves the check to `ScriptThread`. Testing: tested for webdriver with self written test case. Perform actions of pointermove, pointerdown, pointerup in sequence. Click event can now be triggered. Fixes: #35395 cc @xiaochengh @jdm For `MAYBE? TODO:` part I added, should we do it? I read the [spec](https://w3c.github.io/uievents/#event-type-click), it doesn't specify we have to implement MDN's way. If we should work in the MDN's way, it also should be fixed in another PR, as this PR doesn't regress anything. Also I am not sure what is the best way to do it. Should I handle it in https://github.com/servo/servo/blob/4d4f94936f8859f039497df370083fd7ea35fb00/components/script/dom/document.rs#L1296-L1297? --------- Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
* Streams: make writable streams transferrable (#36588)Gregory Terzian5 days1-0/+3
| | | | | | Making writable streams transferrable, part of https://github.com/servo/servo/issues/34676 Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* chore: Update wgpu to v25 (#36486)sagudev5 days1-2/+23
| | | | | | | | | | Updates wgpu to v25 and remove some verbose logging from CTS (that also causes OOM). Testing: WebGPU CTS --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
* Refactor common infrastructure for creating memory reports. (#36579)Josh Matthews5 days4-2/+27
| | | | | | | | | This removes a bunch of duplicated code needed to support ConditionalMallocSizeOf correctly, and fixes multiple places where that code was subtly wrong (the seen pointers hashset was never cleared). Testing: Measuring https://www.nist.gov/image-gallery lots of times. Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* resources: Remove baked in resources (#36042)Jonathan Schwender6 days3-27/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows removing a LazyLock around the resources. We override the baked in resources unconditionally in servoshell upon initialization anyway ([desktop](https://github.com/servo/servo/blob/9f93ccd9427265f39f1a2de38389fec0e80f7bea/ports/servoshell/desktop/cli.rs#L15), [android](https://github.com/servo/servo/blob/9f93ccd9427265f39f1a2de38389fec0e80f7bea/ports/servoshell/egl/android/simpleservo.rs#L49), [ohos](https://github.com/servo/servo/blob/9f93ccd9427265f39f1a2de38389fec0e80f7bea/ports/servoshell/egl/ohos/simpleservo.rs#L43) ), meaning that the baked in resources are unused in servoshell. For 3rd-party embedders, we probably also want to the let them know early that they should initialize the resources, instead of restricting the panics to production mode. Rippy is the only resource which was required. Since it is only 253 bytes large, we just bake that resource in as a fallback. We do want to make using the resources easy from tests, so we add some logic to keep the baked in resources for tests only and initialize the resource reader on first access. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
* libservo: Expose a `ServoBuilder` (#36549)Martin Robinson6 days1-1/+1
| | | | | | | | | Expose a `ServoBuilder` for easily creating Servo instances using default values. This change enables removing `EmbedderTraits`. Testing: This is covered by `Servo` unit tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* compositing: Add memory reporter for WebRender. (#36557)Josh Matthews6 days3-7/+53
| | | | | | | | | | This adds a memory reporter for WebRender's memory usage. I seeded it with a couple entries that looked reasonable based on https://searchfox.org/mozilla-central/rev/2c71f1e9b5947612abdc16b64008162c58c1b9d3/gfx/thebes/gfxPlatform.cpp#722-738. Testing: Verified that new numbers appear in about:memory for servo.org. The new images category is surprisingly large (40mb). Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* net: Report memory usage for image cache. (#36556)Josh Matthews6 days3-4/+8
| | | | | | | | | These changes add a new report for image cache memory usage for each script thread. Testing: Looked at the numbers after browsing various stock photo sites that show galleries of images. Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* Implement GetComputedRole in wd (#36552)Kenzie Raditya Tirtarahardja7 days1-0/+1
| | | | | | | | Implement Webdriver Get Computed Role. [spec](https://w3c.github.io/webdriver/#get-computed-role) Signed-off-by: Kenzie Raditya Tirtarahardja <kenzieradityatirtarahardja.18@gmail.com> Co-authored-by: Kenzie Raditya Tirtarahardja <kenzieradityatirtarahardja.18@gmail.com>
* compositor: Unify the cross process and in-process API (#36543)Martin Robinson7 days1-97/+33
| | | | | | | | | | | | | | | | | | | Because there used to be two traits exposing messages to the compositor, there were two kinds of messages that could be sent: 1. In-process messages from the `Constellation` 2. Cross-process messages from other parts of Servo Now these two types of messages can be unified into one type. This is a reland of #36443, which caused regressions due to the fact that messages to the compositor were no longer triggering the event loop waker. This version of the PR splits out just the bits that unify the two APIs, leaving the cleanup of routes in the constellation for another PR. Testing: This is covered by existing WPT tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Make DOMException serializable (#36535)Kingsley Yung7 days2-1/+50
| | | | | | | | | | | Follow the implementation of making DOMPoint and DOMPointReadOnly serializable in PR #35989 Testing: Passed a test previously expected to fail. Fixes: #36463 --------- Signed-off-by: Kingsley Yung <kingsley@kkoyung.dev>
* Revert "compositor: Unify the cross process and in-process API (#36443)" ↵Martin Robinson8 days1-35/+100
| | | | | | | | | | | | | (#36533) This reverts commit 4c55104b36c7b858a117a6dd90a5dc21b74324d1. This commit introduced an issue where messages from script to the compositor no longer woke up the embedder. There is a larger issue here, but this change exacerbated it. Fixes #36528. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Transfer ReadableStream (#36181)Gregory Terzian8 days1-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | <!-- Please describe your changes on the following line: --> Add transfer support to ReadableStream. Part of https://github.com/servo/servo/issues/34676 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> --------- Signed-off-by: gterzian <2792687+gterzian@users.noreply.github.com>
* libservo: Make zooming and HiDPI scaling work per-`WebView` (#36419)Martin Robinson9 days1-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | libservo: Make zooming and HiDPI scaling work per-`WebView` This change moves all zooming and HiDPI scaling to work per-`WebView` in both libservo and Compositor. This means that you can pinch zoom one `WebView` and it should now work independently of other `WebView`s. This is accomplished by making each `WebView` in the WebRender scene have its own scaling reference frame. All WebViews are now expected to manage their HiDPI scaling factor and this can be set independently of other WebViews. Perhaps in the future this will become a Servo-wide setting. This allows full removal of the `WindowMethods` trait from Servo. Testing: There are not yet any tests for the WebView API, but I hope to add those soon. Co-authored-by: Shubham Gupta <shubham13297@gmail.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Shubham Gupta <shubham13297@gmail.com>
* Update FetchTaskTarget to propagate CSP violations. (#36409)Tim van der Lippe9 days1-1/+18
| | | | | | | | | | | | | | | | | | It also updates the FetchResponseListener to process CSP violations to ensure that iframe elements (amongst others) properly generate the CSP events. These iframe elements are used in the Trusted Types tests themselves and weren't propagating the violations before. However, the tests themselves are still not passing since they also use Websockets, which currently aren't using the fetch machinery itself. That is fixed as part of [1]. [1]: https://github.com/servo/servo/issues/35028 --------- 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>
* compositor: Unify the cross process and in-process API (#36443)Martin Robinson10 days1-100/+35
| | | | | | | | | | | | | | | | | | | | | | Because there used to be two traits exposing messages to the compositor, there were two kinds of messages that could be sent: 1. In-process messages from the `Constellation` 2. Cross-process messages from other parts of Servo Now these two types of messages can be unified into one type. With that done the compositor can simply keep a single `IpcReceiver` for all messages, instead of having to set up a route for the cross-process messsages. This decreases overhead of cross proceses messages a bit, but more importantly solves an issue where Servo would rely on the compositor's cross-process message route after the `Constellation` had called `ROUTER.shutdown()`. This is part of #36442. Testing: This is covered by existing WPT tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* compositing: Send `CompositorDisplayListInfo` as bytes to compositor (#36484)Martin Robinson10 days2-6/+10
| | | | | | | | | | | | | `CompositorDisplayListInfo` is a large data structure that scales with the size of the display list. Serializing it onto the Compositor's IPC channel can cause deadlocks. This change serializes it with bincode and sends it alongside the rest of the serialized display list information on the IPC `bytes_channel`. This should prevent deadlocks when the compositor API is unified. Testing: This is covered by existing WPT tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* feat: Implement display for text selection and caret (#35830)DK Liao12 days1-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR introduces an initial, straightforward implementation for displaying text selection and the caret. This is achieved by passing the selection range and insertion point index down to `TextFragment`, along with the starting offset of each `TextFragment` to determine the proper range for displaying the caret and text selection. Additionally, the `selected_style` was passed into `TextFragment` to specify the background color. During the final build phase, although whitespace is typically ignored when constructing glyphs, we still need to retrieve it to render both the caret and text selection at the correct location. This ensures that whitespace is not overlooked when the `TextFragment` contains an insertion point or selection range. There are several improvements yet to be made, including: - The caret is static and does not flash. - The caret is not rendered when the input field is empty. (I suppose there should be an easy fix somewhere but I haven't found it yet) **Working Examples** macOS https://github.com/user-attachments/assets/f3622cbe-9fa6-40c0-b2d8-b3a8f9842c28 Windows https://github.com/user-attachments/assets/9b008a0d-0011-4c76-a2e2-0e35869a216c Linux [Screencast from 03-07-2025 11_05_41 AM.webm](https://github.com/user-attachments/assets/09a311ad-f975-4450-a66c-b20be525a5ed) --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix part of #33237 (But the cursor isn't blinking yet) - [x] These changes do not require tests because there's no behavior change Signed-off-by: DK Liao <dklassic@gmail.com>
* libservo: Move animation tracking from `WindowMethods` to delegates (#36400)Martin Robinson13 days1-0/+1
| | | | | | | | | | | | | | | | | | This changes removes animation tracking from the `WindowMethods` trait and moves it to `ServoDelegate` and `WebViewDelegate`. - Animation changes per-`WebView` are now triggered in the compositor only when the value is updated there, rather than right after ticking animations. - Both `WebView` and `Servo` now expose an `animation()` method, so tracking animation state actually becomes unecessary in many cases, such as that of desktop servoshell, which can just read the value when the event loop spins. Testing: No tests necessary as the API layer is still untested. Later, tests will be added for the `WebView` API and this can be tested then. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* libservo: Move `EventLooperWaker` from `webxr_traits` to `embedder_traits` ↵Martin Robinson13 days5-26/+8
| | | | | | | | | | | | (#36420) Now that `webxr` is integrated into the Servo directory, `webxr` can depend on `embedder_traits` instead of having it re-export this type conditionally (and sometimes duplicating it). Testing: This just moves a data type, so no tests are necessary. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Add serde and wgsl features to wgpu-core (#36411)Oriol Brufau14 days1-1/+1
| | | | | | | | | | | This fixes errors when running `./mach clippy -r -p layout_2020` and `./mach clippy -r -p script`. Also addressing an unused import warning when running the latter. Testing: These changes do not require tests because it's just a compile error fix. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* Devtools: initial Debugger > Sources panel (#36164)delan azabani2025-04-081-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch adds support for listing scripts in the Sources panel. Classic scripts, both external and inline, are implemented, but worker scripts and imported module scripts are not yet implemented. For example: ```html <!-- sources.html --> <!doctype html><meta charset=utf-8> <script src="classic.js"></script> <script> console.log("inline classic"); new Worker("worker.js"); </script> <script type="module"> import module from "./module.js"; console.log("inline module"); </script> <script src="https://servo.org/js/load-table.js"></script> ``` ```js // classic.js console.log("external classic"); ``` ```js // worker.js console.log("external classic worker"); ``` ```js // module.js export default 1; console.log("external module"); ``` ![image](https://github.com/user-attachments/assets/2f1d8d7c-501f-4fe5-bd07-085c95e504f2) --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes partially implement #36027 <!-- Either: --> - [ ] There are tests for these changes OR - [x] These changes require tests, but they are blocked on #36325 Signed-off-by: Delan Azabani <dazabani@igalia.com> Co-authored-by: atbrakhi <atbrakhi@igalia.com>
* layout: Add initial support for the `::marker` pseudo-element (#36317)Martin Robinson2025-04-071-16/+0
| | | | | | | | | | | | | | | This change adds support for the `::marker` pseudo-element and ensure that markers are cached into the box tree. This is only initial support, there are a few things missing such as animations, transitions, and support the `content` CSS property. Testing: There are WPT tests for this change. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* `compositing`: Combine `webrender_traits` and `compositing_traits` (#36372)Martin Robinson2025-04-0613-535/+503
| | | | | | | | | | | | | | | These two traits both exposed different parts of the compositing API, but now that the compositor doesn't depend directly on `script` any longer and the `script_traits` crate has been split into the `constellation_traits` crate, this can be finally be cleaned up without causing circular dependencies. In addition, some unit tests for the `IOPCompositor`'s scroll node tree are also moved into `compositing_traits` as well. Testing: This just combines two crates, so no new tests are necessary. Fixes: #35984. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Process colorSchemeSimulation in TargetConfigurationActor (#36297)Usman Yahaya Baba2025-04-061-1/+1
| | | | | | | | | | | | | | | | Implements Steps 1,4&6 of https://github.com/servo/servo/issues/35867: - Adds `pub simulate_color_scheme` to `BrowsingContextActor` using `script_chan`. - Processes `colorSchemeSimulation` flag in `TargetConfigurationActor`’s `updateConfiguration`. - Routes `colorSchemeSimulation` from `RootActor` via `TabDescriptorActor` to `BrowsingContextActor`. Testing: Compiles and lints clean. Fixes: https://github.com/servo/servo/issues/35867 --------- Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
* Move `ScriptToConstellationMsg` to `constellation_traits` (#36364)Martin Robinson2025-04-0513-1083/+1078
| | | | | | | | | | | | | | | | | | | | | | | | | | | This is the last big change necessary to create the `constellation_traits` crate. This moves the data structure for messages that originate from the `ScriptThread` and are sent to the `Contellation` to `constellation_traits`, effectively splitting `script_traits` in half. Before, `script_traits` was responsible for exposing the API of both the `ScriptThread` and the `Constellation` to the rest of Servo. - Data structures that are used by `ScriptToConstellationMsg` are moved to `constellation_traits`. The dependency graph looks a bit like this: `script_layout_interface` depends on `script_traits` depends on `constellation_traits` depends on `embedder_traits`. - Data structures that are used in the embedding layer (`UntrustedNodeAddress`, `CompositorHitTestResult`, `TouchEventResult` and `AnimationState`) are moved to embedder_traits, to avoid a dependency cycle between `webrender_traits` and `constellation_traits`. - Types dealing with MessagePorts and serialization are moved to `constellation_traits::message_port`. Testing: This is covered by existing tests as it just moves types around. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Make the memory reporting multi-process aware (#35863)webbeef2025-04-051-9/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | So far the memory reporter aggregates reports from all processes, and runs the system reporter only in the main process. Instead it is desirable to have per-process reports. We do so by: - creating a ProcessReports struct that holds includes the pid in addition to the reports themselves. - running the system memory reporter also in content processes. - updating the about:memory page to create one report per process, and add useful information like the pid and the urls loaded in a given process. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors ![image](https://github.com/user-attachments/assets/0bafe140-539d-4d6a-8316-639309a22d4a) Signed-off-by: webbeef <me@webbeef.org>
* Check all ancestor navigable trustworthiness for mixed content (#36157)Sebastian C2025-04-052-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | Propagate through documents a flag that represents if any of the ancestor navigables has a potentially trustworthy origin. The "potentially trustworthy origin" concept appears to have gotten confused in a couple of places and we were instead testing if a URL had "potentially trustworthy" properties. The main test for the ancestor navigables is [mixed-content/nested-iframes](https://github.com/web-platform-tests/wpt/blob/master/mixed-content/nested-iframes.window.js) --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #36108 <!-- Either: --> - [X] There are tests for these changes --------- Signed-off-by: Sebastian C <sebsebmc@gmail.com>
* constellation: Rename messages sent to the `Constellation` (#36341)Martin Robinson2025-04-043-9/+11
| | | | | | | | | | | | | | | | | | | | Messages that are sent to the `Constellation` have pretty ambiguous names. This change does two renames: - `ConstellationMsg` → `EmbedderToConstellationMessage` - `ScriptMsg` → `ScriptToConstellationMessage` This naming reflects that the `Constellation` stands in between the embedding layer and the script layer and can receive messages from both. Soon both of these message types will live in `constellation_traits`, reflecting the idea that the `_traits` variant for a crate is responsible for exposing the API for that crate. Testing: No new tests are necessary here as this just renames two enums. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* constellation: Stop assuming that the viewport is shared by all WebViews ↵Martin Robinson2025-04-046-42/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#36312) The `Constellation` previously held a `window_size` member, but this assumes that all `WebView`s have the same size. This change removes that assumption as well as making sure that all `WebView`s pass their size and HiDIP scaling to the `Constellation` when they are created. In addition - `WindowSizeData` is renamed to `ViewportDetails`, as it was holding more than just the size and it didn't necessarily correspond to a "window." It's used for tracking viewport data, whether for an `<iframe>` or the main `WebView` viewport. - `ViewportDetails` is stored more consistently so that conceptually an `<iframe>` can also have its own HiDPI scaling. This isn't something we necessarily want, but it makes everything conceptually simpler. The goal with this change is to work toward allowing per-`WebView` HiDPI scaling and sizing. There are still some corresponding changes in the compositor to make that happen, but they will in a subsequent change. Testing: This is covered by existing tests. There should be no behavior changes. Fixes: This is part of #36232. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* webgpu: Add a `webgpu_traits` crate (#36320)Martin Robinson2025-04-0412-6/+897
| | | | | | | | | | | | | | | This breaks the `script_traits` dependency on `webgpu`. In general, the `traits` crates shouldn't depend on Servo non-`traits` crates. This is necessary to move "script to constellation" messages to the `constellation_traits` crate, making it the entire API for talking to the constellation. This will break a circular dependency when that happens. Testing: Successfully building is enough of a test for this one as it is mainly moving types around. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Webdriver delete cookie (#36306)Euclid Ye2025-04-042-0/+2
| | | | | | | | | | 1. Implement `WebDriverCommand::DeleteCookie` 2. Remove unnecessary clone for `WebDriverCommand::GetNamedCookie` Fixes: #36287 --------- Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
* fix: root element not establishing stacking context (#35390) (#36174)Michael Rees2025-04-031-0/+6
| | | | | | | | | | | | | | | | | - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #35390 - [X] There are tests for these changes [Successful WPT run](https://github.com/reesmichael1/servo/actions/runs/14097679625) (which includes the new test files) (I didn't make the formatting changes intentionally--those came from `mach format` following `mach test-tidy`.) --------- Signed-off-by: Michael Rees <mrees@noeontheend.com>
* Support single-value `<select>` elements (#35684)Simon Wülker2025-04-031-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://github.com/user-attachments/assets/9aba75ff-4190-4a85-89ed-d3f3aa53d3b0 Among other things this adds a new `EmbedderMsg::ShowSelectElementMenu` to tell the embedder to display a select popup at the given location. This is a draft because some small style adjustments need to be made: * the select element should always have the width of the largest option * the border should be part of the shadow tree Apart from that, it's mostly ready for review. <details><summary>HTML for demo video</summary> ```html <html> <body> <select id="c" name="choice"> <option value="first">First Value</option> <option value="second">Second Value</option> <option value="third">Third Value</option> </select> </body> </html> ``` </details> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] Part of https://github.com/servo/servo/issues/3551 - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* libservo: Start moving `WindowMethods` to `WebViewDelegate` (#36223)Martin Robinson2025-04-022-3/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `WindowMethods` is used by the embedding layer to get information from the embedder. This change moves the functionality for getting screen size and `WebView` offsets to `WebViewDelegate`. This is important because `WebView`s might be on different screens or have different offsets on the screen itself, so it makes sense for this to be per-`WebView` and not global to the embedder. HiDPI and animation state functionality will move to the embedder in subsequent changes. Signed-off-by: Martin Robinson <mrobinson@igalia.com> <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because they just modify the `WebView` API surface a bit. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* libservo: Remove a couple `EmbedderMethods` (#36276)Martin Robinson2025-04-012-5/+0
| | | | | | | | | | | | | | | | | | | | | | | - Remove `EmbedderMethods::get_user_agent_string`. This is now part of the `Preferences` data structure, which should allow it to be per-`WebView` in the future. - Remove `EmbedderMethods::get_version_string`. This was used to include some data along with WebRender captures about the Servo version. This isn't really necessary and it was done to replace code in the past that output the WebRender version, so also isn't what the original code did. I think we can just remove this entirely. The idea with these changes is that `EmbedderMethods` can be removed in a followup and the rest of the methods can be added to `ServoDelegate`. These two methods are ones that cannot be added to a delegate as they are used during `Servo` initialization. Testing: There is currently no testing for libservo. These changes are meant as preparation for adding a suite of `WebView` unit tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* canvas: Implement line dash setters and getters (#36257)Steven Novaryo2025-04-011-0/+2
| | | | | | | | | | | Implement `setLineDash`, `getLineDash`, and `lineDashOffset` from `CanvasPathDrawingStyles` mixin, according to the spec https://html.spec.whatwg.org/multipage/canvas.html#canvaspathdrawingstyles. Testing: Existing WPT. --------- Signed-off-by: stevennovaryo <steven.novaryo@gmail.com>
* Add SimulateColorScheme command and script thread handling (#36253)Usman Yahaya Baba2025-04-012-0/+4
| | | | | | | | | | | | | | | | Implements Steps 2-3 of #35867: - Adds `SimulateColorScheme` to `DevtoolScriptControlMsg` for light/dark mode simulation. - Handles it in `ScriptThread` with `handle_theme_change` to toggle themes. Testing: This PR does not require testing because it only adds infrastructure (command and handler) but doesn’t yet integrate with devtools actors. Fixes: Part of #35867 (https://github.com/servo/servo/issues/35867) --------- Signed-off-by: Uthman Yahaya Baba <uthmanyahayababa@gmail.com>
* Refuse to provide partial response from earlier ranged request to API that ↵Simon Wülker2025-03-311-0/+5
| | | | | | | did not make a range request (#36227) Part of https://github.com/servo/servo/issues/33616 Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* Organize component Cargo.toml dependencies (#36224)Alex Touchet2025-03-305-12/+12
| | | Signed-off-by: Alex Touchet <26315797+atouchet@users.noreply.github.com>
* layout: Simplify and generalize the usage of pseudo-elements (#36202)Martin Robinson2025-03-291-57/+18
| | | | | | | | | | | | | | | | | | | | | - Remove the last remaining Servo-specific PseudoElement enum from layout. This was made to select `::before` and `::after` (both eager pseudo-elements), but now `traverse_pseudo_element` is called `traverse_eager_pseudo_element` and should work on any eager pseudo element. - Expose a single way of getting psuedo-element variants of ThreadSafeLayoutElement in the Layout DOM, which returns `None` when the pseudo-element doesn't apply (not defined for eager pseudo-elements or when trying to get `<details>` related pseudo-elements on elements that they don't apply to). - Ensure that NodeAndStyleInfo always refers to a node. This is done by making sure that anonymous boxes are all associated with their originating node. These changes are prepatory work for implementation of the `::marker` pseudo-element as well as ensuring that all anonymous boxes can be cached into the box tree eventually. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Animation: Aggregate Animated Image Info to Document (#36141)TIN TUN AUNG2025-03-282-0/+29
| | | Signed-off-by: rayguo17 <rayguo17@gmail.com>
* Allow setting userscripts directly without the need of files (#35388)Tony2025-03-273-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Allow settings userscripts through preferences Signed-off-by: Tony <legendmastertony@gmail.com> * mach fmt instead of cargo fmt Signed-off-by: Tony <legendmastertony@gmail.com> * Fix pref loading not working for array values Signed-off-by: Tony <legendmastertony@gmail.com> * Use pref! in userscripts instead Signed-off-by: Tony <legendmastertony@gmail.com> * Implement the model jdm suggested - Remove userscripts from all places and move it to servoshell - Add in `UserContentManager` struct and passing it through `Servo::new` all the way down to script thread Signed-off-by: Tony <legendmastertony@gmail.com> * Apply suggestions from code review and format Signed-off-by: Tony <legendmastertony@gmail.com> * Revert unrelated change Signed-off-by: Tony <legendmastertony@gmail.com> --------- Signed-off-by: Tony <legendmastertony@gmail.com> Signed-off-by: Tony <68118705+Legend-Master@users.noreply.github.com>
* Make DOMPoint and DOMPointReadOnly serializable (#35989)Josh Matthews2025-03-273-8/+63
| | | | | | | | | | | | | | | | | | | | | | | * script: Make DOMPointReadOnly serializable. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Make DOMPoint serializable. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * script: Shrink worker script event. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Update components/script/dom/dompoint.rs Co-authored-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net> Co-authored-by: Martin Robinson <mrobinson@igalia.com>