Auto merge of #16159 - bholley:note_dirty_descendants, r=heycam

Centralize note_dirty_descendants implementation, and fully propagate dirty_descendants in resolve_style.

The current code can leave the tree in an inconsistent state, with the dirty
descendants bit not fully propagated.

Reviewed in https://bugzilla.mozilla.org/show_bug.cgi?id=1350441

<!-- 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/16159)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-03-29 06:52:07 -05:00 committed by GitHub
commit 8adf191973
4 changed files with 68 additions and 27 deletions

View file

@ -63,7 +63,8 @@ use style::attr::AttrValue;
use style::computed_values::display;
use style::context::{QuirksMode, SharedStyleContext};
use style::data::ElementData;
use style::dom::{LayoutIterator, NodeInfo, OpaqueNode, PresentationalHintsSynthetizer, TElement, TNode};
use style::dom::{DirtyDescendants, LayoutIterator, NodeInfo, OpaqueNode, PresentationalHintsSynthetizer};
use style::dom::{TElement, TNode};
use style::dom::UnsafeNode;
use style::element_state::*;
use style::properties::{ComputedValues, PropertyDeclarationBlock};
@ -487,6 +488,9 @@ impl<'le> ServoLayoutElement<'le> {
}
}
// FIXME(bholley): This should be merged with TElement::note_dirty_descendants,
// but that requires re-testing and possibly fixing the broken callers given
// the FIXME below, which I don't have time to do right now.
pub unsafe fn note_dirty_descendant(&self) {
use ::selectors::Element;
@ -501,19 +505,7 @@ impl<'le> ServoLayoutElement<'le> {
current = el.parent_element();
}
debug_assert!(self.dirty_descendants_bit_is_propagated());
}
fn dirty_descendants_bit_is_propagated(&self) -> bool {
use ::selectors::Element;
let mut current = Some(*self);
while let Some(el) = current {
if !el.has_dirty_descendants() { return false; }
current = el.parent_element();
}
true
debug_assert!(self.descendants_bit_is_propagated::<DirtyDescendants>());
}
}