195 Commits

Author SHA1 Message Date
Gae24
e2f17e0d28 deps: Bump jni-rs to 0.22 (#44322)
Update jni-rs to 0.22, the main changes involve the introduction of
`with_env` within native methods, and updating uses of
`attach_current_thread`, which now requires a closure passed to it.
Callback object is now stored inside a `OnceLock`, since it would crash
when it was deleted, probably once a `WakeupCallback` was dropped:
```
JNI DETECTED ERROR IN APPLICATION: JNI ERROR (app bug): jobject is an invalid global reference: 0x2fc6 (deleted reference at index 382)
```
Also update android-activity and rustls-platform-verifier.

Testing: We don't have android tests in CI, manual testing is required
Fixes: Part of #40979

---------

Signed-off-by: Gae24 <96017547+Gae24@users.noreply.github.com>
2026-04-23 11:55:29 +00:00
Jonathan Schwender
0ea42bc774 profile: Add instrumentation to startup related functions (#44456)
Follow-up to #44443.
This helps investigating the cold-start timeline, and could be used
by tooling to A/B compare branches affecting the cold-start time.

Additionally also change the `handle_request::select` span, so that we
can see the blocked time (which was probably what was intended), since
the actual time spent on recv after select is insignificant.

Testing: Tracing output is not covered by automatic tests.

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2026-04-23 11:47:27 +00:00
Jonathan Schwender
ab5deb4030 profile: Add initial trace event (#44443)
Adds a profiling event at the startup of servoshell, right after
initializing the tracing subsystem. To support this, add macro
abstractions for tracing events.
The existing span (macros) have a start and an end, but for one-off
events, we don't need a span and hence it make sense to also add the
event macros.

The new event at startup is useful when measuring / optimizing general
startup time. Adding a timestamp as field, allows us to ground the
measurement and compare it against time measured outside of servo,
regardless of how the profiling backend (tracing-perfetto,
tracing-hitrace, future backends) save timestamps.

Testing: Build-testing: the HarmonyOS build enables the tracing feature.
On other platforms this is not the case in CI.

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2026-04-23 09:18:28 +00:00
Euclid Ye
d3932a2118 Android: Fix black screen when exiting menu or resuming activity in lifecycle (#44327)
We should request repaint for the platform window when `resume_painting`
or entering
[Resumed](https://developer.android.com/guide/components/activities/activity-lifecycle#onresume)
state in Android activity lifecycle.

Fixes: #44300
Fixes: #40632
Fixes: #39737
Testing: Manually tested with following video proof


https://github.com/user-attachments/assets/046c045d-12d1-43fa-9387-fc504cc4bfe5

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2026-04-18 06:20:30 +00:00
Jonathan Schwender
f4877c190e Embed default resources in Servo applications using a servo-default-resources crate (#43182)
This PR considers the following constraints:

- Resources must be available when building servo via a published
crates.io package (i.e. no `../../../resources/<file>` file references).
- Minimal setup when writing tests (`nextest` spawns each test in its
own process, so we don't want to explicitly initialize the resource
handler for every `#[test]` fn)
- Use local resources when developing locally
- Support loading the resources from a proper resource directory if the
embedder wishes so, including via a custom mechanism, not necessarily as
files

(File) Resources that are only accessed from servoshell are out of scope
of this PR, since it mainly focusses on unblocking publishing `libservo`
to crates.io.

Baking the resources into the binary by default simplifies the setup a
lot. We already supported that before, but only for testing purposes and
explicitly not for production builds.

Using [`inventory`](https://crates.io/crates/inventory) adds a simple
way for the embedder to replace the default baked in resources, while
also keeping the test usage of baked in resources simple.

rippy.png is also referenced from image_cache - We simply duplicate it,
since the image is small, to avoid adding unnecessarily complex
solutions like adding a dedicated crate.


Testing: Covered by existing tests. [mach try
full](https://github.com/jschwe/servo/actions/runs/23811669469)
Fixes: Part of #43145

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2026-04-01 07:16:28 +00:00
Euclid Ye
2f5e3fdb5c cargo: Rename workspace-local library starting with c to servo_* (#43622)
- canvas 
- constellation_traits
- canvas_traits
- constellation

Testing: This should not change any behaviour.

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2026-03-25 06:04:57 +00:00
Euclid Ye
cae0752676 cargo: Rename workspace-local library starting with b to servo_* (#43552)
Follow up of #43526. This addresses Nico's comment:
https://github.com/servo/servo/pull/43526#issuecomment-4104953308

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

Testing: This should not change any behaviour.

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2026-03-23 08:26:49 +00:00
Christian Duerr
3c9221c3b5 servo: Rename WebView::pinch_zoom to adjust_pinch_zoom and add pinch zoom getter (#43228)
Previously the `pinch_zoom` method on `WebView` would be used to update
the page's pinch zoom level, however there was no way for the embedder
to retrieve the current pinch zoom.

This patch renames the existing `pinch_zoom` method to
`adjust_pinch_zoom` and changes the `pinch_zoom` method to instead
return the current pinch zoom level.

---

Decided to go for the breaking change since I'd find `pinch_zoom`
combined with `get_pinch_zoom` to be confusing, however I'm happy to
change that if a non-breaking change is preferred.

Motivation for this patch is just that I'd like to display the zoom
level in my UI while rendering.

Testing: Since this change adds a simple getter to the API, we can
probably avoid a unit test in this case.

---------

Signed-off-by: Christian Duerr <contact@christianduerr.com>
2026-03-18 04:30:45 +00:00
Narfinger
c204a799a7 OHOS CI: Fix resident-smaps recording (#42985)
Because of the move of the reporting function to
update_user_interface_state and the multiple events of
LoadStatus::Complete, the previous reporting did not work correctly
anymore.

This fixes it by manually summing up the reports for
'resident-according-to-smaps' and using the hitrace-bencher
point_filter_type Largest.

This should restore the bencher graph.

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

Testing: No automatic test but manual test here:
https://github.com/Narfinger/servo/actions/runs/22617931816

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
2026-03-03 14:28:21 +00:00
Steven Novaryo
ad358de589 libservo: Add allow_virtual_keyboard flag for InputMethodControl (#42467)
Following the convention of other major UAs of gating the virtual
keyboard by certain user activation, adding a flags to let the embedder
knows about the user activation. This would be used to determine whether
the virtual keyboard needs to be shown or not in android and ohos.

Testing: Manual testing.

---------

Signed-off-by: Jo Steven Novaryo <steven.novaryo@gmail.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2026-02-24 07:30:49 +00:00
atbrakhi
b6a1761198 Expose a GamepadProvider and use Responder types for messages (#41568)
Expose a `GamepadProvider` and use `Responder` types for messages

Testing: 
Fixes: https://github.com/servo/servo/issues/41453

---------

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

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

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-01-24 09:17:35 +00:00
Josh Matthews
4a2a73ad56 webdriver: Reset prefs to the values present at server start. (#42044)
The test harness attempts to reset preferences to default values when
running a test in which previously-set preferences are no longer set.
This leads to confusing interactions with any preference customizations
that are present, such as `--pref whatever` or `--prefs-file
something.json`, which are not considered when calculating the default.
This PR changes that: whatever preference values are present when the
webdriver server starts is treated as the default value.

Testing: This is a servo-specific webdriver extension, and we're fixing
an interaction with the test harness. I don't see another way to test
this besides observing the impact on our test results.
Fixes: #42043

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2026-01-21 07:52:17 +00:00
Jonathan Schwender
66d8601c81 servoshell: ohos / android: Decouple initialization and window creation (#41532)
We can start initializing servo without needing to wait for the
creation of a window.
This allows us to perform initialization of servo itself,
concurrently to the app UI thread setting up the app UI.
Once the native window is ready, we can then let servo create
the first window and load the initial URL.
This is also interesting in the context of using servo as a
webview library, where loading the library / initialising the
webview and loading the first url are typically decoupled
steps.

Note: on the android port the Java code is not touched, which means that
we effectively still
perform the initialization at the same point in time on android. 
The change to call the base servo initialiation from the Java app, can
be done in a seperate PR, perhaps by someone more familiar with android
than me.

Follow-up PRs will add multi-window support, which means that some of
the multi-webview related code in this PR has open todos,
which will be addressed by follow-ups.



Testing: The ohos-port is tested in CI, the android port was manually
tested by me.

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2026-01-14 16:21:18 +00:00
Euclid Ye
6ed4beb51b ohos: Fix build with tracing feature (#41803)
Testing: Tested locally with the feature.
Fixes: the build part of #41802.

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2026-01-09 14:48:20 +00:00
Martin Robinson
b89f47913c servoshell: Remove HeadedWindow-specific methods from PlatformWindow (#41773)
Instead of having `HeadedWindow`-specific methods here, just expose a
way to access the concrete type of a window. This is also exposed for
embedded ports and unused. They will use it in an upcoming change.

Testing: This shouldn't change behavior and is thus covered by existing
tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2026-01-08 15:36:43 +00:00
Narfinger
1b8d1bf63c libservo: Stop exporting ipc-channel for gamepad responders and use callbacks (#41412)
With this we stop exporting ipc-channel in libservo and switch to
GenericChannel/GenericCallback.

Testing: Generic Channels are tested all over the place.

---------

Signed-off-by: Narfinger <Narfinger@users.noreply.github.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2026-01-06 16:57:02 +00:00
Wayne Van Son
5b9263690d Refactor allow to expect (#41586)
Replace `allow` with `expect` lints for `unused`, `unsafe_code`,
`dead_code`, and `non_upper_case_globals`.

Testing: So far just check it compiled on `x86_64-linux` on NixOS. Need
to use the module `system.fontconfig.enable = true;` I think in my NixOS
config.
Part of: #40383 

Searching `allow\(.*\)` for `.rs` files shows the following. for
(total_results:total_files) went from `707:386` to `675:368`, a
reduction of `32:18`.

How many files is too many files per PR? I feel like the 20-30 I have is
too big.

---------

Signed-off-by: Wayne Van Son <waynevanson@gmail.com>
2026-01-01 13:40:20 +00:00
Jonathan Schwender
133c9b4266 servoshell: ohos: Move main thread code into function (#41540)
Refactor the code out of the lambda and move it into a dedicated
function. This is a first step towards untangling initialization and
window creation (see #41532 )

Testing: No functionality change, covered by existing tests

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2025-12-27 17:47:51 +00:00
Jonathan Schwender
f2028d61c3 servoshell: Reduce allocations during cmdline parsing (#41522)
- The helper method now accepts args without the binary name. This
allows us to remove the injection of servo / servoshell in the tests and
on android / ohos.
- Allow parsing str slices, instead of requiring Vec<String>. This
allows removing unnecessary conversions / allocations.

Testing: Covered by existing unit, integration and wpt tests, which pass
commandline arguments.

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2025-12-25 14:28:47 +00:00
Mukilan Thiyagarajan
2ccd9f54ad libservo: Let UserContentManager be per WebView and add basic support for mutations. (#41352)
This change moves the `UserContentManager` abstraction from the
`ServoBuilder` to `WebViewBuilder` so that embedders can inject content
for each `WebView` independently. It also adds basic support for runtime
mutations to the `UserContentManager` API. Only adding new scripts is
currently supported, but future changes will add support for both other
mutations such as removal of scripts and addition & removal of
stylesheets. Future changes could also optimize the way mutations are
propagated to `ScriptThread`s by sending just the "delta" rather than
the whole `UserContents` structure for each mutation.

The `UserContentManager` now becomes just a convenient handle for the
embedders to invoke the mutation API while the actual management of the
manager's content is handled by the Constellation. The mutations are
relayed to the constellation via messages. The change also separates the
serialized version containg the user contents into a new `UserContent`
structure so that the API cannot be misused.

Testing: New unit tests have been added for the different scenarios
involving UserContentManager.

---------

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-12-23 06:15:01 +00:00
WaterWhisperer
6623cc1dbb feat: gamepad feature flag (#41451)
Put the Gamepad API and its supporting infrastructure behind a `gamepad`
feature flag. This allows embedders to opt-out of gamepad support at
compile time to save on binary size and reduce dependencies.

Testing:
1. `./mach build -d` (Gamepad enabled by default)
2. `cargo build -p servoshell --no-default-features --features
"libservo/clipboard,js_jit,max_log_level,webgpu"` (Gamepad Disabled)
3. `cargo build -p servoshell --features "gamepad,webxr,..."` (Gamepad &
WebXR Enabled)

Fixes: #40897

Signed-off-by: WaterWhisperer <waterwhisperer24@qq.com>
2025-12-21 13:18:06 +00:00
atbrakhi
ba1122b4f5 Add ServoDelegate and WebViewDelegate methods for Console API (#41351)
Route console messages through the embedding API instead of printing
directly, giving embedders control over console output handling.

Testing: Should be covered by exsisting tests
Fixes: #41145

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
2025-12-17 19:06:27 +00:00
Martin Robinson
575b7ab87b libservo: Make UserInterfaceCommand consistent and always forward mouse events to open egui dialogs (#41347)
This change addresses some inconsistencies in the way that events are
handled for `egui`. It moves event and `UserInterfaceCommand` handling
to
`ServoShellWindow` which allows sharing the implementation with the
embedded ports. In addition, moving event handling there makes it
simpler to always forward mouse events to egui dialogs when they are
open.

Fixes: #41339.
Testing: There is no real testing of this layer of servoshell, which is
why this regressed in the first place.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-12-17 12:11:11 +00:00
Martin Robinson
5b99d3c2b3 servoshell: Create new WebDriver WebViews in new toplevel windows (#41235)
This change makes it is that WebDriver can create whole new windows for
each new `WebView` in servoshell. The motivation for this is:

1. This is how the WebDriver specification is written. The command that
   create a new WebView is actually called "New Window" [^1], so this
   increases compliance with the specification and now we obey the
   type hint sent with that command.
2. This change allows testing multi-window support via the WPT.
3. This will allow adding optimizations (#39923) that are otherwise
   impossible because the WPT expects all open `WebView` to be live and
   visible.

This does not make the change yet for windows opened via `window.open()`
(popups), as that requires #41220 to fix. In order to make this possible
a few changes to the code had to take place:

1. The new `PlatformWindow` creation function has to be passed down to
   the WebDriver handler, which normally doesn't know how to make
   `PlatformWindow`s.
2. This allows moving the UI command code back to the shared part of
   servoshell, meaning that the embedded ports can use it as well
   eventually.
3. Headless windows need a real id to differeniate them now intead of
   just 0.
4. When dropping the headless `PlatformWindow` we need to make it
   current. I'm not sure why surfman doesn't do this, but this is now
   necessary as there are multiple contexts. This is also true when
   resizing the `RenderingContext`.

Finally, errors when making the context current are upgraded to
`error!`s as they typically break the entire execution of the program.

[^1]: https://w3c.github.io/webdriver/#new-window

Testing: This is tested by the entire WPT suite.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-12-16 10:11:33 +00:00
Euclid Ye
e81e92fbc2 ohos: Do not alert when notified LoadStatus::Complete (#41229)
Other platforms don't have this alert. It is simply obnoxious.
Also not accurate, as the page may still be loading other content.

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-12-12 16:25:42 +00:00
Martin Robinson
824f551f03 Rename IOCompositor to Paint (#41176)
For a long time, the "Compositor" hasn't done any compositing. This is
handled by WebRender. In addition the "Compositor" does many other
tasks. This change renames `IOCompositor` to `Paint`.

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

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

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-12-10 15:09:49 +00:00
Mukilan Thiyagarajan
7e744697d7 libservo: Trigger shutdown internally from Servo's Drop impl (#41012)
Remove the public API to trigger shutdown and instead trigger the
process from `Servo`'s implementation of `Drop` trait.

This makes it hard to create issues involving the order of destruction
of `Servo` and `WebView`s. It will also allow us to implement
asynchronous shutdown in the future.

Testing: Should be covered by existing unit tests.

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-12-03 08:26:30 +00:00
Martin Robinson
105eb4256a servoshell: Add support for opening new windows on desktop (#40927)
This change finishes adding support for opening new windows in the
desktop version of servoshell. A new button is added to the tab bar
which opens a new window (this can be adjusted later, if necessary).
User interface commands now need to be processed in the context of the
`App` as we need access to a reference to the `ActiveEventLoop` to
create a new window.

Testing: servoshell is mainly untested, though a future change will add
new
unit tests for multi-window functionality.
Fixes: #13997.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-12-02 13:03:10 +00:00
Martin Robinson
cf8c67df92 libservo: Finish the SimpleDialog API (#40982)
Finish exposing the `SimpleDialog` API in libservo, abstracting away the
response senders into structures with methods. In addition, add a
default behavior so that embedders do not have to explicitly send a
reponse when dialogs are ignored. This makes the API much harder to
misuse.

Finally, the WebDriver API for setting the prompt dialog entry
field is corrected to actually set that value rather than the message.
This makes sense as part of this change as the type safety of the
structures makes setting the message (the old, wrong behavior) harder
 to implement.

Testing: This causes a WebDriver conformance test to start passing.

---------

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-12-02 08:20:49 +00:00
Martin Robinson
c4b0d21180 libservo: Clean up Servo exports and export more at the root (#40951)
This change makes it easier for embedders to embed the types that they
need by exporting almost everything necessary to use Servo at the root
of libservo, apart from a few exceptions. In addition, the `Servo` is
moved
to its own file so that public exports can be more easily spotted from
`components/servo/lib.rs`.

Testing: This should not change behavior and is thus covered by existing
tests.
Fixes: #18475.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-29 17:26:48 +00:00
Martin Robinson
8c24a80a04 servoshell: Always exit via RunningAppState::schedule_exit (#40953)
This prevents crashes when exiting servoshell in different situations.
For instance, this fixes a crash when running WPT tests on some systems.

Testing: This fixes an issue when running WPT tests locally.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-29 11:26:25 +00:00
Martin Robinson
516cdbd7d0 libservo: Starting removing the multi-document interface API (#40923)
For a while Servo has while had a somewhat unfinished multi-document
interface API that was meant to implement a kind of window manager
inside a single `RenderingContext`. This came with some focus handling
and a paint order implementation. This code was never really finished
and the `WebView` API is moving toward a design where compositing
different `WebView`s together is up to the embedder.

This is finally possible now that rendering to multiple
`RenderingContext`s is supported. In addition, the MDI API interferes
with focus handling when `WebView`s are distributed across windows.
Given these two points, this change starts to remove the MDI API.

- All `WebView`s can still be hidden / unhidden and start in an unhidden
  state.
- All `WebView`s always have system focus. System focus never properly
  interfaced with Servo's internal focus system anyway. A followup
  change will add proper system focus integration.
- There are still some leftovers from the MDI interface (such as
  `WebView`s having their own size). These will be cleaned up in a
  followup change. Only the changes necessary to get multi-window
  support working are included here.

Testing: This should not change observable behavior and tests are
updated for the
new APIs.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-28 10:21:49 +00:00
Martin Robinson
6d4937b5d6 servoshell: Add architectural support for opening multiple windows (#40883)
This change is a major re-architecture of servoshell to support multiple
windows. Unfortunately it was not possible to do this incrementally, but
@mukilan and I did this together so we feel more confident about these
changes.

The main change here is that now the `HashMap` of windows that `App`
has can be filled with more than one `ServoShellWindow`.
`ServoShellWindow` is a wrapper around a `PlatformWindow` which can
either be headed, headless, or for embedded platforms. Embedded
platforms (Android and OHOS) are only expected to have a single window,
but there is no reason that more windows cannot be added.

There is still a little bit more work to be done in order to fully
enable
mulitple windows, so this change is just the architectural preparation.

This change enables the embedded and desktop versions of servoshell to
start to be fully integrated so that the entire `RunningAppState` is
shared between them.


Testing: servoshell is the test harness so these changes are covered
by the WPT tests.

---------

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2025-11-27 10:41:32 +00:00
Martin Robinson
b4ad68fe3e libservo: Remove ServoDelegate::notify_animating_changed (#40886)
This is dead code #40799, as it is never called. Remove the delegate
call and the entire `ServoShellServoDelegate` as the only thing that it
was doing was printing top-level errors which only happen when something
goes very wrong. It's quite likely that backtraces printed earlier
will be more useful.

Testing: This just removes dead code, so should be covered by existing
tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-25 17:13:50 +00:00
d-kraus
0a0a20a9c6 Replace some #[allow] with #[expect] (#40865)
Replaces some #[allow] with #[expect]. In case where the lint
expectation was unfulfilled, I removed it.


Testing: Refactor
Part of: https://github.com/servo/servo/issues/40383

Signed-off-by: Dennis Kraus <kraus@posteo.de>
2025-11-24 22:41:45 +00:00
Martin Robinson
3b67bc7d98 libservo: Have WebView take a RenderingContext rather than Servo (#40794)
This is the last major change before we can try to implement support for
multiple windows in Servo. This change makes it so that each `WebView`
(via `WebViewBuilder`) takes the `RenderingContext` as an argument,
rather than `Servo` (via `ServoBuilder`) as a whole.

In the compositor, when registering the `RenderingContext`, if a
`Painter` is found for it, it is returned. Otherwise, a new `Painter`
(and WebRender instance) is created for it. There is currently no way to
unregister a `RenderingContext`. We should come up with a good metric
for when is the best time to clean up `Painter`s and WebRender instances
for defunct `RenderingContext`s. This could perhaps be done via a `Weak`
handle to the `RenderingContext`.

Testing: This should not really change observable behavior, so should be
covered by existing tests.
Fixes: #13995 
Closes: #40261

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-21 18:12:17 +00:00
Martin Robinson
39676a6f60 libservo: Remove Servo::animating() (#40799)
Instead of relying on `Sevo::animating()` in servoshell to drive the
event loop, it is sufficient to just let the `RefreshDriver` wake it up
when it is time to re-render.

This allows us to remove `Servo::animating()` completely. It is a bit
odd that there is a global API to track this, rather than per-`WebView`
or window, so this change just removes it entirely.

Testing: This should make the main loop of headless servoshell more
efficient,
but I do not think this difference is going to be observable in any way.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-21 17:35:45 +00:00
atbrakhi
9c4db3b7d1 servoshell: Share WebView management between desktop and EGL platforms (#40766)
Desktop and EGL implementations were maintaining identical WebView
collection logic (HashMap, creation order tracking, focus management).

Extracted this into a shared WebViewCollection struct in
RunningAppStateBase. Both platforms now use the common implementation
through trait methods


Testing: Existing tests should cover this change. 
Fixes: part of #40530

---------

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
2025-11-21 12:53:22 +00:00
Martin Robinson
36031e22f2 compositing: Make RefreshDriver per-RenderingContext (#40738)
Instead of having a global `RefreshDriver` for all of Servo, let each
`RenderingContext` have its own `RefreshDriver`. This allows for things
like per-monitor `RefreshDriver`s and helps to ensure that multiple
`BaseRefreshDriver`s can be created for the same `RefreshDriver`.

Testing: This shouldn't change behavior and thus is covered by existing
tests.

---------

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-19 14:31:25 +00:00
atbrakhi
b822e83251 servoshell: Move webdriver_receiver to shared base (#40538)
This PR eliminates duplicate code while maintaining the same
functionality across all platforms.. We move `webdriver_receiver` to
shared base where `webdriver_sender` lives

Testing: No functional changes. Existing tests should test this.
Fixes: Part of https://github.com/servo/servo/issues/40530

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
2025-11-10 16:13:37 +00:00
atbrakhi
5098355aa6 servoshell: Move screenshot stability tracking to shared base (#40534)
Move screenshot stability tracking to shared base. This PR eliminates
duplicate code while maintaining the same functionality across all
platforms.

Testing: No functional changes. Existing tests should test this.
Fixes: Part of #40530

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
2025-11-10 12:35:42 +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
Martin Robinson
2c77d9d8a1 libservo: Integrate context menu into the show_embedder_control API (#40402)
This PR integrates showing context menus into the
`WebViewDelegate::show_embedder_control` API. In addition,
`ContextMenuItem` and `ContextMenuAction` data types are exposed which
abstract away the different components of the context menu. Later
changes will implement this API for servoshell as well as add
element-specific actions such as "Select All" and "Copy Image URL".

Testing: This change adds a WebView API test.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
2025-11-04 21:08:04 +00:00
Euclid Ye
2d89cd7471 Reduce unnecessary type conversion and share WebDriverCommandMsg::LoadUrl handler across platform (#40393)
- Reduces unnecessary type conversion between `ServoUrl`, `Url`, string
slice
- Share `WebDriverCommandMsg::LoadUrl` handler across platform

Testing: Covered by existing test. Manually tested for OHOS.

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-11-04 13:57:00 +00:00
Euclid Ye
29993f3711 servoshell: Move handle_webdriver_script_command to RunningAppStateTrait (#40372)
Share more code between egl and Desktop.

Testing: Just refactoring

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-11-03 20:54:32 +00:00
Martin Robinson
493acd7e43 servoshell: Add a VsyncRefreshDriver for Android (#40306)
This adds an implementation of `VsyncRefreshDriver` ensuring that frame
updates are driven by the system compositor.

Testing: This should increase the smoothness of animations, but I'm
not sure how to test that exactly.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-11-03 08:00:29 +00:00
atbrakhi
2453846ef7 servoshell: Move servo to RunningAppStateBase (#40315)
There are several code duplicates in servoshell. In this PR, we extract
`servo` from the desktop and EGL implementations into a shared
`RunningAppStateBase` trait. This eliminates duplicate code while
maintaining the same functionality across all platforms.

This is part of refactoring effort to consolidate shared code between
desktop and EGL implementations.

Testing: No functional changes. Existing tests should test this.

Signed-off-by: atbrakhi <atbrakhi@igalia.com>
2025-11-01 11:24:03 +00:00
Euclid Ye
86572dcd2c servoshell: Move webview_by_id into RunningAppStateTrait (#40330)
This reduces code duplication between egl and Desktop.

Testing: No behaviour change. Just simplification.

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-11-01 11:13:46 +00:00
Euclid Ye
b363eaeb39 servoshell: Implement WebDriverCommandMsg::TakeScreenshot for egl (#40303)
Move the screenshot handler to `RunningAppStateBase` to be shared
between egl and desktop. This enables screenshot/element screenshot
capability for egl.

Testing: Existing test. For egl, tested on Ohos.
Fixes: Part of #40279

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-10-31 13:02:29 +00:00