aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2017-09-17 09:57:12 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2017-09-17 10:19:59 +0200
commitf58207b851494562f855b8fdb929a529d9850f44 (patch)
tree0b22eb4014bb7e83c6ef1c84f4b879a4b04f8fb4 /components/script/dom
parent95dc54d216d63b7314214afc1b50025b73a132b1 (diff)
downloadservo-f58207b851494562f855b8fdb929a529d9850f44.tar.gz
servo-f58207b851494562f855b8fdb929a529d9850f44.zip
Introduce MainThreadScriptMsg::RegisterPaintWorklet
This avoids the need for a generic task to send messages to the layout thread through the main script thread.
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/paintworkletglobalscope.rs4
-rw-r--r--components/script/dom/workletglobalscope.rs44
2 files changed, 18 insertions, 30 deletions
diff --git a/components/script/dom/paintworkletglobalscope.rs b/components/script/dom/paintworkletglobalscope.rs
index 0a01e62cd9b..8eba2c8bb14 100644
--- a/components/script/dom/paintworkletglobalscope.rs
+++ b/components/script/dom/paintworkletglobalscope.rs
@@ -46,7 +46,6 @@ use js::rust::Runtime;
use msg::constellation_msg::PipelineId;
use net_traits::image::base::PixelFormat;
use net_traits::image_cache::ImageCache;
-use script_layout_interface::message::Msg;
use script_traits::DrawAPaintImageResult;
use script_traits::Painter;
use servo_atoms::Atom;
@@ -443,8 +442,7 @@ impl PaintWorkletGlobalScopeMethods for PaintWorkletGlobalScope {
// Inform layout that there is a registered paint worklet.
// TODO: layout will end up getting this message multiple times.
let painter = self.painter(name.clone());
- let msg = Msg::RegisterPaint(name, properties, painter);
- self.worklet_global.send_to_layout(msg);
+ self.worklet_global.register_paint_worklet(name, properties, painter);
Ok(())
}
diff --git a/components/script/dom/workletglobalscope.rs b/components/script/dom/workletglobalscope.rs
index f603547bb19..210ede4172e 100644
--- a/components/script/dom/workletglobalscope.rs
+++ b/components/script/dom/workletglobalscope.rs
@@ -22,12 +22,10 @@ use net_traits::ResourceThreads;
use net_traits::image_cache::ImageCache;
use profile_traits::mem;
use profile_traits::time;
-use script_layout_interface::message::Msg;
-use script_runtime::ScriptThreadEventCategory;
-use script_thread::{MainThreadScriptMsg, ScriptThread, Task};
-use script_traits::ScriptMsg;
-use script_traits::ScriptToConstellationChan;
-use script_traits::TimerSchedulerMsg;
+use script_thread::MainThreadScriptMsg;
+use script_traits::{Painter, ScriptMsg};
+use script_traits::{ScriptToConstellationChan, TimerSchedulerMsg};
+use servo_atoms::Atom;
use servo_url::ImmutableOrigin;
use servo_url::MutableOrigin;
use servo_url::ServoUrl;
@@ -93,31 +91,23 @@ impl WorkletGlobalScope {
self.globalscope.evaluate_js_on_global_with_result(&*script, rval.handle_mut())
}
- /// Run a task in the main script thread.
- pub fn run_in_script_thread<T>(&self, task: T)
- where
- T: 'static + Send + Task,
- {
+ /// Register a paint worklet to the script thread.
+ pub fn register_paint_worklet(
+ &self,
+ name: Atom,
+ properties: Vec<Atom>,
+ painter: Box<Painter>,
+ ) {
self.to_script_thread_sender
- .send(MainThreadScriptMsg::MainThreadTask(
- ScriptThreadEventCategory::WorkletEvent,
- box task,
- ))
+ .send(MainThreadScriptMsg::RegisterPaintWorklet {
+ pipeline_id: self.globalscope.pipeline_id(),
+ name,
+ properties,
+ painter,
+ })
.expect("Worklet thread outlived script thread.");
}
- /// Send a message to layout.
- pub fn send_to_layout(&self, msg: Msg) {
- struct SendToLayoutTask(PipelineId, Msg);
- impl Task for SendToLayoutTask {
- fn run_with_script_thread(self: Box<Self>, script_thread: &ScriptThread) {
- script_thread.send_to_layout(self.0, self.1);
- }
- }
- let pipeline_id = self.globalscope.pipeline_id();
- self.run_in_script_thread(SendToLayoutTask(pipeline_id, msg));
- }
-
/// The base URL of this global.
pub fn base_url(&self) -> ServoUrl {
self.base_url.clone()