mirror of
https://github.com/servo/servo.git
synced 2025-08-12 08:55:32 +01:00
style: Unify invalidated_child with invalidated_descendants.
I think invalidated_descendants was buggy, and this fixes it.
This commit is contained in:
parent
557353c1f6
commit
9e61c1962b
2 changed files with 16 additions and 38 deletions
|
@ -203,16 +203,20 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
fn invalidated_child(
|
||||
fn invalidated_descendants(
|
||||
&self,
|
||||
element: E,
|
||||
_data: Option<&mut ElementData>,
|
||||
data: Option<&mut ElementData>,
|
||||
child: E,
|
||||
) {
|
||||
if child.get_data().is_none() {
|
||||
return;
|
||||
}
|
||||
|
||||
if data.as_ref().map_or(true, |d| d.styles.is_display_none()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The child may not be a flattened tree child of the current element,
|
||||
// but may be arbitrarily deep.
|
||||
//
|
||||
|
@ -220,24 +224,12 @@ where
|
|||
// we need to propagate it as appropriate.
|
||||
let mut current = child.traversal_parent();
|
||||
while let Some(parent) = current.take() {
|
||||
unsafe { parent.set_dirty_descendants() };
|
||||
current = parent.traversal_parent();
|
||||
|
||||
if parent == element {
|
||||
break;
|
||||
}
|
||||
|
||||
unsafe { parent.set_dirty_descendants() };
|
||||
current = parent.traversal_parent();
|
||||
}
|
||||
}
|
||||
|
||||
fn invalidated_descendants(
|
||||
&self,
|
||||
element: E,
|
||||
data: Option<&mut ElementData>,
|
||||
) {
|
||||
// FIXME(emilio): We probably want to walk the flattened tree here too,
|
||||
// and remove invalidated_child instead, or something like that.
|
||||
if data.as_ref().map_or(false, |d| !d.styles.is_display_none()) {
|
||||
unsafe { element.set_dirty_descendants() };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -54,14 +54,6 @@ where
|
|||
data: Option<&mut ElementData>,
|
||||
);
|
||||
|
||||
/// Executes an arbitrary action when a direct child is invalidated.
|
||||
fn invalidated_child(
|
||||
&self,
|
||||
element: E,
|
||||
data: Option<&mut ElementData>,
|
||||
child: E,
|
||||
);
|
||||
|
||||
/// Executes an action when `Self` is invalidated.
|
||||
fn invalidated_self(
|
||||
&self,
|
||||
|
@ -74,6 +66,7 @@ where
|
|||
&self,
|
||||
element: E,
|
||||
data: Option<&mut ElementData>,
|
||||
child: E,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -388,23 +381,23 @@ where
|
|||
sibling_invalidations,
|
||||
);
|
||||
|
||||
let invalidated_descendants = child_invalidator.invalidate_descendants(
|
||||
&invalidations_for_descendants
|
||||
);
|
||||
|
||||
// The child may not be a flattened tree child of the current element,
|
||||
// but may be arbitrarily deep.
|
||||
//
|
||||
// Since we keep the traversal flags in terms of the flattened tree,
|
||||
// we need to propagate it as appropriate.
|
||||
if invalidated_child {
|
||||
self.processor.invalidated_child(
|
||||
if invalidated_child || invalidated_descendants {
|
||||
self.processor.invalidated_descendants(
|
||||
self.element,
|
||||
self.data.as_mut().map(|d| &mut **d),
|
||||
child,
|
||||
);
|
||||
}
|
||||
|
||||
let invalidated_descendants = child_invalidator.invalidate_descendants(
|
||||
&invalidations_for_descendants
|
||||
);
|
||||
|
||||
invalidated_child || invalidated_descendants
|
||||
}
|
||||
|
||||
|
@ -517,13 +510,6 @@ where
|
|||
|
||||
any_descendant |= self.invalidate_nac(invalidations);
|
||||
|
||||
if any_descendant {
|
||||
self.processor.invalidated_descendants(
|
||||
self.element,
|
||||
self.data.as_mut().map(|d| &mut **d)
|
||||
);
|
||||
}
|
||||
|
||||
any_descendant
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue