aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_thread.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2017-09-16 01:55:26 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2017-09-16 15:10:07 +0200
commit52a6f63608a25e0574fd43b69f404f79a9a6c28f (patch)
tree5768b3035ba5c95cf1e335188d4f41456ad0bc04 /components/script/script_thread.rs
parent7ca52152a63615b38cecd9e149032bba712d3bc5 (diff)
downloadservo-52a6f63608a25e0574fd43b69f404f79a9a6c28f.tar.gz
servo-52a6f63608a25e0574fd43b69f404f79a9a6c28f.zip
Introduce MainThreadScriptMsg::MainThreadRunnable
This will allow us to separate the types for tasks that must run on the main script thread and regular tasks.
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r--components/script/script_thread.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index c15531ff595..e1183368137 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -274,7 +274,7 @@ enum MixedMessage {
FromScheduler(TimerEvent),
}
-/// Messages used to control the script event loop
+/// Messages used to control the script event loop.
#[derive(Debug)]
pub enum MainThreadScriptMsg {
/// Common variants associated with the script messages
@@ -289,6 +289,8 @@ pub enum MainThreadScriptMsg {
/// Notifies the script thread that a new worklet has been loaded, and thus the page should be
/// reflowed.
WorkletLoaded(PipelineId),
+ /// Runs a Runnable in the main thread.
+ MainThreadRunnable(ScriptThreadEventCategory, Box<Runnable + Send>),
}
impl OpaqueSender<CommonScriptMsg> for Box<ScriptChan + Send> {
@@ -1167,9 +1169,9 @@ impl ScriptThread {
MixedMessage::FromImageCache(_) => ScriptThreadEventCategory::ImageCacheMsg,
MixedMessage::FromScript(ref inner_msg) => {
match *inner_msg {
- MainThreadScriptMsg::Common(CommonScriptMsg::RunnableMsg(ref category, _)) =>
- *category,
- _ => ScriptThreadEventCategory::ScriptEvent
+ MainThreadScriptMsg::Common(CommonScriptMsg::RunnableMsg(category, _)) |
+ MainThreadScriptMsg::MainThreadRunnable(category, _) => category,
+ _ => ScriptThreadEventCategory::ScriptEvent,
}
},
MixedMessage::FromScheduler(_) => ScriptThreadEventCategory::TimerEvent
@@ -1299,7 +1301,7 @@ impl ScriptThread {
self.handle_exit_window_msg(id)
},
MainThreadScriptMsg::Common(CommonScriptMsg::RunnableMsg(_, runnable)) => {
- runnable.main_thread_handler(self)
+ runnable.handler()
}
MainThreadScriptMsg::Common(CommonScriptMsg::CollectReports(chan)) => {
self.collect_reports(chan)
@@ -1307,6 +1309,9 @@ impl ScriptThread {
MainThreadScriptMsg::WorkletLoaded(pipeline_id) => {
self.handle_worklet_loaded(pipeline_id)
},
+ MainThreadScriptMsg::MainThreadRunnable(_, runnable) => {
+ runnable.main_thread_handler(self)
+ },
}
}