mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Issue #3236 - Implement timers (setTimeout/setInterval) for workers
This commit is contained in:
parent
fd70b366ae
commit
0d7e13f646
11 changed files with 261 additions and 185 deletions
|
@ -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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue