Commit graph

634 commits

Author SHA1 Message Date
Simon Wülker
3d320fa96a
Update rustfmt to the 2024 style edition (#35764)
* 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>
2025-03-03 11:26:53 +00:00
Bi Fuguo
929f87f598
add cancelable property to the TouchEvent (#35713)
* add `cancelable` property to the `TouchEvent`
set cancellable = false when sending move events to script, if the first touch_move event did not cancel it

Signed-off-by: kongbai1996 <1782765876@qq.com>

* modified review commentss

Signed-off-by: kongbai1996 <1782765876@qq.com>

---------

Signed-off-by: kongbai1996 <1782765876@qq.com>
2025-03-02 08:12:26 +00:00
Martin Robinson
e670464fef
compositor Remove frame_tree_id member (#35702)
This is unused.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-02-27 14:06:57 +00:00
Shubham Gupta
6b69f381e0
Set limits on pinch zoom (#35692)
Signed-off-by: Shubham Gupta <shubham13297@gmail.com>
2025-02-27 11:56:48 +00:00
Martin Robinson
9d5171f3c5
libservo: Add WebView immediately to the Compositor (#35662)
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>
2025-02-26 16:16:48 +00:00
Martin Robinson
23524a5413
libservo: Move size handling to RenderContext from WindowMethods (#35621)
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>
2025-02-25 15:03:53 +00:00
Bi Fuguo
f3a8bf8ca2
Touch handler: Fix race condition and rate-limit move events (#35537)
* TouchSequenceInfo is added to store information about a touch sequence.
  For details about TouchSequenceInfo, see the code comments.
The handling_touch_move attribute is added to the TouchHandler, indicating that the script is processing the touch move event.
  When handling_touch_move is set to true, the touch move event does not need to be sent to the script thread.

Signed-off-by: kongbai1996 <1782765876@qq.com>

* move touch state, active_touch_point and handling_touch_move to TouchSequenceInfo form TouchHandler.
remove TouchSequenceInfo end_sequence property, add Finished state mark sequence end.
if preventDefault on touchup, do not prevent Fling.

Signed-off-by: kongbai1996 <1782765876@qq.com>

* Refactor Touchhandler

- Add a newtype wrapper for the TouchSequenceId
- Move more state back into the TouchSequenceState
- Rename TouchAction to TouchMoveAction,
  since it only covers immediate actions now.
  Everything else is handled via state, since
  it needs to wait on the handler.

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>

* Fix test-tidy

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>

* Fix clippy missing-default lint

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>

* Fix remaining clippy lints

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>

* Remove accidental committed test file

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>

* Remove wrong todo comment

(move events that are sent to script are just raw  touchpoints,
 no merging needed)

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>

* Fix preventdefault after long touch_down handler

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>

---------

Signed-off-by: kongbai1996 <1782765876@qq.com>
Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Co-authored-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2025-02-25 07:13:16 +00:00
Martin Robinson
54b5c7b632
compositing: Move image output and shutdown management out of the compositor (#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>
2025-02-20 18:27:49 +00:00
Martin Robinson
168f7ead15
compositing: Split non-WebView-specific data into ServoRenderer (#35536)
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>
2025-02-19 15:29:32 +00:00
Martin Robinson
e5c9a0365d
libservo: Rework and clarify the rendering model of the WebView (#35522)
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>
2025-02-19 10:35:56 +00:00
Bi Fuguo
3fe42a0b5a
implement Touchevent prevent default behavior (#35031)
* implement Touchevent prevent default behavior

* The status change logic of the `TouchHandler` is changed.
> The `WaitingForScript` state is canceled. TouchAction can be identified
  based on the current touch type and numbers if touch points.
* Sends current event to script thread along with recognized `TouchAction`.
> After dispatch event, script thread sends a `TouchEventProcess(EventResult)`
  message to main thread. If the event is set to `DefaultAllowed`, the
  corresponding `TouchAction` information is added.
* After receiving `DefaultAllowed(TouchAction)` message, main thread executes corresponding action.
> `DefaultPrevented(TouchEventType)` is received. Use `prevent_click` to mark
  that the default `Click` is blocked, and `prevent_move` to mark that the
  default `Scroll` and `Zoom` are blocked. In this way, all TouchActions
  implement preventDefault.
Signed-off-by: Bi Fuguo <1782765876@qq.com>

* fix some suggestions

* support preventDefault fling
* move `TouchAction` to share touch directory
* check preventDefault everytime when touch
* fix zoom ineffective

Signed-off-by: Bi Fuguo <1782765876@qq.com>

* fix some suggestions

rename on_event_processed to  on_touch_event_processed
clear unused features

Signed-off-by: Bi Fuguo <1782765876@qq.com>

* Optimizes pan performance by continuously sliding without waiting for the eventhandler.

Signed-off-by: kongbai1996 <1782765876@qq.com>

* resolve conflict

Signed-off-by: kongbai1996 <1782765876@qq.com>

---------

Signed-off-by: Bi Fuguo <1782765876@qq.com>
Signed-off-by: kongbai1996 <1782765876@qq.com>
2025-02-17 10:50:04 +00:00
Martin Robinson
6dce329acc
libservo: Expose an OffscreenRenderingContext and use it for servoshell (#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>
2025-02-17 08:35:05 +00:00
Bi Fuguo
3a63622d6b
fix issue #35449: handle touch events in on_input_event. (#35450)
Signed-off-by: kongbai1996 <1782765876@qq.com>
2025-02-13 08:05:03 +00:00
webbeef
8cd280ca3b
Update window.screenX and window.screenY when moving the embedder window (#35246)
Signed-off-by: webbeef <me@webbeef.org>
2025-02-13 03:13:32 +00:00
Martin Robinson
0908a47780
libservo: Expose a single InputEvent type and pass it to script (#35430)
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>
2025-02-12 17:07:15 +00:00
Martin Robinson
71bfd2d13f
libservo: Don't bounce ready-to-present frame notifications to the 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>
2025-02-12 08:25:58 +00:00
Martin Robinson
84006ba76d
libservo: Remove message-based API (#35366)
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-02-10 04:14:16 +00:00
Martin Robinson
643885e6f1
deps: Upgrade to webrender@0.66 (#35325)
In addition to some small API changes, this downstream version of
WebRender no longer depends on a very old version of time. This is the
last step toward removing the dependency on `time0.1`.

The review for this commit should also include: 9f552bebab

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-02-07 11:57:26 +00:00
Ngo Iok Ui (Wu Yu Wei)
b5b69988cc
fix: bring back connection method to fix WebGL texture error (#35358)
* Bring back connection method to fix texture error

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Print GL info in log instead

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

---------

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>
2025-02-07 10:36:37 +00:00
Ngo Iok Ui (Wu Yu Wei)
07aa4ce093
Simplify RenderingContext trait methods (#35251)
There are a few methods are still difficult to implement without
the help of surfman. To simplify the trait methods, all methods that
return surfman types are removed. They are either handled by
embedders themselves or abstract to simpler types that servo
components need. The most noticeable changes are:

- Methods related to native surface are moved to servo_glue. The
  embedder should decide when to remove/replace the surface and it's
  outside of servo's scope.
- Methods required by servo media now return exact media types for it.

The other major change is sevevral difficult trait methods that are
reuiqred by WebGL and Servo media have default implementation. So they
can be optional for users to implement.

Signed-off-by: Wu Wayne <yuweiwu@pm.me>
2025-02-05 12:02:11 +00:00
Martin Robinson
e41b34a1bf
libservo: Remove Servo::repaint_synchronously (#35283)
This method is unused, so remove it.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-02-04 15:08:40 +00:00
DK Liao
4461380792
chore: Rename CompositeTarget enum (#35263)
* chore: Rename CompositeTarget enum

Signed-off-by: DK Liao <dklassic@gmail.com>

sync name in other documents

Signed-off-by: DK Liao <dklassic@gmail.com>

sync more name in other documents

Signed-off-by: DK Liao <dklassic@gmail.com>

* Fix Android/ohos

Signed-off-by: DK Liao <dklassic@gmail.com>

---------

Signed-off-by: DK Liao <dklassic@gmail.com>
2025-02-04 04:38:11 +00:00
Martin Robinson
ad07db0b0c
script_traits: Rename ConstellationControlMsg to ScriptThreadMessage (#35226)
At some point in the past this message was only sent from the
`Constellation` to `script`, but nowadays this is sent from various
parts of servo to the `ScriptThread`, so this is a better name. In
particular, the current name makes it seeem like this message controls
the `Constellation`, which it does not.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-01-30 22:46:17 +00:00
Delan Azabani
5e9de2cb61
Include WebViewId into EmbedderMsg variants where possible (#35211)
`EmbedderMsg` was previously paired with an implicit
`Option<WebViewId>`, even though almost all variants were either always
`Some` or always `None`, depending on whether there was a `WebView
involved.

This patch adds the `WebViewId` to as many `EmbedderMsg` variants as
possible, so we can call their associated `WebView` delegate methods
without needing to check and unwrap the `Option`. In many cases, this
required more changes to plumb through the `WebViewId`.

Notably, all `Request`s now explicitly need a `WebView` or not, in order
to ensure that it is passed when appropriate.

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-01-30 11:15:35 +00:00
Martin Robinson
9eeb602f7a
compositor: Remove some unused messages to the compositor (#35223)
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-01-30 09:21:23 +00:00
Martin Robinson
9dbc942bee
libservo: Port desktop servoshell to use the new WebView API (#35183)
This removes all uses of `EmbedderEvent` in the desktop servoshell to
use the new `WebView` API -- filling it out when necessary.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Delan Azabani <dazabani@igalia.com>
2025-01-28 14:57:57 +00:00
Martin Robinson
a1cf0cbf86
libservo: Stop using script_traits in the embedding layer (#35185)
Many types used directly in the `libservo` API are in the
`script_traits` crate, which was created to break circular dependencies.
Move all API exposed types to `embedder_traits` which now contains types
exposed via the `libservo` embedding API. Also expose these at the root
of the `libservo` `servo` crate so that the API won't break when they
move around in the future.

The idea with `embedder_traits` in the future is that it contains types
that are available throughout servo because they are used in the
embedding API and thus should have minimal dependencies on other Servo
crates (a bit like `base`).

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-01-28 11:15:36 +00:00
Delan Azabani
2ce7709b8b
libservo: Add an initial WebView data structure to the API (#35119)
This patch introduces a new handle-based webview API to libservo, with
two main design goals:

1. The lifetime of the handles controls the lifetime of the webview,
   giving the embedder full control over exactly when webviews are
   created and destroyed. This is consistent with how WebKitGTK’s
   WebView works; the engine can only create webviews via a create
   request, and can only destroy them via a close request.
2. All methods are infallible; if the constellation dies, the embedder
   finds out when calling Servo::handle_events.

For the moment, the embedder is only responsible for creating the
WebView id, and not the internal TopLevelBrowsingContext data
structures. This is so that the ScriptThread is able to get a handle on
the new WebView's WindowProxy in the case that it's an auxiliary
browsing context. In the future, the embedder should also be responsible
for creating the TopLevelBrowsingContext and the ScriptThread should
have mechanism to associate the two views so that WebView creation is
always executed through the same code path in the embedding layer. For
now, it's enough that the embedder can get a handle to the new WebView
when it's creation is requested.

Once we replace EmbedderMsg with a webview delegate trait, we will pass
WebView handles to the embedder, rather than webview ids. We’ll also add
detailed docs, once the design settles.

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-01-25 08:17:50 +00:00
Delan Azabani
8976f2420c
Remove type parameter from Servo and IOCompositor (#35121) (#35156)
* Remove type parameter from Servo and IOCompositor (#35121)

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>

* Fix compile error in libservo example

Signed-off-by: Delan Azabani <dazabani@igalia.com>

* Fix compile error in servoshell

Signed-off-by: Delan Azabani <dazabani@igalia.com>

---------

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-01-24 07:41:21 +00:00
DK Liao
a0eceee2ed
feat: Turn RenderingContext into a trait (#35052)
* feat: turn RenderingContext into a trait

Signed-off-by: DK Liao <dklassic@gmail.com>

Add comment and handle drop error

Signed-off-by: DK Liao <dklassic@gmail.com>

Add doc comment

Signed-off-by: DK Liao <dklassic@gmail.com>

Allow make_current to propagate Error

Signed-off-by: DK Liao <dklassic@gmail.com>

Fix all make_current occurances

Signed-off-by: DK Liao <dklassic@gmail.com>

Move back to Rc<dyn RenderingContext>

Signed-off-by: DK Liao <dklassic@gmail.com>

fix android/ohos

Signed-off-by: DK Liao <dklassic@gmail.com>

Fix build

Signed-off-by: DK Liao <dklassic@gmail.com>

fix android/ohos again

Signed-off-by: DK Liao <dklassic@gmail.com>

* Fix macOS smoke test

Signed-off-by: DK Liao <dklassic@gmail.com>

* Add comment for create_texture and destroy_texture

Signed-off-by: DK Liao <dklassic@gmail.com>

* Improve comments written

Signed-off-by: DK Liao <dklassic@gmail.com>

---------

Signed-off-by: DK Liao <dklassic@gmail.com>
2025-01-24 02:39:39 +00:00
Martin Robinson
0e616e0c5d
api: Flatten and simplify Servo preferences (#34966)
Flatten and simplify Servo's preferences code. In addition, have both
preferences and options passed in as arguments to `Servo::new()` and
make sure not to use the globally set preferences in `servoshell` (as
much as possible now).

Instead of a complex procedural macro to generate preferences, just
expose a very simple derive macro that adds string based getters and
setters.

- All command-line parsing is moved to servoshell.
- There is no longer the concept of a missing preference.
- Preferences no longer have to be part of the resources bundle because
  they now have reasonable default values.
- servoshell specific preferences are no longer part of the preferences
  exposed by the Servo API.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-01-14 13:54:06 +00:00
Nico Burns
deb819f233
Upgrade rustc to 1.83 (#34793)
* Upgrade rustc to 1.83

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Fix crown (change copied from linked clippy function)

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Fix named lifetime lint

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Bump shell.nix

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Fix non-local impl warnings

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Format with 1.83 formatting changes

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Fix manual non-local impl

Signed-off-by: Nico Burns <nico@nicoburns.com>

* More fixes for crown

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Fix tidy

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Fix needless_return lints

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Fix doc comment lint

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Fix missing wait lint

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Allow needless_lifetimes lint

Signed-off-by: Nico Burns <nico@nicoburns.com>

* more doc comments

Signed-off-by: Nico Burns <nico@nicoburns.com>

* More needless_returns

Signed-off-by: Nico Burns <nico@nicoburns.com>

* is_empty lint

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Fix needless_lifetime lints

Signed-off-by: Nico Burns <nico@nicoburns.com>

* fix div_ceil lint

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Allow non-minimal bool

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Non-local impl in constellation

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Missing wait in constellation

Signed-off-by: Nico Burns <nico@nicoburns.com>

* fmt

Signed-off-by: Nico Burns <nico@nicoburns.com>

* remove useless lints table

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Fixup comments

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Allow non-local definition in sandboxing code to simplify feature flagging

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Remove wait calls and allow zombie_processes lint

Signed-off-by: Nico Burns <nico@nicoburns.com>

---------

Signed-off-by: Nico Burns <nico@nicoburns.com>
2025-01-01 09:38:28 +00:00
Ngo Iok Ui (Wu Yu Wei)
d581acab3b
chore: remove WindowMethods::rendering_context (#34780)
* Create Servo without initial webview ID

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Add rendering context in App struct

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Make webview manager optional

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Move window creation to init

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Create window from external rendering context

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Resize surface in compositor

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Obey clippy

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Update Android and OHOS

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Add missing arguent on OHOS

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Show webview after focused on Android and OH

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Remove rendering_context in ServoWindowCallbacks

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

* Create surface before swapchain in headless mode

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>

---------

Signed-off-by: Wu Yuwei <yuweiwu@pm.me>
2025-01-01 08:26:23 +00:00
Josh Matthews
915901bdec
compositing: Invert check for webxr when determining animation status. (#34715)
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
2024-12-20 12:15:13 +00:00
Nico Burns
63793ccbb7
Use webrender_api::units::DevicePixel rather than style_traits::DevicePixel unless interfacing with Stylo (#34353)
* Use webrender_api::units::DevicePixel rather than style_traits::DevicePixel unless interfacing with Stylo

Signed-off-by: Nico Burns <nico@nicoburns.com>

* Fix OpenHarmony build

Signed-off-by: Nico Burns <nico@nicoburns.com>

---------

Signed-off-by: Nico Burns <nico@nicoburns.com>
2024-11-25 23:42:04 +00:00
Martin Robinson
4451a59f88
compositing: Properly clean up pending paint metrics (#34305)
Not all pending display list epochs are painted immediately or at all.
Soemtimes WebRender is one or more display lists behind the latest and
sometimes an epoch isn't painted at all if a new display list arrives
before the old one is painted. These situations aren't errors, but they
might indicate performance issues.

Instead of forever printing warnings when this happens, properly clean
up pending paint metrics after compositing. If earlier pending paint
metrics for a pipeline exist, remove them. If a pipeline is no longer
known by the compositor, remove its pending paint metrics.

This change fixes situations where warnings flood the output and a small
memory leak.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2024-11-20 16:05:26 +00:00
Delan Azabani
caf2467649
Set all tracing spans to trace level for now (#34256)
* Clean up tracing instrumentation

Signed-off-by: Delan Azabani <dazabani@igalia.com>

* Set all tracing spans to trace level for now

Signed-off-by: Delan Azabani <dazabani@igalia.com>

---------

Signed-off-by: Delan Azabani <dazabani@igalia.com>
2024-11-19 02:53:43 +00:00
Delan Azabani
aa7116c75d
Plumb time profiler output into tracing (#34238)
* Plumb time profiler output into tracing

Signed-off-by: Delan Azabani <dazabani@igalia.com>

* Enter the span tightly around the callback

Signed-off-by: Delan Azabani <dazabani@igalia.com>

* Use `info_span!()` shorthand

Signed-off-by: Delan Azabani <dazabani@igalia.com>

---------

Signed-off-by: Delan Azabani <dazabani@igalia.com>
2024-11-15 09:10:01 +00:00
Ngo Iok Ui (Wu Yu Wei)
47a243614f
feat: webxr feature flag (#34241)
* Add webxr feature flag

Add webxr feature flag to embedder_traits

Add webxr flag to constellation

Add webxr flag to compositor

Add webxr flag to canvas

Turn registry into optional

Add webxr flag to servo lib

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>
Co-authored-by: august kline <me@augustkline.com>

* Cargo fmt

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>

* Add missing license

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>

* Cargo clippy

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>

---------

Signed-off-by: Wu Yu Wei <yuweiwu@pm.me>
Co-authored-by: august kline <me@augustkline.com>
2024-11-13 17:16:58 +00:00
Jonathan Schwender
72971bd271
Add simple fling implementation (#33219)
* Add simple fling implementation

Add a simple fling implementation, which depends on a refresh tick from the
embedder.
Currently this refresh tick is only implemented for OpenHarmony
(using the vsync signal).
The fling implementation is very simple, without any fancy things like acceleration.
This can be improved in the future.

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>

* Multiply initial velocity with 2

This makes the experience much more snappy.

Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>

* address review comments

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>

* Rename constants and add todo

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>

* fmt

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>

* Add a few periods to make comments consistent

Signed-off-by: Martin Robinson <mrobinson@igalia.com>

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
Signed-off-by: Jonathan Schwender <jonathan.schwender@huawei.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-11-10 10:15:42 +00:00
Delan Azabani
fa1f7e5839
Gate all use of tracing behind Cargo feature (#33845)
Signed-off-by: Delan Azabani <dazabani@igalia.com>
2024-10-16 10:24:24 +00:00
Martin Robinson
9195344b75
compositor: Create a single cross-process compositor API (#33619) (#33660)
Instead of exposing many different kinds of messages to the compositor
that are routed through the constellation, expose a single message type
which can be sent across IPC channels. In addition, this IPC channel and
the route to the crossbeam channel with the compositor is created along
with the `CompositorProxy`, simplifying what needs to be passed around
during pipeline initialization.

Previously, some image updates (from video) were sent over IPC with a
special serialization routine and some were sent via crossbeam channels
(canvas). Now all updates go over the IPC channel `IpcSharedMemory` is
used to avoid serialization penalties. This should improve performance
and reduce copies for video, but add a memory copy overhead for canvas.
This will improve in the future when canvas renders directly into a
texture.

All-in-all this is a simplification which opens the path toward having a
standard compositor API and reduces the number of duplicate messages and
proxying that had to happen in libservo.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-10-09 17:30:24 +00:00
Martin Robinson
719b5aba24
tools: Improve instrumentation and add it for some layout (#33647)
Improves the instrumentation to skip all function arguments and also add
spans for some layout modes. This is preparation for improving the
performance of flexbox.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-10-05 08:55:40 +00:00
Martin Robinson
48f8ff6236
Revert "compositor: Create a single cross-process compositor API (#33619)" (#33645)
This reverts commit f2f5614ad6.

This is causing intermittent crashes: 3104425501

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-10-04 09:08:19 +00:00
Martin Robinson
f2f5614ad6
compositor: Create a single cross-process compositor API (#33619)
Instead of exposing many different kinds of messages to the compositor
that are routed through the constellation, expose a single message type
which can be sent across IPC channels. In addition, this IPC channel and
the route to the crossbeam channel with the compositor is created along
with the `CompositorProxy`, simplifying what needs to be passed around
during pipeline initialization.

Previously, some image updates (from video) were sent over IPC with a
special serialization routine and some were sent via crossbeam channels
(canvas). Now all updates go over the IPC channel `IpcSharedMemory` is
used to avoid serialization penalties. This should improve performance
and reduce copies for video, but add a memory copy overhead for canvas.
This will improve in the future when canvas renders directly into a
texture.

All-in-all this is a simplification which opens the path toward having a
standard compositor API and reduces the number of duplicate messages and
proxying that had to happen in libservo.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-10-03 14:42:04 +00:00
tanishka
cd803c8341
clippy: Fix warning in components/compositing (#33625)
Signed-off-by: taniishkaaa <tanishkasingh2004@gmail.com>
2024-10-03 10:55:30 +00:00
Ngo Iok Ui (Wu Yu Wei)
88dad77483
Compositor: add document id to NewWebRenderFrame variant (#33597)
* Add document id to NewWebRenderFrame variant

Signed-off-by: Wu Wayne <yuweiwu@pm.me>

* Match the arguments order

Signed-off-by: Wu Wayne <yuweiwu@pm.me>

---------

Signed-off-by: Wu Wayne <yuweiwu@pm.me>
2024-10-02 07:34:15 +00:00
Martin Robinson
abad89a49c
fonts: Make FontKey and FontInstanceKey generation asynchronous (#33600)
Instead of a blocking a layout thread on the generation of WebRender
`FontKey`s and `FontInstanceKey`s, generate the keys ahead of time and
send the font data to WebRender asynchronously. This has the benefit of
allowing use of the font much more quickly in layout, though blocking
display list sending itself on the font data upload.

In order to make this work for web fonts, `FontContext` now asks the
`SystemFontService` for a `FontKey`s and `FontInstanceKey`s for new web
fonts. This should happen much more quickly as the `SystemFontService`
is only blocking in order to load system fonts into memory now. In
practice this still drops layout thread blocking to fractions of a
millisecond instead of multiple milliseconds as before.

In addition, ensure that we don't send font data or generate keys for
fonts that are used in layout but never added to display lists. This
should help to reduce memory usage and increase performance.

Performance of this change was verified by putting a microbenchmark
around `FontContext::create_font` which is what triggered font key
generation.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-10-01 15:31:26 +00:00
Martin Robinson
ac567645a7
fonts: Simplify FontContext in two ways that affect the unit test (#33541)
This is done by no longer forwarding compositor-bound messages through
SystemFontService and making `FontContext` non-generic:

- Messages from the `FontContext` to the `Compositor` no longer need to be
  forwarded through the `SystemFontService`. Instead send these messages
  directly through the script IPC channel to the `Compositor`.

- Instead of adding a mock `SystemFontServiceProxy`, simply implement a
  mock `SystemFontService` on the other side of an IPC channel in the
  `font_context` unit test. This allows making `FontContext`
  non-generic, greatly simplifying the code. The extra complexity moves
  into the unit test.

These changes necessitate adding a new kind of `FontIdentifier`,
`FontIdentifier::Mock` due to the fact that local fonts have
platform-specific identifiers. This avoids having to pretend like the
system font service can have web fonts -- which was always a bit of a
hack.

These two changes are combined into one PR because they both require
extensive and similar chages in the font_context unit test which
dependended on the details of both of them.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-09-25 20:15:47 +00:00
Martin Robinson
ade902207f
fonts: Use IpcSharedMemory to send font data (#33530)
This changes modifes the way that font data is sent over IPC channels.
Instead of serializing the data or sending it via IPC byte senders, font
data is copied into shared memory and a copy of the handle is sent over
the channel.

There is also the idea of sending the file handle of the on disk data of
system fonts. This could be implemented as a further followup once there
is an abstraction in `ipc-channel` over file handles.

To accomplish this, a `FontData` abstraction is added, which also allows
caching an in-memory shared `Arc<Vec<u8>>` version of the data (neeeded
by some APIs). This could also be a place for caching font tables in the
future.

Finally, the `FontCacheThread` is renamed to the `SystemFontService`
while the proxy for this is now named `SystemFontServiceProxy`.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2024-09-25 07:31:55 +00:00