diff options
Diffstat (limited to 'components/script/dom/document.rs')
-rw-r--r-- | components/script/dom/document.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index 367ce9e2377..e15d735527b 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -356,6 +356,8 @@ pub struct Document { top_level_dom_complete: Cell<u64>, load_event_start: Cell<u64>, load_event_end: Cell<u64>, + unload_event_start: Cell<u64>, + unload_event_end: Cell<u64>, /// <https://html.spec.whatwg.org/multipage/#concept-document-https-state> https_state: Cell<HttpsState>, /// The document's origin. @@ -406,6 +408,8 @@ pub struct Document { fired_unload: Cell<bool>, /// List of responsive images responsive_images: DomRefCell<Vec<Dom<HTMLImageElement>>>, + /// Number of redirects for the document load + redirect_count: Cell<u16>, } #[derive(JSTraceable, MallocSizeOf)] @@ -2290,6 +2294,14 @@ impl Document { self.load_event_end.get() } + pub fn get_unload_event_start(&self) -> u64 { + self.unload_event_start.get() + } + + pub fn get_unload_event_end(&self) -> u64 { + self.unload_event_end.get() + } + pub fn start_tti(&self) { if self.get_interactive_metrics().needs_tti() { self.tti_window.borrow_mut().start_window(); @@ -2654,6 +2666,8 @@ impl Document { top_level_dom_complete: Cell::new(Default::default()), load_event_start: Cell::new(Default::default()), load_event_end: Cell::new(Default::default()), + unload_event_start: Cell::new(Default::default()), + unload_event_end: Cell::new(Default::default()), https_state: Cell::new(HttpsState::None), origin: origin, referrer: referrer, @@ -2674,6 +2688,7 @@ impl Document { salvageable: Cell::new(true), fired_unload: Cell::new(false), responsive_images: Default::default(), + redirect_count: Cell::new(0), } } @@ -2739,6 +2754,14 @@ impl Document { document } + pub fn get_redirect_count(&self) -> u16 { + self.redirect_count.get() + } + + pub fn set_redirect_count(&self, count: u16) { + self.redirect_count.set(count) + } + fn create_node_list<F: Fn(&Node) -> bool>(&self, callback: F) -> DomRoot<NodeList> { let doc = self.GetDocumentElement(); let maybe_node = doc.r().map(Castable::upcast::<Node>); @@ -4268,6 +4291,9 @@ impl DocumentMethods for Document { return Ok(DomRoot::from_ref(self)); } + // TODO: prompt to unload. + // TODO: set unload_event_start and unload_event_end + window_from_node(self).set_navigation_start(); // Step 7 |