diff options
author | CYBAI <cyb.ai.815@gmail.com> | 2018-06-10 21:02:11 +0800 |
---|---|---|
committer | CYBAI <cyb.ai.815@gmail.com> | 2018-10-18 19:13:23 +0800 |
commit | 42903412c768f289558554419add125ce908e342 (patch) | |
tree | 5778ea48efc1659006fbacb4dd6ed270b91cd8fb /components/script/dom | |
parent | 924a78c6c678e9448df9983bb370ff40910465bd (diff) | |
download | servo-42903412c768f289558554419add125ce908e342.tar.gz servo-42903412c768f289558554419add125ce908e342.zip |
Make first argument of DOMManipulationTaskSource as a Box<ScriptChan +
Send>
We don't have `window` for `workers`. So, if we use `global.as_window()`
to get the DOMManipulationTaskSource, it will make worker panic.
Instead, we should get the DOMManipulationTaskSource from each own
thread.
Ref: https://github.com/servo/servo/pull/20755#discussion_r193557746
Diffstat (limited to 'components/script/dom')
-rw-r--r-- | components/script/dom/globalscope.rs | 11 | ||||
-rw-r--r-- | components/script/dom/workerglobalscope.rs | 5 |
2 files changed, 16 insertions, 0 deletions
diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index c38a5869d61..a3e879326bc 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -56,6 +56,7 @@ use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use task::TaskCanceller; use task_source::TaskSourceName; +use task_source::dom_manipulation::DOMManipulationTaskSource; use task_source::file_reading::FileReadingTaskSource; use task_source::networking::NetworkingTaskSource; use task_source::performance_timeline::PerformanceTimelineTaskSource; @@ -680,6 +681,16 @@ impl GlobalScope { unreachable!(); } + pub fn dom_manipulation_task_source(&self) -> DOMManipulationTaskSource { + if let Some(window) = self.downcast::<Window>() { + return window.dom_manipulation_task_source(); + } + if let Some(worker) = self.downcast::<WorkerGlobalScope>() { + return worker.dom_manipulation_task_source(); + } + unreachable!(); + } + /// Channel to send messages to the file reading task source of /// this of this global scope. pub fn file_reading_task_source(&self) -> FileReadingTaskSource { diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index fa2d0a449cf..edcdb329af8 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -43,6 +43,7 @@ use std::rc::Rc; use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; use task::TaskCanceller; +use task_source::dom_manipulation::DOMManipulationTaskSource; use task_source::file_reading::FileReadingTaskSource; use task_source::networking::NetworkingTaskSource; use task_source::performance_timeline::PerformanceTimelineTaskSource; @@ -419,6 +420,10 @@ impl WorkerGlobalScope { } } + pub fn dom_manipulation_task_source(&self) -> DOMManipulationTaskSource { + DOMManipulationTaskSource(self.script_chan(), self.pipeline_id()) + } + pub fn file_reading_task_source(&self) -> FileReadingTaskSource { FileReadingTaskSource(self.script_chan(), self.pipeline_id()) } |