From b4daadf7f28dced2dd5e5d6b4470271292469b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 3 Mar 2017 00:37:10 +0100 Subject: [PATCH 1/4] style: Remove unused screen_size_changed layout context field. --- components/layout_thread/lib.rs | 5 ----- components/style/context.rs | 3 --- ports/geckolib/glue.rs | 1 - 3 files changed, 9 deletions(-) diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index c196f394d51..c144f0f526c 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -496,7 +496,6 @@ impl LayoutThread { // Create a layout context for use in building display lists, hit testing, &c. fn build_layout_context(&self, rw_data: &LayoutThreadData, - screen_size_changed: bool, goal: ReflowGoal, request_images: bool) -> LayoutContext { @@ -506,7 +505,6 @@ impl LayoutThread { LayoutContext { style_context: SharedStyleContext { viewport_size: self.viewport_size.clone(), - screen_size_changed: screen_size_changed, stylist: rw_data.stylist.clone(), goal: goal, running_animations: self.running_animations.clone(), @@ -1120,7 +1118,6 @@ impl LayoutThread { // Create a layout context for use throughout the following passes. let mut layout_context = self.build_layout_context(&*rw_data, - viewport_size_changed, data.reflow_info.goal, true); @@ -1351,7 +1348,6 @@ impl LayoutThread { }; let mut layout_context = self.build_layout_context(&*rw_data, - false, reflow_info.goal, false); @@ -1387,7 +1383,6 @@ impl LayoutThread { }; let mut layout_context = self.build_layout_context(&*rw_data, - false, reflow_info.goal, false); diff --git a/components/style/context.rs b/components/style/context.rs index bbf3a7ed61c..c97e6f531f9 100644 --- a/components/style/context.rs +++ b/components/style/context.rs @@ -64,9 +64,6 @@ pub struct SharedStyleContext { /// The current viewport size. pub viewport_size: Size2D, - /// Screen sized changed? - pub screen_size_changed: bool, - /// The CSS selector stylist. pub stylist: Arc, diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 915b5e1a77b..bf438eff024 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -164,7 +164,6 @@ fn create_shared_context(per_doc_data: &PerDocumentStyleDataImpl) -> SharedStyle SharedStyleContext { // FIXME (bug 1303229): Use the actual viewport size here viewport_size: Size2D::new(Au(0), Au(0)), - screen_size_changed: false, goal: ReflowGoal::ForScriptQuery, stylist: per_doc_data.stylist.clone(), running_animations: per_doc_data.running_animations.clone(), From 71997e6ed9b56ada204efcbc0211c99a481b0847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 3 Mar 2017 00:59:47 +0100 Subject: [PATCH 2/4] style: Remove unused goal field from SharedStyleContext. --- components/layout_thread/lib.rs | 14 +++----------- components/style/context.rs | 3 --- ports/geckolib/glue.rs | 3 +-- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index c144f0f526c..f15ee197dfd 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -496,7 +496,6 @@ impl LayoutThread { // Create a layout context for use in building display lists, hit testing, &c. fn build_layout_context(&self, rw_data: &LayoutThreadData, - goal: ReflowGoal, request_images: bool) -> LayoutContext { let thread_local_style_context_creation_data = @@ -506,7 +505,6 @@ impl LayoutThread { style_context: SharedStyleContext { viewport_size: self.viewport_size.clone(), stylist: rw_data.stylist.clone(), - goal: goal, running_animations: self.running_animations.clone(), expired_animations: self.expired_animations.clone(), error_reporter: self.error_reporter.clone(), @@ -1117,9 +1115,7 @@ impl LayoutThread { } // Create a layout context for use throughout the following passes. - let mut layout_context = self.build_layout_context(&*rw_data, - data.reflow_info.goal, - true); + let mut layout_context = self.build_layout_context(&*rw_data, true); // NB: Type inference falls apart here for some reason, so we need to be very verbose. :-( let traversal_driver = if self.parallel_flag && self.parallel_traversal.is_some() { @@ -1347,9 +1343,7 @@ impl LayoutThread { page_clip_rect: max_rect(), }; - let mut layout_context = self.build_layout_context(&*rw_data, - reflow_info.goal, - false); + let mut layout_context = self.build_layout_context(&*rw_data, false); if let Some(mut root_flow) = self.root_flow.clone() { // Perform an abbreviated style recalc that operates without access to the DOM. @@ -1382,9 +1376,7 @@ impl LayoutThread { page_clip_rect: max_rect(), }; - let mut layout_context = self.build_layout_context(&*rw_data, - reflow_info.goal, - false); + let mut layout_context = self.build_layout_context(&*rw_data, false); // No need to do a style recalc here. if self.root_flow.is_none() { diff --git a/components/style/context.rs b/components/style/context.rs index c97e6f531f9..e8adc79faa9 100644 --- a/components/style/context.rs +++ b/components/style/context.rs @@ -67,9 +67,6 @@ pub struct SharedStyleContext { /// The CSS selector stylist. pub stylist: Arc, - /// Why is this reflow occurring - pub goal: ReflowGoal, - /// The animations that are currently running. pub running_animations: Arc>>>, diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index bf438eff024..8c3584c1026 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -20,7 +20,7 @@ use std::fmt::Write; use std::ptr; use std::sync::{Arc, Mutex}; use style::arc_ptr_eq; -use style::context::{QuirksMode, ReflowGoal, SharedStyleContext, StyleContext}; +use style::context::{QuirksMode, SharedStyleContext, StyleContext}; use style::context::{ThreadLocalStyleContext, ThreadLocalStyleContextCreationInfo}; use style::data::{ElementData, ElementStyles, RestyleData}; use style::dom::{ShowSubtreeData, TElement, TNode}; @@ -164,7 +164,6 @@ fn create_shared_context(per_doc_data: &PerDocumentStyleDataImpl) -> SharedStyle SharedStyleContext { // FIXME (bug 1303229): Use the actual viewport size here viewport_size: Size2D::new(Au(0), Au(0)), - goal: ReflowGoal::ForScriptQuery, stylist: per_doc_data.stylist.clone(), running_animations: per_doc_data.running_animations.clone(), expired_animations: per_doc_data.expired_animations.clone(), From 072f93e41e3d771b938cd8e3ade5cdbfbcd34784 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 3 Mar 2017 01:00:24 +0100 Subject: [PATCH 3/4] layout_thread: Simplify needs_dirtying setup. --- components/layout_thread/lib.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index f15ee197dfd..1838eb7126f 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -1031,9 +1031,6 @@ impl LayoutThread { Au::from_f32_px(constraints.size.height)) }); - // Handle conditions where the entire flow tree is invalid. - let mut needs_dirtying = false; - let viewport_size_changed = self.viewport_size != old_viewport_size; if viewport_size_changed { if let Some(constraints) = rw_data.stylist.viewport_constraints() { @@ -1067,9 +1064,9 @@ impl LayoutThread { } // If the entire flow tree is invalid, then it will be reflowed anyhow. - needs_dirtying |= Arc::get_mut(&mut rw_data.stylist).unwrap().update(&data.document_stylesheets, - Some(&*UA_STYLESHEETS), - data.stylesheets_changed); + let needs_dirtying = Arc::get_mut(&mut rw_data.stylist).unwrap().update(&data.document_stylesheets, + Some(&*UA_STYLESHEETS), + data.stylesheets_changed); let needs_reflow = viewport_size_changed && !needs_dirtying; if needs_dirtying { if let Some(mut d) = element.mutate_data() { From 8832b5ab0a966b59aef3a7dd35c996c3b13fc390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 3 Mar 2017 01:00:49 +0100 Subject: [PATCH 4/4] layout_thread: Also reposition elements when reflowing all nodes. Fixes #15801 --- components/layout_thread/lib.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index 1838eb7126f..1609ea2ae17 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -1500,7 +1500,9 @@ impl LayoutThread { fn reflow_all_nodes(flow: &mut Flow) { debug!("reflowing all nodes!"); - flow::mut_base(flow).restyle_damage.insert(REPAINT | STORE_OVERFLOW | REFLOW); + flow::mut_base(flow) + .restyle_damage + .insert(REPAINT | STORE_OVERFLOW | REFLOW | REPOSITION); for child in flow::child_iter_mut(flow) { LayoutThread::reflow_all_nodes(child);