mirror of
https://github.com/servo/servo.git
synced 2025-06-08 16:43:28 +00:00
No-op refactor: root_flow param for perform_post_style_recalc_layout_passes
This whole method was a large `if let` block: ```rust if let Some(mut root_flow) = self.root_flow.clone() { // ... } ``` Move that `if let` to callers to make it clear that the method doesn’t need to be called when `self.root_flow` is `None`. By itself, this commit doesn’t change anything. But it enables the next one.
This commit is contained in:
parent
bb54f0a429
commit
02dc8b286a
1 changed files with 92 additions and 90 deletions
|
@ -1189,11 +1189,14 @@ impl LayoutThread {
|
|||
unsafe { layout_context.style_context.stylist.rule_tree.maybe_gc(); }
|
||||
|
||||
// Perform post-style recalculation layout passes.
|
||||
self.perform_post_style_recalc_layout_passes(&data.reflow_info,
|
||||
if let Some(mut root_flow) = self.root_flow.clone() {
|
||||
self.perform_post_style_recalc_layout_passes(&mut root_flow,
|
||||
&data.reflow_info,
|
||||
Some(&data.query_type),
|
||||
Some(&document),
|
||||
&mut rw_data,
|
||||
&mut layout_context);
|
||||
}
|
||||
|
||||
self.respond_to_query_if_necessary(&data.query_type,
|
||||
&mut *rw_data,
|
||||
|
@ -1360,34 +1363,34 @@ impl LayoutThread {
|
|||
let mut layout_context = self.build_layout_context(guards, &*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.
|
||||
let animations = self.running_animations.read();
|
||||
profile(time::ProfilerCategory::LayoutStyleRecalc,
|
||||
self.profiler_metadata(),
|
||||
self.time_profiler_chan.clone(),
|
||||
|| {
|
||||
animation::recalc_style_for_animations(&layout_context,
|
||||
FlowRef::deref_mut(&mut root_flow),
|
||||
&animations)
|
||||
animation::recalc_style_for_animations(
|
||||
&layout_context, FlowRef::deref_mut(&mut root_flow), &animations)
|
||||
});
|
||||
}
|
||||
|
||||
self.perform_post_style_recalc_layout_passes(&reflow_info,
|
||||
self.perform_post_style_recalc_layout_passes(&mut root_flow,
|
||||
&reflow_info,
|
||||
None,
|
||||
None,
|
||||
&mut *rw_data,
|
||||
&mut layout_context);
|
||||
|
||||
}
|
||||
assert!(layout_context.pending_images.is_none());
|
||||
}
|
||||
|
||||
fn perform_post_style_recalc_layout_passes(&mut self,
|
||||
root_flow: &mut FlowRef,
|
||||
data: &Reflow,
|
||||
query_type: Option<&ReflowQueryType>,
|
||||
document: Option<&ServoLayoutDocument>,
|
||||
rw_data: &mut LayoutThreadData,
|
||||
context: &mut LayoutContext) {
|
||||
if let Some(mut root_flow) = self.root_flow.clone() {
|
||||
// Kick off animations if any were triggered, expire completed ones.
|
||||
animation::update_animation_state(&self.constellation_chan,
|
||||
&self.script_chan,
|
||||
|
@ -1403,10 +1406,10 @@ impl LayoutThread {
|
|||
|| {
|
||||
// Call `compute_layout_damage` even in non-incremental mode, because it sets flags
|
||||
// that are needed in both incremental and non-incremental traversals.
|
||||
let damage = FlowRef::deref_mut(&mut root_flow).compute_layout_damage();
|
||||
let damage = FlowRef::deref_mut(root_flow).compute_layout_damage();
|
||||
|
||||
if opts::get().nonincremental_layout || damage.contains(REFLOW_ENTIRE_DOCUMENT) {
|
||||
FlowRef::deref_mut(&mut root_flow).reflow_entire_document()
|
||||
FlowRef::deref_mut(root_flow).reflow_entire_document()
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1418,17 +1421,17 @@ impl LayoutThread {
|
|||
profile(time::ProfilerCategory::LayoutGeneratedContent,
|
||||
self.profiler_metadata(),
|
||||
self.time_profiler_chan.clone(),
|
||||
|| sequential::resolve_generated_content(FlowRef::deref_mut(&mut root_flow), &context));
|
||||
|| sequential::resolve_generated_content(FlowRef::deref_mut(root_flow), &context));
|
||||
|
||||
// Guess float placement.
|
||||
profile(time::ProfilerCategory::LayoutFloatPlacementSpeculation,
|
||||
self.profiler_metadata(),
|
||||
self.time_profiler_chan.clone(),
|
||||
|| sequential::guess_float_placement(FlowRef::deref_mut(&mut root_flow)));
|
||||
|| sequential::guess_float_placement(FlowRef::deref_mut(root_flow)));
|
||||
|
||||
// Perform the primary layout passes over the flow tree to compute the locations of all
|
||||
// the boxes.
|
||||
if flow::base(&*root_flow).restyle_damage.intersects(REFLOW | REFLOW_OUT_OF_FLOW) {
|
||||
if flow::base(&**root_flow).restyle_damage.intersects(REFLOW | REFLOW_OUT_OF_FLOW) {
|
||||
profile(time::ProfilerCategory::LayoutMain,
|
||||
self.profiler_metadata(),
|
||||
self.time_profiler_chan.clone(),
|
||||
|
@ -1438,13 +1441,13 @@ impl LayoutThread {
|
|||
if let (true, Some(traversal)) = (self.parallel_flag, self.parallel_traversal.as_mut()) {
|
||||
// Parallel mode.
|
||||
LayoutThread::solve_constraints_parallel(traversal,
|
||||
FlowRef::deref_mut(&mut root_flow),
|
||||
FlowRef::deref_mut(root_flow),
|
||||
profiler_metadata,
|
||||
self.time_profiler_chan.clone(),
|
||||
&*context);
|
||||
} else {
|
||||
//Sequential mode
|
||||
LayoutThread::solve_constraints(FlowRef::deref_mut(&mut root_flow), &context)
|
||||
LayoutThread::solve_constraints(FlowRef::deref_mut(root_flow), &context)
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -1454,7 +1457,7 @@ impl LayoutThread {
|
|||
self.time_profiler_chan.clone(),
|
||||
|| {
|
||||
sequential::store_overflow(context,
|
||||
FlowRef::deref_mut(&mut root_flow) as &mut Flow);
|
||||
FlowRef::deref_mut(root_flow) as &mut Flow);
|
||||
});
|
||||
|
||||
self.perform_post_main_layout_passes(data,
|
||||
|
@ -1463,7 +1466,6 @@ impl LayoutThread {
|
|||
rw_data,
|
||||
context);
|
||||
}
|
||||
}
|
||||
|
||||
fn perform_post_main_layout_passes(&mut self,
|
||||
data: &Reflow,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue