Commit graph

15 commits

Author SHA1 Message Date
Shubham Gupta
520a7f7bc5
Fix broken unit-test of webview (#36238)
This PR fixes the broken unit-test after
[#35662](https://github.com/servo/servo/pull/35662)

Testing: Verified locally and CI confirms too.
Fixes: Migrate the test to use new API

cc: @xiaochengh

Signed-off-by: Shubham Gupta <shubham13297@gmail.com>
2025-04-02 10:00:24 +00:00
Bi Fuguo
53f7c7b1de
Fixed the problem that touchmove cannot be disabled when preventDefault is invoked on touchstart. (#36200)
Signed-off-by: kongbai1996 <1782765876@qq.com>
2025-03-28 23:00:52 +00:00
Martin Robinson
3c51df0f1b
compositor: Remove the script channel from the compositor (#36089)
This is a clean up after #36062 and #35985. It removes the script
channel for each pipeline from the compositor. Now all messages are sent
via the `Constellation` first, which will allow breaking the dependency
on script in the compositor.

In addition, scroll states are actually sent via the `Constellation`,
which was an oversight from #36062. Finally, a typo in a method name is
fixed.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-03-23 11:19:27 +00:00
Martin Robinson
7c574141c0
Create a constellation_traits crate (#36088)
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>
2025-03-22 15:49:08 +00:00
Martin Robinson
5424479768
metrics: Simplify ProgressiveWebMetrics (#35985)
Simply how `ProgressiveWebMetrics` works:

1. Keep only a single struct instead of one in layout and one script
   that both implement the `ProgressiveWebMetrics` trait. Since layout
   and script are the same thread these can now just be a single
   `ProgressiveWebMetrics` struct stored in script.
2. Have the compositor be responsible for informing the Constellation
   (which informs the ScripThread) about paint metrics. This makes
   communication flow one way and removes one dependency between the
   compositor and script (of two).
3. All units tests are moved into the `metrics` crate itself since there
   is only one struct there now.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-03-21 14:55:00 +00:00
Martin Robinson
1f232eb17c
constellation: Proxy ScrollState through the Constellation (#36062)
This will allow removing the dependency of the compositor on
`script_traits`, which should make our internal dependency chain a lot
easier to deal with.

Part of #35984.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-03-21 12:09:01 +00:00
Simon B / GrausamkeitEnjoyer / God's Eye View Developer
205b97d5ed
compositing: Move cursor_pos member and update it in update_cursor() (#35934)
Previously a member of IOCompositor, the `cursor_pos` DevicePoint did not reflect
the true position of the cursor. This caused flickering on mouse hover,
see [issue #35875.] The value of `cursor_pos` within IOCompositor
was always (x=0, y=0) regardless of the true cursor position
(it was never updated, must be a bug or an oversight?).

Moving `cursor_pos` to `ServoRenderer`, updating `cursor_pos` on `dispatch_input_event()`,
and storing cursor position in `ServoRenderer` through method `update_cursor()` fixes
the flickering previously observed.

Signed-off-by: devgev <leifminfagel@gmail.com>
2025-03-13 02:03:46 +00:00
Martin Robinson
2464d0937f
base: Finish rename of TopLevelBrowsingContextId to WebViewId (#35896)
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>
2025-03-11 10:56:10 +00:00
Delan Azabani
69e7499479
compositor: Make input event handling per-WebView (#35716)
This is another step in the move to having a per-WebView renderer. In
this step event handling is made per-WebView. Most events sent to Servo
are sent via the WebView API already, so this just moves more event
handling code to the per-WebView render portion of the compositor.

- ServoRenderer is given shared ownership and interior mutability as
  it is now shared among all WebView(Renderers).
- Some messages coming from other parts of Servo must now carry a
  WebViewId as well so that they can be associated with a particular
  WebView.
- There needs to be some reorganization of `ServoRenderer` in order to
  avoid issues with double borrow of `RefCells`.

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-03-05 18:47:13 +00:00
Martin Robinson
f3e6e4f04e
compositor: Make PipelineDetails and pending paint metrics per-WebView (#35701)
This is one of the first big steps toward making the compositor work
per-WebView. It moves the collection of pipelines into the per-WebView
data structure in the compositor as well as the pending paint metrics.

This means that more messages need to carry information about the
WebView they apply to. Note that there are still a few places that we
need to map from `PipelineId` to `WebViewId`, so this also includes a
shared mapping which tracks this. The mapping can be removed once event
handling is fully per-WebView.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Delan Azabani <dazabani@igalia.com>
2025-03-04 02:31:23 +00:00
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
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
Jonathan Schwender
53fcc98585
ohos: Support resizing the surface (#35158)
A window resize requires to also resize the webview,
otherwise it will stay at the original size.

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
2025-01-29 15:45:17 +00:00
Martin Robinson
3398fc017b
Move non-gfx things out of gfx_traits and create a base crate (#32296)
For a long time, `gfx_traits` has held a lot of things unrelated to graphics
and also unrelated to the `gfx` crate (which is mostly about fonts).
This is a cleanup which does a few things:

1. Move non `gfx` crate things out of `gfx_traits`. This is important in
   order to prevent dependency cycles with a different integration between
   layout, script, and fonts.
2. Rename the `msg` crate to `base`. It didn't really contain anything
   to do with messages and instead mostly holds ids, which are used
   across many different crates in Servo. This new crate will hold the
   *rare* data types that are widely used.

Details:

 - All BackgroundHangMonitor-related things from base to a new
   `background_hang_monitor_api` crate.
 - Moved `TraversalDirection` to `script_traits`
 - Moved `Epoch`-related things from `gfx_traits` to `base`.
 - Moved `PrintTree` to base. This should be widely useful in Servo.
 - Moved `WebrenderApi` from `base` to `webrender_traits` and renamed it
   to `WebRenderFontApi`.
2024-05-17 12:28:58 +00:00
Ngo Iok Ui (Wu Yu Wei)
66878fb834
Initial internal support for multiple webviews (#31417)
* Add multiple concurrent top-level browsing contexts

Co-authored-by: Delan Azabani <dazabani@igalia.com>

* Rename variables and comments

There are some variable and comments still use browser as names.
This commit renames them to webview.

* Update log message from web view to webview

* Revert offscreen_framebuffer_id rename

* Rename all web view to webview

* Cargo fmt

* Fix viewport/event/clear coordinates when multiview is disabled

* Only deprecate things when multiview is enabled

* Update WebViewManger with shown and invisible sets

Replace visible_webviews and native_window_is_visible with shown_webviews
and invisible_webviews. Add 4 more methods to set them accordingly. The
behavior of is_effectively_visible will return true if the wbview is in
shown_webviews set but not in invisible_webviews.

* Update variant behaviors

* Rename WebViewVisibilityChanged to MarkWebViewInvisible

* Fix unit test by marking id 3 visible again

* Update MarkWebViewInvisible and add UnmarkWebViewInvisible

* Update format and doc comments

* Clean up doc comments

* Address style and naming changes

* Rename UpdateWebView to UpdateFrameTreeForWebView

* constellation: send frame tree unconditionally over focus and feature

* Clarify shown and invisible sets in constellation WebViewManager

* Eliminate forward_to_constellation!()

* Actually remove the unused macro

* Don’t gate compositor changes on multiview feature flag

* Update todo in mouse event dispatch

* Pass all visible webview ids in a single ReadyToPresent message

* Fix compile and lint errors

* servoshell: fix gap between minibrowser toolbar and webview

* Fix failure in /_mozilla/mozilla/window_resizeTo.html

* Fix compile warnings

* Remove stray dbg!()

* Remove confusing “effectively visible” logic (see #31815, #31816)

* Allow embedder to show/hide/raise webviews without ipc

* Update root pipeline only when painting order actually changes

* Stop gating old focus and SetFrameTree behaviour behind Cargo feature

* Use webview_id and WebViewId in webview-related code

* Improve logging of webview-related embedder events

* Allow webview Show and Raise events to optionally hide all others

* Don’t do anything in response to WebViewPaintingOrder

* Remove WebViewPaintingOrder, since its payload is unreliable

* On MoveResizeWebView, only update root pipeline if rect changed

* Rename IOCompositor methods for clarity

* compositor: add event tracing; log webview ops even without ipc

* Add temporary debug logging

* Add more temporary debug logging

* Remove temporary logging in compositor

* Remove temporary debug logging

* Add temporary debug logging, but defer I/O until panic

* Capture a backtrace with each crash log entry

* Proper error handling without panicking in WebViewManager

* Clean up imports in constellation

---------

Co-authored-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2024-04-03 11:06:28 +00:00