Skip to content

Commit

Permalink
Event to make a browser visible
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrouget committed Aug 15, 2017
1 parent 6876e42 commit d9e7bdd
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
7 changes: 7 additions & 0 deletions components/compositing/compositor.rs
Expand Up @@ -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);
}
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions components/compositing/windowing.rs
Expand Up @@ -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 {
Expand All @@ -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"),
}
}
}
Expand Down
21 changes: 19 additions & 2 deletions components/constellation/constellation.rs
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions components/script_traits/lib.rs
Expand Up @@ -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
Expand Down

0 comments on commit d9e7bdd

Please sign in to comment.