Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement synchronous about:blank loading. #13996

Merged
merged 6 commits into from Dec 1, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Implement synchronous about:blank loading.

Based on initial work by jdm in <#8600>.
  • Loading branch information
Ms2ger committed Nov 30, 2016
commit b86965f3948cb830b084a53133ec949af0d11ff7
@@ -42,7 +42,7 @@ use rand::{Rng, SeedableRng, StdRng, random};
use script_traits::{AnimationState, AnimationTickType, CompositorEvent};
use script_traits::{ConstellationControlMsg, ConstellationMsg as FromCompositorMsg};
use script_traits::{DocumentState, LayoutControlMsg, LoadData};
use script_traits::{IFrameLoadInfo, IFrameSandboxState, TimerEventRequest};
use script_traits::{IFrameLoadInfo, IFrameLoadInfoWithData, IFrameSandboxState, TimerEventRequest};
use script_traits::{LayoutMsg as FromLayoutMsg, ScriptMsg as FromScriptMsg, ScriptThreadFactory};
use script_traits::{LogEntry, ServiceWorkerMsg, webdriver_msg};
use script_traits::{MozBrowserErrorType, MozBrowserEvent, WebDriverCommandMsg, WindowSizeData};
@@ -914,11 +914,17 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}
FromScriptMsg::ScriptLoadedURLInIFrame(load_info) => {
debug!("constellation got iframe URL load message {:?} {:?} {:?}",
load_info.parent_pipeline_id,
load_info.info.parent_pipeline_id,
load_info.old_pipeline_id,
load_info.new_pipeline_id);
load_info.info.new_pipeline_id);
self.handle_script_loaded_url_in_iframe_msg(load_info);
}
FromScriptMsg::ScriptLoadedAboutBlankInIFrame(load_info, lc) => {

This comment has been minimized.

@asajeffrey

asajeffrey Nov 24, 2016

Member

Nit: rename to ScriptNewFrame?

debug!("constellation got loaded `about:blank` in iframe message {:?} {:?}",
load_info.parent_pipeline_id,
load_info.new_pipeline_id);
self.handle_script_loaded_about_blank_in_iframe_msg(load_info, lc);
}
FromScriptMsg::ChangeRunningAnimationsState(pipeline_id, animation_state) => {
self.handle_change_running_animations_state(pipeline_id, animation_state)
}
@@ -1363,14 +1369,14 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
// will result in a new pipeline being spawned and a frame tree being added to
// parent_pipeline_id's frame tree's children. This message is never the result of a
// page navigation.
fn handle_script_loaded_url_in_iframe_msg(&mut self, load_info: IFrameLoadInfo) {
fn handle_script_loaded_url_in_iframe_msg(&mut self, load_info: IFrameLoadInfoWithData) {
let (load_data, window_size, is_private) = {
let old_pipeline = load_info.old_pipeline_id
.and_then(|old_pipeline_id| self.pipelines.get(&old_pipeline_id));

let source_pipeline = match self.pipelines.get(&load_info.parent_pipeline_id) {
let source_pipeline = match self.pipelines.get(&load_info.info.parent_pipeline_id) {
Some(source_pipeline) => source_pipeline,
None => return warn!("Script loaded url in closed iframe {}.", load_info.parent_pipeline_id),
None => return warn!("Script loaded url in closed iframe {}.", load_info.info.parent_pipeline_id),
};

// If no url is specified, reload.
@@ -1384,7 +1390,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
LoadData::new(url, None, None)
});

let is_private = load_info.is_private || source_pipeline.is_private;
let is_private = load_info.info.is_private || source_pipeline.is_private;

let window_size = old_pipeline.and_then(|old_pipeline| old_pipeline.size);

@@ -1396,20 +1402,65 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
};

// Create the new pipeline, attached to the parent and push to pending frames
self.new_pipeline(load_info.new_pipeline_id,
load_info.frame_id,
Some((load_info.parent_pipeline_id, load_info.frame_type)),
self.new_pipeline(load_info.info.new_pipeline_id,
load_info.info.frame_id,
Some((load_info.info.parent_pipeline_id, load_info.info.frame_type)),
window_size,
load_data,
load_info.sandbox,
is_private);

self.pending_frames.push(FrameChange {
frame_id: load_info.frame_id,
frame_id: load_info.info.frame_id,
old_pipeline_id: load_info.old_pipeline_id,
new_pipeline_id: load_info.new_pipeline_id,
new_pipeline_id: load_info.info.new_pipeline_id,
document_ready: false,
replace: load_info.info.replace,
});
}

fn handle_script_loaded_about_blank_in_iframe_msg(&mut self,
load_info: IFrameLoadInfo,
layout_sender: IpcSender<LayoutControlMsg>) {
let IFrameLoadInfo {
parent_pipeline_id,
new_pipeline_id,
frame_type,
replace,
frame_id,
is_private,
} = load_info;

let pipeline = {
let parent_pipeline = match self.pipelines.get(&parent_pipeline_id) {
Some(parent_pipeline) => parent_pipeline,
None => return warn!("Script loaded url in closed iframe {}.", parent_pipeline_id),
};

let script_sender = parent_pipeline.script_chan.clone();

let url = ServoUrl::parse("about:blank").expect("infallible");
Pipeline::new(new_pipeline_id,
frame_id,
Some((parent_pipeline_id, frame_type)),
script_sender,
layout_sender,
self.compositor_proxy.clone_compositor_proxy(),
is_private || parent_pipeline.is_private,
url,
None,
parent_pipeline.visible)
};

assert!(!self.pipelines.contains_key(&new_pipeline_id));
self.pipelines.insert(new_pipeline_id, pipeline);

self.pending_frames.push(FrameChange {
frame_id: frame_id,
old_pipeline_id: None,
new_pipeline_id: new_pipeline_id,
document_ready: false,
replace: load_info.replace,
replace: replace,
});
}

@@ -256,17 +256,19 @@ impl Pipeline {
Ok((pipeline, child_process))
}

fn new(id: PipelineId,
frame_id: FrameId,
parent_info: Option<(PipelineId, FrameType)>,
script_chan: Rc<ScriptChan>,
layout_chan: IpcSender<LayoutControlMsg>,
compositor_proxy: Box<CompositorProxy + 'static + Send>,
is_private: bool,
url: ServoUrl,
size: Option<TypedSize2D<f32, PagePx>>,
visible: bool)
-> Pipeline {
/// Creates a new `Pipeline`, after the script and layout threads have been
/// spawned.
pub fn new(id: PipelineId,
frame_id: FrameId,
parent_info: Option<(PipelineId, FrameType)>,
script_chan: Rc<ScriptChan>,
layout_chan: IpcSender<LayoutControlMsg>,
compositor_proxy: Box<CompositorProxy + 'static + Send>,
is_private: bool,
url: ServoUrl,
size: Option<TypedSize2D<f32, PagePx>>,
visible: bool)
-> Pipeline {
let pipeline = Pipeline {
id: id,
frame_id: frame_id,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.