auto merge of #1394 : kmcallister/servo/style-damage, r=pcwalton

This fixes the computation of restyle damage on `color-change-text.html`, which can be seen with `RUST_LOG=servo::layout::layout_task`.

However we can't prune the layout traversals yet, because we don't reuse `Flow` objects between reflows, so we have no old values to fall back to.

I think this used to work because `FlowContexts` (as they were called then) were stored in a DOM node's `LayoutData` and reused.  But it's possible that it never really worked, and my testing when I landed the restyle damage code was insufficient (I didn't understand the layout code nearly as well back then).

r? @pcwalton
This commit is contained in:
bors-servo 2013-12-12 15:17:27 -08:00
commit 144737ce1b
5 changed files with 38 additions and 34 deletions

View file

@ -15,7 +15,7 @@ use layout::extra::LayoutAuxMethods;
use layout::flow::{Flow, ImmutableFlowUtils, MutableFlowUtils, PreorderFlowTraversal};
use layout::flow::{PostorderFlowTraversal};
use layout::flow;
use layout::incremental::{RestyleDamage, BubbleWidths};
use layout::incremental::{RestyleDamage};
use layout::util::{LayoutData, LayoutDataAccess};
use extra::arc::{Arc, RWArc, MutexArc};
@ -100,7 +100,7 @@ impl PostorderFlowTraversal for ComputeDamageTraversal {
fn process(&mut self, flow: &mut Flow) -> bool {
let mut damage = flow::base(flow).restyle_damage;
for child in flow::child_iter(flow) {
damage.union_in_place(flow::base(*child).restyle_damage)
damage.union_in_place(flow::base(*child).restyle_damage.propagate_up())
}
flow::mut_base(flow).restyle_damage = damage;
true
@ -120,6 +120,7 @@ impl PreorderFlowTraversal for PropagateDamageTraversal {
if self.all_style_damage {
flow::mut_base(flow).restyle_damage.union_in_place(RestyleDamage::all())
}
debug!("restyle damage = {:?}", flow::base(flow).restyle_damage);
let prop = flow::base(flow).restyle_damage.propagate_down();
if prop.is_nonempty() {
@ -142,10 +143,13 @@ impl<'self> PostorderFlowTraversal for BubbleWidthsTraversal<'self> {
true
}
// FIXME: We can't prune until we start reusing flows
/*
#[inline]
fn should_prune(&mut self, flow: &mut Flow) -> bool {
flow::mut_base(flow).restyle_damage.lacks(BubbleWidths)
}
*/
}
/// The assign-widths traversal. In Gecko this corresponds to `Reflow`.
@ -371,10 +375,9 @@ impl LayoutTask {
layout_context: &mut LayoutContext) {
let _ = layout_root.traverse_postorder(&mut BubbleWidthsTraversal(layout_context));
// FIXME(kmc): We want to do
// for flow in layout_root.traverse_preorder_prune(|f|
// f.restyle_damage().lacks(Reflow))
// but FloatContext values can't be reused, so we need to recompute them every time.
// FIXME(kmc): We want to prune nodes without the Reflow restyle damage
// bit, but FloatContext values can't be reused, so we need to
// recompute them every time.
// NOTE: this currently computes borders, so any pruning should separate that operation out.
let _ = layout_root.traverse_preorder(&mut AssignWidthsTraversal(layout_context));