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:
Simon Sapin 2017-03-19 14:29:07 +01:00
parent bb54f0a429
commit 02dc8b286a

View file

@ -1189,11 +1189,14 @@ impl LayoutThread {
unsafe { layout_context.style_context.stylist.rule_tree.maybe_gc(); } unsafe { layout_context.style_context.stylist.rule_tree.maybe_gc(); }
// Perform post-style recalculation layout passes. // 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(&data.query_type),
Some(&document), Some(&document),
&mut rw_data, &mut rw_data,
&mut layout_context); &mut layout_context);
}
self.respond_to_query_if_necessary(&data.query_type, self.respond_to_query_if_necessary(&data.query_type,
&mut *rw_data, &mut *rw_data,
@ -1360,34 +1363,34 @@ impl LayoutThread {
let mut layout_context = self.build_layout_context(guards, &*rw_data, false); let mut layout_context = self.build_layout_context(guards, &*rw_data, 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.
let animations = self.running_animations.read(); let animations = self.running_animations.read();
profile(time::ProfilerCategory::LayoutStyleRecalc, profile(time::ProfilerCategory::LayoutStyleRecalc,
self.profiler_metadata(), self.profiler_metadata(),
self.time_profiler_chan.clone(), self.time_profiler_chan.clone(),
|| { || {
animation::recalc_style_for_animations(&layout_context, animation::recalc_style_for_animations(
FlowRef::deref_mut(&mut root_flow), &layout_context, FlowRef::deref_mut(&mut root_flow), &animations)
&animations)
}); });
} }
self.perform_post_style_recalc_layout_passes(&mut root_flow,
self.perform_post_style_recalc_layout_passes(&reflow_info, &reflow_info,
None, None,
None, None,
&mut *rw_data, &mut *rw_data,
&mut layout_context); &mut layout_context);
}
assert!(layout_context.pending_images.is_none()); assert!(layout_context.pending_images.is_none());
} }
fn perform_post_style_recalc_layout_passes(&mut self, fn perform_post_style_recalc_layout_passes(&mut self,
root_flow: &mut FlowRef,
data: &Reflow, data: &Reflow,
query_type: Option<&ReflowQueryType>, query_type: Option<&ReflowQueryType>,
document: Option<&ServoLayoutDocument>, document: Option<&ServoLayoutDocument>,
rw_data: &mut LayoutThreadData, rw_data: &mut LayoutThreadData,
context: &mut LayoutContext) { context: &mut LayoutContext) {
if let Some(mut root_flow) = self.root_flow.clone() {
// Kick off animations if any were triggered, expire completed ones. // Kick off animations if any were triggered, expire completed ones.
animation::update_animation_state(&self.constellation_chan, animation::update_animation_state(&self.constellation_chan,
&self.script_chan, &self.script_chan,
@ -1403,10 +1406,10 @@ impl LayoutThread {
|| { || {
// Call `compute_layout_damage` even in non-incremental mode, because it sets flags // Call `compute_layout_damage` even in non-incremental mode, because it sets flags
// that are needed in both incremental and non-incremental traversals. // 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) { 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, profile(time::ProfilerCategory::LayoutGeneratedContent,
self.profiler_metadata(), self.profiler_metadata(),
self.time_profiler_chan.clone(), 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. // Guess float placement.
profile(time::ProfilerCategory::LayoutFloatPlacementSpeculation, profile(time::ProfilerCategory::LayoutFloatPlacementSpeculation,
self.profiler_metadata(), self.profiler_metadata(),
self.time_profiler_chan.clone(), 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 // Perform the primary layout passes over the flow tree to compute the locations of all
// the boxes. // 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, profile(time::ProfilerCategory::LayoutMain,
self.profiler_metadata(), self.profiler_metadata(),
self.time_profiler_chan.clone(), self.time_profiler_chan.clone(),
@ -1438,13 +1441,13 @@ impl LayoutThread {
if let (true, Some(traversal)) = (self.parallel_flag, self.parallel_traversal.as_mut()) { if let (true, Some(traversal)) = (self.parallel_flag, self.parallel_traversal.as_mut()) {
// Parallel mode. // Parallel mode.
LayoutThread::solve_constraints_parallel(traversal, LayoutThread::solve_constraints_parallel(traversal,
FlowRef::deref_mut(&mut root_flow), FlowRef::deref_mut(root_flow),
profiler_metadata, profiler_metadata,
self.time_profiler_chan.clone(), self.time_profiler_chan.clone(),
&*context); &*context);
} else { } else {
//Sequential mode //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(), self.time_profiler_chan.clone(),
|| { || {
sequential::store_overflow(context, 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, self.perform_post_main_layout_passes(data,
@ -1463,7 +1466,6 @@ impl LayoutThread {
rw_data, rw_data,
context); context);
} }
}
fn perform_post_main_layout_passes(&mut self, fn perform_post_main_layout_passes(&mut self,
data: &Reflow, data: &Reflow,