diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2016-09-27 14:39:44 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2016-10-06 20:59:10 +0200 |
commit | d7c2da450bb7a4e1b393c1260cd13ec658d408f0 (patch) | |
tree | 7a4395008bbc5e4df8b6ada7147da4888af767d4 | |
parent | 3e5c0c386c425e51067038228561e78d10c80a53 (diff) | |
download | servo-d7c2da450bb7a4e1b393c1260cd13ec658d408f0.tar.gz servo-d7c2da450bb7a4e1b393c1260cd13ec658d408f0.zip |
Introduce GlobalScope::live_devtools_updates
-rw-r--r-- | components/script/devtools.rs | 3 | ||||
-rw-r--r-- | components/script/dom/bindings/global.rs | 9 | ||||
-rw-r--r-- | components/script/dom/dedicatedworkerglobalscope.rs | 2 | ||||
-rw-r--r-- | components/script/dom/globalscope.rs | 13 | ||||
-rw-r--r-- | components/script/dom/serviceworkerglobalscope.rs | 2 | ||||
-rw-r--r-- | components/script/dom/window.rs | 13 | ||||
-rw-r--r-- | components/script/dom/workerglobalscope.rs | 9 | ||||
-rw-r--r-- | components/script/script_thread.rs | 6 |
8 files changed, 20 insertions, 37 deletions
diff --git a/components/script/devtools.rs b/components/script/devtools.rs index d515d1fb99a..9da8093f287 100644 --- a/components/script/devtools.rs +++ b/components/script/devtools.rs @@ -20,6 +20,7 @@ use dom::bindings::reflector::Reflectable; use dom::bindings::str::DOMString; use dom::browsingcontext::BrowsingContext; use dom::element::Element; +use dom::globalscope::GlobalScope; use dom::node::Node; use dom::window::Window; use ipc_channel::ipc::IpcSender; @@ -245,7 +246,7 @@ pub fn handle_modify_attribute(context: &BrowsingContext, } } -pub fn handle_wants_live_notifications(global: &GlobalRef, send_notifications: bool) { +pub fn handle_wants_live_notifications(global: &GlobalScope, send_notifications: bool) { global.set_devtools_wants_updates(send_notifications); } diff --git a/components/script/dom/bindings/global.rs b/components/script/dom/bindings/global.rs index b49a3b51ba3..fdfd5edd82a 100644 --- a/components/script/dom/bindings/global.rs +++ b/components/script/dom/bindings/global.rs @@ -258,15 +258,6 @@ impl<'a> GlobalRef<'a> { ) } - /// Set the `bool` value to indicate whether developer tools has requested - /// updates from the global - pub fn set_devtools_wants_updates(&self, send_updates: bool) { - match *self { - GlobalRef::Window(window) => window.set_devtools_wants_updates(send_updates), - GlobalRef::Worker(worker) => worker.set_devtools_wants_updates(send_updates), - } - } - /// Schedule the given `callback` to be invoked after at least `duration` milliseconds have /// passed. pub fn schedule_callback(&self, diff --git a/components/script/dom/dedicatedworkerglobalscope.rs b/components/script/dom/dedicatedworkerglobalscope.rs index 49a46b88575..f68d27a6871 100644 --- a/components/script/dom/dedicatedworkerglobalscope.rs +++ b/components/script/dom/dedicatedworkerglobalscope.rs @@ -307,7 +307,7 @@ impl DedicatedWorkerGlobalScope { DevtoolScriptControlMsg::GetCachedMessages(pipe_id, message_types, sender) => devtools::handle_get_cached_messages(pipe_id, message_types, sender), DevtoolScriptControlMsg::WantsLiveNotifications(_pipe_id, bool_val) => - devtools::handle_wants_live_notifications(&global_ref, bool_val), + devtools::handle_wants_live_notifications(self.upcast(), bool_val), _ => debug!("got an unusable devtools control message inside the worker!"), } }, diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index a09e727f772..e5f42c3f9ed 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -15,6 +15,10 @@ pub struct GlobalScope { eventtarget: EventTarget, crypto: MutNullableHeap<JS<Crypto>>, next_worker_id: Cell<WorkerId>, + + /// A flag to indicate whether the developer tools has requested + /// live updates from the worker. + devtools_wants_updates: Cell<bool>, } impl GlobalScope { @@ -23,6 +27,7 @@ impl GlobalScope { eventtarget: EventTarget::new_inherited(), crypto: Default::default(), next_worker_id: Cell::new(WorkerId(0)), + devtools_wants_updates: Default::default(), } } @@ -49,4 +54,12 @@ impl GlobalScope { self.next_worker_id.set(WorkerId(id_num + 1)); worker_id } + + pub fn live_devtools_updates(&self) -> bool { + self.devtools_wants_updates.get() + } + + pub fn set_devtools_wants_updates(&self, value: bool) { + self.devtools_wants_updates.set(value); + } } diff --git a/components/script/dom/serviceworkerglobalscope.rs b/components/script/dom/serviceworkerglobalscope.rs index d635f1cd41f..a65eb325138 100644 --- a/components/script/dom/serviceworkerglobalscope.rs +++ b/components/script/dom/serviceworkerglobalscope.rs @@ -212,7 +212,7 @@ impl ServiceWorkerGlobalScope { DevtoolScriptControlMsg::GetCachedMessages(pipe_id, message_types, sender) => devtools::handle_get_cached_messages(pipe_id, message_types, sender), DevtoolScriptControlMsg::WantsLiveNotifications(_pipe_id, bool_val) => - devtools::handle_wants_live_notifications(&global_ref, bool_val), + devtools::handle_wants_live_notifications(self.upcast(), bool_val), _ => debug!("got an unusable devtools control message inside the worker!"), } true diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index 406371261d0..046246191a1 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -192,10 +192,6 @@ pub struct Window { #[ignore_heap_size_of = "channels are hard"] devtools_marker_sender: DOMRefCell<Option<IpcSender<TimelineMarker>>>, - /// A flag to indicate whether the developer tools have requested live updates of - /// page changes. - devtools_wants_updates: Cell<bool>, - /// Pending resize event, if any. resize_event: Cell<Option<(WindowSizeData, WindowSizeType)>>, @@ -1474,10 +1470,6 @@ impl Window { had_clip_rect } - pub fn set_devtools_wants_updates(&self, value: bool) { - self.devtools_wants_updates.set(value); - } - // https://html.spec.whatwg.org/multipage/#accessing-other-browsing-contexts pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option<Root<Window>> { None @@ -1664,7 +1656,6 @@ impl Window { devtools_marker_sender: DOMRefCell::new(None), devtools_markers: DOMRefCell::new(HashSet::new()), - devtools_wants_updates: Cell::new(false), webdriver_script_chan: DOMRefCell::new(None), ignore_further_async_events: Arc::new(AtomicBool::new(false)), error_reporter: error_reporter, @@ -1680,10 +1671,6 @@ impl Window { &self.console_timers } - pub fn live_devtools_updates(&self) -> bool { - return self.devtools_wants_updates.get(); - } - /// https://html.spec.whatwg.org/multipage/#report-the-error pub fn report_an_error(&self, error_info: ErrorInfo, value: HandleValue) { // Step 1. diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs index b72ae48251c..cc0a9dfcbf7 100644 --- a/components/script/dom/workerglobalscope.rs +++ b/components/script/dom/workerglobalscope.rs @@ -107,10 +107,6 @@ pub struct WorkerGlobalScope { /// `IpcSender` doesn't exist from_devtools_receiver: Receiver<DevtoolScriptControlMsg>, - /// A flag to indicate whether the developer tools has requested live updates - /// from the worker - devtools_wants_updates: Cell<bool>, - #[ignore_heap_size_of = "Defined in std"] constellation_chan: IpcSender<ConstellationMsg>, @@ -150,7 +146,6 @@ impl WorkerGlobalScope { to_devtools_sender: init.to_devtools_sender, from_devtools_sender: init.from_devtools_sender, from_devtools_receiver: from_devtools_receiver, - devtools_wants_updates: Cell::new(false), constellation_chan: init.constellation_chan, scheduler_chan: init.scheduler_chan, console_timers: TimerSet::new(), @@ -472,10 +467,6 @@ impl WorkerGlobalScope { self.timers.fire_timer(timer_id, self); } - pub fn set_devtools_wants_updates(&self, value: bool) { - self.devtools_wants_updates.set(value); - } - pub fn close(&self) { if let Some(ref closing) = self.closing { closing.store(true, Ordering::SeqCst); diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 61ecacda815..0b26647f3e8 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -40,6 +40,7 @@ use dom::browsingcontext::BrowsingContext; use dom::document::{Document, DocumentProgressHandler, DocumentSource, FocusType, IsHTMLDocument}; use dom::element::Element; use dom::event::{Event, EventBubbles, EventCancelable}; +use dom::globalscope::GlobalScope; use dom::htmlanchorelement::HTMLAnchorElement; use dom::node::{Node, NodeDamage, window_from_node}; use dom::serviceworker::TrustedServiceWorkerAddress; @@ -1004,8 +1005,7 @@ impl ScriptThread { Some(browsing_context) => browsing_context.active_window(), None => return warn!("Message sent to closed pipeline {}.", id), }; - let global_ref = GlobalRef::Window(window.r()); - devtools::handle_wants_live_notifications(&global_ref, to_send) + devtools::handle_wants_live_notifications(window.upcast(), to_send) }, DevtoolScriptControlMsg::SetTimelineMarkers(_pipeline_id, marker_types, reply) => devtools::handle_set_timeline_markers(&context, marker_types, reply), @@ -2153,7 +2153,7 @@ impl ScriptThread { }; let window = context.active_window(); - if window.live_devtools_updates() { + if window.upcast::<GlobalScope>().live_devtools_updates() { let css_error = CSSError { filename: filename, line: line, |