aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
authorConnor Brewster <connor.brewster@eagles.oc.edu>2016-07-06 10:46:39 -0600
committerConnor Brewster <connor.brewster@eagles.oc.edu>2016-07-06 10:46:56 -0600
commitd6f4dc06df4412d7fd58170914c941e34c5c799b (patch)
treee2b29840007d1877b2058d46a593c89e5e38f729 /components/script
parent68fb9ebc413f9cfc1ad4ca578d904c164836db74 (diff)
downloadservo-d6f4dc06df4412d7fd58170914c941e34c5c799b.tar.gz
servo-d6f4dc06df4412d7fd58170914c941e34c5c799b.zip
Combined DOMManipulationTask runnable variants into a single variant
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/htmldetailselement.rs2
-rw-r--r--components/script/dom/htmlformelement.rs3
-rw-r--r--components/script/dom/htmlimageelement.rs2
-rw-r--r--components/script/dom/htmlmediaelement.rs8
-rw-r--r--components/script/dom/storage.rs8
-rw-r--r--components/script/script_thread.rs9
-rw-r--r--components/script/task_source/dom_manipulation.rs26
7 files changed, 22 insertions, 36 deletions
diff --git a/components/script/dom/htmldetailselement.rs b/components/script/dom/htmldetailselement.rs
index d63e15178aa..07c85ed6e2e 100644
--- a/components/script/dom/htmldetailselement.rs
+++ b/components/script/dom/htmldetailselement.rs
@@ -79,7 +79,7 @@ impl VirtualMethods for HTMLDetailsElement {
element: details,
toggle_number: counter
};
- let _ = task_source.queue(DOMManipulationTask::FireToggleEvent(runnable));
+ let _ = task_source.queue(DOMManipulationTask::Runnable(runnable));
}
}
}
diff --git a/components/script/dom/htmlformelement.rs b/components/script/dom/htmlformelement.rs
index b31d33d5685..90baba4ebb1 100644
--- a/components/script/dom/htmlformelement.rs
+++ b/components/script/dom/htmlformelement.rs
@@ -484,8 +484,7 @@ impl HTMLFormElement {
};
// Step 3
- window.dom_manipulation_task_source().queue(
- DOMManipulationTask::PlannedNavigation(nav)).unwrap();
+ window.dom_manipulation_task_source().queue(DOMManipulationTask::Runnable(nav)).unwrap();
}
/// Interactively validate the constraints of form elements
diff --git a/components/script/dom/htmlimageelement.rs b/components/script/dom/htmlimageelement.rs
index 2b61a800a1a..27152ca93f4 100644
--- a/components/script/dom/htmlimageelement.rs
+++ b/components/script/dom/htmlimageelement.rs
@@ -183,7 +183,7 @@ impl HTMLImageElement {
src: src.into(),
});
let task = window.dom_manipulation_task_source();
- let _ = task.queue(DOMManipulationTask::Miscellaneous(runnable));
+ let _ = task.queue(DOMManipulationTask::Runnable(runnable));
}
}
}
diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs
index 49d42c31f1a..7cfe19ba789 100644
--- a/components/script/dom/htmlmediaelement.rs
+++ b/components/script/dom/htmlmediaelement.rs
@@ -242,7 +242,7 @@ impl HTMLMediaElement {
elem: Trusted::new(self),
};
let win = window_from_node(self);
- let _ = win.dom_manipulation_task_source().queue(DOMManipulationTask::MediaTask(box task));
+ let _ = win.dom_manipulation_task_source().queue(DOMManipulationTask::Runnable(box task));
}
// https://html.spec.whatwg.org/multipage/#internal-pause-steps step 2.2
@@ -266,13 +266,13 @@ impl HTMLMediaElement {
elem: Trusted::new(self),
};
let win = window_from_node(self);
- let _ = win.dom_manipulation_task_source().queue(DOMManipulationTask::MediaTask(box task));
+ let _ = win.dom_manipulation_task_source().queue(DOMManipulationTask::Runnable(box task));
}
fn queue_fire_simple_event(&self, type_: &'static str) {
let win = window_from_node(self);
let task = FireSimpleEventTask::new(self, type_);
- let _ = win.dom_manipulation_task_source().queue(DOMManipulationTask::MediaTask(box task));
+ let _ = win.dom_manipulation_task_source().queue(DOMManipulationTask::Runnable(box task));
}
fn fire_simple_event(&self, type_: &str) {
@@ -497,7 +497,7 @@ impl HTMLMediaElement {
fn queue_dedicated_media_source_failure_steps(&self) {
let _ = window_from_node(self).dom_manipulation_task_source().queue(
- DOMManipulationTask::MediaTask(box DedicatedMediaSourceFailureTask::new(self)));
+ DOMManipulationTask::Runnable(box DedicatedMediaSourceFailureTask::new(self)));
}
// 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 03747ed5ab6..65824532209 100644
--- a/components/script/dom/storage.rs
+++ b/components/script/dom/storage.rs
@@ -17,7 +17,7 @@ use dom::urlhelper::UrlHelper;
use ipc_channel::ipc::{self, IpcSender};
use net_traits::IpcSend;
use net_traits::storage_thread::{StorageThreadMsg, StorageType};
-use script_thread::{MainThreadRunnable, ScriptThread};
+use script_thread::{Runnable, ScriptThread};
use task_source::TaskSource;
use task_source::dom_manipulation::DOMManipulationTask;
use url::Url;
@@ -161,7 +161,7 @@ impl Storage {
let global_ref = global_root.r();
let task_source = global_ref.as_window().dom_manipulation_task_source();
let trusted_storage = Trusted::new(self);
- task_source.queue(DOMManipulationTask::SendStorageNotification(
+ task_source.queue(DOMManipulationTask::Runnable(
box StorageEventRunnable::new(trusted_storage, key, old_value, new_value))).unwrap();
}
}
@@ -180,8 +180,8 @@ impl StorageEventRunnable {
}
}
-impl MainThreadRunnable for StorageEventRunnable {
- fn handler(self: Box<StorageEventRunnable>, script_thread: &ScriptThread) {
+impl Runnable for StorageEventRunnable {
+ fn main_thread_handler(self: Box<StorageEventRunnable>, script_thread: &ScriptThread) {
let this = *self;
let storage_root = this.element.root();
let storage = storage_root.r();
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index 05689baac39..788a40532aa 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -200,11 +200,8 @@ impl<T: Runnable + Send> Runnable for CancellableRunnable<T> {
pub trait Runnable {
fn is_cancelled(&self) -> bool { false }
- fn handler(self: Box<Self>);
-}
-
-pub trait MainThreadRunnable {
- fn handler(self: Box<Self>, script_thread: &ScriptThread);
+ fn handler(self: Box<Self>) {}
+ fn main_thread_handler(self: Box<Self>, _script_thread: &ScriptThread) { self.handler(); }
}
enum MixedMessage {
@@ -1223,7 +1220,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(DOMManipulationTask::DocumentProgress(handler)).unwrap();
+ self.dom_manipulation_task_source.queue(DOMManipulationTask::Runnable(handler)).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 fbe864a9005..a1c06f2c09e 100644
--- a/components/script/task_source/dom_manipulation.rs
+++ b/components/script/task_source/dom_manipulation.rs
@@ -5,7 +5,7 @@
use dom::bindings::refcounted::Trusted;
use dom::event::{EventBubbles, EventCancelable};
use dom::eventtarget::EventTarget;
-use script_thread::{MainThreadRunnable, MainThreadScriptMsg, Runnable, ScriptThread};
+use script_thread::{MainThreadScriptMsg, Runnable, ScriptThread};
use std::result::Result;
use std::sync::mpsc::Sender;
use string_cache::Atom;
@@ -39,21 +39,12 @@ impl DOMManipulationTaskSource {
}
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(Trusted<EventTarget>, Atom, EventBubbles, EventCancelable),
// https://html.spec.whatwg.org/multipage/#fire-a-simple-event
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
- MediaTask(Box<Runnable + Send>),
- // https://html.spec.whatwg.org/multipage/#planned-navigation
- PlannedNavigation(Box<Runnable + Send>),
- // https://html.spec.whatwg.org/multipage/#send-a-storage-notification
- SendStorageNotification(Box<MainThreadRunnable + Send>),
- Miscellaneous(Box<Runnable + Send>),
+
+ Runnable(Box<Runnable + Send>),
}
impl DOMManipulationTask {
@@ -61,7 +52,6 @@ impl DOMManipulationTask {
use self::DOMManipulationTask::*;
match self {
- DocumentProgress(runnable) => runnable.handler(),
FireEvent(element, name, bubbles, cancelable) => {
let target = element.root();
target.fire_event(&*name, bubbles, cancelable);
@@ -70,11 +60,11 @@ impl DOMManipulationTask {
let target = element.root();
target.fire_simple_event(&*name);
}
- FireToggleEvent(runnable) => runnable.handler(),
- MediaTask(runnable) => runnable.handler(),
- PlannedNavigation(runnable) => runnable.handler(),
- SendStorageNotification(runnable) => runnable.handler(script_thread),
- Miscellaneous(runnable) => runnable.handler(),
+ Runnable(runnable) => {
+ if !runnable.is_cancelled() {
+ runnable.main_thread_handler(script_thread);
+ }
+ }
}
}
}