script/compositor: Handle cursor updates from script (#38518)

Instead of using WebRender hit testing to update the cursor, base it on
layout hit tests. This allows removing the majority of WebRender hit
test items and finally opens up the possibility of adding support for
custom cursors. In addition, this change fixes an issue where cursors
were not set properly on areas of the viewport that extended past the
page content.

Testing: This is difficult to test as verifying that the cursor changed
properly is beyond the capabilities of Servo's test harnesses.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
Co-authored-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Martin Robinson 2025-08-07 20:49:38 +02:00 committed by GitHub
parent 87538282db
commit 6651f37c05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 279 additions and 259 deletions

View file

@ -34,6 +34,7 @@ serde = { workspace = true }
servo_url = { path = "../../url" }
strum = { workspace = true }
strum_macros = { workspace = true }
stylo_traits = { workspace = true }
uuid = { workspace = true }
webgpu_traits = { workspace = true }
webrender_api = { workspace = true }

View file

@ -19,10 +19,10 @@ use base::Epoch;
use base::cross_process_instant::CrossProcessInstant;
use base::id::{MessagePortId, PipelineId, WebViewId};
use embedder_traits::{
CompositorHitTestResult, Cursor, FocusId, InputEvent, JavaScriptEvaluationId,
MediaSessionActionType, Theme, TraversalId, ViewportDetails, WebDriverCommandMsg,
WebDriverCommandResponse,
CompositorHitTestResult, FocusId, InputEvent, JavaScriptEvaluationId, MediaSessionActionType,
Theme, TraversalId, ViewportDetails, WebDriverCommandMsg, WebDriverCommandResponse,
};
use euclid::Point2D;
pub use from_script_message::*;
use ipc_channel::ipc::IpcSender;
use malloc_size_of_derive::MallocSizeOf;
@ -31,6 +31,7 @@ use serde::{Deserialize, Serialize};
use servo_url::{ImmutableOrigin, ServoUrl};
pub use structured_data::*;
use strum_macros::IntoStaticStr;
use style_traits::CSSPixel;
use webrender_api::units::LayoutVector2D;
use webrender_api::{ExternalScrollId, ImageKey};
@ -76,8 +77,9 @@ pub enum EmbedderToConstellationMessage {
BlurWebView,
/// Forward an input event to an appropriate ScriptTask.
ForwardInputEvent(WebViewId, InputEvent, Option<CompositorHitTestResult>),
/// Requesting a change to the onscreen cursor.
SetCursor(WebViewId, Cursor),
/// Request that the given pipeline do a hit test at the location and reset the
/// cursor accordingly. This happens after a display list update is rendered.
RefreshCursor(PipelineId, Point2D<f32, CSSPixel>),
/// Enable the sampling profiler, with a given sampling rate and max total sampling duration.
ToggleProfiler(Duration, Duration),
/// Request to exit from fullscreen mode