From 88bf133d2a52a9d2da8d282e3b573c95a88ff3be Mon Sep 17 00:00:00 2001 From: Paul Rouget Date: Tue, 6 Mar 2018 16:17:59 +0800 Subject: [PATCH] Send window size even when there is not top level browsing context yet --- components/compositing/compositor.rs | 7 +++---- components/constellation/constellation.rs | 8 +++++--- components/script_traits/lib.rs | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/components/compositing/compositor.rs b/components/compositing/compositor.rs index 62d5740d31a..027151af9b4 100644 --- a/components/compositing/compositor.rs +++ b/components/compositing/compositor.rs @@ -646,10 +646,9 @@ impl IOCompositor { device_pixel_ratio: dppx, initial_viewport: initial_viewport, }; - let top_level_browsing_context_id = match self.root_pipeline { - Some(ref pipeline) => pipeline.top_level_browsing_context_id, - None => return warn!("Window resize without root pipeline."), - }; + let top_level_browsing_context_id = self.root_pipeline.as_ref().map(|pipeline| { + pipeline.top_level_browsing_context_id + }); let msg = ConstellationMsg::WindowSize(top_level_browsing_context_id, data, size_type); if let Err(e) = self.constellation_chan.send(msg) { diff --git a/components/constellation/constellation.rs b/components/constellation/constellation.rs index 3db4c5c39f2..f6a47ba14b1 100644 --- a/components/constellation/constellation.rs +++ b/components/constellation/constellation.rs @@ -2551,14 +2551,16 @@ impl Constellation /// Called when the window is resized. fn handle_window_size_msg(&mut self, - top_level_browsing_context_id: TopLevelBrowsingContextId, + top_level_browsing_context_id: Option, new_size: WindowSizeData, size_type: WindowSizeType) { debug!("handle_window_size_msg: {:?}", new_size.initial_viewport.to_untyped()); - let browsing_context_id = BrowsingContextId::from(top_level_browsing_context_id); - self.resize_browsing_context(new_size, size_type, browsing_context_id); + if let Some(top_level_browsing_context_id) = top_level_browsing_context_id { + let browsing_context_id = BrowsingContextId::from(top_level_browsing_context_id); + self.resize_browsing_context(new_size, size_type, browsing_context_id); + } if let Some(resize_channel) = self.webdriver.resize_channel.take() { let _ = resize_channel.send(new_size); diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs index 14e0472da60..eec50faf09b 100644 --- a/components/script_traits/lib.rs +++ b/components/script_traits/lib.rs @@ -678,7 +678,7 @@ pub enum ConstellationMsg { /// Request to traverse the joint session history of the provided browsing context. TraverseHistory(TopLevelBrowsingContextId, TraversalDirection), /// Inform the constellation of a window being resized. - WindowSize(TopLevelBrowsingContextId, WindowSizeData, WindowSizeType), + WindowSize(Option, WindowSizeData, WindowSizeType), /// Requests that the constellation instruct layout to begin a new tick of the animation. TickAnimation(PipelineId, AnimationTickType), /// Dispatch a webdriver command