mirror of
https://github.com/servo/servo.git
synced 2025-07-29 18:20:24 +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
|
@ -56,7 +56,7 @@ use js::rust::Runtime;
|
|||
use layout_interface::{LayoutChan, LayoutRPC};
|
||||
use libc;
|
||||
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_cache_thread::{ImageCacheChan, ImageCacheThread};
|
||||
use net_traits::response::HttpsState;
|
||||
|
@ -294,7 +294,7 @@ no_jsmanaged_fields!(PropertyDeclarationBlock);
|
|||
no_jsmanaged_fields!(HashSet<T>);
|
||||
// These three are interdependent, if you plan to put jsmanaged data
|
||||
// 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!(WorkerId);
|
||||
no_jsmanaged_fields!(QuirksMode);
|
||||
|
|
|
@ -43,7 +43,8 @@ use js::rust::Runtime;
|
|||
use layout_interface::{ContentBoxResponse, ContentBoxesResponse, ResolvedStyleResponse, ScriptReflow};
|
||||
use layout_interface::{LayoutChan, LayoutRPC, Msg, Reflow, ReflowQueryType, MarginStyleResponse};
|
||||
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 net_traits::ResourceThread;
|
||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheThread};
|
||||
|
@ -181,7 +182,7 @@ pub struct Window {
|
|||
next_subpage_id: Cell<SubpageId>,
|
||||
|
||||
/// Pending resize event, if any.
|
||||
resize_event: Cell<Option<WindowSizeData>>,
|
||||
resize_event: Cell<Option<(WindowSizeData, WindowSizeType)>>,
|
||||
|
||||
/// Pipeline id associated with this page.
|
||||
id: PipelineId,
|
||||
|
@ -1280,11 +1281,11 @@ impl Window {
|
|||
self.pending_reflow_count.set(self.pending_reflow_count.get() + 1);
|
||||
}
|
||||
|
||||
pub fn set_resize_event(&self, event: WindowSizeData) {
|
||||
self.resize_event.set(Some(event));
|
||||
pub fn set_resize_event(&self, event: WindowSizeData, event_type: WindowSizeType) {
|
||||
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();
|
||||
self.resize_event.set(None);
|
||||
event
|
||||
|
|
|
@ -61,7 +61,7 @@ use layout_interface::{self, LayoutChan, NewLayoutThreadInfo, ScriptLayoutChan};
|
|||
use mem::heap_size_of_self_and_children;
|
||||
use msg::constellation_msg::{ConstellationChan, LoadData};
|
||||
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 net_traits::LoadData as NetLoadData;
|
||||
use net_traits::image_cache_thread::{ImageCacheChan, ImageCacheResult, ImageCacheThread};
|
||||
|
@ -635,8 +635,8 @@ impl ScriptThread {
|
|||
}
|
||||
}
|
||||
|
||||
for (id, size) in resizes {
|
||||
self.handle_event(id, ResizeEvent(size));
|
||||
for (id, (size, size_type)) in resizes {
|
||||
self.handle_event(id, ResizeEvent(size, size_type));
|
||||
}
|
||||
|
||||
// Store new resizes, and gather all other events.
|
||||
|
@ -689,9 +689,9 @@ impl ScriptThread {
|
|||
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.handle_resize(id, size);
|
||||
self.handle_resize(id, size, size_type);
|
||||
})
|
||||
}
|
||||
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) {
|
||||
let window = page.window();
|
||||
window.set_resize_event(size);
|
||||
window.set_resize_event(size, size_type);
|
||||
return;
|
||||
}
|
||||
let mut loads = self.incomplete_loads.borrow_mut();
|
||||
|
@ -1670,8 +1670,8 @@ impl ScriptThread {
|
|||
}
|
||||
|
||||
match event {
|
||||
ResizeEvent(new_size) => {
|
||||
self.handle_resize_event(pipeline_id, new_size);
|
||||
ResizeEvent(new_size, size_type) => {
|
||||
self.handle_resize_event(pipeline_id, new_size, size_type);
|
||||
}
|
||||
|
||||
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 window = page.window();
|
||||
window.set_window_size(new_size);
|
||||
|
@ -1849,11 +1849,13 @@ impl ScriptThread {
|
|||
|
||||
// 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
|
||||
let uievent = UIEvent::new(window.r(),
|
||||
DOMString::from("resize"), EventBubbles::DoesNotBubble,
|
||||
EventCancelable::NotCancelable, Some(window.r()),
|
||||
0i32);
|
||||
uievent.upcast::<Event>().fire(window.upcast());
|
||||
if size_type == WindowSizeType::Resize {
|
||||
let uievent = UIEvent::new(window.r(),
|
||||
DOMString::from("resize"), EventBubbles::DoesNotBubble,
|
||||
EventCancelable::NotCancelable, Some(window.r()),
|
||||
0i32);
|
||||
uievent.upcast::<Event>().fire(window.upcast());
|
||||
}
|
||||
}
|
||||
|
||||
/// Initiate a non-blocking fetch for a specified resource. Stores the InProgressLoad
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue