mirror of
https://github.com/servo/servo.git
synced 2025-07-31 19:20:22 +01:00
Auto merge of #10654 - notriddle:no_resize_on_initial_load, r=asajeffrey
compositing/script: Do not dispatch the resize event when initially l… …oading. No bug report corresponds to this, but I noticed it while trying to reduce #10593 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10654) <!-- Reviewable:end -->
This commit is contained in:
commit
47a0f58f98
10 changed files with 103 additions and 48 deletions
|
@ -31,7 +31,7 @@ use layers::scene::Scene;
|
||||||
use layout_traits::LayoutControlChan;
|
use layout_traits::LayoutControlChan;
|
||||||
use msg::constellation_msg::{ConvertPipelineIdFromWebRender, ConvertPipelineIdToWebRender, Image, PixelFormat};
|
use msg::constellation_msg::{ConvertPipelineIdFromWebRender, ConvertPipelineIdToWebRender, Image, PixelFormat};
|
||||||
use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData};
|
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 pipeline::CompositionPipeline;
|
||||||
use profile_traits::mem::{self, ReportKind, Reporter, ReporterRequest};
|
use profile_traits::mem::{self, ReportKind, Reporter, ReporterRequest};
|
||||||
use profile_traits::time::{self, ProfilerCategory, profile};
|
use profile_traits::time::{self, ProfilerCategory, profile};
|
||||||
|
@ -461,7 +461,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
compositor.update_zoom_transform();
|
compositor.update_zoom_transform();
|
||||||
|
|
||||||
// Tell the constellation about the initial window size.
|
// Tell the constellation about the initial window size.
|
||||||
compositor.send_window_size();
|
compositor.send_window_size(WindowSizeType::Initial);
|
||||||
|
|
||||||
compositor
|
compositor
|
||||||
}
|
}
|
||||||
|
@ -822,7 +822,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
|
|
||||||
// Initialize the new constellation channel by sending it the root window size.
|
// Initialize the new constellation channel by sending it the root window size.
|
||||||
self.constellation_chan = new_constellation_chan;
|
self.constellation_chan = new_constellation_chan;
|
||||||
self.send_window_size();
|
self.send_window_size(WindowSizeType::Initial);
|
||||||
|
|
||||||
self.frame_tree_id.next();
|
self.frame_tree_id.next();
|
||||||
self.composite_if_necessary(CompositingReason::NewFrameTree);
|
self.composite_if_necessary(CompositingReason::NewFrameTree);
|
||||||
|
@ -1062,15 +1062,15 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
self.pending_subpages.insert(subpage_pipeline_id);
|
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 dppx = self.page_zoom * self.device_pixels_per_screen_px();
|
||||||
let initial_viewport = self.window_size.as_f32() / dppx;
|
let initial_viewport = self.window_size.as_f32() / dppx;
|
||||||
let visible_viewport = initial_viewport / self.viewport_zoom;
|
let visible_viewport = initial_viewport / self.viewport_zoom;
|
||||||
let msg = ConstellationMsg::ResizedWindow(WindowSizeData {
|
let msg = ConstellationMsg::WindowSize(WindowSizeData {
|
||||||
device_pixel_ratio: dppx,
|
device_pixel_ratio: dppx,
|
||||||
initial_viewport: initial_viewport,
|
initial_viewport: initial_viewport,
|
||||||
visible_viewport: visible_viewport,
|
visible_viewport: visible_viewport,
|
||||||
});
|
}, size_type);
|
||||||
|
|
||||||
if let Err(e) = self.constellation_chan.send(msg) {
|
if let Err(e) = self.constellation_chan.send(msg) {
|
||||||
warn!("Sending window resize to constellation failed ({}).", e);
|
warn!("Sending window resize to constellation failed ({}).", e);
|
||||||
|
@ -1295,7 +1295,7 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
self.window_size = new_size;
|
self.window_size = new_size;
|
||||||
|
|
||||||
self.scene.set_root_layer_size(new_size.as_f32());
|
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) {
|
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) {
|
fn on_zoom_reset_window_event(&mut self) {
|
||||||
self.page_zoom = ScaleFactor::new(1.0);
|
self.page_zoom = ScaleFactor::new(1.0);
|
||||||
self.update_zoom_transform();
|
self.update_zoom_transform();
|
||||||
self.send_window_size();
|
self.send_window_size(WindowSizeType::Resize);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_zoom_window_event(&mut self, magnification: f32) {
|
fn on_zoom_window_event(&mut self, magnification: f32) {
|
||||||
self.page_zoom = ScaleFactor::new((self.page_zoom.get() * magnification)
|
self.page_zoom = ScaleFactor::new((self.page_zoom.get() * magnification)
|
||||||
.max(MIN_ZOOM).min(MAX_ZOOM));
|
.max(MIN_ZOOM).min(MAX_ZOOM));
|
||||||
self.update_zoom_transform();
|
self.update_zoom_transform();
|
||||||
self.send_window_size();
|
self.send_window_size(WindowSizeType::Resize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Simulate a pinch zoom
|
/// Simulate a pinch zoom
|
||||||
|
|
|
@ -33,7 +33,7 @@ use msg::constellation_msg::WebDriverCommandMsg;
|
||||||
use msg::constellation_msg::{FrameId, PipelineId};
|
use msg::constellation_msg::{FrameId, PipelineId};
|
||||||
use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData};
|
use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData};
|
||||||
use msg::constellation_msg::{PipelineNamespace, PipelineNamespaceId, NavigationDirection};
|
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::constellation_msg::{self, ConstellationChan, PanicMsg};
|
||||||
use msg::webdriver_msg;
|
use msg::webdriver_msg;
|
||||||
use net_traits::image_cache_thread::ImageCacheThread;
|
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");
|
debug!("constellation got navigation message from compositor");
|
||||||
self.handle_navigate_msg(pipeline_info, direction);
|
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");
|
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)) => {
|
Request::Compositor(FromCompositorMsg::TickAnimation(pipeline_id, tick_type)) => {
|
||||||
self.handle_tick_animation(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,
|
visible_viewport: *size,
|
||||||
initial_viewport: *size * ScaleFactor::new(1.0),
|
initial_viewport: *size * ScaleFactor::new(1.0),
|
||||||
device_pixel_ratio: self.window_size.device_pixel_ratio,
|
device_pixel_ratio: self.window_size.device_pixel_ratio,
|
||||||
});
|
}, WindowSizeType::Initial);
|
||||||
|
|
||||||
// Store the new rect inside the pipeline
|
// Store the new rect inside the pipeline
|
||||||
let result = {
|
let result = {
|
||||||
|
@ -1581,8 +1581,8 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Called when the window is resized.
|
/// Called when the window is resized.
|
||||||
fn handle_resized_window_msg(&mut self, new_size: WindowSizeData) {
|
fn handle_window_size_msg(&mut self, new_size: WindowSizeData, size_type: WindowSizeType) {
|
||||||
debug!("handle_resized_window_msg: {:?} {:?}", new_size.initial_viewport.to_untyped(),
|
debug!("handle_window_size_msg: {:?} {:?}", new_size.initial_viewport.to_untyped(),
|
||||||
new_size.visible_viewport.to_untyped());
|
new_size.visible_viewport.to_untyped());
|
||||||
|
|
||||||
if let Some(root_frame_id) = self.root_frame_id {
|
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),
|
None => return warn!("Pipeline {:?} resized after closing.", pipeline_id),
|
||||||
Some(pipeline) => pipeline,
|
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) {
|
for pipeline_id in frame.prev.iter().chain(&frame.next) {
|
||||||
let pipeline = match self.pipelines.get(&pipeline_id) {
|
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,
|
Some(pipeline) => pipeline,
|
||||||
};
|
};
|
||||||
let _ = pipeline.script_chan.send(ConstellationControlMsg::ResizeInactive(pipeline.id,
|
let _ = pipeline.script_chan.send(ConstellationControlMsg::ResizeInactive(
|
||||||
new_size));
|
pipeline.id,
|
||||||
|
new_size
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1616,8 +1625,11 @@ impl<LTF: LayoutThreadFactory, STF: ScriptThreadFactory> Constellation<LTF, STF>
|
||||||
Some(pipeline) => pipeline,
|
Some(pipeline) => pipeline,
|
||||||
};
|
};
|
||||||
if pipeline.parent_info.is_none() {
|
if pipeline.parent_info.is_none() {
|
||||||
let _ = pipeline.script_chan.send(ConstellationControlMsg::Resize(pipeline.id,
|
let _ = pipeline.script_chan.send(ConstellationControlMsg::Resize(
|
||||||
new_size));
|
pipeline.id,
|
||||||
|
new_size,
|
||||||
|
size_type
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ use gfx_traits::Epoch;
|
||||||
use ipc_channel::ipc::{IpcSender};
|
use ipc_channel::ipc::{IpcSender};
|
||||||
use msg::constellation_msg::{FrameId, Key, KeyState, KeyModifiers, LoadData};
|
use msg::constellation_msg::{FrameId, Key, KeyState, KeyModifiers, LoadData};
|
||||||
use msg::constellation_msg::{NavigationDirection, PipelineId, SubpageId};
|
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 std::collections::HashMap;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ pub enum CompositorMsg {
|
||||||
KeyEvent(Key, KeyState, KeyModifiers),
|
KeyEvent(Key, KeyState, KeyModifiers),
|
||||||
LoadUrl(PipelineId, LoadData),
|
LoadUrl(PipelineId, LoadData),
|
||||||
Navigate(Option<(PipelineId, SubpageId)>, NavigationDirection),
|
Navigate(Option<(PipelineId, SubpageId)>, NavigationDirection),
|
||||||
ResizedWindow(WindowSizeData),
|
WindowSize(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
|
||||||
|
|
|
@ -50,6 +50,12 @@ pub struct WindowSizeData {
|
||||||
pub device_pixel_ratio: ScaleFactor<ViewportPx, DevicePixel, f32>,
|
pub device_pixel_ratio: ScaleFactor<ViewportPx, DevicePixel, f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Eq, PartialEq, Serialize, Copy, Clone, HeapSizeOf)]
|
||||||
|
pub enum WindowSizeType {
|
||||||
|
Initial,
|
||||||
|
Resize,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Copy, Clone, Debug, Deserialize, Serialize)]
|
#[derive(PartialEq, Eq, Copy, Clone, Debug, Deserialize, Serialize)]
|
||||||
pub enum KeyState {
|
pub enum KeyState {
|
||||||
Pressed,
|
Pressed,
|
||||||
|
|
|
@ -56,7 +56,7 @@ use js::rust::Runtime;
|
||||||
use layout_interface::{LayoutChan, LayoutRPC};
|
use layout_interface::{LayoutChan, LayoutRPC};
|
||||||
use libc;
|
use libc;
|
||||||
use msg::constellation_msg::ConstellationChan;
|
use msg::constellation_msg::ConstellationChan;
|
||||||
use msg::constellation_msg::{PipelineId, SubpageId, WindowSizeData};
|
use msg::constellation_msg::{PipelineId, SubpageId, WindowSizeData, WindowSizeType};
|
||||||
use net_traits::image::base::{Image, ImageMetadata};
|
use net_traits::image::base::{Image, ImageMetadata};
|
||||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread};
|
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread};
|
||||||
use net_traits::response::HttpsState;
|
use net_traits::response::HttpsState;
|
||||||
|
@ -294,7 +294,7 @@ no_jsmanaged_fields!(PropertyDeclarationBlock);
|
||||||
no_jsmanaged_fields!(HashSet<T>);
|
no_jsmanaged_fields!(HashSet<T>);
|
||||||
// These three are interdependent, if you plan to put jsmanaged data
|
// These three are interdependent, if you plan to put jsmanaged data
|
||||||
// in one of these make sure it is propagated properly to containing structs
|
// in one of these make sure it is propagated properly to containing structs
|
||||||
no_jsmanaged_fields!(SubpageId, WindowSizeData, PipelineId);
|
no_jsmanaged_fields!(SubpageId, WindowSizeData, WindowSizeType, PipelineId);
|
||||||
no_jsmanaged_fields!(TimerEventId, TimerSource);
|
no_jsmanaged_fields!(TimerEventId, TimerSource);
|
||||||
no_jsmanaged_fields!(WorkerId);
|
no_jsmanaged_fields!(WorkerId);
|
||||||
no_jsmanaged_fields!(QuirksMode);
|
no_jsmanaged_fields!(QuirksMode);
|
||||||
|
|
|
@ -43,7 +43,8 @@ use js::rust::Runtime;
|
||||||
use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow};
|
use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow};
|
||||||
use layout_interface::{LayoutChan, LayoutRPC, Msg, Reflow, ReflowQueryType, MarginStyleResponse};
|
use layout_interface::{LayoutChan, LayoutRPC, Msg, Reflow, ReflowQueryType, MarginStyleResponse};
|
||||||
use libc;
|
use libc;
|
||||||
use msg::constellation_msg::{ConstellationChan, LoadData, PipelineId, SubpageId, WindowSizeData};
|
use msg::constellation_msg::{ConstellationChan, LoadData, PipelineId, SubpageId};
|
||||||
|
use msg::constellation_msg::{WindowSizeData, WindowSizeType};
|
||||||
use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
|
use msg::webdriver_msg::{WebDriverJSError, WebDriverJSResult};
|
||||||
use net_traits::ResourceThread;
|
use net_traits::ResourceThread;
|
||||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread};
|
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread};
|
||||||
|
@ -181,7 +182,7 @@ pub struct Window {
|
||||||
next_subpage_id: Cell<SubpageId>,
|
next_subpage_id: Cell<SubpageId>,
|
||||||
|
|
||||||
/// Pending resize event, if any.
|
/// Pending resize event, if any.
|
||||||
resize_event: Cell<Option<WindowSizeData>>,
|
resize_event: Cell<Option<(WindowSizeData, WindowSizeType)>>,
|
||||||
|
|
||||||
/// Pipeline id associated with this page.
|
/// Pipeline id associated with this page.
|
||||||
id: PipelineId,
|
id: PipelineId,
|
||||||
|
@ -1280,11 +1281,11 @@ impl Window {
|
||||||
self.pending_reflow_count.set(self.pending_reflow_count.get() + 1);
|
self.pending_reflow_count.set(self.pending_reflow_count.get() + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_resize_event(&self, event: WindowSizeData) {
|
pub fn set_resize_event(&self, event: WindowSizeData, event_type: WindowSizeType) {
|
||||||
self.resize_event.set(Some(event));
|
self.resize_event.set(Some((event, event_type)));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn steal_resize_event(&self) -> Option<WindowSizeData> {
|
pub fn steal_resize_event(&self) -> Option<(WindowSizeData, WindowSizeType)> {
|
||||||
let event = self.resize_event.get();
|
let event = self.resize_event.get();
|
||||||
self.resize_event.set(None);
|
self.resize_event.set(None);
|
||||||
event
|
event
|
||||||
|
|
|
@ -61,7 +61,7 @@ use layout_interface::{self, LayoutChan, NewLayoutThreadInfo, ScriptLayoutChan};
|
||||||
use mem::heap_size_of_self_and_children;
|
use mem::heap_size_of_self_and_children;
|
||||||
use msg::constellation_msg::{ConstellationChan, LoadData};
|
use msg::constellation_msg::{ConstellationChan, LoadData};
|
||||||
use msg::constellation_msg::{PipelineId, PipelineNamespace};
|
use msg::constellation_msg::{PipelineId, PipelineNamespace};
|
||||||
use msg::constellation_msg::{SubpageId, WindowSizeData};
|
use msg::constellation_msg::{SubpageId, WindowSizeData, WindowSizeType};
|
||||||
use msg::webdriver_msg::WebDriverScriptCommand;
|
use msg::webdriver_msg::WebDriverScriptCommand;
|
||||||
use net_traits::LoadData as NetLoadData;
|
use net_traits::LoadData as NetLoadData;
|
||||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheResult, ImageCacheThread};
|
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheResult, ImageCacheThread};
|
||||||
|
@ -635,8 +635,8 @@ impl ScriptThread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (id, size) in resizes {
|
for (id, (size, size_type)) in resizes {
|
||||||
self.handle_event(id, ResizeEvent(size));
|
self.handle_event(id, ResizeEvent(size, size_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store new resizes, and gather all other events.
|
// Store new resizes, and gather all other events.
|
||||||
|
@ -689,9 +689,9 @@ impl ScriptThread {
|
||||||
self.handle_new_layout(new_layout_info);
|
self.handle_new_layout(new_layout_info);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
FromConstellation(ConstellationControlMsg::Resize(id, size)) => {
|
FromConstellation(ConstellationControlMsg::Resize(id, size, size_type)) => {
|
||||||
self.profile_event(ScriptThreadEventCategory::Resize, || {
|
self.profile_event(ScriptThreadEventCategory::Resize, || {
|
||||||
self.handle_resize(id, size);
|
self.handle_resize(id, size, size_type);
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
FromConstellation(ConstellationControlMsg::Viewport(id, rect)) => {
|
FromConstellation(ConstellationControlMsg::Viewport(id, rect)) => {
|
||||||
|
@ -1020,10 +1020,10 @@ impl ScriptThread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_resize(&self, id: PipelineId, size: WindowSizeData) {
|
fn handle_resize(&self, id: PipelineId, size: WindowSizeData, size_type: WindowSizeType) {
|
||||||
if let Some(ref page) = self.find_subpage(id) {
|
if let Some(ref page) = self.find_subpage(id) {
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
window.set_resize_event(size);
|
window.set_resize_event(size, size_type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let mut loads = self.incomplete_loads.borrow_mut();
|
let mut loads = self.incomplete_loads.borrow_mut();
|
||||||
|
@ -1670,8 +1670,8 @@ impl ScriptThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
ResizeEvent(new_size) => {
|
ResizeEvent(new_size, size_type) => {
|
||||||
self.handle_resize_event(pipeline_id, new_size);
|
self.handle_resize_event(pipeline_id, new_size, size_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseButtonEvent(event_type, button, point) => {
|
MouseButtonEvent(event_type, button, point) => {
|
||||||
|
@ -1831,7 +1831,7 @@ impl ScriptThread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_resize_event(&self, pipeline_id: PipelineId, new_size: WindowSizeData) {
|
fn handle_resize_event(&self, pipeline_id: PipelineId, new_size: WindowSizeData, size_type: WindowSizeType) {
|
||||||
let page = get_page(&self.root_page(), pipeline_id);
|
let page = get_page(&self.root_page(), pipeline_id);
|
||||||
let window = page.window();
|
let window = page.window();
|
||||||
window.set_window_size(new_size);
|
window.set_window_size(new_size);
|
||||||
|
@ -1849,11 +1849,13 @@ impl ScriptThread {
|
||||||
|
|
||||||
// http://dev.w3.org/csswg/cssom-view/#resizing-viewports
|
// http://dev.w3.org/csswg/cssom-view/#resizing-viewports
|
||||||
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#event-type-resize
|
// https://dvcs.w3.org/hg/dom3events/raw-file/tip/html/DOM3-Events.html#event-type-resize
|
||||||
let uievent = UIEvent::new(window.r(),
|
if size_type == WindowSizeType::Resize {
|
||||||
DOMString::from("resize"), EventBubbles::DoesNotBubble,
|
let uievent = UIEvent::new(window.r(),
|
||||||
EventCancelable::NotCancelable, Some(window.r()),
|
DOMString::from("resize"), EventBubbles::DoesNotBubble,
|
||||||
0i32);
|
EventCancelable::NotCancelable, Some(window.r()),
|
||||||
uievent.upcast::<Event>().fire(window.upcast());
|
0i32);
|
||||||
|
uievent.upcast::<Event>().fire(window.upcast());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Initiate a non-blocking fetch for a specified resource. Stores the InProgressLoad
|
/// Initiate a non-blocking fetch for a specified resource. Stores the InProgressLoad
|
||||||
|
|
|
@ -41,7 +41,7 @@ use gfx_traits::Epoch;
|
||||||
use gfx_traits::LayerId;
|
use gfx_traits::LayerId;
|
||||||
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
use ipc_channel::ipc::{IpcReceiver, IpcSender};
|
||||||
use libc::c_void;
|
use libc::c_void;
|
||||||
use msg::constellation_msg::{ConstellationChan, PanicMsg, PipelineId, WindowSizeData};
|
use msg::constellation_msg::{ConstellationChan, PanicMsg, PipelineId, WindowSizeData, WindowSizeType};
|
||||||
use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData};
|
use msg::constellation_msg::{Key, KeyModifiers, KeyState, LoadData};
|
||||||
use msg::constellation_msg::{PipelineNamespaceId, SubpageId};
|
use msg::constellation_msg::{PipelineNamespaceId, SubpageId};
|
||||||
use msg::webdriver_msg::WebDriverScriptCommand;
|
use msg::webdriver_msg::WebDriverScriptCommand;
|
||||||
|
@ -109,7 +109,7 @@ pub enum ConstellationControlMsg {
|
||||||
/// Gives a channel and ID to a layout thread, as well as the ID of that layout's parent
|
/// Gives a channel and ID to a layout thread, as well as the ID of that layout's parent
|
||||||
AttachLayout(NewLayoutInfo),
|
AttachLayout(NewLayoutInfo),
|
||||||
/// Window resized. Sends a DOM event eventually, but first we combine events.
|
/// Window resized. Sends a DOM event eventually, but first we combine events.
|
||||||
Resize(PipelineId, WindowSizeData),
|
Resize(PipelineId, WindowSizeData, WindowSizeType),
|
||||||
/// Notifies script that window has been resized but to not take immediate action.
|
/// Notifies script that window has been resized but to not take immediate action.
|
||||||
ResizeInactive(PipelineId, WindowSizeData),
|
ResizeInactive(PipelineId, WindowSizeData),
|
||||||
/// Notifies the script that a pipeline should be closed.
|
/// Notifies the script that a pipeline should be closed.
|
||||||
|
@ -220,7 +220,7 @@ pub enum MouseEventType {
|
||||||
#[derive(Deserialize, Serialize)]
|
#[derive(Deserialize, Serialize)]
|
||||||
pub enum CompositorEvent {
|
pub enum CompositorEvent {
|
||||||
/// The window was resized.
|
/// The window was resized.
|
||||||
ResizeEvent(WindowSizeData),
|
ResizeEvent(WindowSizeData, WindowSizeType),
|
||||||
/// A mouse button state changed.
|
/// A mouse button state changed.
|
||||||
MouseButtonEvent(MouseEventType, MouseButton, Point2D<f32>),
|
MouseButtonEvent(MouseEventType, MouseButton, Point2D<f32>),
|
||||||
/// The mouse was moved over a point (or was moved out of the recognizable region).
|
/// The mouse was moved over a point (or was moved out of the recognizable region).
|
||||||
|
|
|
@ -6682,6 +6682,12 @@
|
||||||
"url": "/_mozilla/mozilla/window_requestAnimationFrame2.html"
|
"url": "/_mozilla/mozilla/window_requestAnimationFrame2.html"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"mozilla/window_resize_not_triggered_on_load.html": [
|
||||||
|
{
|
||||||
|
"path": "mozilla/window_resize_not_triggered_on_load.html",
|
||||||
|
"url": "/_mozilla/mozilla/window_resize_not_triggered_on_load.html"
|
||||||
|
}
|
||||||
|
],
|
||||||
"mozilla/window_setInterval.html": [
|
"mozilla/window_setInterval.html": [
|
||||||
{
|
{
|
||||||
"path": "mozilla/window_setInterval.html",
|
"path": "mozilla/window_setInterval.html",
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<link rel="author" title="Mozilla" href="https://www.mozilla.org/">
|
||||||
|
<link rel="author" title="Michael Howell" href="https://www.notriddle.com/">
|
||||||
|
<link rel="help" href="https://drafts.csswg.org/cssom-view/#resizing-viewports">
|
||||||
|
<script>
|
||||||
|
<!-- This event handler needs to be registered before the first layout -->
|
||||||
|
var resize_run = false;
|
||||||
|
window.onresize = function() {
|
||||||
|
resize_run = true;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
<title>window.onresize should not be called when the window first loads</title>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<div id=d></div>
|
||||||
|
<script>
|
||||||
|
var t = async_test("window.onresize should not be called when the window first loads");
|
||||||
|
var d = document.getElementById("d");
|
||||||
|
window.getComputedStyle(d, null).getPropertyValue("width");
|
||||||
|
d.style.width = "1px";
|
||||||
|
window.onload = function() {
|
||||||
|
t.step(function() {
|
||||||
|
assert_true(!resize_run);
|
||||||
|
t.done();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue