mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +01:00
Introduce GlobalScope::live_devtools_updates
This commit is contained in:
parent
3e5c0c386c
commit
d7c2da450b
8 changed files with 20 additions and 37 deletions
|
@ -20,6 +20,7 @@ use dom::bindings::reflector::Reflectable;
|
||||||
use dom::bindings::str::DOMString;
|
use dom::bindings::str::DOMString;
|
||||||
use dom::browsingcontext::BrowsingContext;
|
use dom::browsingcontext::BrowsingContext;
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::node::Node;
|
use dom::node::Node;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
use ipc_channel::ipc::IpcSender;
|
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);
|
global.set_devtools_wants_updates(send_notifications);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
/// Schedule the given `callback` to be invoked after at least `duration` milliseconds have
|
||||||
/// passed.
|
/// passed.
|
||||||
pub fn schedule_callback(&self,
|
pub fn schedule_callback(&self,
|
||||||
|
|
|
@ -307,7 +307,7 @@ impl DedicatedWorkerGlobalScope {
|
||||||
DevtoolScriptControlMsg::GetCachedMessages(pipe_id, message_types, sender) =>
|
DevtoolScriptControlMsg::GetCachedMessages(pipe_id, message_types, sender) =>
|
||||||
devtools::handle_get_cached_messages(pipe_id, message_types, sender),
|
devtools::handle_get_cached_messages(pipe_id, message_types, sender),
|
||||||
DevtoolScriptControlMsg::WantsLiveNotifications(_pipe_id, bool_val) =>
|
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!"),
|
_ => debug!("got an unusable devtools control message inside the worker!"),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -15,6 +15,10 @@ pub struct GlobalScope {
|
||||||
eventtarget: EventTarget,
|
eventtarget: EventTarget,
|
||||||
crypto: MutNullableHeap<JS<Crypto>>,
|
crypto: MutNullableHeap<JS<Crypto>>,
|
||||||
next_worker_id: Cell<WorkerId>,
|
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 {
|
impl GlobalScope {
|
||||||
|
@ -23,6 +27,7 @@ impl GlobalScope {
|
||||||
eventtarget: EventTarget::new_inherited(),
|
eventtarget: EventTarget::new_inherited(),
|
||||||
crypto: Default::default(),
|
crypto: Default::default(),
|
||||||
next_worker_id: Cell::new(WorkerId(0)),
|
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));
|
self.next_worker_id.set(WorkerId(id_num + 1));
|
||||||
worker_id
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,7 +212,7 @@ impl ServiceWorkerGlobalScope {
|
||||||
DevtoolScriptControlMsg::GetCachedMessages(pipe_id, message_types, sender) =>
|
DevtoolScriptControlMsg::GetCachedMessages(pipe_id, message_types, sender) =>
|
||||||
devtools::handle_get_cached_messages(pipe_id, message_types, sender),
|
devtools::handle_get_cached_messages(pipe_id, message_types, sender),
|
||||||
DevtoolScriptControlMsg::WantsLiveNotifications(_pipe_id, bool_val) =>
|
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!"),
|
_ => debug!("got an unusable devtools control message inside the worker!"),
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
|
|
|
@ -192,10 +192,6 @@ pub struct Window {
|
||||||
#[ignore_heap_size_of = "channels are hard"]
|
#[ignore_heap_size_of = "channels are hard"]
|
||||||
devtools_marker_sender: DOMRefCell<Option<IpcSender<TimelineMarker>>>,
|
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.
|
/// Pending resize event, if any.
|
||||||
resize_event: Cell<Option<(WindowSizeData, WindowSizeType)>>,
|
resize_event: Cell<Option<(WindowSizeData, WindowSizeType)>>,
|
||||||
|
|
||||||
|
@ -1474,10 +1470,6 @@ impl Window {
|
||||||
had_clip_rect
|
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
|
// https://html.spec.whatwg.org/multipage/#accessing-other-browsing-contexts
|
||||||
pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option<Root<Window>> {
|
pub fn IndexedGetter(&self, _index: u32, _found: &mut bool) -> Option<Root<Window>> {
|
||||||
None
|
None
|
||||||
|
@ -1664,7 +1656,6 @@ impl Window {
|
||||||
|
|
||||||
devtools_marker_sender: DOMRefCell::new(None),
|
devtools_marker_sender: DOMRefCell::new(None),
|
||||||
devtools_markers: DOMRefCell::new(HashSet::new()),
|
devtools_markers: DOMRefCell::new(HashSet::new()),
|
||||||
devtools_wants_updates: Cell::new(false),
|
|
||||||
webdriver_script_chan: DOMRefCell::new(None),
|
webdriver_script_chan: DOMRefCell::new(None),
|
||||||
ignore_further_async_events: Arc::new(AtomicBool::new(false)),
|
ignore_further_async_events: Arc::new(AtomicBool::new(false)),
|
||||||
error_reporter: error_reporter,
|
error_reporter: error_reporter,
|
||||||
|
@ -1680,10 +1671,6 @@ impl Window {
|
||||||
&self.console_timers
|
&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
|
/// https://html.spec.whatwg.org/multipage/#report-the-error
|
||||||
pub fn report_an_error(&self, error_info: ErrorInfo, value: HandleValue) {
|
pub fn report_an_error(&self, error_info: ErrorInfo, value: HandleValue) {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
|
|
|
@ -107,10 +107,6 @@ pub struct WorkerGlobalScope {
|
||||||
/// `IpcSender` doesn't exist
|
/// `IpcSender` doesn't exist
|
||||||
from_devtools_receiver: Receiver<DevtoolScriptControlMsg>,
|
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"]
|
#[ignore_heap_size_of = "Defined in std"]
|
||||||
constellation_chan: IpcSender<ConstellationMsg>,
|
constellation_chan: IpcSender<ConstellationMsg>,
|
||||||
|
|
||||||
|
@ -150,7 +146,6 @@ impl WorkerGlobalScope {
|
||||||
to_devtools_sender: init.to_devtools_sender,
|
to_devtools_sender: init.to_devtools_sender,
|
||||||
from_devtools_sender: init.from_devtools_sender,
|
from_devtools_sender: init.from_devtools_sender,
|
||||||
from_devtools_receiver: from_devtools_receiver,
|
from_devtools_receiver: from_devtools_receiver,
|
||||||
devtools_wants_updates: Cell::new(false),
|
|
||||||
constellation_chan: init.constellation_chan,
|
constellation_chan: init.constellation_chan,
|
||||||
scheduler_chan: init.scheduler_chan,
|
scheduler_chan: init.scheduler_chan,
|
||||||
console_timers: TimerSet::new(),
|
console_timers: TimerSet::new(),
|
||||||
|
@ -472,10 +467,6 @@ impl WorkerGlobalScope {
|
||||||
self.timers.fire_timer(timer_id, self);
|
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) {
|
pub fn close(&self) {
|
||||||
if let Some(ref closing) = self.closing {
|
if let Some(ref closing) = self.closing {
|
||||||
closing.store(true, Ordering::SeqCst);
|
closing.store(true, Ordering::SeqCst);
|
||||||
|
|
|
@ -40,6 +40,7 @@ use dom::browsingcontext::BrowsingContext;
|
||||||
use dom::document::{Document, DocumentProgressHandler, DocumentSource, FocusType, IsHTMLDocument};
|
use dom::document::{Document, DocumentProgressHandler, DocumentSource, FocusType, IsHTMLDocument};
|
||||||
use dom::element::Element;
|
use dom::element::Element;
|
||||||
use dom::event::{Event, EventBubbles, EventCancelable};
|
use dom::event::{Event, EventBubbles, EventCancelable};
|
||||||
|
use dom::globalscope::GlobalScope;
|
||||||
use dom::htmlanchorelement::HTMLAnchorElement;
|
use dom::htmlanchorelement::HTMLAnchorElement;
|
||||||
use dom::node::{Node, NodeDamage, window_from_node};
|
use dom::node::{Node, NodeDamage, window_from_node};
|
||||||
use dom::serviceworker::TrustedServiceWorkerAddress;
|
use dom::serviceworker::TrustedServiceWorkerAddress;
|
||||||
|
@ -1004,8 +1005,7 @@ impl ScriptThread {
|
||||||
Some(browsing_context) => browsing_context.active_window(),
|
Some(browsing_context) => browsing_context.active_window(),
|
||||||
None => return warn!("Message sent to closed pipeline {}.", id),
|
None => return warn!("Message sent to closed pipeline {}.", id),
|
||||||
};
|
};
|
||||||
let global_ref = GlobalRef::Window(window.r());
|
devtools::handle_wants_live_notifications(window.upcast(), to_send)
|
||||||
devtools::handle_wants_live_notifications(&global_ref, to_send)
|
|
||||||
},
|
},
|
||||||
DevtoolScriptControlMsg::SetTimelineMarkers(_pipeline_id, marker_types, reply) =>
|
DevtoolScriptControlMsg::SetTimelineMarkers(_pipeline_id, marker_types, reply) =>
|
||||||
devtools::handle_set_timeline_markers(&context, marker_types, reply),
|
devtools::handle_set_timeline_markers(&context, marker_types, reply),
|
||||||
|
@ -2153,7 +2153,7 @@ impl ScriptThread {
|
||||||
};
|
};
|
||||||
|
|
||||||
let window = context.active_window();
|
let window = context.active_window();
|
||||||
if window.live_devtools_updates() {
|
if window.upcast::<GlobalScope>().live_devtools_updates() {
|
||||||
let css_error = CSSError {
|
let css_error = CSSError {
|
||||||
filename: filename,
|
filename: filename,
|
||||||
line: line,
|
line: line,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue