diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-08-23 03:55:27 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-23 03:55:27 -0500 |
commit | 5b4c9c7c770c676bd9eb2721fb23764e56c43dcc (patch) | |
tree | 8c81cc1aacfa103457953f5d7d6798e994ae3706 | |
parent | 1c9c0334ba7b03e0757a101d2758c1284566f420 (diff) | |
parent | ecdcfa8226e0d6a5956b79e589b2c9115fcc994c (diff) | |
download | servo-5b4c9c7c770c676bd9eb2721fb23764e56c43dcc.tar.gz servo-5b4c9c7c770c676bd9eb2721fb23764e56c43dcc.zip |
Auto merge of #18181 - paulrouget:close_browser, r=cbrewster
Make it possible to close a browsing context from the embedder
<!-- Please describe your changes on the following line: -->
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [x] `./mach build -d` does not report any errors
- [x] `./mach test-tidy` does not report any errors
- [x] These changes fix #18006 (github issue number if applicable).
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/18181)
<!-- Reviewable:end -->
-rw-r--r-- | components/compositing/compositor.rs | 7 | ||||
-rw-r--r-- | components/compositing/windowing.rs | 3 | ||||
-rw-r--r-- | components/constellation/constellation.rs | 12 | ||||
-rw-r--r-- | components/script_traits/lib.rs | 2 |
4 files changed, 23 insertions, 1 deletions
diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index d8ec355bf55..a7f979af812 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -828,6 +828,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) { diff --git a/components/compositing/windowing.rs b/components/compositing/windowing.rs index 8f647c0d0d6..ed8b0501742 100644 --- a/components/compositing/windowing.rs +++ b/components/compositing/windowing.rs @@ -79,6 +79,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), @@ -106,6 +108,7 @@ impl Debug for WindowEvent { WindowEvent::Quit => write!(f, "Quit"), WindowEvent::Reload(..) => write!(f, "Reload"), WindowEvent::NewBrowser(..) => write!(f, "NewBrowser"), + WindowEvent::CloseBrowser(..) => write!(f, "CloseBrowser"), WindowEvent::SelectBrowser(..) => write!(f, "SelectBrowser"), WindowEvent::ToggleWebRenderDebug(..) => write!(f, "ToggleWebRenderDebug"), } diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index e35ad261864..ad15d1673b8 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -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); @@ -1544,6 +1549,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 { diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 3b5a47a3ef7..0d39e1fb524 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -767,6 +767,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), } |