Ability to create new TopLevelBrowsingContext

This commit is contained in:
Paul Rouget 2017-07-15 07:35:59 +02:00
parent 899aa0c371
commit bb3ac8f266
5 changed files with 24 additions and 12 deletions

View file

@ -955,10 +955,11 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
println!("sent response");
}
}
// This should only be called once per constellation, and only by the browser
FromCompositorMsg::InitLoadUrl(url) => {
// Create a new top level browsing context. Will use response_chan to return
// the browsing context id.
FromCompositorMsg::NewBrowser(url, response_chan) => {
debug!("constellation got init load URL message");
self.handle_init_load(url);
self.handle_new_top_level_browsing_context(url, response_chan);
}
// Handle a forward or back request
FromCompositorMsg::TraverseHistory(top_level_browsing_context_id, direction) => {
@ -1473,14 +1474,19 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}
}
fn handle_init_load(&mut self, url: ServoUrl) {
fn handle_new_top_level_browsing_context(&mut self, url: ServoUrl, reply: IpcSender<TopLevelBrowsingContextId>) {
let window_size = self.window_size.initial_viewport;
let pipeline_id = PipelineId::new();
let top_level_browsing_context_id = TopLevelBrowsingContextId::new();
if let Err(e) = reply.send(top_level_browsing_context_id) {
warn!("Failed to send newly created top level browsing context ({}).", e);
}
let browsing_context_id = BrowsingContextId::from(top_level_browsing_context_id);
let load_data = LoadData::new(url.clone(), None, None, None);
let sandbox = IFrameSandboxState::IFrameUnsandboxed;
self.focus_pipeline_id = Some(pipeline_id);
if self.focus_pipeline_id.is_none() {
self.focus_pipeline_id = Some(pipeline_id);
}
self.new_pipeline(pipeline_id,
browsing_context_id,
top_level_browsing_context_id,