Send window size even when there is not top level browsing context yet

This commit is contained in:
Paul Rouget 2018-03-06 16:17:59 +08:00
parent 74249b6322
commit 88bf133d2a
3 changed files with 9 additions and 8 deletions

View file

@ -646,10 +646,9 @@ impl<Window: WindowMethods> IOCompositor<Window> {
device_pixel_ratio: dppx, device_pixel_ratio: dppx,
initial_viewport: initial_viewport, initial_viewport: initial_viewport,
}; };
let top_level_browsing_context_id = match self.root_pipeline { let top_level_browsing_context_id = self.root_pipeline.as_ref().map(|pipeline| {
Some(ref pipeline) => pipeline.top_level_browsing_context_id, pipeline.top_level_browsing_context_id
None => return warn!("Window resize without root pipeline."), });
};
let msg = ConstellationMsg::WindowSize(top_level_browsing_context_id, data, size_type); let msg = ConstellationMsg::WindowSize(top_level_browsing_context_id, data, size_type);
if let Err(e) = self.constellation_chan.send(msg) { if let Err(e) = self.constellation_chan.send(msg) {

View file

@ -2551,14 +2551,16 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF>
/// Called when the window is resized. /// Called when the window is resized.
fn handle_window_size_msg(&mut self, fn handle_window_size_msg(&mut self,
top_level_browsing_context_id: TopLevelBrowsingContextId, top_level_browsing_context_id: Option<TopLevelBrowsingContextId>,
new_size: WindowSizeData, new_size: WindowSizeData,
size_type: WindowSizeType) size_type: WindowSizeType)
{ {
debug!("handle_window_size_msg: {:?}", new_size.initial_viewport.to_untyped()); debug!("handle_window_size_msg: {:?}", new_size.initial_viewport.to_untyped());
if let Some(top_level_browsing_context_id) = top_level_browsing_context_id {
let browsing_context_id = BrowsingContextId::from(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); self.resize_browsing_context(new_size, size_type, browsing_context_id);
}
if let Some(resize_channel) = self.webdriver.resize_channel.take() { if let Some(resize_channel) = self.webdriver.resize_channel.take() {
let _ = resize_channel.send(new_size); let _ = resize_channel.send(new_size);

View file

@ -678,7 +678,7 @@ pub enum ConstellationMsg {
/// Request to traverse the joint session history of the provided browsing context. /// Request to traverse the joint session history of the provided browsing context.
TraverseHistory(TopLevelBrowsingContextId, TraversalDirection), TraverseHistory(TopLevelBrowsingContextId, TraversalDirection),
/// Inform the constellation of a window being resized. /// Inform the constellation of a window being resized.
WindowSize(TopLevelBrowsingContextId, WindowSizeData, WindowSizeType), WindowSize(Option<TopLevelBrowsingContextId>, WindowSizeData, WindowSizeType),
/// Requests that the constellation instruct layout to begin a new tick of the animation. /// Requests that the constellation instruct layout to begin a new tick of the animation.
TickAnimation(PipelineId, AnimationTickType), TickAnimation(PipelineId, AnimationTickType),
/// Dispatch a webdriver command /// Dispatch a webdriver command