aboutsummaryrefslogtreecommitdiffstats
path: root/components/script_traits
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-06-07 11:57:07 -0700
committerGitHub <noreply@github.com>2017-06-07 11:57:07 -0700
commitbf46da065db58549a74c489d521f9375f4137637 (patch)
treef13d373c0cde75888eaba2c1db38dc04129669b3 /components/script_traits
parenteaefcbe55186b874b96c6dffc7e8dd2b6283634d (diff)
parentfd17dcd60442e71f75010a34c6bcfe1c04aca3e5 (diff)
downloadservo-bf46da065db58549a74c489d521f9375f4137637.tar.gz
servo-bf46da065db58549a74c489d521f9375f4137637.zip
Auto merge of #17150 - asajeffrey:script-paint-worklets-plumbing, r=jdm
Implemented the plumbing for paint worklets <!-- Please describe your changes on the following line: --> This PR implements the plumbing for paint worklets: * Adding CSS values for paint worklets. * Implementing a skeleton for the `PaintWorkletGlobalScope` webidl. * Implementing an executor for paint worklet tasks, and passing it from script to layout. * Building the display list items for paint worklet images. This PR does not implement registering or calling paint worklets in JS. Before it merges, this PR needs a reftest added for basic paint worklet functionality. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] There are tests for these changes <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17150) <!-- Reviewable:end -->
Diffstat (limited to 'components/script_traits')
-rw-r--r--components/script_traits/Cargo.toml2
-rw-r--r--components/script_traits/lib.rs31
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>;
+}
+