Commit graph

12 commits

Author SHA1 Message Date
Martin Robinson
f451dccd0b
layout: Store scroll offsets in the ScrollTree (#37428)
There are currently five places that scroll offsets are stored:

 - DOM: A set of scroll offsets used for script.
 - Layout: An array of scroll offsets that is used for tracking
   layout-side scroll offsets.
 - Layout: The scroll offsets stored in the `ScrollTree`. These are
   currently unset and unused.
 - Compositor: The scroll offsets stored in the `ScrollTree` mirrored
   from layout.
 - WebRender: The scrolled offsets stored in the WebRender spatial tree.

This change is the first step in combining the first three into the
layout `ScrollTree`. It eliminates the extra array of scroll offsets
stored in layout in favor of the storing them in the `ScrollTree`. A
followup change will eliminate the ones stored in the DOM.

- In addition the `ScrollState` data structure is eliminated as these
are
now stored in a `HashMap` everywhere when passing them via IPC.
- The offsests stored in layout can now never scroll past the boundaries
of the scrolled content.

Testing: This should not change behavior and is thus covered by existing
WPT tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: stevennovaryo <steven.novaryo@gmail.com>
2025-06-13 12:01:27 +00:00
Martin Robinson
29fc878e15
compositor: Do not allow script to scroll beyond node boundaries (#37412)
The compositor was accepting scroll offsets from the ScriptThread
without checking their boundaries. In some cases this could cause a
temporary discrepancy with the rendered scroll offset. This change makes
it so that all offset updates for scroll ayers in the compositor do not
scroll past the scroll boundaries of the node.

Testing: Two new tests pass with this change:
 - `/css/css-position/sticky/position-sticky-left-003.html`
 -  `/css/css-position/sticky/position-sticky-top-003.html`

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-06-12 17:32:50 +00:00
batu_hoang
73c2864233
Handle Touch events in dispatch_pending_point_input_events (#37285)
Add a missing step in hit test retry
[(comment)](0d02b61f72 (r2131567216)).

cc: @xiaochengh , @kongbai1996

---------

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
2025-06-12 03:13:11 +00:00
Shubham Gupta
f1767e6c1e
Use own ViewportDescription to clamp() initial_scale (#37337)
Use own `ViewportDescription` to `clamp()` initial_scale.

If use `self` it will use current module `ViewportDescription`, which is
old one because new `ViewportDescription` is not set yet.

Testing: Tested Locally
Fixes: #37338

Signed-off-by: Shubham Gupta <shubham13297@gmail.com>
2025-06-11 05:31:05 +00:00
Shubham Gupta
aff2a85372
Add support for parsing and applying viewport <meta> (#35901)
This patch comprises following steps:
1. Parses the `viewport` Attribute from `<meta>`.
2. Creates a `ViewportDescription` struct.
3. Populate values into Viewport struct.
4. Pass & Stash Viewport Description to Webview.
5. Process parsed values of `viewport <meta>`

Testing: Tested locally.
Fixes: #36159

---------

Signed-off-by: Shubham Gupta <shubham13297@gmail.com>
Signed-off-by: Xiaocheng Hu <xiaochengh.work@gmail.com>
Co-authored-by: Xiaocheng Hu <xiaochengh.work@gmail.com>
2025-06-06 15:13:51 +00:00
batu_hoang
b422a65a00
Add retry for hit tests with expired epoch in result (#37085)
Follow up to [hit_test failed occasionally when the touch event is
sent](https://github.com/servo/servo/issues/35788#top) and
https://github.com/servo/servo/issues/36676#issuecomment-2882917136,
this PR adds a retry for hit tests with expired epoch in result.

Hit tests with outdated epoch mean it is too early to perform the hit
test.

Solution: retry hit test for the event on the next webrender frame.
The retry should guarantee that:

- Keep the correct order of events
- Retry time is not too long

Test cases: `./mach test-wpt --product servodriver -r
tests\wpt\tests\webdriver\tests\classic\element_click\events.py`

cc: @xiaochengh , @yezhizhen

---------

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
2025-06-04 05:56:20 +00:00
batu_hoang
f52fa9b672
Synchronize dispatch_actions in WebDriver (#36932)
Implement missing synchronization in `dispatch_actions` of `WebDriver`.
https://w3c.github.io/webdriver/#dispatching-actions

> The user agent event loop has spun enough times to process the DOM
events generated by the last invocation of the >[dispatch tick
actions](https://w3c.github.io/webdriver/#dfn-dispatch-tick-actions)
steps.

- Add a way for `ScriptThread` to notify `WebDriver` about the
completion of input commands.
- Add a `webdriver_id` field for `InputEvent`. `ScriptThread` uses it to
distinguish WebDriver events and sends notification.

Tests:
`./mach test-wpt --product servodriver -r
tests\wpt\tests\webdriver\tests\classic\element_click\events.py` pass if
`hit_testing` pass. Check
[issue](https://github.com/servo/servo/issues/36676#issuecomment-2882917136)

cc: @xiaochengh

---------

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
2025-05-21 11:03:04 +00:00
Martin Robinson
c1a70f4eb2
compositor: Batch all pending scroll event updates into a single transaction (#36974)
When multiple WebViews are updating scroll events, instead of taking the
list of `WebView`s to avoid a double-borrow, batch scroll events into a
single transaction. This should make processing slightly more efficient
and avoids having to take the vector of WebViews.

Testing: No behavior change here and this aspect of WebView interaction
is untestable currently.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-05-16 18:26:59 +00:00
Euclid Ye
e4f62d5c16
Remove duplicate click event in simulate_mouse_click (#36957)
After `InputEvent::Touch` processed by Script, it sends
`TouchEventProcessed` back to Constellation, which goes through hit-test
etc. and loops back to Script again. However,
`WebViewRenderer::simulate_mouse_click` should not send
`MouseButtonAction::Click` due to #36413

Testing: Manually tested by converting mouse to touch

cc @jdm @xiaochengh

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
2025-05-13 10:25:09 +00:00
Kenzie Raditya Tirtarahardja
eaf9224799
Implement wheel action in webdriver (#36744)
https://w3c.github.io/webdriver/#wheel-actions

Test:
`tests/wpt/tests/webdriver/tests/classic/perform_actions/wheel.py::{test_null_response_value,test_params_actions_origin_outside_viewport[element],test_params_actions_origin_outside_viewport[viewport]},
tests/wpt/tests/webdriver/tests/classic/perform_actions/perform.py`
Fixes: https://github.com/servo/servo/issues/36720

cc: @xiaochengh @longvatrong111 @yezhizhen

Signed-off-by: PotatoCP <kenzieradityatirtarahardja.18@gmail.com>
Co-authored-by: PotatoCP <kenzieradityatirtarahardja.18@gmail.com>
2025-05-07 08:41:34 +00:00
Martin Robinson
cbc363bedd
compositor: Tick animations for an entire WebView at once (#36662)
Previously, when processing animations, the compositor would sent a tick
message to each pipeline. This is an issue because now the
`ScriptThread` always processes rendering updates for all `Document`s in
order to ensure properly ordering. This change makes it so that tick
messages are sent for an entire WebView. This means that each
`ScriptThread` will always receive a single tick for every time that
animations are processed, no matter how many frames are animating. This
is the first step toward a refresh driver.

In addition, we discard the idea of ticking animation only for
animations and or only for request animation frame callbacks. The
`ScriptThread` can no longer make this distinction due to the
specification and the compositor shouldn't either.

This should not really change observable behavior, but should make Servo
more efficient when more than a single frame in a `ScriptThread` is
animting at once.

Testing: This is covered by existing WPT tests as it mainly just improve
animation efficiency in a particular case.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-04-24 19:03:14 +00:00
Martin Robinson
70f19c749f
compositing: Rename WebView to WebViewRenderer (#36574)
There is a `WebView` in libservo (new) and a `WebView` in compositing
(old). Nowadays, the "real" `WebView` is the one in the libservo. The
`WebView` in `compositing` is really about rendering the contents of a
`WebView` from libservo. In addition there is also a trait exposed by
the compositor called `RendererWebView` which is a way for the
compositor to talk to libservo without a circular dependency.

This changes does some renames to make things clearer and so that there
is One Less WebView™:

- `compositing::WebView` -> `compositing::WebViewRenderer` (this is the
  same kind of naming as `ServoRenderer`).
- `compositing::RendererWebView` -> `compositing::WebViewTrait`

Testing: This is just a couple renames so should be covered by existing
tests.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2025-04-21 08:47:39 +00:00
Renamed from components/compositing/webview.rs (Browse further)