mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
compositing/script: Do not dispatch the resize event when initially loading.
No bug report corresponds to this, but I noticed it while trying to reduce #10593
This commit is contained in:
parent
75d99eec0f
commit
7940b22158
10 changed files with 103 additions and 48 deletions
|
@ -31,7 +31,7 @@ use layers::scene::Scene;
|
|||
use layout_traits::LayoutControlChan;
|
||||
use msg::constellation_msg::{ConvertPipelineIdFromWebRender, ConvertPipelineIdToWebRender, Image, PixelFormat};
|
||||
use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData};
|
||||
use msg::constellation_msg::{NavigationDirection, PipelineId, WindowSizeData};
|
||||
use msg::constellation_msg::{NavigationDirection, PipelineId, WindowSizeData, WindowSizeType};
|
||||
use pipeline::CompositionPipeline;
|
||||
use profile_traits::mem::{self, ReportKind, Reporter, ReporterRequest};
|
||||
use profile_traits::time::{self, ProfilerCategory, profile};
|
||||
|
@ -461,7 +461,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
compositor.update_zoom_transform();
|
||||
|
||||
// Tell the constellation about the initial window size.
|
||||
compositor.send_window_size();
|
||||
compositor.send_window_size(WindowSizeType::Initial);
|
||||
|
||||
compositor
|
||||
}
|
||||
|
@ -822,7 +822,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
|
||||
// Initialize the new constellation channel by sending it the root window size.
|
||||
self.constellation_chan = new_constellation_chan;
|
||||
self.send_window_size();
|
||||
self.send_window_size(WindowSizeType::Initial);
|
||||
|
||||
self.frame_tree_id.next();
|
||||
self.composite_if_necessary(CompositingReason::NewFrameTree);
|
||||
|
@ -1062,15 +1062,15 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
self.pending_subpages.insert(subpage_pipeline_id);
|
||||
}
|
||||
|
||||
fn send_window_size(&self) {
|
||||
fn send_window_size(&self, size_type: WindowSizeType) {
|
||||
let dppx = self.page_zoom * self.device_pixels_per_screen_px();
|
||||
let initial_viewport = self.window_size.as_f32() / dppx;
|
||||
let visible_viewport = initial_viewport / self.viewport_zoom;
|
||||
let msg = ConstellationMsg::ResizedWindow(WindowSizeData {
|
||||
let msg = ConstellationMsg::WindowSize(WindowSizeData {
|
||||
device_pixel_ratio: dppx,
|
||||
initial_viewport: initial_viewport,
|
||||
visible_viewport: visible_viewport,
|
||||
});
|
||||
}, size_type);
|
||||
|
||||
if let Err(e) = self.constellation_chan.send(msg) {
|
||||
warn!("Sending window resize to constellation failed ({}).", e);
|
||||
|
@ -1295,7 +1295,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
self.window_size = new_size;
|
||||
|
||||
self.scene.set_root_layer_size(new_size.as_f32());
|
||||
self.send_window_size();
|
||||
self.send_window_size(WindowSizeType::Resize);
|
||||
}
|
||||
|
||||
fn on_load_url_window_event(&mut self, url_string: String) {
|
||||
|
@ -1725,14 +1725,14 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
|||
fn on_zoom_reset_window_event(&mut self) {
|
||||
self.page_zoom = ScaleFactor::new(1.0);
|
||||
self.update_zoom_transform();
|
||||
self.send_window_size();
|
||||
self.send_window_size(WindowSizeType::Resize);
|
||||
}
|
||||
|
||||
fn on_zoom_window_event(&mut self, magnification: f32) {
|
||||
self.page_zoom = ScaleFactor::new((self.page_zoom.get() * magnification)
|
||||
.max(MIN_ZOOM).min(MAX_ZOOM));
|
||||
self.update_zoom_transform();
|
||||
self.send_window_size();
|
||||
self.send_window_size(WindowSizeType::Resize);
|
||||
}
|
||||
|
||||
/// Simulate a pinch zoom
|
||||
|
|
|
@ -33,7 +33,7 @@ use msg::constellation_msg::WebDriverCommandMsg;
|
|||
use msg::constellation_msg::{FrameId, PipelineId};
|
||||
use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData};
|
||||
use msg::constellation_msg::{PipelineNamespace, PipelineNamespaceId, NavigationDirection};
|
||||
use msg::constellation_msg::{SubpageId, WindowSizeData};
|
||||
use msg::constellation_msg::{SubpageId, WindowSizeData, WindowSizeType};
|
||||
use msg::constellation_msg::{self, ConstellationChan, PanicMsg};
|
||||
use msg::webdriver_msg;
|
||||
use net_traits::image_cache_thread::ImageCacheThread;
|
||||
|
@ -639,9 +639,9 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
|||
debug!("constellation got navigation message from compositor");
|
||||
self.handle_navigate_msg(pipeline_info, direction);
|
||||
}
|
||||
Request::Compositor(FromCompositorMsg::ResizedWindow(new_size)) => {
|
||||
Request::Compositor(FromCompositorMsg::WindowSize(new_size, size_type)) => {
|
||||
debug!("constellation got window resize message");
|
||||
self.handle_resized_window_msg(new_size);
|
||||
self.handle_window_size_msg(new_size, size_type);
|
||||
}
|
||||
Request::Compositor(FromCompositorMsg::TickAnimation(pipeline_id, tick_type)) => {
|
||||
self.handle_tick_animation(pipeline_id, tick_type)
|
||||
|
@ -910,7 +910,7 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
|||
visible_viewport: *size,
|
||||
initial_viewport: *size * ScaleFactor::new(1.0),
|
||||
device_pixel_ratio: self.window_size.device_pixel_ratio,
|
||||
});
|
||||
}, WindowSizeType::Initial);
|
||||
|
||||
// Store the new rect inside the pipeline
|
||||
let result = {
|
||||
|
@ -1581,8 +1581,8 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
|||
}
|
||||
|
||||
/// Called when the window is resized.
|
||||
fn handle_resized_window_msg(&mut self, new_size: WindowSizeData) {
|
||||
debug!("handle_resized_window_msg: {:?} {:?}", new_size.initial_viewport.to_untyped(),
|
||||
fn handle_window_size_msg(&mut self, new_size: WindowSizeData, size_type: WindowSizeType) {
|
||||
debug!("handle_window_size_msg: {:?} {:?}", new_size.initial_viewport.to_untyped(),
|
||||
new_size.visible_viewport.to_untyped());
|
||||
|
||||
if let Some(root_frame_id) = self.root_frame_id {
|
||||
|
@ -1597,14 +1597,23 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
|||
None => return warn!("Pipeline {:?} resized after closing.", pipeline_id),
|
||||
Some(pipeline) => pipeline,
|
||||
};
|
||||
let _ = pipeline.script_chan.send(ConstellationControlMsg::Resize(pipeline.id, new_size));
|
||||
let _ = pipeline.script_chan.send(ConstellationControlMsg::Resize(
|
||||
pipeline.id,
|
||||
new_size,
|
||||
size_type
|
||||
));
|
||||
for pipeline_id in frame.prev.iter().chain(&frame.next) {
|
||||
let pipeline = match self.pipelines.get(&pipeline_id) {
|
||||
None => { warn!("Inactive pipeline {:?} resized after closing.", pipeline_id); continue; },
|
||||
None => {
|
||||
warn!("Inactive pipeline {:?} resized after closing.", pipeline_id);
|
||||
continue;
|
||||
},
|
||||
Some(pipeline) => pipeline,
|
||||
};
|
||||
let _ = pipeline.script_chan.send(ConstellationControlMsg::ResizeInactive(pipeline.id,
|
||||
new_size));
|
||||
let _ = pipeline.script_chan.send(ConstellationControlMsg::ResizeInactive(
|
||||
pipeline.id,
|
||||
new_size
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1616,8 +1625,11 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
|||
Some(pipeline) => pipeline,
|
||||
};
|
||||
if pipeline.parent_info.is_none() {
|
||||
let _ = pipeline.script_chan.send(ConstellationControlMsg::Resize(pipeline.id,
|
||||
new_size));
|
||||
let _ = pipeline.script_chan.send(ConstellationControlMsg::Resize(
|
||||
pipeline.id,
|
||||
new_size,
|
||||
size_type
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ use gfx_traits::Epoch;
|
|||
use ipc_channel::ipc::{IpcSender};
|
||||
use msg::constellation_msg::{FrameId, Key, KeyState, KeyModifiers, LoadData};
|
||||
use msg::constellation_msg::{NavigationDirection, PipelineId, SubpageId};
|
||||
use msg::constellation_msg::{WebDriverCommandMsg, WindowSizeData};
|
||||
use msg::constellation_msg::{WebDriverCommandMsg, WindowSizeData, WindowSizeType};
|
||||
use std::collections::HashMap;
|
||||
use url::Url;
|
||||
|
||||
|
@ -103,7 +103,7 @@ pub enum CompositorMsg {
|
|||
KeyEvent(Key, KeyState, KeyModifiers),
|
||||
LoadUrl(PipelineId, LoadData),
|
||||
Navigate(Option<(PipelineId, SubpageId)>, NavigationDirection),
|
||||
ResizedWindow(WindowSizeData),
|
||||
WindowSize(WindowSizeData, WindowSizeType),
|
||||
/// Requests that the constellation instruct layout to begin a new tick of the animation.
|
||||
TickAnimation(PipelineId, AnimationTickType),
|
||||
/// Dispatch a webdriver command
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue