aboutsummaryrefslogtreecommitdiffstats
path: root/components/servo/lib.rs
Commit message (Collapse)AuthorAgeFilesLines
* layout: Combine `layout_2020` and `layout_thread_2020` into a crate called ↵Martin Robinson2 days1-5/+6
| | | | | | | | | | | | | | | | | | `layout` (#36613) Now that legacy layout has been removed, the name `layout_2020` doesn't make much sense any longer, also it's 2025 now for better or worse. The split between the "layout thread" and "layout" also doesn't make as much sense since layout doesn't run on it's own thread. There's a possibility that it will in the future, but that should be something that the user of the crate controls rather than layout iself. This is part of the larger layout interface cleanup and optimization that @Looriool and I are doing. Testing: Covered by existing tests as this is just code movement. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* compositing: Remove `windowing.rs` and making `compositing` private (#36582)Martin Robinson4 days1-4/+5
| | | | | | | | | | | This file used to contain the `EmbedderDelegate` and `WindowMethods` traits, but these are gone now, so we can move the one remaining enum to be in `compositor.rs` where it is used. This change also stops exposing the `compositing` crate as public Servo API. Testing: This does not change behavior so is covered by existing tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* libservo: Expose a `ServoBuilder` (#36549)Martin Robinson5 days1-19/+85
| | | | | | | | | 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 Matthews5 days1-0/+1
| | | | | | | | | | 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>
* compositor: Unify the cross process and in-process API (#36543)Martin Robinson6 days1-7/+5
| | | | | | | | | | | | | | | | | | | 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>
* Revert "compositor: Unify the cross process and in-process API (#36443)" ↵Martin Robinson6 days1-10/+35
| | | | | | | | | | | | | (#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>
* libservo: Make zooming and HiDPI scaling work per-`WebView` (#36419)Martin Robinson7 days1-22/+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>
* compositor: Unify the cross process and in-process API (#36443)Martin Robinson9 days1-35/+10
| | | | | | | | | | | | | | | | | | | | | | 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>
* libservo: Create a `WebViewBuilder` class to construct `WebView`s (#36483)Martin Robinson9 days1-24/+1
| | | | | | | | | | | This exposes a new method of creating `WebView`s using the Rust builder pattern. This will be more important as we add more kinds of configuration options for `WebView` such as size and HiDPI scaling. Testing: The API currently doesn't have tests, but functionality is ensured by the fact that servoshell is the test harness. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* libservo: Move animation tracking from `WindowMethods` to delegates (#36400)Martin Robinson12 days1-0/+26
| | | | | | | | | | | | | | | | | | 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>
* `compositing`: Combine `webrender_traits` and `compositing_traits` (#36372)Martin Robinson2025-04-061-8/+7
| | | | | | | | | | | | | | | 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>
* Move `ScriptToConstellationMsg` to `constellation_traits` (#36364)Martin Robinson2025-04-051-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* constellation: Rename messages sent to the `Constellation` (#36341)Martin Robinson2025-04-041-12/+14
| | | | | | | | | | | | | | | | | | | | 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-041-21/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#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>
* Support single-value `<select>` elements (#35684)Simon Wülker2025-04-031-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-021-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `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-011-93/+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>
* Allow setting userscripts directly without the need of files (#35388)Tony2025-03-271-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* feat(notification): add `EmbedderMsg::ShowNotification` (#36055)Jason Tsai2025-03-241-0/+6
| | | Signed-off-by: Jason Tsai <git@pews.dev>
* Create a `constellation_traits` crate (#36088)Martin Robinson2025-03-221-2/+3
| | | | | | | | | | | | | | This change creates a `constellation_traits` crate. Previously messages to the `Constellation` were in the `compositing_traits` crate, which came about organically. This change moves these to a new crate which also contains data types that are used in both compositing/libservo and script (ie types that cross the process boundary). The idea is similar to `embedding_traits`, but this is meant for types not exposed to the API. This change allows deduplicating `UntrustedNodeAddress`, which previously had two versions to avoid circular dependencies. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* libservo: Notify delegates of send errors in request objects (#35668)Delan Azabani2025-03-191-9/+45
| | | | | | | | | | | | | | | | | | | | | | | | | * libservo: Notify delegates of send errors in request objects Signed-off-by: Delan Azabani <dazabani@igalia.com> * Remove webview error sender for simplicity Signed-off-by: Delan Azabani <dazabani@igalia.com> * Remove error sender trait, now that there is only one impl Signed-off-by: Delan Azabani <dazabani@igalia.com> * Address review feedback Signed-off-by: Delan Azabani <dazabani@igalia.com> * Add unit tests Signed-off-by: Delan Azabani <dazabani@igalia.com> --------- Signed-off-by: Delan Azabani <dazabani@igalia.com>
* Remove legacy layout (layout 2013) (#35943)Oriol Brufau2025-03-131-22/+2
| | | | | | We were already not compiling it and not running tests on it by default. So it's simpler to just completely remove it. Signed-off-by: Oriol Brufau <obrufau@igalia.com>
* base: Finish rename of `TopLevelBrowsingContextId` to `WebViewId` (#35896)Martin Robinson2025-03-111-3/+3
| | | | | | The `WebViewId` name is a lot more descriptive these days to the casual reader, so I think we can go ahead and finish the rename. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Remove obsolete memory profiler console output (#35861)webbeef2025-03-081-1/+1
| | | Signed-off-by: webbeef <me@webbeef.org>
* Update rustfmt to the 2024 style edition (#35764)Simon Wülker2025-03-031-8/+8
| | | | | | | | | | | | | * Use 2024 style edition Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> * Reformat all code Signed-off-by: Simon Wülker <simon.wuelker@arcor.de> --------- Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
* libservo: Stop double-buffering `OffscreenRenderingContext` (#35638)Martin Robinson2025-02-281-1/+1
| | | | | | | | | | | The `OffscreenRenderingContext` does not need to be double-buffered. Instead, when resizing the framebuffer, create a new one and blit the old contents onto the new surface. This allows immediately displaying the contents without having to render paint the WebRender scene one more time. In addition to speeding up the rendering pipeline, the goal here is to reduce flickering during resizes (though there is more work to do). Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* libservo: Clean up interfaces for alert()/confirm()/prompt() (#35579)Delan Azabani2025-02-271-2/+2
| | | Signed-off-by: Delan Azabani <dazabani@igalia.com>
* libservo: Add `WebView` immediately to the Compositor (#35662)Martin Robinson2025-02-261-5/+0
| | | | | | | | | When creating a `WebView`, let the Compositor know synchronously that it exists. This allows the embedder to immediately call methods like `WebView::focus()`. In addition remove messages associated with the `WebViewDelegate::notify_ready_to_show()` method (and the method itself), as now `WebView`s can be shown immediately. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* libservo: Move size handling to `RenderContext` from `WindowMethods` (#35621)Martin Robinson2025-02-251-5/+5
| | | | | | | | | | | | | | | | | | | | | This is the first step toward removing `WindowMethods`, which will gradually be integrated into the `WebView` and `WebViewDelegate`. Sizing of the `WebView` is now handled by the a size associated with a `RenderingContext`. `WebView`s will eventually just paint the entire size of their `RenderingContext`. Notes: - This is transitionary step so now there is a `WebView::resize` and a `WebView::move_resize`. The first is the future which will resize the `WebView` and its associated `RenderingContext`. The second is a function that the virtual `WebView`s that will soon be replaced by a the one-`WebView` per `WebView` model. - We do not need to call `WebView::move_resize` at as much any longer because the default size of the `WebView` is to take up the whole `RenderingContext`. - `SurfmanRenderingContext` is no longer exposed in the API, as a surfman context doesn't naturally have a size unless a surface is bound to it. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* libservo: Refactor ipc-channel default response logic (#35624)Delan Azabani2025-02-241-25/+8
| | | Signed-off-by: Delan Azabani <dazabani@igalia.com>
* libservo: Convert `intercept_web_resource_load` into `load_web_resource` ↵Martin Robinson2025-02-211-14/+11
| | | | | | | | | | | | | | | | | | | | | (#35564) Rework the `WebViewDelegate::intercept_web_resource_load` into `WebViewDelegate::load_web_resource` and clean up internal messaging. The main thing here is adding objects which manage the response to these delegate methods. Now we have `WebResourceLoad` and `InterceptedWebResourceLoad` which make it much harder to misuse the API. In addition, the internal messaging for this is cleaned up. Canceling and finishing the load are unrelated to the HTTP body so they are no longer subtypes of an HttpBodyData message. Processing of messages is made a bit more efficient by collecting all body chunks in a vector and only flattening the chunks at the end. Finally, "interceptor" is a much more common spelling than "intercepter" so I've gone ahead and made this change everywhere. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* compositing: Move image output and shutdown management out of the compositor ↵Martin Robinson2025-02-201-19/+32
| | | | | | | | | | | | | | | | | | | | | | | (#35538) This is a step toward the renderer-per-WebView goal. It moves various details out of `IOCompositor`. - Image output: This is moved to servoshell as now applications can access the image contents of a `WebView` via `RenderingContext::read_to_image`. Most options for this are moved to `ServoShellPreferences` apart from `wait_for_stable_image` as this requires a specific kind of coordination in the `ScriptThread` that is also very expensive. Instead, paint is now simply delayed until a stable image is reached and `WebView::paint()` returns a boolean. Maybe this can be revisited in the future. - Shutdown: Shutdown is now managed by libservo itself. Shutdown state is shared between the compositor and `Servo` instance. In the future, this sharing might be unecessary. - `CompositeTarget` has been removed entirely. This no longer needs to be passed when creating a Servo instance. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Ngo Iok Ui (Wu Yu Wei) <yuweiwu@pm.me>
* libservo: Move GL acclerated media setup out of `RenderingContext` and ↵Martin Robinson2025-02-201-70/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | simplify it (#35553) This moves the GL accelerated media setup out of `RenderingContext` which prevents making libservo dependo on the Wayland and X11 versions of surfman explicitly. This support is experimental and (honestly) a bit broken. I've confirmed that this works as well as it did before the change. The main thing here is that the configuration, which currently needs surfman types, moves to servoshell. In addition: 1. Instead of passing the information to the Constellation, the setup is stored statically. This is necessary to avoid introducing a dependency on `media` in `webrender_traits`. It's quite likely that `media` types should move to the internal embedding API to avoid this. This is preserved for a followup change. 2. The whole system of wrapping the media channels in an abstract type is removed. They could be either mpsc channels or IPC channels. This was never going to work because mpsc channels cannot be serialized and deserialized with serde. Instead this just uses IPC channels. We also have other ways of doing this kind of abstraction in Servo so we do not need another. The `mpsc` version was hard-coded to be disabled. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* libservo: Clean up destroyed webview handles (#35547)Delan Azabani2025-02-201-0/+11
| | | | | | | | | | | When the embedder drops the last WebView handle, the webview is destroyed, but the weak handle in libservo never gets cleaned up. This patch adds a step to `spin_event_loop` that cleans up any weak handles that have been destroyed. In theory, checking the strong count should be more efficient than trying to upgrade each handle (only to throw away the strong handle). Signed-off-by: Delan Azabani <dazabani@igalia.com>
* compositing: Split non-WebView-specific data into `ServoRenderer` (#35536)Martin Robinson2025-02-191-3/+3
| | | | | | | This will become the new global Servo renderer while each WebView will also have its renderer (but not yet). Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Ngo Iok Ui (Wu Yu Wei) <yuweiwu@pm.me>
* Remove `Servo::allow_navigation_request` (#35544)Martin Robinson2025-02-191-11/+1
| | | | | This method is now unused in the new Servo API. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* libservo: Rework and clarify the rendering model of the `WebView` (#35522)Martin Robinson2025-02-191-8/+8
| | | | | | | | | | | | | | | | | Make the rendering model of the `WebView` clearer: 1. `WebViewDelegate::notify_new_frame_ready()` indicates that the WebView has become dirty and needs to be repainted. 2. `WebView::paint()` asks Servo to paint the contents of the `WebView` into the `RenderingContext`. 3. `RenderingContext::present()` does a buffer swap if the `RenderingContext` is actually double-buffered. This is documented and all in-tree embedders are updated to work with this new model. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Ngo Iok Ui (Wu Yu Wei) <yuweiwu@pm.me> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* libservo: Expose `SoftwareRenderingContext` and `WindowRenderingContext` ↵Martin Robinson2025-02-181-2/+6
| | | | | | | | | | | | | | (#35501) Expose two easy-to-use wrappers around `SurfmanRenderingContext` that make the API simpler to use: - `WindowRenderingContext`: This `RenderingContext` is a newtype around `SurfmanRenderingContext` takes a `raw-window-handle` display and window and creates a full window rendering context. - `SoftwareRenderingContext`: is wraps `SurfmanRenderingContext` and adds a swap chain in order to expose a software GL rendering context. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Make WebBluetooth an optional feature. (#35479)Josh Matthews2025-02-181-5/+10
| | | Signed-off-by: Josh Matthews <josh@joshmatthews.net>
* libservo: Expose an `OffscreenRenderingContext` and use it for servoshell ↵Martin Robinson2025-02-171-10/+2
| | | | | | | | | | | | | | | | | | (#35465) Create a new `RenderingContext` which is used to render to a `SurfmanRenderingContext`-related offscreen buffer. This allows having a temporary place to render Servo and then blitting the results to a subsection of the parent `RenderingContext`. The goal with this change is to remove the details of how servoshell renders from the `Compositor` and prepare for the compositor-per-WebView world. Co-authred-by: Ngo Iok Ui (Wu Yu Wei) <yuweiwu@pm.me> Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* servoshell: Actually set the Servo delegate in servoshell (#35502)Martin Robinson2025-02-161-5/+5
| | | | | | This was implemented, but unset. Fixes #35481. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* libservo: change 'request_fullscreen_state_change' API to a notification ↵Mukilan Thiyagarajan2025-02-131-2/+2
| | | | | (#35445) Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* libservo: Expose a single `InputEvent` type and pass it to script (#35430)Martin Robinson2025-02-121-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | This change exposes a single `InputEvent` type and now there is only a single delegate method for this `WebViewDelegate::notify_input_event`. - Clipboard events are now handled as `EditingAction` inpute events. In the future this can include things like "Select All", etc. In addition, many parts of the dance to pass these events can now be simplified due to this abstraction. - All forwarded events are handled the same way in the `Constellation`, though they may carry an optional hit test (for events that have a `point`) which affects which `Pipeline` they are sent to. - In the `ScriptThread` we now accept these `InputEvents` and use them everywhere. Now all "compositor events" are "input events". - This allows removing several data structures which are no longer necessary. - We no longer inform the embedder when an event was handled by a WebView as that was only important for a MDI feature that will no longer be so important the full-featured `WebView` API. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* libservo: Don't bounce ready-to-present frame notifications to the ↵Martin Robinson2025-02-121-7/+12
| | | | | | | | | | | | | | | Constellation (#35369) Instead of telling the Constellation to tell the embedder that new frames are ready, have the compositor tell the embedder directly. This should reduce frame latency. Now, after processing compositor updates, run any pending `WebView::new_frame_ready` delegate methods. This change also removes the `refresh` call from the Java interface as that was the only other place that the compositor was rendering the WebRender scene outside of event looping spinning. This `refresh` call was completely unused. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* libservo: Add a delegate method for HTTP authentication (#35400)Martin Robinson2025-02-101-1/+15
| | | | | | | | | | | | Add a delegate method for HTTP authentication and a related `AuthenticationRequest` object that carries with it the URL as well as whether or not the authentication request is for a proxy or not. This is now separate from the prompt API because requesting authentication doesn't necessarily involve prompting -- this is an implementation detail of the embedder. In addition, the internal bits are cleaned up slightly. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* libservo: Flesh out permissions API (#35396)Martin Robinson2025-02-101-9/+17
| | | | | | | | | | | | | - Update the script crate to better reflect the modern Permission specifcation -- removing the necessity for an `Insecure` variant of the permissions prompt. - Have all allow/deny type requests in the internal API use an `AllowOrDeny` enum for clarity. - Expose `PermissionsRequest` and `PermissionFeature` data types to the API and use them in the delegate method. - Update both servoshell implementations to use the API. Signed-off-by: Martin Robinson <mrobinson@igalia.com> Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
* libservo: Remove message-based API (#35366)Martin Robinson2025-02-101-607/+285
| | | Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* libservo: Add a `ClipboardDelegate` and a default implementation (#35297)Martin Robinson2025-02-071-7/+9
| | | | | | | | | | | | | | | | | Add a `ClipboardDelegate` to the `WebView` API and a default implementation in libservo for this delegate that works on Mac, Windows, and Linux. Support for Android will be added in the future. This means that embedders do not need to do anything special to get clipboard support, but can choose to override it or implement it for other platforms. In addition, this adds support for handling fetches of clipboard contents and renames things to reflect that eventually other types of clipboard content will be supported. Part of this is removing the string argument from the `ClipboardEventType::Paste` enum because script will need to get other types of content from the clipboard than just a string. It now talks to the embedder to get this information directly. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
* Migrate Android and OHOS ports to the delegate API (#35315)Mukilan Thiyagarajan2025-02-061-2/+2
| | | | Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>