diff options
-rw-r--r-- | components/script/dom/htmldetailselement.rs | 3 | ||||
-rw-r--r-- | components/script/dom/htmlformelement.rs | 3 | ||||
-rw-r--r-- | components/script/dom/htmlimageelement.rs | 2 | ||||
-rw-r--r-- | components/script/dom/htmlmediaelement.rs | 9 | ||||
-rw-r--r-- | components/script/dom/storage.rs | 3 | ||||
-rw-r--r-- | components/script/script_thread.rs | 2 | ||||
-rw-r--r-- | components/script/task_source/dom_manipulation.rs | 15 | ||||
-rw-r--r-- | components/script/task_source/mod.rs | 13 | ||||
-rw-r--r-- | components/script/task_source/user_interaction.rs | 13 |
9 files changed, 42 insertions, 21 deletions
diff --git a/components/script/dom/htmldetailselement.rs b/components/script/dom/htmldetailselement.rs index 734ab8d0749..3c86a9fd0d9 100644 --- a/components/script/dom/htmldetailselement.rs +++ b/components/script/dom/htmldetailselement.rs @@ -5,6 +5,7 @@ use dom::attr::Attr; use dom::bindings::codegen::Bindings::HTMLDetailsElementBinding; use dom::bindings::codegen::Bindings::HTMLDetailsElementBinding::HTMLDetailsElementMethods; +use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::Castable; use dom::bindings::js::Root; use dom::bindings::refcounted::Trusted; @@ -78,7 +79,7 @@ impl VirtualMethods for HTMLDetailsElement { element: details, toggle_number: counter }; - let _ = task_source.queue(runnable, window.r()); + let _ = task_source.queue(runnable, GlobalRef::Window(&window)); } } } diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs index 903722d0cf4..9d7ce208ee2 100644 --- a/components/script/dom/htmlformelement.rs +++ b/components/script/dom/htmlformelement.rs @@ -12,6 +12,7 @@ use dom::bindings::codegen::Bindings::HTMLFormElementBinding::HTMLFormElementMet use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods; use dom::bindings::codegen::Bindings::HTMLTextAreaElementBinding::HTMLTextAreaElementMethods; use dom::bindings::conversions::DerivedFrom; +use dom::bindings::global::GlobalRef; use dom::bindings::inheritance::{Castable, ElementTypeId, HTMLElementTypeId, NodeTypeId}; use dom::bindings::js::{JS, MutNullableHeap, Root}; use dom::bindings::refcounted::Trusted; @@ -484,7 +485,7 @@ impl HTMLFormElement { }; // Step 3 - window.dom_manipulation_task_source().queue(nav, window).unwrap(); + window.dom_manipulation_task_source().queue(nav, GlobalRef::Window(window)).unwrap(); } /// Interactively validate the constraints of form elements diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs index 6671ca5bf55..cb0f65d0b2b 100644 --- a/components/script/dom/htmlimageelement.rs +++ b/components/script/dom/htmlimageelement.rs @@ -184,7 +184,7 @@ impl HTMLImageElement { src: src.into(), }; let task = window.dom_manipulation_task_source(); - let _ = task.queue(runnable, window); + let _ = task.queue(runnable, GlobalRef::Window(window)); } } } diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs index b95244f02bf..9a4c394649a 100644 --- a/components/script/dom/htmlmediaelement.rs +++ b/components/script/dom/htmlmediaelement.rs @@ -241,7 +241,7 @@ impl HTMLMediaElement { elem: Trusted::new(self), }; let win = window_from_node(self); - let _ = win.dom_manipulation_task_source().queue(task, win.r()); + let _ = win.dom_manipulation_task_source().queue(task, GlobalRef::Window(&win)); } // https://html.spec.whatwg.org/multipage/#internal-pause-steps step 2.2 @@ -265,13 +265,13 @@ impl HTMLMediaElement { elem: Trusted::new(self), }; let win = window_from_node(self); - let _ = win.dom_manipulation_task_source().queue(task, win.r()); + let _ = win.dom_manipulation_task_source().queue(task, GlobalRef::Window(&win)); } fn queue_fire_simple_event(&self, type_: &'static str) { let win = window_from_node(self); let task = box FireSimpleEventTask::new(self, type_); - let _ = win.dom_manipulation_task_source().queue(task, win.r()); + let _ = win.dom_manipulation_task_source().queue(task, GlobalRef::Window(&win)); } fn fire_simple_event(&self, type_: &str) { @@ -498,7 +498,8 @@ impl HTMLMediaElement { fn queue_dedicated_media_source_failure_steps(&self) { let window = window_from_node(self); - let _ = window.dom_manipulation_task_source().queue(box DedicatedMediaSourceFailureTask::new(self), window.r()); + let _ = window.dom_manipulation_task_source().queue(box DedicatedMediaSourceFailureTask::new(self), + GlobalRef::Window(&window)); } // https://html.spec.whatwg.org/multipage/#dedicated-media-source-failure-steps diff --git a/components/script/dom/storage.rs b/components/script/dom/storage.rs index 11dfc3ab5d2..d6d1e1968f8 100644 --- a/components/script/dom/storage.rs +++ b/components/script/dom/storage.rs @@ -161,7 +161,8 @@ impl Storage { let window = global_ref.as_window(); let task_source = window.dom_manipulation_task_source(); let trusted_storage = Trusted::new(self); - task_source.queue(box StorageEventRunnable::new(trusted_storage, key, old_value, new_value), window).unwrap(); + task_source.queue(box StorageEventRunnable::new(trusted_storage, key, old_value, new_value), + global_ref).unwrap(); } } diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 788ec212a72..4fd9bc32bcc 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1227,7 +1227,7 @@ impl ScriptThread { // https://html.spec.whatwg.org/multipage/#the-end step 7 let handler = box DocumentProgressHandler::new(Trusted::new(doc)); - self.dom_manipulation_task_source.queue(handler, doc.window()).unwrap(); + self.dom_manipulation_task_source.queue(handler, GlobalRef::Window(doc.window())).unwrap(); self.constellation_chan.send(ConstellationMsg::LoadComplete(pipeline)).unwrap(); } diff --git a/components/script/task_source/dom_manipulation.rs b/components/script/task_source/dom_manipulation.rs index b8bad662353..4f5384ae2ed 100644 --- a/components/script/task_source/dom_manipulation.rs +++ b/components/script/task_source/dom_manipulation.rs @@ -2,11 +2,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use dom::bindings::global::GlobalRef; use dom::bindings::refcounted::Trusted; use dom::event::{EventBubbles, EventCancelable, EventRunnable, SimpleEventRunnable}; use dom::eventtarget::EventTarget; use dom::window::Window; -use script_thread::{MainThreadScriptMsg, Runnable, ScriptThread}; +use script_thread::{MainThreadScriptMsg, Runnable, RunnableWrapper, ScriptThread}; use std::result::Result; use std::sync::mpsc::Sender; use string_cache::Atom; @@ -16,8 +17,12 @@ use task_source::TaskSource; pub struct DOMManipulationTaskSource(pub Sender<MainThreadScriptMsg>); impl TaskSource for DOMManipulationTaskSource { - fn queue<T: Runnable + Send + 'static>(&self, msg: Box<T>, window: &Window) -> Result<(), ()> { - let msg = DOMManipulationTask(window.get_runnable_wrapper().wrap_runnable(msg)); + fn queue_with_wrapper<T>(&self, + msg: Box<T>, + wrapper: &RunnableWrapper) + -> Result<(), ()> + where T: Runnable + Send + 'static { + let msg = DOMManipulationTask(wrapper.wrap_runnable(msg)); self.0.send(MainThreadScriptMsg::DOMManipulation(msg)).map_err(|_| ()) } } @@ -36,7 +41,7 @@ impl DOMManipulationTaskSource { bubbles: bubbles, cancelable: cancelable, }; - let _ = self.queue(runnable, window); + let _ = self.queue(runnable, GlobalRef::Window(window)); } pub fn queue_simple_event(&self, target: &EventTarget, name: Atom, window: &Window) { @@ -45,7 +50,7 @@ impl DOMManipulationTaskSource { target: target, name: name, }; - let _ = self.queue(runnable, window); + let _ = self.queue(runnable, GlobalRef::Window(window)); } } diff --git a/components/script/task_source/mod.rs b/components/script/task_source/mod.rs index 48fc775d959..cb607c57acb 100644 --- a/components/script/task_source/mod.rs +++ b/components/script/task_source/mod.rs @@ -8,10 +8,17 @@ pub mod history_traversal; pub mod networking; pub mod user_interaction; -use dom::window::Window; -use script_thread::Runnable; +use dom::bindings::global::GlobalRef; +use script_thread::{Runnable, RunnableWrapper}; use std::result::Result; pub trait TaskSource { - fn queue<T: Runnable + Send + 'static>(&self, msg: Box<T>, window: &Window) -> Result<(), ()>; + fn queue_with_wrapper<T>(&self, + msg: Box<T>, + wrapper: &RunnableWrapper) + -> Result<(), ()> + where T: Runnable + Send + 'static; + fn queue<T: Runnable + Send + 'static>(&self, msg: Box<T>, global: GlobalRef) -> Result<(), ()> { + self.queue_with_wrapper(msg, &global.get_runnable_wrapper()) + } } diff --git a/components/script/task_source/user_interaction.rs b/components/script/task_source/user_interaction.rs index 2f4c0923801..cddafb80ee4 100644 --- a/components/script/task_source/user_interaction.rs +++ b/components/script/task_source/user_interaction.rs @@ -2,11 +2,12 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +use dom::bindings::global::GlobalRef; use dom::bindings::refcounted::Trusted; use dom::event::{EventBubbles, EventCancelable, EventRunnable}; use dom::eventtarget::EventTarget; use dom::window::Window; -use script_thread::{MainThreadScriptMsg, Runnable, ScriptThread}; +use script_thread::{MainThreadScriptMsg, Runnable, RunnableWrapper, ScriptThread}; use std::result::Result; use std::sync::mpsc::Sender; use string_cache::Atom; @@ -16,8 +17,12 @@ use task_source::TaskSource; pub struct UserInteractionTaskSource(pub Sender<MainThreadScriptMsg>); impl TaskSource for UserInteractionTaskSource { - fn queue<T: Runnable + Send + 'static>(&self, msg: Box<T>, window: &Window) -> Result<(), ()> { - let msg = UserInteractionTask(window.get_runnable_wrapper().wrap_runnable(msg)); + fn queue_with_wrapper<T>(&self, + msg: Box<T>, + wrapper: &RunnableWrapper) + -> Result<(), ()> + where T: Runnable + Send + 'static { + let msg = UserInteractionTask(wrapper.wrap_runnable(msg)); self.0.send(MainThreadScriptMsg::UserInteraction(msg)).map_err(|_| ()) } } @@ -36,7 +41,7 @@ impl UserInteractionTaskSource { bubbles: bubbles, cancelable: cancelable, }; - let _ = self.queue(runnable, window); + let _ = self.queue(runnable, GlobalRef::Window(window)); } } |