mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Auto merge of #15805 - emilio:reposition, r=glennw
layout_thread: Also reposition elements when reflowing all nodes. <!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/15805) <!-- Reviewable:end -->
This commit is contained in:
commit
aeb7ab867f
3 changed files with 10 additions and 32 deletions
|
@ -496,8 +496,6 @@ impl LayoutThread {
|
||||||
// Create a layout context for use in building display lists, hit testing, &c.
|
// Create a layout context for use in building display lists, hit testing, &c.
|
||||||
fn build_layout_context(&self,
|
fn build_layout_context(&self,
|
||||||
rw_data: &LayoutThreadData,
|
rw_data: &LayoutThreadData,
|
||||||
screen_size_changed: bool,
|
|
||||||
goal: ReflowGoal,
|
|
||||||
request_images: bool)
|
request_images: bool)
|
||||||
-> LayoutContext {
|
-> LayoutContext {
|
||||||
let thread_local_style_context_creation_data =
|
let thread_local_style_context_creation_data =
|
||||||
|
@ -506,9 +504,7 @@ impl LayoutThread {
|
||||||
LayoutContext {
|
LayoutContext {
|
||||||
style_context: SharedStyleContext {
|
style_context: SharedStyleContext {
|
||||||
viewport_size: self.viewport_size.clone(),
|
viewport_size: self.viewport_size.clone(),
|
||||||
screen_size_changed: screen_size_changed,
|
|
||||||
stylist: rw_data.stylist.clone(),
|
stylist: rw_data.stylist.clone(),
|
||||||
goal: goal,
|
|
||||||
running_animations: self.running_animations.clone(),
|
running_animations: self.running_animations.clone(),
|
||||||
expired_animations: self.expired_animations.clone(),
|
expired_animations: self.expired_animations.clone(),
|
||||||
error_reporter: self.error_reporter.clone(),
|
error_reporter: self.error_reporter.clone(),
|
||||||
|
@ -1035,9 +1031,6 @@ impl LayoutThread {
|
||||||
Au::from_f32_px(constraints.size.height))
|
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;
|
let viewport_size_changed = self.viewport_size != old_viewport_size;
|
||||||
if viewport_size_changed {
|
if viewport_size_changed {
|
||||||
if let Some(constraints) = rw_data.stylist.viewport_constraints() {
|
if let Some(constraints) = rw_data.stylist.viewport_constraints() {
|
||||||
|
@ -1071,9 +1064,9 @@ impl LayoutThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the entire flow tree is invalid, then it will be reflowed anyhow.
|
// 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,
|
let needs_dirtying = Arc::get_mut(&mut rw_data.stylist).unwrap().update(&data.document_stylesheets,
|
||||||
Some(&*UA_STYLESHEETS),
|
Some(&*UA_STYLESHEETS),
|
||||||
data.stylesheets_changed);
|
data.stylesheets_changed);
|
||||||
let needs_reflow = viewport_size_changed && !needs_dirtying;
|
let needs_reflow = viewport_size_changed && !needs_dirtying;
|
||||||
if needs_dirtying {
|
if needs_dirtying {
|
||||||
if let Some(mut d) = element.mutate_data() {
|
if let Some(mut d) = element.mutate_data() {
|
||||||
|
@ -1119,10 +1112,7 @@ impl LayoutThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a layout context for use throughout the following passes.
|
// Create a layout context for use throughout the following passes.
|
||||||
let mut layout_context = self.build_layout_context(&*rw_data,
|
let mut layout_context = self.build_layout_context(&*rw_data, true);
|
||||||
viewport_size_changed,
|
|
||||||
data.reflow_info.goal,
|
|
||||||
true);
|
|
||||||
|
|
||||||
// NB: Type inference falls apart here for some reason, so we need to be very verbose. :-(
|
// 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() {
|
let traversal_driver = if self.parallel_flag && self.parallel_traversal.is_some() {
|
||||||
|
@ -1350,10 +1340,7 @@ impl LayoutThread {
|
||||||
page_clip_rect: max_rect(),
|
page_clip_rect: max_rect(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut layout_context = self.build_layout_context(&*rw_data,
|
let mut layout_context = self.build_layout_context(&*rw_data, false);
|
||||||
false,
|
|
||||||
reflow_info.goal,
|
|
||||||
false);
|
|
||||||
|
|
||||||
if let Some(mut root_flow) = self.root_flow.clone() {
|
if let Some(mut root_flow) = self.root_flow.clone() {
|
||||||
// Perform an abbreviated style recalc that operates without access to the DOM.
|
// Perform an abbreviated style recalc that operates without access to the DOM.
|
||||||
|
@ -1386,10 +1373,7 @@ impl LayoutThread {
|
||||||
page_clip_rect: max_rect(),
|
page_clip_rect: max_rect(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut layout_context = self.build_layout_context(&*rw_data,
|
let mut layout_context = self.build_layout_context(&*rw_data, false);
|
||||||
false,
|
|
||||||
reflow_info.goal,
|
|
||||||
false);
|
|
||||||
|
|
||||||
// No need to do a style recalc here.
|
// No need to do a style recalc here.
|
||||||
if self.root_flow.is_none() {
|
if self.root_flow.is_none() {
|
||||||
|
@ -1516,7 +1500,9 @@ impl LayoutThread {
|
||||||
|
|
||||||
fn reflow_all_nodes(flow: &mut Flow) {
|
fn reflow_all_nodes(flow: &mut Flow) {
|
||||||
debug!("reflowing all nodes!");
|
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) {
|
for child in flow::child_iter_mut(flow) {
|
||||||
LayoutThread::reflow_all_nodes(child);
|
LayoutThread::reflow_all_nodes(child);
|
||||||
|
|
|
@ -64,15 +64,9 @@ pub struct SharedStyleContext {
|
||||||
/// The current viewport size.
|
/// The current viewport size.
|
||||||
pub viewport_size: Size2D<Au>,
|
pub viewport_size: Size2D<Au>,
|
||||||
|
|
||||||
/// Screen sized changed?
|
|
||||||
pub screen_size_changed: bool,
|
|
||||||
|
|
||||||
/// The CSS selector stylist.
|
/// The CSS selector stylist.
|
||||||
pub stylist: Arc<Stylist>,
|
pub stylist: Arc<Stylist>,
|
||||||
|
|
||||||
/// Why is this reflow occurring
|
|
||||||
pub goal: ReflowGoal,
|
|
||||||
|
|
||||||
/// The animations that are currently running.
|
/// The animations that are currently running.
|
||||||
pub running_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>,
|
pub running_animations: Arc<RwLock<HashMap<OpaqueNode, Vec<Animation>>>>,
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ use std::fmt::Write;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use style::arc_ptr_eq;
|
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::context::{ThreadLocalStyleContext, ThreadLocalStyleContextCreationInfo};
|
||||||
use style::data::{ElementData, ElementStyles, RestyleData};
|
use style::data::{ElementData, ElementStyles, RestyleData};
|
||||||
use style::dom::{ShowSubtreeData, TElement, TNode};
|
use style::dom::{ShowSubtreeData, TElement, TNode};
|
||||||
|
@ -164,8 +164,6 @@ fn create_shared_context(per_doc_data: &PerDocumentStyleDataImpl) -> SharedStyle
|
||||||
SharedStyleContext {
|
SharedStyleContext {
|
||||||
// FIXME (bug 1303229): Use the actual viewport size here
|
// FIXME (bug 1303229): Use the actual viewport size here
|
||||||
viewport_size: Size2D::new(Au(0), Au(0)),
|
viewport_size: Size2D::new(Au(0), Au(0)),
|
||||||
screen_size_changed: false,
|
|
||||||
goal: ReflowGoal::ForScriptQuery,
|
|
||||||
stylist: per_doc_data.stylist.clone(),
|
stylist: per_doc_data.stylist.clone(),
|
||||||
running_animations: per_doc_data.running_animations.clone(),
|
running_animations: per_doc_data.running_animations.clone(),
|
||||||
expired_animations: per_doc_data.expired_animations.clone(),
|
expired_animations: per_doc_data.expired_animations.clone(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue