diff options
Diffstat (limited to 'components/shared')
-rw-r--r-- | components/shared/compositing/lib.rs | 5 | ||||
-rw-r--r-- | components/shared/constellation/from_script_message.rs | 9 | ||||
-rw-r--r-- | components/shared/constellation/lib.rs | 9 | ||||
-rw-r--r-- | components/shared/constellation/structured_data/mod.rs | 3 | ||||
-rw-r--r-- | components/shared/constellation/structured_data/serializable.rs | 6 | ||||
-rw-r--r-- | components/shared/constellation/structured_data/transferable.rs | 6 | ||||
-rw-r--r-- | components/shared/embedder/input_events.rs | 7 | ||||
-rw-r--r-- | components/shared/embedder/lib.rs | 93 | ||||
-rw-r--r-- | components/shared/embedder/webdriver.rs | 2 | ||||
-rw-r--r-- | components/shared/net/lib.rs | 2 | ||||
-rw-r--r-- | components/shared/net/request.rs | 4 | ||||
-rw-r--r-- | components/shared/profile/mem.rs | 6 | ||||
-rw-r--r-- | components/shared/profile/time.rs | 25 | ||||
-rw-r--r-- | components/shared/script/lib.rs | 7 | ||||
-rw-r--r-- | components/shared/script_layout/lib.rs | 1 |
15 files changed, 130 insertions, 55 deletions
diff --git a/components/shared/compositing/lib.rs b/components/shared/compositing/lib.rs index 31371f87529..a6701ca2b52 100644 --- a/components/shared/compositing/lib.rs +++ b/components/shared/compositing/lib.rs @@ -14,6 +14,7 @@ use embedder_traits::{ use euclid::Rect; use ipc_channel::ipc::IpcSender; use log::warn; +use malloc_size_of_derive::MallocSizeOf; use pixels::Image; use strum_macros::IntoStaticStr; use style_traits::CSSPixel; @@ -103,6 +104,8 @@ pub enum CompositorMsg { WebDriverMouseButtonEvent(WebViewId, MouseButtonAction, MouseButton, f32, f32), /// WebDriver mouse move event WebDriverMouseMoveEvent(WebViewId, f32, f32), + // Webdriver wheel scroll event + WebDriverWheelScrollEvent(WebViewId, f32, f32, f64, f64), /// Inform WebRender of the existence of this pipeline. SendInitialTransaction(WebRenderPipelineId), @@ -188,7 +191,7 @@ pub struct CompositionPipeline { } /// A mechanism to send messages from ScriptThread to the parent process' WebRender instance. -#[derive(Clone, Deserialize, Serialize)] +#[derive(Clone, Deserialize, MallocSizeOf, Serialize)] pub struct CrossProcessCompositorApi(pub IpcSender<CompositorMsg>); impl CrossProcessCompositorApi { diff --git a/components/shared/constellation/from_script_message.rs b/components/shared/constellation/from_script_message.rs index 21665c24e57..3856def660e 100644 --- a/components/shared/constellation/from_script_message.rs +++ b/components/shared/constellation/from_script_message.rs @@ -15,8 +15,8 @@ use base::id::{ use canvas_traits::canvas::{CanvasId, CanvasMsg}; use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId}; use embedder_traits::{ - AnimationState, EmbedderMsg, FocusSequenceNumber, MediaSessionEvent, TouchEventResult, - ViewportDetails, + AnimationState, EmbedderMsg, FocusSequenceNumber, JSValue, JavaScriptEvaluationError, + JavaScriptEvaluationId, MediaSessionEvent, TouchEventResult, ViewportDetails, }; use euclid::default::Size2D as UntypedSize2D; use http::{HeaderMap, Method}; @@ -644,6 +644,11 @@ pub enum ScriptToConstellationMessage { IFrameSizes(Vec<IFrameSizeMsg>), /// Request results from the memory reporter. ReportMemory(IpcSender<MemoryReportResult>), + /// Return the result of the evaluated JavaScript with the given [`JavaScriptEvaluationId`]. + FinishJavaScriptEvaluation( + JavaScriptEvaluationId, + Result<JSValue, JavaScriptEvaluationError>, + ), } impl fmt::Debug for ScriptToConstellationMessage { diff --git a/components/shared/constellation/lib.rs b/components/shared/constellation/lib.rs index 559bc2dd2d1..d85fbe31bdf 100644 --- a/components/shared/constellation/lib.rs +++ b/components/shared/constellation/lib.rs @@ -19,8 +19,8 @@ use base::Epoch; use base::cross_process_instant::CrossProcessInstant; use base::id::{MessagePortId, PipelineId, WebViewId}; use embedder_traits::{ - CompositorHitTestResult, Cursor, InputEvent, MediaSessionActionType, Theme, ViewportDetails, - WebDriverCommandMsg, + CompositorHitTestResult, Cursor, InputEvent, JavaScriptEvaluationId, MediaSessionActionType, + Theme, ViewportDetails, WebDriverCommandMsg, }; use euclid::Vector2D; pub use from_script_message::*; @@ -92,6 +92,9 @@ pub enum EmbedderToConstellationMessage { SetScrollStates(PipelineId, Vec<ScrollState>), /// Notify the constellation that a particular paint metric event has happened for the given pipeline. PaintMetric(PipelineId, PaintMetricEvent), + /// Evaluate a JavaScript string in the context of a `WebView`. When execution is complete or an + /// error is encountered, a correpsonding message will be sent to the embedding layer. + EvaluateJavaScript(WebViewId, JavaScriptEvaluationId, String), } /// A description of a paint metric that is sent from the Servo renderer to the @@ -149,7 +152,7 @@ pub enum TraversalDirection { } /// A task on the <https://html.spec.whatwg.org/multipage/#port-message-queue> -#[derive(Debug, Deserialize, MallocSizeOf, Serialize)] +#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)] pub struct PortMessageTask { /// The origin of this task. pub origin: ImmutableOrigin, diff --git a/components/shared/constellation/structured_data/mod.rs b/components/shared/constellation/structured_data/mod.rs index 41fc05493a2..3fb9d0c5f67 100644 --- a/components/shared/constellation/structured_data/mod.rs +++ b/components/shared/constellation/structured_data/mod.rs @@ -20,7 +20,7 @@ pub use transferable::*; /// A data-holder for serialized data and transferred objects. /// <https://html.spec.whatwg.org/multipage/#structuredserializewithtransfer> -#[derive(Debug, Default, Deserialize, MallocSizeOf, Serialize)] +#[derive(Clone, Debug, Default, Deserialize, MallocSizeOf, Serialize)] pub struct StructuredSerializedData { /// Data serialized by SpiderMonkey. pub serialized: Vec<u8>, @@ -43,6 +43,7 @@ impl StructuredSerializedData { Transferrable::MessagePort => is_field_empty(&self.ports), Transferrable::ReadableStream => is_field_empty(&self.ports), Transferrable::WritableStream => is_field_empty(&self.ports), + Transferrable::TransformStream => is_field_empty(&self.ports), } } diff --git a/components/shared/constellation/structured_data/serializable.rs b/components/shared/constellation/structured_data/serializable.rs index 22370087665..194f0567c51 100644 --- a/components/shared/constellation/structured_data/serializable.rs +++ b/components/shared/constellation/structured_data/serializable.rs @@ -88,7 +88,7 @@ impl Clone for BroadcastMsg { } /// File-based blob -#[derive(Debug, Deserialize, MallocSizeOf, Serialize)] +#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)] pub struct FileBlob { #[ignore_malloc_size_of = "Uuid are hard(not really)"] id: Uuid, @@ -164,7 +164,7 @@ impl BroadcastClone for BlobImpl { } /// The data backing a DOM Blob. -#[derive(Debug, Deserialize, MallocSizeOf, Serialize)] +#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)] pub struct BlobImpl { /// UUID of the blob. blob_id: BlobId, @@ -177,7 +177,7 @@ pub struct BlobImpl { } /// Different backends of Blob -#[derive(Debug, Deserialize, MallocSizeOf, Serialize)] +#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)] pub enum BlobData { /// File-based blob, whose content lives in the net process File(FileBlob), diff --git a/components/shared/constellation/structured_data/transferable.rs b/components/shared/constellation/structured_data/transferable.rs index 7e4fe0e6d2d..528c1e79e65 100644 --- a/components/shared/constellation/structured_data/transferable.rs +++ b/components/shared/constellation/structured_data/transferable.rs @@ -24,9 +24,11 @@ pub enum Transferrable { ReadableStream, /// The `WritableStream` interface. WritableStream, + /// The `TransformStream` interface. + TransformStream, } -#[derive(Debug, Deserialize, MallocSizeOf, Serialize)] +#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)] enum MessagePortState { /// <https://html.spec.whatwg.org/multipage/#detached> Detached, @@ -40,7 +42,7 @@ enum MessagePortState { Disabled(bool), } -#[derive(Debug, Deserialize, MallocSizeOf, Serialize)] +#[derive(Clone, Debug, Deserialize, MallocSizeOf, Serialize)] /// The data and logic backing the DOM managed MessagePort. pub struct MessagePortImpl { /// The current state of the port. diff --git a/components/shared/embedder/input_events.rs b/components/shared/embedder/input_events.rs index 0268be6dd9c..acaa9afb3ff 100644 --- a/components/shared/embedder/input_events.rs +++ b/components/shared/embedder/input_events.rs @@ -61,15 +61,16 @@ pub enum MouseButton { Other(u16), } -impl From<u16> for MouseButton { - fn from(value: u16) -> Self { +impl<T: Into<u64>> From<T> for MouseButton { + fn from(value: T) -> Self { + let value = value.into(); match value { 0 => MouseButton::Left, 1 => MouseButton::Middle, 2 => MouseButton::Right, 3 => MouseButton::Back, 4 => MouseButton::Forward, - _ => MouseButton::Other(value), + _ => MouseButton::Other(value as u16), } } } diff --git a/components/shared/embedder/lib.rs b/components/shared/embedder/lib.rs index c87fa9019ef..575c8f54ff6 100644 --- a/components/shared/embedder/lib.rs +++ b/components/shared/embedder/lib.rs @@ -13,8 +13,10 @@ pub mod resources; pub mod user_content_manager; mod webdriver; +use std::collections::HashMap; use std::ffi::c_void; use std::fmt::{Debug, Display, Error, Formatter}; +use std::hash::Hash; use std::path::PathBuf; use std::sync::Arc; @@ -362,15 +364,13 @@ pub enum EmbedderMsg { ShutdownComplete, /// Request to display a notification. ShowNotification(Option<WebViewId>, Notification), - /// Indicates that the user has activated a `<select>` element. - /// - /// The embedder should respond with the new state of the `<select>` element. - ShowSelectElementMenu( - WebViewId, - Vec<SelectElementOptionOrOptgroup>, - Option<usize>, - DeviceIntRect, - IpcSender<Option<usize>>, + /// Request to display a form control to the embedder. + ShowFormControl(WebViewId, DeviceIntRect, FormControl), + /// Inform the embedding layer that a JavaScript evaluation has + /// finished with the given result. + FinishJavaScriptEvaluation( + JavaScriptEvaluationId, + Result<JSValue, JavaScriptEvaluationError>, ), } @@ -381,6 +381,18 @@ impl Debug for EmbedderMsg { } } +#[derive(Deserialize, Serialize)] +pub enum FormControl { + /// Indicates that the user has activated a `<select>` element. + SelectElement( + Vec<SelectElementOptionOrOptgroup>, + Option<usize>, + IpcSender<Option<usize>>, + ), + /// Indicates that the user has activated a `<input type=color>` element. + ColorPicker(RgbColor, IpcSender<Option<RgbColor>>), +} + /// Filter for file selection; /// the `String` content is expected to be extension (e.g, "doc", without the prefixing ".") #[derive(Clone, Debug, Deserialize, Serialize)] @@ -857,3 +869,66 @@ impl Display for FocusSequenceNumber { Display::fmt(&self.0, f) } } + +/// An identifier for a particular JavaScript evaluation that is used to track the +/// evaluation from the embedding layer to the script layer and then back. +#[derive(Clone, Copy, Deserialize, Eq, Hash, PartialEq, Serialize)] +pub struct JavaScriptEvaluationId(pub usize); + +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] +pub enum JSValue { + Undefined, + Null, + Boolean(bool), + Number(f64), + String(String), + Element(String), + Frame(String), + Window(String), + Array(Vec<JSValue>), + Object(HashMap<String, JSValue>), +} + +impl From<&WebDriverJSValue> for JSValue { + fn from(value: &WebDriverJSValue) -> Self { + match value { + WebDriverJSValue::Undefined => Self::Undefined, + WebDriverJSValue::Null => Self::Null, + WebDriverJSValue::Boolean(value) => Self::Boolean(*value), + WebDriverJSValue::Int(value) => Self::Number(*value as f64), + WebDriverJSValue::Number(value) => Self::Number(*value), + WebDriverJSValue::String(value) => Self::String(value.clone()), + WebDriverJSValue::Element(web_element) => Self::Element(web_element.0.clone()), + WebDriverJSValue::Frame(web_frame) => Self::Frame(web_frame.0.clone()), + WebDriverJSValue::Window(web_window) => Self::Window(web_window.0.clone()), + WebDriverJSValue::ArrayLike(vector) => { + Self::Array(vector.iter().map(Into::into).collect()) + }, + WebDriverJSValue::Object(map) => Self::Object( + map.iter() + .map(|(key, value)| (key.clone(), value.into())) + .collect(), + ), + } + } +} + +#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)] +pub enum JavaScriptEvaluationError { + /// An internal Servo error prevented the JavaSript evaluation from completing properly. + /// This indicates a bug in Servo. + InternalError, + /// The `WebView` on which this evaluation request was triggered is not ready. This might + /// happen if the `WebView`'s `Document` is changing due to ongoing load events, for instance. + WebViewNotReady, + /// The script executed successfully, but Servo could not serialize the JavaScript return + /// value into a [`JSValue`]. + SerializationError, +} + +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +pub struct RgbColor { + pub red: u8, + pub green: u8, + pub blue: u8, +} diff --git a/components/shared/embedder/webdriver.rs b/components/shared/embedder/webdriver.rs index 9577163411e..3716a29951a 100644 --- a/components/shared/embedder/webdriver.rs +++ b/components/shared/embedder/webdriver.rs @@ -44,6 +44,8 @@ pub enum WebDriverCommandMsg { MouseButtonAction(WebViewId, MouseButtonAction, MouseButton, f32, f32), /// Act as if the mouse was moved in the browsing context with the given ID. MouseMoveAction(WebViewId, f32, f32), + /// Act as if the mouse wheel is scrolled in the browsing context given the given ID. + WheelScrollAction(WebViewId, f32, f32, f64, f64), /// Set the window size. SetWindowSize(WebViewId, DeviceIntSize, IpcSender<Size2D<f32, CSSPixel>>), /// Take a screenshot of the window. diff --git a/components/shared/net/lib.rs b/components/shared/net/lib.rs index 05ad102f42f..0126bdbcd80 100644 --- a/components/shared/net/lib.rs +++ b/components/shared/net/lib.rs @@ -517,8 +517,6 @@ pub enum CoreResourceMsg { SetHistoryState(HistoryStateId, Vec<u8>), /// Removes history states for the given ids RemoveHistoryStates(Vec<HistoryStateId>), - /// Synchronization message solely for knowing the state of the ResourceChannelManager loop - Synchronize(IpcSender<()>), /// Clear the network cache. ClearCache, /// Send the service worker network mediator for an origin to CoreResourceThread diff --git a/components/shared/net/request.rs b/components/shared/net/request.rs index 9c3693316b0..259132b55c4 100644 --- a/components/shared/net/request.rs +++ b/components/shared/net/request.rs @@ -8,7 +8,7 @@ use base::id::{PipelineId, WebViewId}; use content_security_policy::{self as csp}; use http::header::{AUTHORIZATION, HeaderName}; use http::{HeaderMap, Method}; -use ipc_channel::ipc::{self, IpcReceiver, IpcSender}; +use ipc_channel::ipc::{self, IpcReceiver, IpcSender, IpcSharedMemory}; use malloc_size_of_derive::MallocSizeOf; use mime::Mime; use serde::{Deserialize, Serialize}; @@ -156,7 +156,7 @@ pub enum BodySource { #[derive(Debug, Deserialize, Serialize)] pub enum BodyChunkResponse { /// A chunk of bytes. - Chunk(Vec<u8>), + Chunk(IpcSharedMemory), /// The body is done. Done, /// There was an error streaming the body, diff --git a/components/shared/profile/mem.rs b/components/shared/profile/mem.rs index 1be4eb5abc4..b626facd042 100644 --- a/components/shared/profile/mem.rs +++ b/components/shared/profile/mem.rs @@ -279,7 +279,6 @@ thread_local!(static SEEN_POINTERS: LazyCell<RefCell<HashSet<*const c_void>>> = /// The function is expected to call all the desired [MallocSizeOf::size_of] /// for allocations reachable from the current thread. pub fn perform_memory_report<F: FnOnce(&mut MallocSizeOfOps)>(f: F) { - SEEN_POINTERS.with(|pointers| pointers.borrow_mut().clear()); let seen_pointer = move |ptr| SEEN_POINTERS.with(|pointers| !pointers.borrow_mut().insert(ptr)); let mut ops = MallocSizeOfOps::new( servo_allocator::usable_size, @@ -287,4 +286,9 @@ pub fn perform_memory_report<F: FnOnce(&mut MallocSizeOfOps)>(f: F) { Some(Box::new(seen_pointer)), ); f(&mut ops); + SEEN_POINTERS.with(|pointers| { + let mut pointers = pointers.borrow_mut(); + pointers.clear(); + pointers.shrink_to_fit(); + }); } diff --git a/components/shared/profile/time.rs b/components/shared/profile/time.rs index af2aba06662..877d1aaee15 100644 --- a/components/shared/profile/time.rs +++ b/components/shared/profile/time.rs @@ -8,7 +8,6 @@ use log::warn; use malloc_size_of_derive::MallocSizeOf; use serde::{Deserialize, Serialize}; use servo_config::opts; -use strum_macros::IntoStaticStr; use time::Duration; #[derive(Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)] @@ -59,9 +58,7 @@ pub enum ProfilerMsg { /// Usage sites of variants marked “Rust tracing only” are not visible to rust-analyzer. #[repr(u32)] -#[derive( - Clone, Copy, Debug, Deserialize, Eq, Hash, IntoStaticStr, Ord, PartialEq, PartialOrd, Serialize, -)] +#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, Ord, PartialEq, PartialOrd, Serialize)] pub enum ProfilerCategory { /// The compositor is rasterising or presenting. /// @@ -71,17 +68,6 @@ pub enum ProfilerCategory { /// The script thread is doing layout work. LayoutPerform = 0x10, - /// Events currently only used by Layout 2013. - LayoutStyleRecalc = 0x11, - LayoutTextShaping = 0x12, - LayoutRestyleDamagePropagation = 0x13, - LayoutGeneratedContent = 0x18, - LayoutFloatPlacementSpeculation = 0x1a, - LayoutMain = 0x1b, - LayoutStoreOverflow = 0x1c, - LayoutParallelWarmup = 0x1d, - LayoutDispListBuild = 0x1e, - ImageSaving = 0x51, ScriptAttachLayout = 0x60, ScriptConstellationMsg = 0x61, @@ -139,15 +125,6 @@ impl ProfilerCategory { match self { ProfilerCategory::Compositing => "Compositing", ProfilerCategory::LayoutPerform => "LayoutPerform", - ProfilerCategory::LayoutStyleRecalc => "LayoutStyleRecalc", - ProfilerCategory::LayoutTextShaping => "LayoutTextShaping", - ProfilerCategory::LayoutRestyleDamagePropagation => "LayoutRestyleDamagePropagation", - ProfilerCategory::LayoutGeneratedContent => "LayoutGeneratedContent", - ProfilerCategory::LayoutFloatPlacementSpeculation => "LayoutFloatPlacementSpeculation", - ProfilerCategory::LayoutMain => "LayoutMain", - ProfilerCategory::LayoutStoreOverflow => "LayoutStoreOverflow", - ProfilerCategory::LayoutParallelWarmup => "LayoutParallelWarmup", - ProfilerCategory::LayoutDispListBuild => "LayoutDispListBuild", ProfilerCategory::ImageSaving => "ImageSaving", ProfilerCategory::ScriptAttachLayout => "ScriptAttachLayout", ProfilerCategory::ScriptConstellationMsg => "ScriptConstellationMsg", diff --git a/components/shared/script/lib.rs b/components/shared/script/lib.rs index 748c42400a8..29acc51765c 100644 --- a/components/shared/script/lib.rs +++ b/components/shared/script/lib.rs @@ -27,8 +27,8 @@ use crossbeam_channel::{RecvTimeoutError, Sender}; use devtools_traits::ScriptToDevtoolsControlMsg; use embedder_traits::user_content_manager::UserContentManager; use embedder_traits::{ - CompositorHitTestResult, FocusSequenceNumber, InputEvent, MediaSessionActionType, Theme, - ViewportDetails, WebDriverScriptCommand, + CompositorHitTestResult, FocusSequenceNumber, InputEvent, JavaScriptEvaluationId, + MediaSessionActionType, Theme, ViewportDetails, WebDriverScriptCommand, }; use euclid::{Rect, Scale, Size2D, UnknownUnit}; use ipc_channel::ipc::{IpcReceiver, IpcSender}; @@ -245,6 +245,9 @@ pub enum ScriptThreadMessage { /// The compositor scrolled and is updating the scroll states of the nodes in the given /// pipeline via the Constellation. SetScrollStates(PipelineId, Vec<ScrollState>), + /// Evaluate the given JavaScript and return a result via a corresponding message + /// to the Constellation. + EvaluateJavaScript(PipelineId, JavaScriptEvaluationId, String), } impl fmt::Debug for ScriptThreadMessage { diff --git a/components/shared/script_layout/lib.rs b/components/shared/script_layout/lib.rs index 8c5d4edc4e0..1f526b64240 100644 --- a/components/shared/script_layout/lib.rs +++ b/components/shared/script_layout/lib.rs @@ -114,6 +114,7 @@ pub enum LayoutElementType { HTMLTableRowElement, HTMLTableSectionElement, HTMLTextAreaElement, + SVGImageElement, SVGSVGElement, } |