aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_task.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/script_task.rs')
-rw-r--r--components/script/script_task.rs17
1 files changed, 13 insertions, 4 deletions
diff --git a/components/script/script_task.rs b/components/script/script_task.rs
index 4901a3e9e20..17259132eb6 100644
--- a/components/script/script_task.rs
+++ b/components/script/script_task.rs
@@ -24,7 +24,7 @@ use dom::uievent::UIEvent;
use dom::eventtarget::{EventTarget, EventTargetHelpers};
use dom::node;
use dom::node::{ElementNodeTypeId, Node, NodeHelpers};
-use dom::window::{TimerId, Window, WindowHelpers};
+use dom::window::{Window, WindowHelpers};
use dom::worker::{Worker, TrustedWorkerAddress};
use dom::xmlhttprequest::{TrustedXHRAddress, XMLHttpRequest, XHRProgress};
use html::hubbub_html_parser::{InputString, InputUrl, HtmlParserResult, HtmlDiscoveredScript};
@@ -32,6 +32,7 @@ use html::hubbub_html_parser;
use layout_interface::{ScriptLayoutChan, LayoutChan, ReflowForDisplay};
use layout_interface;
use page::{Page, IterablePage, Frame};
+use timers::TimerId;
use devtools_traits;
use devtools_traits::{DevtoolsControlChan, DevtoolsControlPort, NewGlobal, NodeInfo, GetRootNode};
@@ -73,6 +74,11 @@ use std::u32;
local_data_key!(pub StackRoots: *const RootCollection)
+pub enum TimerSource {
+ FromWindow(PipelineId),
+ FromWorker
+}
+
/// Messages used to control script event loops, such as ScriptTask and
/// DedicatedWorkerGlobalScope.
pub enum ScriptMsg {
@@ -85,8 +91,10 @@ pub enum ScriptMsg {
/// Instructs the script task to send a navigate message to
/// the constellation (only dispatched to ScriptTask).
NavigateMsg(NavigationDirection),
- /// Fires a JavaScript timeout (only dispatched to ScriptTask).
- FireTimerMsg(PipelineId, TimerId),
+ /// Fires a JavaScript timeout
+ /// TimerSource must be FromWindow when dispatched to ScriptTask and
+ /// must be FromWorker when dispatched to a DedicatedGlobalWorkerScope
+ FireTimerMsg(TimerSource, TimerId),
/// Notifies the script that a window associated with a particular pipeline
/// should be closed (only dispatched to ScriptTask).
ExitWindowMsg(PipelineId),
@@ -497,7 +505,8 @@ impl ScriptTask {
FromScript(TriggerLoadMsg(id, load_data)) => self.trigger_load(id, load_data),
FromScript(TriggerFragmentMsg(id, url)) => self.trigger_fragment(id, url),
FromConstellation(SendEventMsg(id, event)) => self.handle_event(id, event),
- FromScript(FireTimerMsg(id, timer_id)) => self.handle_fire_timer_msg(id, timer_id),
+ FromScript(FireTimerMsg(FromWindow(id), timer_id)) => self.handle_fire_timer_msg(id, timer_id),
+ FromScript(FireTimerMsg(FromWorker, _)) => fail!("Worker timeouts must not be sent to script task"),
FromScript(NavigateMsg(direction)) => self.handle_navigate_msg(direction),
FromConstellation(ReflowCompleteMsg(id, reflow_id)) => self.handle_reflow_complete_msg(id, reflow_id),
FromConstellation(ResizeInactiveMsg(id, new_size)) => self.handle_resize_inactive_msg(id, new_size),