diff options
Diffstat (limited to 'components/script_traits')
-rw-r--r-- | components/script_traits/Cargo.toml | 2 | ||||
-rw-r--r-- | components/script_traits/lib.rs | 31 |
2 files changed, 32 insertions, 1 deletions
diff --git a/components/script_traits/Cargo.toml b/components/script_traits/Cargo.toml index 2e957b3882f..ac85cd782ec 100644 --- a/components/script_traits/Cargo.toml +++ b/components/script_traits/Cargo.toml @@ -10,6 +10,7 @@ name = "script_traits" path = "lib.rs" [dependencies] +app_units = "0.4" bluetooth_traits = {path = "../bluetooth_traits"} canvas_traits = {path = "../canvas_traits"} cookie = "0.6" @@ -29,6 +30,7 @@ profile_traits = {path = "../profile_traits"} rustc-serialize = "0.3.4" serde = "0.9" serde_derive = "0.9" +servo_atoms = {path = "../atoms"} servo_url = {path = "../url"} style_traits = {path = "../style_traits", features = ["servo"]} time = "0.1.12" diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index ba92857efbc..c036eee28d9 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -9,6 +9,7 @@ #![deny(missing_docs)] #![deny(unsafe_code)] +extern crate app_units; extern crate bluetooth_traits; extern crate canvas_traits; extern crate cookie as cookie_rs; @@ -30,6 +31,7 @@ extern crate rustc_serialize; extern crate serde; #[macro_use] extern crate serde_derive; +extern crate servo_atoms; extern crate servo_url; extern crate style_traits; extern crate time; @@ -39,6 +41,7 @@ extern crate webvr_traits; mod script_msg; pub mod webdriver_msg; +use app_units::Au; use bluetooth_traits::BluetoothRequest; use devtools_traits::{DevtoolScriptControlMsg, ScriptToDevtoolsControlMsg, WorkerId}; use euclid::Size2D; @@ -63,12 +66,13 @@ use net_traits::storage_thread::StorageType; use profile_traits::mem; use profile_traits::time as profile_time; use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use servo_atoms::Atom; use servo_url::ImmutableOrigin; use servo_url::ServoUrl; use std::collections::HashMap; use std::fmt; use std::sync::Arc; -use std::sync::mpsc::{Receiver, Sender}; +use std::sync::mpsc::{Receiver, Sender, RecvTimeoutError}; use style_traits::CSSPixel; use webdriver_msg::{LoadStatus, WebDriverScriptCommand}; use webrender_traits::ClipId; @@ -813,3 +817,28 @@ pub struct WorkerScriptLoadOrigin { /// the pipeline id of the entity requesting the load pub pipeline_id: Option<PipelineId>, } + +/// Errors from executing a paint worklet +#[derive(Debug, Deserialize, Serialize, Clone)] +pub enum PaintWorkletError { + /// Execution timed out. + Timeout, + /// No such worklet. + WorkletNotFound, +} + +impl From<RecvTimeoutError> for PaintWorkletError { + fn from(_: RecvTimeoutError) -> PaintWorkletError { + PaintWorkletError::Timeout + } +} + +/// Execute paint code in the worklet thread pool.< +pub trait PaintWorkletExecutor: Sync + Send { + /// https://drafts.css-houdini.org/css-paint-api/#draw-a-paint-image + fn draw_a_paint_image(&self, + name: Atom, + concrete_object_size: Size2D<Au>) + -> Result<Image, PaintWorkletError>; +} + |