aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_thread.rs
diff options
context:
space:
mode:
authorMs2ger <Ms2ger@gmail.com>2016-11-28 10:23:04 +0100
committerMs2ger <Ms2ger@gmail.com>2016-11-30 11:26:35 +0100
commitb86965f3948cb830b084a53133ec949af0d11ff7 (patch)
tree6cfc43be4b56abfe483ce436fc2a113705382376 /components/script/script_thread.rs
parent2677540cd0fe93b741e82e1176b5073a8a92fba6 (diff)
downloadservo-b86965f3948cb830b084a53133ec949af0d11ff7.tar.gz
servo-b86965f3948cb830b084a53133ec949af0d11ff7.zip
Implement synchronous about:blank loading.
Based on initial work by jdm in <https://github.com/servo/servo/pull/8600>.
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r--components/script/script_thread.rs43
1 files changed, 39 insertions, 4 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index e7a1f95ec9d..140d57ec754 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -71,7 +71,8 @@ use js::rust::Runtime;
use layout_wrapper::ServoLayoutNode;
use mem::heap_size_of_self_and_children;
use msg::constellation_msg::{FrameId, FrameType, PipelineId, PipelineNamespace};
-use net_traits::{CoreResourceMsg, IpcSend, Metadata, ReferrerPolicy, ResourceThreads};
+use net_traits::{CoreResourceMsg, FetchMetadata, FetchResponseListener};
+use net_traits::{IpcSend, Metadata, ReferrerPolicy, ResourceThreads};
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheResult, ImageCacheThread};
use net_traits::request::{CredentialsMode, Destination, RequestInit};
use net_traits::storage_thread::StorageType;
@@ -605,6 +606,17 @@ impl ScriptThread {
});
}
+ pub fn process_attach_layout(new_layout_info: NewLayoutInfo) {
+ SCRIPT_THREAD_ROOT.with(|root| {
+ if let Some(script_thread) = root.get() {
+ let script_thread = unsafe { &*script_thread };
+ script_thread.profile_event(ScriptThreadEventCategory::AttachLayout, || {
+ script_thread.handle_new_layout(new_layout_info);
+ })
+ }
+ });
+ }
+
pub fn find_document(id: PipelineId) -> Option<Root<Document>> {
SCRIPT_THREAD_ROOT.with(|root| root.get().and_then(|script_thread| {
let script_thread = unsafe { &*script_thread };
@@ -1219,7 +1231,11 @@ impl ScriptThread {
let new_load = InProgressLoad::new(new_pipeline_id, frame_id, parent_info,
layout_chan, window_size,
load_data.url.clone());
- self.start_page_load(new_load, load_data);
+ if load_data.url.as_str() == "about:blank" {
+ self.start_page_load_about_blank(new_load);
+ } else {
+ self.start_page_load(new_load, load_data);
+ }
}
fn handle_loads_complete(&self, pipeline: PipelineId) {
@@ -1645,7 +1661,8 @@ impl ScriptThread {
/// Notify the containing document of a child frame that has completed loading.
fn handle_frame_load_event(&self, parent_id: PipelineId, frame_id: FrameId, child_id: PipelineId) {
- match self.documents.borrow().find_iframe(parent_id, frame_id) {
+ let iframe = self.documents.borrow().find_iframe(parent_id, frame_id);
+ match iframe {
Some(iframe) => iframe.iframe_load_event_steps(child_id),
None => warn!("Message sent to closed pipeline {}.", parent_id),
}
@@ -2018,7 +2035,8 @@ impl ScriptThread {
replace: bool) {
match frame_id {
Some(frame_id) => {
- if let Some(iframe) = self.documents.borrow().find_iframe(parent_pipeline_id, frame_id) {
+ let iframe = self.documents.borrow().find_iframe(parent_pipeline_id, frame_id);
+ if let Some(iframe) = iframe {
iframe.navigate_or_reload_child_browsing_context(Some(load_data), replace);
}
}
@@ -2096,6 +2114,23 @@ impl ScriptThread {
self.incomplete_loads.borrow_mut().push(incomplete);
}
+ /// Synchronously fetch `about:blank`. Stores the `InProgressLoad`
+ /// argument until a notification is received that the fetch is complete.
+ fn start_page_load_about_blank(&self, incomplete: InProgressLoad) {
+ let id = incomplete.pipeline_id;
+
+ self.incomplete_loads.borrow_mut().push(incomplete);
+
+ let url = ServoUrl::parse("about:blank").unwrap();
+ let mut context = ParserContext::new(id, url.clone());
+
+ let mut meta = Metadata::default(url);
+ meta.set_content_type(Some(&mime!(Text / Html)));
+ context.process_response(Ok(FetchMetadata::Unfiltered(meta)));
+ context.process_response_chunk(vec![]);
+ context.process_response_eof(Ok(()));
+ }
+
fn handle_parsing_complete(&self, id: PipelineId) {
let document = match self.documents.borrow().find_document(id) {
Some(document) => document,