diff options
author | Martin Robinson <mrobinson@igalia.com> | 2025-01-28 12:15:36 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-28 11:15:36 +0000 |
commit | a1cf0cbf86b93c863bc2b7693a382668d0f38e7c (patch) | |
tree | 2a3dd81905f68de153387cf4b298cabb034a5dfd | |
parent | 78b90030bdaf2af5deefdc065f3688bfa5c37fee (diff) | |
download | servo-a1cf0cbf86b93c863bc2b7693a382668d0f38e7c.tar.gz servo-a1cf0cbf86b93c863bc2b7693a382668d0f38e7c.zip |
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>
39 files changed, 330 insertions, 334 deletions
diff --git a/Cargo.lock b/Cargo.lock index 643aa09e5d0..b79d5ac8c77 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8344,6 +8344,7 @@ dependencies = [ "compositing_traits", "cookie 0.18.1", "crossbeam-channel", + "embedder_traits", "euclid", "http 0.2.12", "image", diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 6aef9294078..85c17ca96a1 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -19,7 +19,7 @@ use compositing_traits::{ CompositionPipeline, CompositorMsg, CompositorReceiver, ConstellationMsg, SendableFrameTree, }; use crossbeam_channel::Sender; -use embedder_traits::Cursor; +use embedder_traits::{Cursor, MouseButton, MouseEventType, TouchEventType, TouchId, WheelDelta}; use euclid::{Point2D, Rect, Scale, Transform3D, Vector2D}; use fnv::{FnvHashMap, FnvHashSet}; use image::{DynamicImage, ImageFormat}; @@ -31,8 +31,8 @@ use profile_traits::time::{self as profile_time, ProfilerCategory}; use profile_traits::time_profile; use script_traits::CompositorEvent::{MouseButtonEvent, MouseMoveEvent, TouchEvent, WheelEvent}; use script_traits::{ - AnimationState, AnimationTickType, ConstellationControlMsg, MouseButton, MouseEventType, - ScrollState, TouchEventType, TouchId, WheelDelta, WindowSizeData, WindowSizeType, + AnimationState, AnimationTickType, ConstellationControlMsg, ScrollState, WindowSizeData, + WindowSizeType, }; use servo_geometry::{DeviceIndependentPixel, FramebufferUintLength}; use style_traits::{CSSPixel, PinchZoomFactor}; diff --git a/components/compositing/touch.rs b/components/compositing/touch.rs index b3793ece116..b12384e1fd6 100644 --- a/components/compositing/touch.rs +++ b/components/compositing/touch.rs @@ -2,9 +2,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ +use embedder_traits::TouchId; use euclid::{Point2D, Scale, Vector2D}; use log::{debug, warn}; -use script_traits::{EventResult, TouchId}; +use script_traits::EventResult; use webrender_api::units::{DeviceIntPoint, DevicePixel, LayoutVector2D}; use self::TouchState::*; diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs index f2648246c2b..116dbe13b79 100644 --- a/components/compositing/windowing.rs +++ b/components/compositing/windowing.rs @@ -8,15 +8,14 @@ use std::fmt::{Debug, Error, Formatter}; use std::time::Duration; use base::id::{PipelineId, TopLevelBrowsingContextId}; -use embedder_traits::EventLoopWaker; +use embedder_traits::{ + ClipboardEventType, EventLoopWaker, GamepadEvent, MediaSessionActionType, MouseButton, Theme, + TouchEventType, TouchId, TraversalDirection, WheelDelta, +}; use euclid::Scale; use keyboard_types::{CompositionEvent, KeyboardEvent}; use libc::c_void; use net::protocols::ProtocolRegistry; -use script_traits::{ - ClipboardEventType, GamepadEvent, MediaSessionActionType, MouseButton, Theme, TouchEventType, - TouchId, TraversalDirection, WheelDelta, -}; use servo_geometry::{DeviceIndependentIntRect, DeviceIndependentIntSize, DeviceIndependentPixel}; use servo_url::ServoUrl; use webrender_api::units::{ diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index bf58ece059c..54360b8cd42 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -117,7 +117,8 @@ use devtools_traits::{ }; use embedder_traits::resources::{self, Resource}; use embedder_traits::{ - Cursor, EmbedderMsg, EmbedderProxy, MediaSessionEvent, MediaSessionPlaybackState, + ClipboardEventType, Cursor, EmbedderMsg, EmbedderProxy, GamepadEvent, MediaSessionActionType, + MediaSessionEvent, MediaSessionPlaybackState, MouseEventType, Theme, TraversalDirection, }; use euclid::default::Size2D as UntypedSize2D; use euclid::Size2D; @@ -138,14 +139,13 @@ use script_layout_interface::{LayoutFactory, ScriptThreadFactory}; use script_traits::CompositorEvent::{MouseButtonEvent, MouseMoveEvent}; use script_traits::{ webdriver_msg, AnimationState, AnimationTickType, AuxiliaryBrowsingContextLoadInfo, - BroadcastMsg, ClipboardEventType, CompositorEvent, ConstellationControlMsg, - DiscardBrowsingContext, DocumentActivity, DocumentState, GamepadEvent, IFrameLoadInfo, - IFrameLoadInfoWithData, IFrameSandboxState, IFrameSizeMsg, Job, LayoutMsg as FromLayoutMsg, - LoadData, LoadOrigin, LogEntry, MediaSessionActionType, MessagePortMsg, MouseEventType, + BroadcastMsg, CompositorEvent, ConstellationControlMsg, DiscardBrowsingContext, + DocumentActivity, DocumentState, IFrameLoadInfo, IFrameLoadInfoWithData, IFrameSandboxState, + IFrameSizeMsg, Job, LayoutMsg as FromLayoutMsg, LoadData, LoadOrigin, LogEntry, MessagePortMsg, NavigationHistoryBehavior, PortMessageTask, SWManagerMsg, SWManagerSenders, ScriptMsg as FromScriptMsg, ScriptToConstellationChan, ServiceWorkerManagerFactory, - ServiceWorkerMsg, StructuredSerializedData, Theme, TraversalDirection, UpdatePipelineIdReason, - WebDriverCommandMsg, WindowSizeData, WindowSizeType, + ServiceWorkerMsg, StructuredSerializedData, UpdatePipelineIdReason, WebDriverCommandMsg, + WindowSizeData, WindowSizeType, }; use serde::{Deserialize, Serialize}; use servo_config::{opts, pref}; diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index d019b498de5..689a848caed 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -22,7 +22,10 @@ use cookie::Cookie; use cssparser::match_ignore_ascii_case; use devtools_traits::ScriptToDevtoolsControlMsg; use dom_struct::dom_struct; -use embedder_traits::EmbedderMsg; +use embedder_traits::{ + ClipboardEventType, EmbedderMsg, MouseButton, MouseEventType, TouchEventType, TouchId, + WheelDelta, +}; use encoding_rs::{Encoding, UTF_8}; use euclid::default::{Point2D, Rect, Size2D}; use html5ever::{local_name, namespace_url, ns, LocalName, Namespace, QualName}; @@ -48,9 +51,8 @@ use profile_traits::ipc as profile_ipc; use profile_traits::time::{TimerMetadata, TimerMetadataFrameType, TimerMetadataReflowType}; use script_layout_interface::{PendingRestyle, TrustedNodeAddress}; use script_traits::{ - AnimationState, AnimationTickType, ClipboardEventType, CompositorEvent, DocumentActivity, - MouseButton, MouseEventType, ScriptMsg, TouchEventType, TouchId, UntrustedNodeAddress, - WheelDelta, + AnimationState, AnimationTickType, CompositorEvent, DocumentActivity, ScriptMsg, + UntrustedNodeAddress, }; use servo_arc::Arc; use servo_atoms::Atom; diff --git a/components/script/dom/gamepad.rs b/components/script/dom/gamepad.rs index 45328e61494..0e31d5a7549 100644 --- a/components/script/dom/gamepad.rs +++ b/components/script/dom/gamepad.rs @@ -5,8 +5,8 @@ use std::cell::Cell; use dom_struct::dom_struct; +use embedder_traits::{GamepadSupportedHapticEffects, GamepadUpdateType}; use js::typedarray::{Float64, Float64Array}; -use script_traits::{GamepadSupportedHapticEffects, GamepadUpdateType}; use super::bindings::buffer_source::HeapBufferSource; use crate::dom::bindings::codegen::Bindings::GamepadBinding::{GamepadHand, GamepadMethods}; diff --git a/components/script/dom/gamepadhapticactuator.rs b/components/script/dom/gamepadhapticactuator.rs index efd0c370176..d152f633c02 100644 --- a/components/script/dom/gamepadhapticactuator.rs +++ b/components/script/dom/gamepadhapticactuator.rs @@ -6,11 +6,10 @@ use std::cell::Cell; use std::rc::Rc; use dom_struct::dom_struct; -use embedder_traits::{DualRumbleEffectParams, EmbedderMsg}; +use embedder_traits::{DualRumbleEffectParams, EmbedderMsg, GamepadSupportedHapticEffects}; use ipc_channel::ipc; use ipc_channel::router::ROUTER; use js::rust::MutableHandleValue; -use script_traits::GamepadSupportedHapticEffects; use crate::dom::bindings::cell::DomRefCell; use crate::dom::bindings::codegen::Bindings::GamepadHapticActuatorBinding::{ diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index ba5cbc5b720..62d9fee32bd 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -22,7 +22,9 @@ use content_security_policy::{CheckResult, CspList, PolicyDisposition}; use crossbeam_channel::Sender; use devtools_traits::{PageError, ScriptToDevtoolsControlMsg}; use dom_struct::dom_struct; -use embedder_traits::EmbedderMsg; +use embedder_traits::{ + EmbedderMsg, GamepadEvent, GamepadSupportedHapticEffects, GamepadUpdateType, +}; use ipc_channel::ipc::{self, IpcSender}; use ipc_channel::router::ROUTER; use js::glue::{IsWrapper, UnwrapObjectDynamic}; @@ -56,8 +58,7 @@ use profile_traits::{ipc as profile_ipc, mem as profile_mem, time as profile_tim use script_traits::serializable::{BlobData, BlobImpl, FileBlob}; use script_traits::transferable::MessagePortImpl; use script_traits::{ - BroadcastMsg, GamepadEvent, GamepadSupportedHapticEffects, GamepadUpdateType, MessagePortMsg, - PortMessageTask, ScriptMsg, ScriptToConstellationChan, + BroadcastMsg, MessagePortMsg, PortMessageTask, ScriptMsg, ScriptToConstellationChan, }; use servo_url::{ImmutableOrigin, MutableOrigin, ServoUrl}; use timers::{TimerEventId, TimerEventRequest, TimerSource}; diff --git a/components/script/dom/history.rs b/components/script/dom/history.rs index ff56442af86..1806dc36553 100644 --- a/components/script/dom/history.rs +++ b/components/script/dom/history.rs @@ -7,13 +7,14 @@ use std::cmp::Ordering; use base::id::HistoryStateId; use dom_struct::dom_struct; +use embedder_traits::TraversalDirection; use js::jsapi::Heap; use js::jsval::{JSVal, NullValue, UndefinedValue}; use js::rust::{HandleValue, MutableHandleValue}; use net_traits::{CoreResourceMsg, IpcSend}; use profile_traits::ipc; use profile_traits::ipc::channel; -use script_traits::{ScriptMsg, StructuredSerializedData, TraversalDirection}; +use script_traits::{ScriptMsg, StructuredSerializedData}; use servo_url::ServoUrl; use crate::dom::bindings::codegen::Bindings::HistoryBinding::HistoryMethods; diff --git a/components/script/dom/mediasession.rs b/components/script/dom/mediasession.rs index d2049273c15..cdb2d2bd75f 100644 --- a/components/script/dom/mediasession.rs +++ b/components/script/dom/mediasession.rs @@ -5,8 +5,10 @@ use std::rc::Rc; use dom_struct::dom_struct; -use embedder_traits::{MediaMetadata as EmbedderMediaMetadata, MediaSessionEvent}; -use script_traits::{MediaSessionActionType, ScriptMsg}; +use embedder_traits::{ + MediaMetadata as EmbedderMediaMetadata, MediaSessionActionType, MediaSessionEvent, +}; +use script_traits::ScriptMsg; use super::bindings::trace::HashMapTracedValues; use crate::conversions::Convert; diff --git a/components/script/dom/webxr/xrinputsource.rs b/components/script/dom/webxr/xrinputsource.rs index f3486a83758..b6fbba4cef1 100644 --- a/components/script/dom/webxr/xrinputsource.rs +++ b/components/script/dom/webxr/xrinputsource.rs @@ -3,11 +3,11 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use dom_struct::dom_struct; +use embedder_traits::GamepadSupportedHapticEffects; use js::conversions::ToJSValConvertible; use js::jsapi::Heap; use js::jsval::{JSVal, UndefinedValue}; use js::rust::MutableHandleValue; -use script_traits::GamepadSupportedHapticEffects; use webxr_api::{Handedness, InputFrame, InputId, InputSource, TargetRayMode}; use crate::dom::bindings::codegen::Bindings::XRInputSourceBinding::{ diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index f8725e3fb4a..e8487f24b95 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -25,7 +25,7 @@ use crossbeam_channel::{unbounded, Sender}; use cssparser::{Parser, ParserInput, SourceLocation}; use devtools_traits::{ScriptToDevtoolsControlMsg, TimelineMarker, TimelineMarkerType}; use dom_struct::dom_struct; -use embedder_traits::{EmbedderMsg, PromptDefinition, PromptOrigin, PromptResult}; +use embedder_traits::{EmbedderMsg, PromptDefinition, PromptOrigin, PromptResult, Theme}; use euclid::default::{Point2D as UntypedPoint2D, Rect as UntypedRect}; use euclid::{Point2D, Rect, Scale, Size2D, Vector2D}; use fonts::FontContext; @@ -59,8 +59,8 @@ use script_layout_interface::{ use script_traits::webdriver_msg::{WebDriverJSError, WebDriverJSResult}; use script_traits::{ ConstellationControlMsg, DocumentState, LoadData, LoadOrigin, NavigationHistoryBehavior, - ScriptMsg, ScriptToConstellationChan, ScrollState, StructuredSerializedData, Theme, - WindowSizeData, WindowSizeType, + ScriptMsg, ScriptToConstellationChan, ScrollState, StructuredSerializedData, WindowSizeData, + WindowSizeType, }; use selectors::attr::CaseSensitivity; use servo_arc::Arc as ServoArc; diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index c232fb9fe51..9e3b94e91af 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -45,7 +45,10 @@ use devtools_traits::{ CSSError, DevtoolScriptControlMsg, DevtoolsPageInfo, NavigationState, ScriptToDevtoolsControlMsg, WorkerId, }; -use embedder_traits::EmbedderMsg; +use embedder_traits::{ + EmbedderMsg, MediaSessionActionType, MouseButton, MouseEventType, Theme, TouchEventType, + TouchId, WheelDelta, +}; use euclid::default::{Point2D, Rect}; use fonts::{FontContext, SystemFontServiceProxy}; use headers::{HeaderMapExt, LastModified, ReferrerPolicy as ReferrerPolicyHeader}; @@ -80,11 +83,10 @@ use script_layout_interface::{ use script_traits::webdriver_msg::WebDriverScriptCommand; use script_traits::{ CompositorEvent, ConstellationControlMsg, DiscardBrowsingContext, DocumentActivity, - EventResult, InitialScriptState, JsEvalResult, LoadData, LoadOrigin, MediaSessionActionType, - MouseButton, MouseEventType, NavigationHistoryBehavior, NewLayoutInfo, Painter, - ProgressiveWebMetricType, ScriptMsg, ScriptToConstellationChan, ScrollState, - StructuredSerializedData, Theme, TouchEventType, TouchId, UntrustedNodeAddress, - UpdatePipelineIdReason, WheelDelta, WindowSizeData, WindowSizeType, + EventResult, InitialScriptState, JsEvalResult, LoadData, LoadOrigin, NavigationHistoryBehavior, + NewLayoutInfo, Painter, ProgressiveWebMetricType, ScriptMsg, ScriptToConstellationChan, + ScrollState, StructuredSerializedData, UntrustedNodeAddress, UpdatePipelineIdReason, + WindowSizeData, WindowSizeType, }; use servo_atoms::Atom; use servo_config::opts; diff --git a/components/servo/lib.rs b/components/servo/lib.rs index c96926d9af0..5f3d45076be 100644 --- a/components/servo/lib.rs +++ b/components/servo/lib.rs @@ -54,7 +54,7 @@ use constellation::{ UnprivilegedContent, }; use crossbeam_channel::{unbounded, Sender}; -use embedder_traits::{EmbedderMsg, EmbedderProxy, EmbedderReceiver, EventLoopWaker}; +pub use embedder_traits::*; use env_logger::Builder as EnvLoggerBuilder; use euclid::Scale; use fonts::SystemFontService; @@ -71,6 +71,7 @@ pub use gleam::gl; use gleam::gl::RENDERER; use ipc_channel::ipc::{self, IpcSender}; use ipc_channel::router::ROUTER; +pub use keyboard_types::*; #[cfg(feature = "layout_2013")] pub use layout_thread_2013; use log::{error, trace, warn, Log, Metadata, Record}; @@ -107,10 +108,10 @@ use webrender_traits::{ }; pub use { background_hang_monitor, base, bluetooth, bluetooth_traits, canvas, canvas_traits, compositing, - devtools, devtools_traits, embedder_traits, euclid, fonts, ipc_channel, keyboard_types, - layout_thread_2020, media, net, net_traits, profile, profile_traits, script, - script_layout_interface, script_traits, servo_config as config, servo_config, servo_geometry, - servo_url, style, style_traits, webrender_api, webrender_traits, + devtools, devtools_traits, euclid, fonts, ipc_channel, layout_thread_2020, media, net, + net_traits, profile, profile_traits, script, script_layout_interface, script_traits, + servo_config as config, servo_config, servo_geometry, servo_url, style, style_traits, + webrender_api, webrender_traits, }; use crate::proxies::ConstellationProxy; diff --git a/components/shared/compositing/constellation_msg.rs b/components/shared/compositing/constellation_msg.rs index 8b641ecf46e..cf251e3d977 100644 --- a/components/shared/compositing/constellation_msg.rs +++ b/components/shared/compositing/constellation_msg.rs @@ -8,12 +8,13 @@ use std::time::Duration; use base::id::{BrowsingContextId, PipelineId, TopLevelBrowsingContextId, WebViewId}; use base::Epoch; -use embedder_traits::Cursor; +use embedder_traits::{ + ClipboardEventType, Cursor, GamepadEvent, MediaSessionActionType, Theme, TraversalDirection, +}; use ipc_channel::ipc::IpcSender; use keyboard_types::{CompositionEvent, KeyboardEvent}; use script_traits::{ - AnimationTickType, ClipboardEventType, CompositorEvent, GamepadEvent, LogEntry, - MediaSessionActionType, Theme, TraversalDirection, WebDriverCommandMsg, WindowSizeData, + AnimationTickType, CompositorEvent, LogEntry, WebDriverCommandMsg, WindowSizeData, WindowSizeType, }; use servo_url::ServoUrl; diff --git a/components/shared/compositing/lib.rs b/components/shared/compositing/lib.rs index f4afdc211b2..bf8a3cf02a9 100644 --- a/components/shared/compositing/lib.rs +++ b/components/shared/compositing/lib.rs @@ -12,14 +12,12 @@ use base::id::{PipelineId, TopLevelBrowsingContextId}; use base::Epoch; pub use constellation_msg::ConstellationMsg; use crossbeam_channel::{Receiver, Sender}; -use embedder_traits::EventLoopWaker; +use embedder_traits::{EventLoopWaker, MouseButton, MouseEventType}; use euclid::Rect; use ipc_channel::ipc::IpcSender; use log::warn; use pixels::Image; -use script_traits::{ - AnimationState, ConstellationControlMsg, EventResult, MouseButton, MouseEventType, -}; +use script_traits::{AnimationState, ConstellationControlMsg, EventResult}; use style_traits::CSSPixel; use webrender_api::units::DeviceRect; use webrender_api::DocumentId; diff --git a/components/shared/embedder/lib.rs b/components/shared/embedder/lib.rs index 1a3632713ab..b89a0516bc4 100644 --- a/components/shared/embedder/lib.rs +++ b/components/shared/embedder/lib.rs @@ -539,3 +539,210 @@ impl WebResourceResponse { self } } + +/// The type of input represented by a multi-touch event. +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +pub enum TouchEventType { + /// A new touch point came in contact with the screen. + Down, + /// An existing touch point changed location. + Move, + /// A touch point was removed from the screen. + Up, + /// The system stopped tracking a touch point. + Cancel, +} + +/// An opaque identifier for a touch point. +/// +/// <http://w3c.github.io/touch-events/#widl-Touch-identifier> +#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)] +pub struct TouchId(pub i32); + +#[derive( + Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize, +)] +/// Index of gamepad in list of system's connected gamepads +pub struct GamepadIndex(pub usize); + +#[derive(Clone, Debug, Deserialize, Serialize)] +/// The minimum and maximum values that can be reported for axis or button input from this gamepad +pub struct GamepadInputBounds { + /// Minimum and maximum axis values + pub axis_bounds: (f64, f64), + /// Minimum and maximum button values + pub button_bounds: (f64, f64), +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +/// The haptic effects supported by this gamepad +pub struct GamepadSupportedHapticEffects { + /// Gamepad support for dual rumble effects + pub supports_dual_rumble: bool, + /// Gamepad support for trigger rumble effects + pub supports_trigger_rumble: bool, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +/// The type of Gamepad event +pub enum GamepadEvent { + /// A new gamepad has been connected + /// <https://www.w3.org/TR/gamepad/#event-gamepadconnected> + Connected( + GamepadIndex, + String, + GamepadInputBounds, + GamepadSupportedHapticEffects, + ), + /// An existing gamepad has been disconnected + /// <https://www.w3.org/TR/gamepad/#event-gamepaddisconnected> + Disconnected(GamepadIndex), + /// An existing gamepad has been updated + /// <https://www.w3.org/TR/gamepad/#receiving-inputs> + Updated(GamepadIndex, GamepadUpdateType), +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +/// The type of Gamepad input being updated +pub enum GamepadUpdateType { + /// Axis index and input value + /// <https://www.w3.org/TR/gamepad/#dfn-represents-a-standard-gamepad-axis> + Axis(usize, f64), + /// Button index and input value + /// <https://www.w3.org/TR/gamepad/#dfn-represents-a-standard-gamepad-button> + Button(usize, f64), +} + +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +pub enum MouseButton { + /// The left mouse button. + Left = 1, + /// The right mouse button. + Right = 2, + /// The middle mouse button. + Middle = 4, +} + +/// The types of mouse events +#[derive(Debug, Deserialize, MallocSizeOf, Serialize)] +pub enum MouseEventType { + /// Mouse button clicked + Click, + /// Mouse button down + MouseDown, + /// Mouse button up + MouseUp, +} + +/// Mode to measure WheelDelta floats in +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] +pub enum WheelMode { + /// Delta values are specified in pixels + DeltaPixel = 0x00, + /// Delta values are specified in lines + DeltaLine = 0x01, + /// Delta values are specified in pages + DeltaPage = 0x02, +} + +/// The Wheel event deltas in every direction +#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] +pub struct WheelDelta { + /// Delta in the left/right direction + pub x: f64, + /// Delta in the up/down direction + pub y: f64, + /// Delta in the direction going into/out of the screen + pub z: f64, + /// Mode to measure the floats in + pub mode: WheelMode, +} + +/// The mouse button involved in the event. +/// The types of clipboard events +#[derive(Clone, Debug, Deserialize, Serialize)] +pub enum ClipboardEventType { + /// Contents of the system clipboard are changed + Change, + /// Copy + Copy, + /// Cut + Cut, + /// Paste + Paste(String), +} + +impl ClipboardEventType { + /// Convert to event name + pub fn as_str(&self) -> &str { + match *self { + ClipboardEventType::Change => "clipboardchange", + ClipboardEventType::Copy => "copy", + ClipboardEventType::Cut => "cut", + ClipboardEventType::Paste(..) => "paste", + } + } +} + +/// The direction of a history traversal +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] +pub enum TraversalDirection { + /// Travel forward the given number of documents. + Forward(usize), + /// Travel backward the given number of documents. + Back(usize), +} + +/// The type of platform theme. +#[derive(Clone, Copy, Debug, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)] +pub enum Theme { + /// Light theme. + Light, + /// Dark theme. + Dark, +} +// The type of MediaSession action. +/// <https://w3c.github.io/mediasession/#enumdef-mediasessionaction> +#[derive(Clone, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)] +pub enum MediaSessionActionType { + /// The action intent is to resume playback. + Play, + /// The action intent is to pause the currently active playback. + Pause, + /// The action intent is to move the playback time backward by a short period (i.e. a few + /// seconds). + SeekBackward, + /// The action intent is to move the playback time forward by a short period (i.e. a few + /// seconds). + SeekForward, + /// The action intent is to either start the current playback from the beginning if the + /// playback has a notion, of beginning, or move to the previous item in the playlist if the + /// playback has a notion of playlist. + PreviousTrack, + /// The action is to move to the playback to the next item in the playlist if the playback has + /// a notion of playlist. + NextTrack, + /// The action intent is to skip the advertisement that is currently playing. + SkipAd, + /// The action intent is to stop the playback and clear the state if appropriate. + Stop, + /// The action intent is to move the playback time to a specific time. + SeekTo, +} + +impl From<i32> for MediaSessionActionType { + fn from(value: i32) -> MediaSessionActionType { + match value { + 1 => MediaSessionActionType::Play, + 2 => MediaSessionActionType::Pause, + 3 => MediaSessionActionType::SeekBackward, + 4 => MediaSessionActionType::SeekForward, + 5 => MediaSessionActionType::PreviousTrack, + 6 => MediaSessionActionType::NextTrack, + 7 => MediaSessionActionType::SkipAd, + 8 => MediaSessionActionType::Stop, + 9 => MediaSessionActionType::SeekTo, + _ => panic!("Unknown MediaSessionActionType"), + } + } +} diff --git a/components/shared/script/lib.rs b/components/shared/script/lib.rs index 60f7abba6d6..622b7b8cade 100644 --- a/components/shared/script/lib.rs +++ b/components/shared/script/lib.rs @@ -31,7 +31,10 @@ use bluetooth_traits::BluetoothRequest; use canvas_traits::webgl::WebGLPipeline; use crossbeam_channel::{RecvTimeoutError, Sender}; use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId}; -use embedder_traits::CompositorEventVariant; +use embedder_traits::{ + ClipboardEventType, CompositorEventVariant, GamepadEvent, MediaSessionActionType, MouseButton, + MouseEventType, Theme, TouchEventType, TouchId, WheelDelta, +}; use euclid::default::Point2D; use euclid::{Rect, Scale, Size2D, UnknownUnit, Vector2D}; use http::{HeaderMap, Method}; @@ -65,7 +68,6 @@ use webrender_traits::{ pub use crate::script_msg::{ DOMMessage, EventResult, IFrameSizeMsg, Job, JobError, JobResult, JobResultValue, JobType, LayoutMsg, LogEntry, SWManagerMsg, SWManagerSenders, ScopeThings, ScriptMsg, ServiceWorkerMsg, - TraversalDirection, }; use crate::serializable::{BlobData, BlobImpl}; use crate::transferable::MessagePortImpl; @@ -470,96 +472,6 @@ pub enum AnimationState { NoAnimationCallbacksPresent, } -/// The type of input represented by a multi-touch event. -#[derive(Clone, Copy, Debug, Deserialize, Serialize)] -pub enum TouchEventType { - /// A new touch point came in contact with the screen. - Down, - /// An existing touch point changed location. - Move, - /// A touch point was removed from the screen. - Up, - /// The system stopped tracking a touch point. - Cancel, -} - -/// An opaque identifier for a touch point. -/// -/// <http://w3c.github.io/touch-events/#widl-Touch-identifier> -#[derive(Clone, Copy, Debug, Deserialize, Eq, PartialEq, Serialize)] -pub struct TouchId(pub i32); - -/// The mouse button involved in the event. -#[derive(Clone, Copy, Debug, Deserialize, Serialize)] -pub enum MouseButton { - /// The left mouse button. - Left = 1, - /// The right mouse button. - Right = 2, - /// The middle mouse button. - Middle = 4, -} - -/// The types of mouse events -#[derive(Debug, Deserialize, MallocSizeOf, Serialize)] -pub enum MouseEventType { - /// Mouse button clicked - Click, - /// Mouse button down - MouseDown, - /// Mouse button up - MouseUp, -} - -/// Mode to measure WheelDelta floats in -#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] -pub enum WheelMode { - /// Delta values are specified in pixels - DeltaPixel = 0x00, - /// Delta values are specified in lines - DeltaLine = 0x01, - /// Delta values are specified in pages - DeltaPage = 0x02, -} - -/// The Wheel event deltas in every direction -#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Serialize)] -pub struct WheelDelta { - /// Delta in the left/right direction - pub x: f64, - /// Delta in the up/down direction - pub y: f64, - /// Delta in the direction going into/out of the screen - pub z: f64, - /// Mode to measure the floats in - pub mode: WheelMode, -} - -/// The types of clipboard events -#[derive(Clone, Debug, Deserialize, Serialize)] -pub enum ClipboardEventType { - /// Contents of the system clipboard are changed - Change, - /// Copy - Copy, - /// Cut - Cut, - /// Paste - Paste(String), -} - -impl ClipboardEventType { - /// Convert to event name - pub fn as_str(&self) -> &str { - match *self { - ClipboardEventType::Change => "clipboardchange", - ClipboardEventType::Copy => "copy", - ClipboardEventType::Cut => "cut", - ClipboardEventType::Paste(..) => "paste", - } - } -} - /// Events from the compositor that the script thread needs to know about #[derive(Debug, Deserialize, Serialize)] pub enum CompositorEvent { @@ -784,15 +696,6 @@ pub enum WindowSizeType { Resize, } -/// The type of platform theme. -#[derive(Clone, Copy, Debug, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)] -pub enum Theme { - /// Light theme. - Light, - /// Dark theme. - Dark, -} - /// Messages to the constellation originating from the WebDriver server. #[derive(Debug, Deserialize, Serialize)] pub enum WebDriverCommandMsg { @@ -1044,103 +947,3 @@ impl Clone for BroadcastMsg { } } } - -/// The type of MediaSession action. -/// <https://w3c.github.io/mediasession/#enumdef-mediasessionaction> -#[derive(Clone, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize)] -pub enum MediaSessionActionType { - /// The action intent is to resume playback. - Play, - /// The action intent is to pause the currently active playback. - Pause, - /// The action intent is to move the playback time backward by a short period (i.e. a few - /// seconds). - SeekBackward, - /// The action intent is to move the playback time forward by a short period (i.e. a few - /// seconds). - SeekForward, - /// The action intent is to either start the current playback from the beginning if the - /// playback has a notion, of beginning, or move to the previous item in the playlist if the - /// playback has a notion of playlist. - PreviousTrack, - /// The action is to move to the playback to the next item in the playlist if the playback has - /// a notion of playlist. - NextTrack, - /// The action intent is to skip the advertisement that is currently playing. - SkipAd, - /// The action intent is to stop the playback and clear the state if appropriate. - Stop, - /// The action intent is to move the playback time to a specific time. - SeekTo, -} - -impl From<i32> for MediaSessionActionType { - fn from(value: i32) -> MediaSessionActionType { - match value { - 1 => MediaSessionActionType::Play, - 2 => MediaSessionActionType::Pause, - 3 => MediaSessionActionType::SeekBackward, - 4 => MediaSessionActionType::SeekForward, - 5 => MediaSessionActionType::PreviousTrack, - 6 => MediaSessionActionType::NextTrack, - 7 => MediaSessionActionType::SkipAd, - 8 => MediaSessionActionType::Stop, - 9 => MediaSessionActionType::SeekTo, - _ => panic!("Unknown MediaSessionActionType"), - } - } -} - -#[derive( - Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, Ord, PartialEq, PartialOrd, Serialize, -)] -/// Index of gamepad in list of system's connected gamepads -pub struct GamepadIndex(pub usize); - -#[derive(Clone, Debug, Deserialize, Serialize)] -/// The minimum and maximum values that can be reported for axis or button input from this gamepad -pub struct GamepadInputBounds { - /// Minimum and maximum axis values - pub axis_bounds: (f64, f64), - /// Minimum and maximum button values - pub button_bounds: (f64, f64), -} - -#[derive(Clone, Debug, Deserialize, Serialize)] -/// The haptic effects supported by this gamepad -pub struct GamepadSupportedHapticEffects { - /// Gamepad support for dual rumble effects - pub supports_dual_rumble: bool, - /// Gamepad support for trigger rumble effects - pub supports_trigger_rumble: bool, -} - -#[derive(Clone, Debug, Deserialize, Serialize)] -/// The type of Gamepad event -pub enum GamepadEvent { - /// A new gamepad has been connected - /// <https://www.w3.org/TR/gamepad/#event-gamepadconnected> - Connected( - GamepadIndex, - String, - GamepadInputBounds, - GamepadSupportedHapticEffects, - ), - /// An existing gamepad has been disconnected - /// <https://www.w3.org/TR/gamepad/#event-gamepaddisconnected> - Disconnected(GamepadIndex), - /// An existing gamepad has been updated - /// <https://www.w3.org/TR/gamepad/#receiving-inputs> - Updated(GamepadIndex, GamepadUpdateType), -} - -#[derive(Clone, Debug, Deserialize, Serialize)] -/// The type of Gamepad input being updated -pub enum GamepadUpdateType { - /// Axis index and input value - /// <https://www.w3.org/TR/gamepad/#dfn-represents-a-standard-gamepad-axis> - Axis(usize, f64), - /// Button index and input value - /// <https://www.w3.org/TR/gamepad/#dfn-represents-a-standard-gamepad-button> - Button(usize, f64), -} diff --git a/components/shared/script/script_msg.rs b/components/shared/script/script_msg.rs index e5d3c60b4b5..3a503414d27 100644 --- a/components/shared/script/script_msg.rs +++ b/components/shared/script/script_msg.rs @@ -13,7 +13,7 @@ use base::id::{ use base::Epoch; use canvas_traits::canvas::{CanvasId, CanvasMsg}; use devtools_traits::{ScriptToDevtoolsControlMsg, WorkerId}; -use embedder_traits::{EmbedderMsg, MediaSessionEvent}; +use embedder_traits::{EmbedderMsg, MediaSessionEvent, TraversalDirection}; use euclid::default::Size2D as UntypedSize2D; use euclid::Size2D; use ipc_channel::ipc::{IpcReceiver, IpcSender}; @@ -472,12 +472,3 @@ pub enum SWManagerMsg { /// <https://github.com/servo/servo/issues/24660> PostMessageToClient, } - -/// The direction of a history traversal -#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)] -pub enum TraversalDirection { - /// Travel forward the given number of documents. - Forward(usize), - /// Travel backward the given number of documents. - Back(usize), -} diff --git a/components/webdriver_server/Cargo.toml b/components/webdriver_server/Cargo.toml index 7a1416e89f7..554b411cd53 100644 --- a/components/webdriver_server/Cargo.toml +++ b/components/webdriver_server/Cargo.toml @@ -17,6 +17,7 @@ base64 = { workspace = true } compositing_traits = { workspace = true } cookie = { workspace = true } crossbeam-channel = { workspace = true } +embedder_traits = { workspace = true } euclid = { workspace = true } http = { version = "0.2" } image = { workspace = true } diff --git a/components/webdriver_server/actions.rs b/components/webdriver_server/actions.rs index 9bb644ad374..e2ba7e0bc9b 100644 --- a/components/webdriver_server/actions.rs +++ b/components/webdriver_server/actions.rs @@ -7,10 +7,11 @@ use std::time::{Duration, Instant}; use std::{cmp, thread}; use compositing_traits::ConstellationMsg; +use embedder_traits::{MouseButton, MouseEventType}; use ipc_channel::ipc; use keyboard_types::webdriver::KeyInputState; use script_traits::webdriver_msg::WebDriverScriptCommand; -use script_traits::{MouseButton, MouseEventType, WebDriverCommandMsg}; +use script_traits::WebDriverCommandMsg; use webdriver::actions::{ ActionSequence, ActionsType, GeneralAction, KeyAction, KeyActionItem, KeyDownAction, KeyUpAction, NullActionItem, PointerAction, PointerActionItem, PointerActionParameters, @@ -83,7 +84,7 @@ fn compute_tick_duration(tick_actions: &ActionSequence) -> u64 { } fn u64_to_mouse_button(button: u64) -> Option<MouseButton> { - if MouseButton::Left as u64 == button { + if embedder_traits::MouseButton::Left as u64 == button { Some(MouseButton::Left) } else if MouseButton::Middle as u64 == button { Some(MouseButton::Middle) diff --git a/components/webdriver_server/lib.rs b/components/webdriver_server/lib.rs index 46914c2c11e..a3eb7e48ce1 100644 --- a/components/webdriver_server/lib.rs +++ b/components/webdriver_server/lib.rs @@ -22,6 +22,7 @@ use capabilities::ServoCapabilities; use compositing_traits::ConstellationMsg; use cookie::{CookieBuilder, Expiration}; use crossbeam_channel::{after, select, unbounded, Receiver, Sender}; +use embedder_traits::TraversalDirection; use euclid::{Rect, Size2D}; use http::method::Method; use image::{DynamicImage, ImageFormat, RgbaImage}; @@ -36,7 +37,7 @@ use script_traits::webdriver_msg::{ LoadStatus, WebDriverCookieError, WebDriverFrameId, WebDriverJSError, WebDriverJSResult, WebDriverJSValue, WebDriverScriptCommand, }; -use script_traits::{LoadData, LoadOrigin, TraversalDirection, WebDriverCommandMsg}; +use script_traits::{LoadData, LoadOrigin, WebDriverCommandMsg}; use serde::de::{Deserializer, MapAccess, Visitor}; use serde::ser::Serializer; use serde::{Deserialize, Serialize}; diff --git a/ports/servoshell/desktop/app.rs b/ports/servoshell/desktop/app.rs index 93d2d22cc5d..73b0b00acdb 100644 --- a/ports/servoshell/desktop/app.rs +++ b/ports/servoshell/desktop/app.rs @@ -13,15 +13,14 @@ use std::{env, fs}; use log::{info, trace}; use raw_window_handle::HasDisplayHandle; use servo::base::id::WebViewId; -use servo::compositing::windowing::{EmbedderEvent, WindowMethods}; +use servo::compositing::windowing::{AnimationState, EmbedderEvent, WindowMethods}; use servo::compositing::CompositeTarget; use servo::config::opts::Opts; use servo::config::prefs::Preferences; -use servo::embedder_traits::EventLoopWaker; use servo::servo_config::pref; use servo::servo_url::ServoUrl; use servo::webrender_traits::SurfmanRenderingContext; -use servo::Servo; +use servo::{EventLoopWaker, Servo}; use surfman::Connection; use webxr::glwindow::GlWindowDiscovery; #[cfg(target_os = "windows")] @@ -201,7 +200,7 @@ impl App { fn get_coordinates(&self) -> servo::compositing::windowing::EmbedderCoordinates { self.0.get_coordinates() } - fn set_animation_state(&self, state: servo::compositing::windowing::AnimationState) { + fn set_animation_state(&self, state: AnimationState) { self.0.set_animation_state(state); } } diff --git a/ports/servoshell/desktop/embedder.rs b/ports/servoshell/desktop/embedder.rs index 7d4d7d4a47d..d4c20573ac7 100644 --- a/ports/servoshell/desktop/embedder.rs +++ b/ports/servoshell/desktop/embedder.rs @@ -6,8 +6,8 @@ use net::protocols::ProtocolRegistry; use servo::compositing::windowing::EmbedderMethods; -use servo::embedder_traits::{EmbedderProxy, EventLoopWaker}; use servo::servo_config::pref; +use servo::{EmbedderProxy, EventLoopWaker}; use webxr::glwindow::GlWindowDiscovery; #[cfg(target_os = "windows")] use webxr::openxr::OpenXrDiscovery; diff --git a/ports/servoshell/desktop/events_loop.rs b/ports/servoshell/desktop/events_loop.rs index 1ebaf42dc67..697594d1a0b 100644 --- a/ports/servoshell/desktop/events_loop.rs +++ b/ports/servoshell/desktop/events_loop.rs @@ -8,7 +8,7 @@ use std::sync::{Arc, Condvar, Mutex}; use std::time; use log::warn; -use servo::embedder_traits::EventLoopWaker; +use servo::EventLoopWaker; use winit::error::EventLoopError; use winit::event_loop::EventLoop as WinitEventLoop; #[cfg(target_os = "macos")] diff --git a/ports/servoshell/desktop/headed_window.rs b/ports/servoshell/desktop/headed_window.rs index 3ba227880fb..ec3c9180b0f 100644 --- a/ports/servoshell/desktop/headed_window.rs +++ b/ports/servoshell/desktop/headed_window.rs @@ -15,14 +15,15 @@ use servo::compositing::windowing::{ AnimationState, EmbedderCoordinates, EmbedderEvent, MouseWindowEvent, WindowMethods, }; use servo::config::opts::Opts; -use servo::embedder_traits::Cursor; -use servo::keyboard_types::{Key, KeyState, KeyboardEvent}; -use servo::script_traits::{TouchEventType, WheelDelta, WheelMode}; use servo::servo_config::pref; use servo::servo_geometry::DeviceIndependentPixel; use servo::webrender_api::units::{DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePixel}; use servo::webrender_api::ScrollLocation; use servo::webrender_traits::SurfmanRenderingContext; +use servo::{ + Cursor, Key, KeyState, KeyboardEvent, MouseButton as ServoMouseButton, Theme, TouchEventType, + TouchId, WheelDelta, WheelMode, +}; use surfman::{Context, Device, SurfaceType}; use winit::dpi::{LogicalSize, PhysicalPosition, PhysicalSize}; use winit::event::{ElementState, KeyEvent, MouseButton, MouseScrollDelta, TouchPhase}; @@ -40,7 +41,7 @@ pub struct Window { screen_size: Size2D<u32, DeviceIndependentPixel>, inner_size: Cell<PhysicalSize<u32>>, toolbar_height: Cell<Length<f32, DeviceIndependentPixel>>, - mouse_down_button: Cell<Option<winit::event::MouseButton>>, + mouse_down_button: Cell<Option<MouseButton>>, mouse_down_point: Cell<Point2D<i32, DevicePixel>>, monitor: winit::monitor::MonitorHandle, event_queue: RefCell<Vec<EmbedderEvent>>, @@ -228,18 +229,16 @@ impl Window { /// Helper function to handle a click fn handle_mouse( &self, - button: winit::event::MouseButton, - action: winit::event::ElementState, + button: MouseButton, + action: ElementState, coords: Point2D<i32, DevicePixel>, ) { - use servo::script_traits::MouseButton; - let max_pixel_dist = 10.0 * self.hidpi_factor().get(); let mouse_button = match &button { - winit::event::MouseButton::Left => MouseButton::Left, - winit::event::MouseButton::Right => MouseButton::Right, - winit::event::MouseButton::Middle => MouseButton::Middle, - _ => MouseButton::Left, + MouseButton::Left => ServoMouseButton::Left, + MouseButton::Right => ServoMouseButton::Right, + MouseButton::Middle => ServoMouseButton::Middle, + _ => ServoMouseButton::Left, }; let event = match action { ElementState::Pressed => { @@ -455,8 +454,6 @@ impl WindowPortsMethods for Window { self.event_queue.borrow_mut().push(scroll_event); }, winit::event::WindowEvent::Touch(touch) => { - use servo::script_traits::TouchId; - let phase = winit_phase_to_touch_event_type(touch.phase); let id = TouchId(touch.id as i32); let position = touch.location; @@ -484,8 +481,8 @@ impl WindowPortsMethods for Window { }, winit::event::WindowEvent::ThemeChanged(theme) => { let theme = match theme { - winit::window::Theme::Light => servo::script_traits::Theme::Light, - winit::window::Theme::Dark => servo::script_traits::Theme::Dark, + winit::window::Theme::Light => Theme::Light, + winit::window::Theme::Dark => Theme::Dark, }; self.event_queue .borrow_mut() diff --git a/ports/servoshell/desktop/minibrowser.rs b/ports/servoshell/desktop/minibrowser.rs index 1b03466d2ed..0dda5b2fa3e 100644 --- a/ports/servoshell/desktop/minibrowser.rs +++ b/ports/servoshell/desktop/minibrowser.rs @@ -21,12 +21,11 @@ use glow::NativeFramebuffer; use log::{trace, warn}; use servo::base::id::WebViewId; use servo::compositing::windowing::EmbedderEvent; -use servo::script_traits::TraversalDirection; use servo::servo_geometry::DeviceIndependentPixel; use servo::servo_url::ServoUrl; use servo::webrender_api::units::DevicePixel; use servo::webrender_traits::SurfmanRenderingContext; -use servo::TopLevelBrowsingContextId; +use servo::{TopLevelBrowsingContextId, TraversalDirection}; use winit::event::{ElementState, MouseButton, WindowEvent}; use winit::event_loop::ActiveEventLoop; use winit::window::Window; diff --git a/ports/servoshell/desktop/tracing.rs b/ports/servoshell/desktop/tracing.rs index 097ec01fbc5..fd34a9237bc 100644 --- a/ports/servoshell/desktop/tracing.rs +++ b/ports/servoshell/desktop/tracing.rs @@ -22,7 +22,7 @@ macro_rules! trace_winit_event { }; } -/// Log an event from servo ([servo::embedder_traits::EmbedderMsg]) at trace level. +/// Log an event from servo ([servo::EmbedderMsg]) at trace level. /// - To disable tracing: RUST_LOG='servoshell<servo@=off' /// - To enable tracing: RUST_LOG='servoshell<servo@' /// - Recommended filters when tracing is enabled: @@ -139,7 +139,7 @@ mod from_servo { }; } - impl LogTarget for servo::embedder_traits::EmbedderMsg { + impl LogTarget for servo::EmbedderMsg { fn log_target(&self) -> &'static str { match self { Self::Status(..) => target!("Status"), diff --git a/ports/servoshell/desktop/webview.rs b/ports/servoshell/desktop/webview.rs index 7204bf91a6a..1793673ec5c 100644 --- a/ports/servoshell/desktop/webview.rs +++ b/ports/servoshell/desktop/webview.rs @@ -20,19 +20,17 @@ use log::{debug, error, info, trace, warn}; use servo::base::id::TopLevelBrowsingContextId as WebViewId; use servo::compositing::windowing::{EmbedderEvent, WebRenderDebugOption}; use servo::config::opts::Opts; -use servo::embedder_traits::{ - CompositorEventVariant, ContextMenuResult, DualRumbleEffectParams, EmbedderMsg, FilterPattern, - GamepadHapticEffectType, PermissionPrompt, PermissionRequest, PromptCredentialsInput, - PromptDefinition, PromptOrigin, PromptResult, -}; use servo::ipc_channel::ipc::IpcSender; -use servo::script_traits::{ - ClipboardEventType, GamepadEvent, GamepadIndex, GamepadInputBounds, - GamepadSupportedHapticEffects, GamepadUpdateType, TouchEventType, TraversalDirection, -}; use servo::servo_url::ServoUrl; use servo::webrender_api::units::DeviceRect; use servo::webrender_api::ScrollLocation; +use servo::{ + ClipboardEventType, CompositorEventVariant, ContextMenuResult, DualRumbleEffectParams, + EmbedderMsg, FilterPattern, GamepadEvent, GamepadHapticEffectType, GamepadIndex, + GamepadInputBounds, GamepadSupportedHapticEffects, GamepadUpdateType, PermissionPrompt, + PermissionRequest, PromptCredentialsInput, PromptDefinition, PromptOrigin, PromptResult, + TouchEventType, TraversalDirection, +}; use tinyfiledialogs::{self, MessageBoxIcon, OkCancel, YesNo}; use super::keyutils::{CMD_OR_ALT, CMD_OR_CONTROL}; diff --git a/ports/servoshell/desktop/window_trait.rs b/ports/servoshell/desktop/window_trait.rs index 356230feeb3..33d00f1b1bf 100644 --- a/ports/servoshell/desktop/window_trait.rs +++ b/ports/servoshell/desktop/window_trait.rs @@ -9,9 +9,9 @@ use std::rc::Rc; use euclid::{Length, Scale}; use servo::compositing::windowing::{EmbedderEvent, WindowMethods}; -use servo::embedder_traits::Cursor; use servo::servo_geometry::DeviceIndependentPixel; use servo::webrender_api::units::{DeviceIntPoint, DeviceIntSize, DevicePixel}; +use servo::Cursor; // This should vary by zoom level and maybe actual text size (focused or under cursor) pub const LINE_HEIGHT: f32 = 38.0; diff --git a/ports/servoshell/egl/android/resources.rs b/ports/servoshell/egl/android/resources.rs index 227d97742a6..c6653bf0bc0 100644 --- a/ports/servoshell/egl/android/resources.rs +++ b/ports/servoshell/egl/android/resources.rs @@ -3,7 +3,7 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use std::path::PathBuf; -use servo::embedder_traits::resources::{Resource, ResourceReaderMethods}; +use servo::resources::{Resource, ResourceReaderMethods}; pub(crate) struct ResourceReaderInstance; diff --git a/ports/servoshell/egl/android/simpleservo.rs b/ports/servoshell/egl/android/simpleservo.rs index 916f48ff730..7dc4eae03ca 100644 --- a/ports/servoshell/egl/android/simpleservo.rs +++ b/ports/servoshell/egl/android/simpleservo.rs @@ -10,16 +10,15 @@ use std::rc::Rc; use servo::base::id::WebViewId; use servo::compositing::windowing::EmbedderEvent; use servo::compositing::CompositeTarget; -use servo::embedder_traits::resources; -/// The EventLoopWaker::wake function will be called from any thread. -/// It will be called to notify embedder that some events are available, -/// and that perform_updates need to be called -pub use servo::embedder_traits::EventLoopWaker; -pub use servo::embedder_traits::{InputMethodType, MediaSessionPlaybackState, PromptResult}; use servo::servo_url::ServoUrl; pub use servo::webrender_api::units::DeviceIntRect; use servo::webrender_traits::SurfmanRenderingContext; -use servo::{self, Servo}; +/// The EventLoopWaker::wake function will be called from any thread. +/// It will be called to notify embedder that some events are available, +/// and that perform_updates need to be called +pub use servo::EventLoopWaker; +use servo::{self, resources, Servo}; +pub use servo::{InputMethodType, MediaSessionPlaybackState, PromptResult}; use surfman::{Connection, SurfaceType}; use crate::egl::android::resources::ResourceReaderInstance; diff --git a/ports/servoshell/egl/host_trait.rs b/ports/servoshell/egl/host_trait.rs index 99fac91356c..bc18a48572b 100644 --- a/ports/servoshell/egl/host_trait.rs +++ b/ports/servoshell/egl/host_trait.rs @@ -2,8 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -use servo::embedder_traits::{InputMethodType, MediaSessionPlaybackState, PromptResult}; use servo::webrender_api::units::DeviceIntRect; +use servo::{InputMethodType, MediaSessionPlaybackState, PromptResult}; /// Callbacks. Implemented by embedder. Called by Servo. pub trait HostTrait { diff --git a/ports/servoshell/egl/ohos.rs b/ports/servoshell/egl/ohos.rs index 6dfe5c12bd0..4f9e40b8158 100644 --- a/ports/servoshell/egl/ohos.rs +++ b/ports/servoshell/egl/ohos.rs @@ -21,9 +21,8 @@ use napi_ohos::{Env, JsObject, JsString, NapiRaw}; use ohos_ime::{AttachOptions, Ime, ImeProxy, RawTextEditorProxy}; use ohos_ime_sys::types::InputMethod_EnterKeyType; use servo::compositing::windowing::EmbedderEvent; -use servo::embedder_traits; -use servo::embedder_traits::{InputMethodType, PromptResult}; use servo::style::Zero; +use servo::{InputMethodType, MediaSessionPlaybackState, PromptResult}; use simpleservo::EventLoopWaker; use xcomponent_sys::{ OH_NativeXComponent, OH_NativeXComponent_Callback, OH_NativeXComponent_GetKeyEvent, @@ -740,7 +739,7 @@ impl HostTrait for HostCallbacks { /// and shows the soft keyboard with default settings. fn on_ime_show( &self, - input_type: embedder_traits::InputMethodType, + input_type: InputMethodType, _text: Option<(String, i32)>, multiline: bool, _bounds: servo::webrender_api::units::DeviceIntRect, @@ -790,10 +789,7 @@ impl HostTrait for HostCallbacks { warn!("on_media_session_metadata not implemented"); } - fn on_media_session_playback_state_change( - &self, - state: servo::embedder_traits::MediaSessionPlaybackState, - ) { + fn on_media_session_playback_state_change(&self, state: MediaSessionPlaybackState) { warn!("on_media_session_playback_state_change not implemented"); } diff --git a/ports/servoshell/egl/ohos/resources.rs b/ports/servoshell/egl/ohos/resources.rs index 77d8fe68892..1e9d4df7497 100644 --- a/ports/servoshell/egl/ohos/resources.rs +++ b/ports/servoshell/egl/ohos/resources.rs @@ -4,7 +4,7 @@ use std::fs; use std::path::PathBuf; -use servo::embedder_traits::resources::{Resource, ResourceReaderMethods}; +use servo::resources::{Resource, ResourceReaderMethods}; pub(crate) struct ResourceReaderInstance { resource_dir: PathBuf, diff --git a/ports/servoshell/egl/ohos/simpleservo.rs b/ports/servoshell/egl/ohos/simpleservo.rs index 5321190e296..aa3b9e2943f 100644 --- a/ports/servoshell/egl/ohos/simpleservo.rs +++ b/ports/servoshell/egl/ohos/simpleservo.rs @@ -11,15 +11,14 @@ use log::{debug, error, info}; use servo::base::id::WebViewId; use servo::compositing::windowing::EmbedderEvent; use servo::compositing::CompositeTarget; -use servo::embedder_traits::resources; -/// The EventLoopWaker::wake function will be called from any thread. -/// It will be called to notify embedder that some events are available, -/// and that perform_updates need to be called -pub use servo::embedder_traits::EventLoopWaker; use servo::euclid::Size2D; use servo::servo_url::ServoUrl; use servo::webrender_traits::SurfmanRenderingContext; -use servo::{self, Servo}; +/// The EventLoopWaker::wake function will be called from any thread. +/// It will be called to notify embedder that some events are available, +/// and that perform_updates need to be called +pub use servo::EventLoopWaker; +use servo::{self, resources, Servo}; use surfman::{Connection, SurfaceType}; use xcomponent_sys::{OH_NativeXComponent, OH_NativeXComponent_GetXComponentSize}; diff --git a/ports/servoshell/egl/servo_glue.rs b/ports/servoshell/egl/servo_glue.rs index e5829e02146..e87b7e254fd 100644 --- a/ports/servoshell/egl/servo_glue.rs +++ b/ports/servoshell/egl/servo_glue.rs @@ -15,20 +15,17 @@ use servo::compositing::windowing::{ AnimationState, EmbedderCoordinates, EmbedderEvent, EmbedderMethods, MouseWindowEvent, WindowMethods, }; -use servo::embedder_traits::{ - ContextMenuResult, EmbedderMsg, EmbedderProxy, EventLoopWaker, MediaSessionEvent, - PermissionPrompt, PermissionRequest, PromptDefinition, PromptOrigin, PromptResult, -}; use servo::euclid::{Box2D, Point2D, Rect, Scale, Size2D, Vector2D}; -use servo::keyboard_types::{Key, KeyState, KeyboardEvent}; -use servo::script_traits::{ - MediaSessionActionType, MouseButton, TouchEventType, TouchId, TraversalDirection, -}; use servo::servo_geometry::DeviceIndependentPixel; use servo::webrender_api::units::DevicePixel; use servo::webrender_api::ScrollLocation; use servo::webrender_traits::SurfmanRenderingContext; -use servo::{Servo, TopLevelBrowsingContextId}; +use servo::{ + ContextMenuResult, EmbedderMsg, EmbedderProxy, EventLoopWaker, Key, KeyState, KeyboardEvent, + MediaSessionActionType, MediaSessionEvent, MouseButton, PermissionPrompt, PermissionRequest, + PromptDefinition, PromptOrigin, PromptResult, Servo, TopLevelBrowsingContextId, TouchEventType, + TouchId, TraversalDirection, +}; use crate::egl::host_trait::HostTrait; use crate::prefs::ServoShellPreferences; diff --git a/ports/servoshell/resources.rs b/ports/servoshell/resources.rs index 9801a8923ea..be964247c63 100644 --- a/ports/servoshell/resources.rs +++ b/ports/servoshell/resources.rs @@ -7,7 +7,7 @@ use std::sync::Mutex; use std::{env, fs}; use cfg_if::cfg_if; -use servo::embedder_traits::resources::{self, Resource}; +use servo::resources::{self, Resource}; static CMD_RESOURCE_DIR: Mutex<Option<PathBuf>> = Mutex::new(None); |