diff options
author | bors-servo <servo-ops@mozilla.com> | 2020-07-07 01:24:03 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-07 01:24:03 -0400 |
commit | cbbbe16936151ba5febc01fd3e893203ce0d32df (patch) | |
tree | 7c8d01440934f84b3b2b85ccb6608a66e3fc8333 /components/script/dom/globalscope.rs | |
parent | 4a0cd44ee5f4408cee4d343a40c0359a727a6b9d (diff) | |
parent | 2d7effddefde3210c900200ac599ec5bf0b8d713 (diff) | |
download | servo-cbbbe16936151ba5febc01fd3e893203ce0d32df.tar.gz servo-cbbbe16936151ba5febc01fd3e893203ce0d32df.zip |
Auto merge of #27088 - jdm:group, r=ferjm
Implement Console grouping APIs.
These are used by Hubs and other sites we want to run.
---
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #9274
- [x] These changes do not require tests because we can't test stdout content or devtools messages.
Diffstat (limited to 'components/script/dom/globalscope.rs')
-rw-r--r-- | components/script/dom/globalscope.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs index b82af6a1394..ea25d443ccb 100644 --- a/components/script/dom/globalscope.rs +++ b/components/script/dom/globalscope.rs @@ -295,6 +295,9 @@ pub struct GlobalScope { /// currect https state (from previous request) https_state: Cell<HttpsState>, + + /// The stack of active group labels for the Console APIs. + console_group_stack: DomRefCell<Vec<DOMString>>, } /// A wrapper for glue-code between the ipc router and the event-loop. @@ -744,6 +747,7 @@ impl GlobalScope { gpu_id_hub, frozen_supported_performance_entry_types: DomRefCell::new(Default::default()), https_state: Cell::new(HttpsState::None), + console_group_stack: DomRefCell::new(Vec::new()), } } @@ -2934,6 +2938,21 @@ impl GlobalScope { pub fn wgpu_id_hub(&self) -> Arc<Mutex<Identities>> { self.gpu_id_hub.clone() } + + pub(crate) fn current_group_label(&self) -> Option<DOMString> { + self.console_group_stack + .borrow() + .last() + .map(|label| DOMString::from(format!("[{}]", label))) + } + + pub(crate) fn push_console_group(&self, group: DOMString) { + self.console_group_stack.borrow_mut().push(group); + } + + pub(crate) fn pop_console_group(&self) { + let _ = self.console_group_stack.borrow_mut().pop(); + } } fn timestamp_in_ms(time: Timespec) -> u64 { |