mirror of
https://github.com/servo/servo.git
synced 2025-06-21 23:59:00 +01:00
Make it possible to close a browsing context from the embedder
This commit is contained in:
parent
d7b7e7aea8
commit
ecdcfa8226
4 changed files with 23 additions and 1 deletions
|
@ -811,6 +811,13 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
}
|
||||
}
|
||||
|
||||
WindowEvent::CloseBrowser(ctx) => {
|
||||
let msg = ConstellationMsg::CloseBrowser(ctx);
|
||||
if let Err(e) = self.constellation_chan.send(msg) {
|
||||
warn!("Sending CloseBrowser message to constellation failed ({}).", e);
|
||||
}
|
||||
}
|
||||
|
||||
WindowEvent::SelectBrowser(ctx) => {
|
||||
let msg = ConstellationMsg::SelectBrowser(ctx);
|
||||
if let Err(e) = self.constellation_chan.send(msg) {
|
||||
|
|
|
@ -73,6 +73,8 @@ pub enum WindowEvent {
|
|||
Reload(TopLevelBrowsingContextId),
|
||||
/// Create a new top level browsing context
|
||||
NewBrowser(ServoUrl, IpcSender<TopLevelBrowsingContextId>),
|
||||
/// Close a top level browsing context
|
||||
CloseBrowser(TopLevelBrowsingContextId),
|
||||
/// Make a top level browsing context visible, hiding the previous
|
||||
/// visible one.
|
||||
SelectBrowser(TopLevelBrowsingContextId),
|
||||
|
@ -99,6 +101,7 @@ impl Debug for WindowEvent {
|
|||
WindowEvent::ToggleWebRenderProfiler => write!(f, "ToggleWebRenderProfiler"),
|
||||
WindowEvent::Reload(..) => write!(f, "Reload"),
|
||||
WindowEvent::NewBrowser(..) => write!(f, "NewBrowser"),
|
||||
WindowEvent::CloseBrowser(..) => write!(f, "CloseBrowser"),
|
||||
WindowEvent::SelectBrowser(..) => write!(f, "SelectBrowser"),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -974,9 +974,14 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
|||
// 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");
|
||||
debug!("constellation got NewBrowser message");
|
||||
self.handle_new_top_level_browsing_context(url, response_chan);
|
||||
}
|
||||
// Close a top level browsing context.
|
||||
FromCompositorMsg::CloseBrowser(top_level_browsing_context_id) => {
|
||||
debug!("constellation got CloseBrowser message");
|
||||
self.handle_close_top_level_browsing_context(top_level_browsing_context_id);
|
||||
}
|
||||
// Send frame tree to WebRender. Make it visible.
|
||||
FromCompositorMsg::SelectBrowser(top_level_browsing_context_id) => {
|
||||
self.send_frame_tree(top_level_browsing_context_id);
|
||||
|
@ -1540,6 +1545,11 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
|
|||
});
|
||||
}
|
||||
|
||||
fn handle_close_top_level_browsing_context(&mut self, top_level_browsing_context_id: TopLevelBrowsingContextId) {
|
||||
let browsing_context_id = BrowsingContextId::from(top_level_browsing_context_id);
|
||||
self.close_browsing_context(browsing_context_id, ExitPipelineMode::Normal);
|
||||
}
|
||||
|
||||
fn handle_iframe_size_msg(&mut self,
|
||||
iframe_sizes: Vec<(BrowsingContextId, TypedSize2D<f32, CSSPixel>)>) {
|
||||
for (browsing_context_id, size) in iframe_sizes {
|
||||
|
|
|
@ -765,6 +765,8 @@ pub enum ConstellationMsg {
|
|||
WebVREvents(Vec<PipelineId>, Vec<WebVREvent>),
|
||||
/// Create a new top level browsing context.
|
||||
NewBrowser(ServoUrl, IpcSender<TopLevelBrowsingContextId>),
|
||||
/// Close a top level browsing context.
|
||||
CloseBrowser(TopLevelBrowsingContextId),
|
||||
/// Make browser visible.
|
||||
SelectBrowser(TopLevelBrowsingContextId),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue