Skip to content

Commit

Permalink
servo: Merge #18173 - style: Keep dirty bit invariants during invalid…
Browse files Browse the repository at this point in the history
…ation (from emilio:invalidation-dirty-thingie); r=bholley

There's the question of whether should we be recursing into the invalidation
code for elements without data... Probably not, but that's a somewhat more
risky change.

Bug: 1391444
Source-Repo: https://github.com/servo/servo
Source-Revision: 05f2001914720590c87ccf564389a6fb2e2e1465
  • Loading branch information
emilio committed Aug 21, 2017
1 parent 2dfa874 commit 6022762
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions servo/components/style/invalidation/element/invalidator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ pub struct TreeStyleInvalidator<'a, 'b: 'a, E>
where E: TElement,
{
element: E,
// TODO(emilio): It's tempting enough to just avoid running invalidation for
// elements without data.
//
// But that's be wrong for sibling invalidations when a new element has been
// inserted in the tree and still has no data (though I _think_ the slow
// selector bits save us, it'd be nice not to depend on them).
//
// Seems like we could at least avoid running invalidation for the
// descendants if an element has no data, though.
data: Option<&'a mut ElementData>,
shared_context: &'a SharedStyleContext<'b>,
}
Expand Down Expand Up @@ -353,7 +362,7 @@ impl<'a, 'b: 'a, E> TreeStyleInvalidator<'a, 'b, E>
//
// Since we keep the traversal flags in terms of the flattened tree,
// we need to propagate it as appropriate.
if invalidated_child {
if invalidated_child && child.get_data().is_some() {
let mut current = child.traversal_parent();
while let Some(parent) = current.take() {
if parent == self.element {
Expand Down Expand Up @@ -470,7 +479,7 @@ impl<'a, 'b: 'a, E> TreeStyleInvalidator<'a, 'b, E>

any_descendant |= self.invalidate_nac(invalidations);

if any_descendant {
if any_descendant && self.data.as_ref().map_or(false, |d| !d.styles.is_display_none()) {
unsafe { self.element.set_dirty_descendants() };
}

Expand Down

0 comments on commit 6022762

Please sign in to comment.