From eb82e781a36c055dab4c1cc3772f7a555abd31a6 Mon Sep 17 00:00:00 2001 From: Gregory Terzian Date: Wed, 12 Dec 2018 21:16:07 +0800 Subject: implement windowproxy "delay-load-event-mode", and partially document "completely-loaded" --- components/script/script_thread.rs | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'components/script/script_thread.rs') diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 50f6135ff52..23d7adcf012 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1396,6 +1396,7 @@ impl ScriptThread { match *msg { MixedMessage::FromConstellation(ref inner_msg) => { match *inner_msg { + StopDelayingLoadEventsMode(id) => Some(id), NavigationResponse(id, _) => Some(id), AttachLayout(ref new_layout_info) => Some(new_layout_info.new_pipeline_id), Resize(id, ..) => Some(id), @@ -1533,6 +1534,9 @@ impl ScriptThread { fn handle_msg_from_constellation(&self, msg: ConstellationControlMsg) { match msg { + ConstellationControlMsg::StopDelayingLoadEventsMode(pipeline_id) => { + self.handle_stop_delaying_load_events_mode(pipeline_id) + }, ConstellationControlMsg::NavigationResponse(id, fetch_data) => { match fetch_data { FetchResponseMsg::ProcessResponse(metadata) => { @@ -2080,6 +2084,19 @@ impl ScriptThread { } } + fn handle_stop_delaying_load_events_mode(&self, pipeline_id: PipelineId) { + let window = self.documents.borrow().find_window(pipeline_id); + if let Some(window) = window { + match window.undiscarded_window_proxy() { + Some(window_proxy) => window_proxy.stop_delaying_load_events_mode(), + None => warn!( + "Attempted to take {} of 'delaying-load-events-mode' after having been discarded.", + pipeline_id + ), + }; + } + } + fn handle_unload_document(&self, pipeline_id: PipelineId) { let document = self.documents.borrow().find_document(pipeline_id); if let Some(document) = document { @@ -2166,6 +2183,20 @@ impl ScriptThread { status: Some((204...205, _)), .. }) => { + // If we have an existing window that is being navigated: + if let Some(window) = self.documents.borrow().find_window(id.clone()) { + let window_proxy = window.window_proxy(); + // https://html.spec.whatwg.org/multipage/ + // #navigating-across-documents:delaying-load-events-mode-2 + if window_proxy.parent().is_some() { + // The user agent must take this nested browsing context + // out of the delaying load events mode + // when this navigation algorithm later matures, + // or when it terminates (whether due to having run all the steps, + // or being canceled, or being aborted), whichever happens first. + window_proxy.stop_delaying_load_events_mode(); + } + } self.script_sender .send((id.clone(), ScriptMsg::AbortLoadUrl)) .unwrap(); @@ -2710,6 +2741,13 @@ impl ScriptThread { incomplete.parent_info, incomplete.opener, ); + if window_proxy.parent().is_some() { + // https://html.spec.whatwg.org/multipage/#navigating-across-documents:delaying-load-events-mode-2 + // The user agent must take this nested browsing context + // out of the delaying load events mode + // when this navigation algorithm later matures. + window_proxy.stop_delaying_load_events_mode(); + } window.init_window_proxy(&window_proxy); let last_modified = metadata.headers.as_ref().and_then(|headers| { -- cgit v1.2.3 From 7530faa4eaeb49d5ce0d18c8bfcf90e29832709a Mon Sep 17 00:00:00 2001 From: Gregory Terzian Date: Sat, 15 Dec 2018 15:54:04 +0800 Subject: check for a document being "fully-active" before reflows --- components/script/script_thread.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'components/script/script_thread.rs') diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs index 23d7adcf012..1724a6b2276 100644 --- a/components/script/script_thread.rs +++ b/components/script/script_thread.rs @@ -1314,6 +1314,10 @@ impl ScriptThread { // into this loop too, but for now it's only images. debug!("Issuing batched reflows."); for (_, document) in self.documents.borrow().iter() { + // Step 13 + if !document.is_fully_active() { + continue; + } let window = document.window(); let pending_reflows = window.get_pending_reflow_count(); if pending_reflows > 0 { -- cgit v1.2.3