Event to make a browser visible

This commit is contained in:
Paul Rouget 2017-07-15 07:36:31 +02:00
parent 6876e42d66
commit d9e7bdd7f6
4 changed files with 32 additions and 2 deletions

View file

@ -825,6 +825,13 @@ impl<Window: WindowMethods> IOCompositor<Window> {
warn!("Sending NewBrowser message to constellation failed ({}).", e);
}
}
WindowEvent::SelectBrowser(ctx) => {
let msg = ConstellationMsg::SelectBrowser(ctx);
if let Err(e) = self.constellation_chan.send(msg) {
warn!("Sending SelectBrowser message to constellation failed ({}).", e);
}
}
}
}

View file

@ -73,6 +73,9 @@ pub enum WindowEvent {
Reload(TopLevelBrowsingContextId),
/// Create a new top level browsing context
NewBrowser(ServoUrl, IpcSender<TopLevelBrowsingContextId>),
/// Make a top level browsing context visible, hiding the previous
/// visible one.
SelectBrowser(TopLevelBrowsingContextId),
}
impl Debug for WindowEvent {
@ -96,6 +99,7 @@ impl Debug for WindowEvent {
WindowEvent::ToggleWebRenderProfiler => write!(f, "ToggleWebRenderProfiler"),
WindowEvent::Reload(..) => write!(f, "Reload"),
WindowEvent::NewBrowser(..) => write!(f, "NewBrowser"),
WindowEvent::SelectBrowser(..) => write!(f, "SelectBrowser"),
}
}
}

View file

@ -174,6 +174,9 @@ pub struct Constellation<Message, LTF, STF> {
/// constellation to send messages to the compositor thread.
compositor_proxy: CompositorProxy,
/// The last frame tree sent to WebRender.
active_browser_id: Option<TopLevelBrowsingContextId>,
/// Channels for the constellation to send messages to the public
/// resource-related threads. There are two groups of resource
/// threads: one for public browsing, and one for private
@ -527,6 +530,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
network_listener_sender: network_listener_sender,
network_listener_receiver: network_listener_receiver,
compositor_proxy: state.compositor_proxy,
active_browser_id: None,
debugger_chan: state.debugger_chan,
devtools_chan: state.devtools_chan,
bluetooth_thread: state.bluetooth_thread,
@ -963,6 +967,10 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
debug!("constellation got init load URL message");
self.handle_new_top_level_browsing_context(url, response_chan);
}
// Send frame tree to WebRender. Make it visible.
FromCompositorMsg::SelectBrowser(top_level_browsing_context_id) => {
self.send_frame_tree(top_level_browsing_context_id);
}
// Handle a forward or back request
FromCompositorMsg::TraverseHistory(top_level_browsing_context_id, direction) => {
debug!("constellation got traverse history message from compositor");
@ -2306,7 +2314,11 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
self.notify_history_changed(top_level_id);
// Set paint permissions correctly for the compositor layers.
self.send_frame_tree(top_level_id);
if let Some(id) = self.active_browser_id {
if id == top_level_id {
self.send_frame_tree(top_level_id);
}
}
// Update the owning iframe to point to the new pipeline id.
// This makes things like contentDocument work correctly.
@ -2465,7 +2477,11 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
}
// Build frame tree
self.send_frame_tree(change.top_level_browsing_context_id);
if let Some(id) = self.active_browser_id {
if id == change.top_level_browsing_context_id {
self.send_frame_tree(change.top_level_browsing_context_id );
}
}
}
fn handle_activate_document_msg(&mut self, pipeline_id: PipelineId) {
@ -2902,6 +2918,7 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
fn send_frame_tree(&mut self, top_level_browsing_context_id: TopLevelBrowsingContextId) {
// This might be a mozbrowser iframe, so we need to climb the parent hierarchy,
// even though it's a top-level browsing context.
self.active_browser_id = Some(top_level_browsing_context_id);
let mut browsing_context_id = BrowsingContextId::from(top_level_browsing_context_id);
let mut pipeline_id = match self.browsing_contexts.get(&browsing_context_id) {
Some(browsing_context) => browsing_context.pipeline_id,

View file

@ -765,6 +765,8 @@ pub enum ConstellationMsg {
WebVREvents(Vec<PipelineId>, Vec<WebVREvent>),
/// Create a new top level browsing context.
NewBrowser(ServoUrl, IpcSender<TopLevelBrowsingContextId>),
/// Make browser visible.
SelectBrowser(TopLevelBrowsingContextId),
}
/// Resources required by workerglobalscopes