aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/script/dom/bindings/global.rs4
-rw-r--r--components/script/dom/document.rs6
-rw-r--r--components/script/dom/htmldetailselement.rs1
-rw-r--r--components/script/dom/htmlformelement.rs1
-rw-r--r--components/script/dom/htmlmediaelement.rs1
-rw-r--r--components/script/dom/htmlscriptelement.rs8
-rw-r--r--components/script/dom/storage.rs1
-rw-r--r--components/script/dom/window.rs2
-rw-r--r--components/script/task_source/dom_manipulation.rs28
9 files changed, 33 insertions, 19 deletions
diff --git a/components/script/dom/bindings/global.rs b/components/script/dom/bindings/global.rs
index adb94c9d2ca..cd0dbfabaa8 100644
--- a/components/script/dom/bindings/global.rs
+++ b/components/script/dom/bindings/global.rs
@@ -26,7 +26,7 @@ use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort};
use script_thread::{MainThreadScriptChan, ScriptThread};
use script_traits::{MsDuration, ScriptMsg as ConstellationMsg, TimerEventRequest};
use task_source::TaskSource;
-use task_source::dom_manipulation::DOMManipulationTask;
+use task_source::dom_manipulation::{DOMManipulationTask, DOMManipulationTaskSource};
use timers::{OneshotTimerCallback, OneshotTimerHandle};
use url::Url;
@@ -193,7 +193,7 @@ impl<'a> GlobalRef<'a> {
/// `TaskSource` used to queue DOM manipulation messages to the event loop of this global's
/// thread.
- pub fn dom_manipulation_task_source(&self) -> Box<TaskSource<DOMManipulationTask> + Send> {
+ pub fn dom_manipulation_task_source(&self) -> DOMManipulationTaskSource {
match *self {
GlobalRef::Window(ref window) => window.dom_manipulation_task_source(),
GlobalRef::Worker(_) => unimplemented!(),
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 7729fe5a29a..56f8e98399f 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -1471,10 +1471,8 @@ impl Document {
update_with_current_time_ms(&self.dom_content_loaded_event_start);
- let doctarget = Trusted::new(self.upcast::<EventTarget>());
- let task_source = self.window().dom_manipulation_task_source();
- let _ = task_source.queue(DOMManipulationTask::FireEvent(
- atom!("DOMContentLoaded"), doctarget, EventBubbles::Bubbles, EventCancelable::NotCancelable));
+ self.window().dom_manipulation_task_source().queue_event(self.upcast(), atom!("DOMContentLoaded"),
+ EventBubbles::Bubbles, EventCancelable::NotCancelable);
self.window().reflow(ReflowGoal::ForDisplay,
ReflowQueryType::NoQuery,
ReflowReason::DOMContentLoaded);
diff --git a/components/script/dom/htmldetailselement.rs b/components/script/dom/htmldetailselement.rs
index cde3aef6f86..d63e15178aa 100644
--- a/components/script/dom/htmldetailselement.rs
+++ b/components/script/dom/htmldetailselement.rs
@@ -18,6 +18,7 @@ use dom::virtualmethods::VirtualMethods;
use script_thread::Runnable;
use std::cell::Cell;
use string_cache::Atom;
+use task_source::TaskSource;
use task_source::dom_manipulation::DOMManipulationTask;
#[dom_struct]
diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs
index 7f54fc7842b..30ab440b00e 100644
--- a/components/script/dom/htmlformelement.rs
+++ b/components/script/dom/htmlformelement.rs
@@ -50,6 +50,7 @@ use std::borrow::ToOwned;
use std::cell::Cell;
use std::sync::mpsc::Sender;
use string_cache::Atom;
+use task_source::TaskSource;
use task_source::dom_manipulation::DOMManipulationTask;
use url::form_urlencoded;
use util::str::split_html_space_chars;
diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs
index 9532de74677..7256ae1b131 100644
--- a/components/script/dom/htmlmediaelement.rs
+++ b/components/script/dom/htmlmediaelement.rs
@@ -32,6 +32,7 @@ use script_thread::{Runnable, ScriptThread};
use std::cell::Cell;
use std::sync::{Arc, Mutex};
use string_cache::Atom;
+use task_source::TaskSource;
use task_source::dom_manipulation::DOMManipulationTask;
use time::{self, Timespec, Duration};
use url::Url;
diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs
index edd2152844e..780e5aa064b 100644
--- a/components/script/dom/htmlscriptelement.rs
+++ b/components/script/dom/htmlscriptelement.rs
@@ -462,16 +462,12 @@ impl HTMLScriptElement {
if external {
self.dispatch_load_event();
} else {
- let script_element = Trusted::new(self.upcast::<EventTarget>());
- let task_source = window.dom_manipulation_task_source();
- task_source.queue(DOMManipulationTask::FireSimpleEvent(atom!("load"), script_element)).unwrap();
+ window.dom_manipulation_task_source().queue_simple_event(self.upcast(), atom!("load"));
}
}
pub fn queue_error_event(&self) {
- let task_source = window_from_node(self).dom_manipulation_task_source();
- let script_element = Trusted::new(self.upcast::<EventTarget>());
- task_source.queue(DOMManipulationTask::FireSimpleEvent(atom!("error"), script_element)).unwrap();
+ window_from_node(self).dom_manipulation_task_source().queue_simple_event(self.upcast(), atom!("error"));
}
pub fn dispatch_before_script_execute_event(&self) -> bool {
diff --git a/components/script/dom/storage.rs b/components/script/dom/storage.rs
index 001fd19df3b..03747ed5ab6 100644
--- a/components/script/dom/storage.rs
+++ b/components/script/dom/storage.rs
@@ -18,6 +18,7 @@ use ipc_channel::ipc::{self, IpcSender};
use net_traits::IpcSend;
use net_traits::storage_thread::{StorageThreadMsg, StorageType};
use script_thread::{MainThreadRunnable, ScriptThread};
+use task_source::TaskSource;
use task_source::dom_manipulation::DOMManipulationTask;
use url::Url;
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index 475fef1a0ad..0ed85f576d9 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -280,7 +280,7 @@ impl Window {
self.js_runtime.borrow().as_ref().unwrap().cx()
}
- pub fn dom_manipulation_task_source(&self) -> Box<TaskSource<DOMManipulationTask> + Send> {
+ pub fn dom_manipulation_task_source(&self) -> DOMManipulationTaskSource {
self.dom_manipulation_task_source.clone()
}
diff --git a/components/script/task_source/dom_manipulation.rs b/components/script/task_source/dom_manipulation.rs
index 05b0722f889..67cac79c48c 100644
--- a/components/script/task_source/dom_manipulation.rs
+++ b/components/script/task_source/dom_manipulation.rs
@@ -21,8 +21,24 @@ impl TaskSource<DOMManipulationTask> for DOMManipulationTaskSource {
}
impl DOMManipulationTaskSource {
- pub fn clone(&self) -> Box<TaskSource<DOMManipulationTask> + Send> {
- box DOMManipulationTaskSource((&self.0).clone())
+ pub fn queue_event(&self,
+ target: &EventTarget,
+ name: Atom,
+ bubbles: EventBubbles,
+ cancelable: EventCancelable) {
+ let target = Trusted::new(target);
+ let _ = self.0.send(MainThreadScriptMsg::DOMManipulation(DOMManipulationTask::FireEvent(
+ target, name, bubbles, cancelable)));
+ }
+
+ pub fn queue_simple_event(&self, target: &EventTarget, name: Atom) {
+ let target = Trusted::new(target);
+ let _ = self.0.send(MainThreadScriptMsg::DOMManipulation(DOMManipulationTask::FireSimpleEvent(
+ target, name)));
+ }
+
+ pub fn clone(&self) -> DOMManipulationTaskSource {
+ DOMManipulationTaskSource((&self.0).clone())
}
}
@@ -30,9 +46,9 @@ pub enum DOMManipulationTask {
// https://html.spec.whatwg.org/multipage/#the-end step 7
DocumentProgress(Box<Runnable + Send>),
// https://dom.spec.whatwg.org/#concept-event-fire
- FireEvent(Atom, Trusted<EventTarget>, EventBubbles, EventCancelable),
+ FireEvent(Trusted<EventTarget>, Atom, EventBubbles, EventCancelable),
// https://html.spec.whatwg.org/multipage/#fire-a-simple-event
- FireSimpleEvent(Atom, Trusted<EventTarget>),
+ FireSimpleEvent(Trusted<EventTarget>, Atom),
// https://html.spec.whatwg.org/multipage/#details-notification-task-steps
FireToggleEvent(Box<Runnable + Send>),
// Placeholder until there's a real media element task queue implementation
@@ -49,11 +65,11 @@ impl DOMManipulationTask {
match self {
DocumentProgress(runnable) => runnable.handler(),
- FireEvent(name, element, bubbles, cancelable) => {
+ FireEvent(element, name, bubbles, cancelable) => {
let target = element.root();
target.fire_event(&*name, bubbles, cancelable);
}
- FireSimpleEvent(name, element) => {
+ FireSimpleEvent(element, name) => {
let target = element.root();
target.fire_simple_event(&*name);
}