mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
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>
This commit is contained in:
parent
b7b8619e87
commit
0908a47780
25 changed files with 921 additions and 1200 deletions
|
@ -8,16 +8,13 @@ use std::time::Duration;
|
|||
|
||||
use base::id::{BrowsingContextId, PipelineId, TopLevelBrowsingContextId, WebViewId};
|
||||
use base::Epoch;
|
||||
use embedder_traits::{
|
||||
ClipboardEventType, Cursor, GamepadEvent, MediaSessionActionType, Theme, TraversalDirection,
|
||||
};
|
||||
use embedder_traits::{Cursor, InputEvent, MediaSessionActionType, Theme, TraversalDirection};
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use keyboard_types::{CompositionEvent, KeyboardEvent};
|
||||
use script_traits::{
|
||||
AnimationTickType, CompositorEvent, LogEntry, WebDriverCommandMsg, WindowSizeData,
|
||||
WindowSizeType,
|
||||
AnimationTickType, LogEntry, WebDriverCommandMsg, WindowSizeData, WindowSizeType,
|
||||
};
|
||||
use servo_url::ServoUrl;
|
||||
use webrender_traits::CompositorHitTestResult;
|
||||
|
||||
/// Messages to the constellation.
|
||||
pub enum ConstellationMsg {
|
||||
|
@ -34,10 +31,6 @@ pub enum ConstellationMsg {
|
|||
GetFocusTopLevelBrowsingContext(IpcSender<Option<TopLevelBrowsingContextId>>),
|
||||
/// Query the constellation to see if the current compositor output is stable
|
||||
IsReadyToSaveImage(HashMap<PipelineId, Epoch>),
|
||||
/// Inform the constellation of a key event.
|
||||
Keyboard(WebViewId, KeyboardEvent),
|
||||
/// Inform the constellation of a composition event (IME).
|
||||
IMECompositionEvent(CompositionEvent),
|
||||
/// Whether to allow script to navigate.
|
||||
AllowNavigationResponse(PipelineId, bool),
|
||||
/// Request to load a page.
|
||||
|
@ -70,8 +63,8 @@ pub enum ConstellationMsg {
|
|||
FocusWebView(TopLevelBrowsingContextId),
|
||||
/// Make none of the webviews focused.
|
||||
BlurWebView,
|
||||
/// Forward an event to the script task of the given pipeline.
|
||||
ForwardEvent(PipelineId, CompositorEvent),
|
||||
/// Forward an input event to an appropriate ScriptTask.
|
||||
ForwardInputEvent(InputEvent, Option<CompositorHitTestResult>),
|
||||
/// Requesting a change to the onscreen cursor.
|
||||
SetCursor(WebViewId, Cursor),
|
||||
/// Enable the sampling profiler, with a given sampling rate and max total sampling duration.
|
||||
|
@ -82,12 +75,6 @@ pub enum ConstellationMsg {
|
|||
MediaSessionAction(MediaSessionActionType),
|
||||
/// Set whether to use less resources, by stopping animations and running timers at a heavily limited rate.
|
||||
SetWebViewThrottled(TopLevelBrowsingContextId, bool),
|
||||
/// Virtual keyboard was dismissed
|
||||
IMEDismissed,
|
||||
/// Gamepad state has changed
|
||||
Gamepad(GamepadEvent),
|
||||
/// Inform the constellation of a clipboard event.
|
||||
Clipboard(ClipboardEventType),
|
||||
}
|
||||
|
||||
impl fmt::Debug for ConstellationMsg {
|
||||
|
@ -106,8 +93,6 @@ impl ConstellationMsg {
|
|||
GetPipeline(..) => "GetPipeline",
|
||||
GetFocusTopLevelBrowsingContext(..) => "GetFocusTopLevelBrowsingContext",
|
||||
IsReadyToSaveImage(..) => "IsReadyToSaveImage",
|
||||
Keyboard(..) => "Keyboard",
|
||||
IMECompositionEvent(..) => "IMECompositionEvent",
|
||||
AllowNavigationResponse(..) => "AllowNavigationResponse",
|
||||
LoadUrl(..) => "LoadUrl",
|
||||
TraverseHistory(..) => "TraverseHistory",
|
||||
|
@ -123,16 +108,13 @@ impl ConstellationMsg {
|
|||
FocusWebView(..) => "FocusWebView",
|
||||
BlurWebView => "BlurWebView",
|
||||
SendError(..) => "SendError",
|
||||
ForwardEvent(..) => "ForwardEvent",
|
||||
ForwardInputEvent(..) => "ForwardEvent",
|
||||
SetCursor(..) => "SetCursor",
|
||||
ToggleProfiler(..) => "EnableProfiler",
|
||||
ExitFullScreen(..) => "ExitFullScreen",
|
||||
MediaSessionAction(..) => "MediaSessionAction",
|
||||
SetWebViewThrottled(..) => "SetWebViewThrottled",
|
||||
IMEDismissed => "IMEDismissed",
|
||||
ClearCache => "ClearCache",
|
||||
Gamepad(..) => "Gamepad",
|
||||
Clipboard(..) => "Clipboard",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ use base::id::{PipelineId, TopLevelBrowsingContextId};
|
|||
use base::Epoch;
|
||||
pub use constellation_msg::ConstellationMsg;
|
||||
use crossbeam_channel::{Receiver, Sender};
|
||||
use embedder_traits::{EventLoopWaker, MouseButton, MouseEventType};
|
||||
use embedder_traits::{EventLoopWaker, MouseButton, MouseButtonAction};
|
||||
use euclid::Rect;
|
||||
use ipc_channel::ipc::IpcSender;
|
||||
use log::warn;
|
||||
|
@ -93,7 +93,7 @@ pub enum CompositorMsg {
|
|||
/// The load of a page has completed
|
||||
LoadComplete(TopLevelBrowsingContextId),
|
||||
/// WebDriver mouse button event
|
||||
WebDriverMouseButtonEvent(MouseEventType, MouseButton, f32, f32),
|
||||
WebDriverMouseButtonEvent(MouseButtonAction, MouseButton, f32, f32),
|
||||
/// WebDriver mouse move event
|
||||
WebDriverMouseMoveEvent(f32, f32),
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue