style: Don't propagate bits for children invalidated under display:none/not in the flat tree

Much like invalidated_descendants. This preserves our invariant that we
only visit elements with data in the post-traversal.

Differential Revision: https://phabricator.services.mozilla.com/D160338
This commit is contained in:
Emilio Cobos Álvarez 2022-10-26 14:37:34 +00:00 committed by Martin Robinson
parent 8dcf5cddca
commit 3c4d198ad7

View file

@ -152,13 +152,16 @@ where
/// Sets the appropriate restyle hint after invalidating the style of a given
/// element.
pub fn invalidated_self<E>(element: E)
pub fn invalidated_self<E>(element: E) -> bool
where
E: TElement,
{
if let Some(mut data) = element.mutate_data() {
let mut data = match element.mutate_data() {
Some(data) => data,
None => return false,
};
data.hint.insert(RestyleHint::RESTYLE_SELF);
}
true
}
/// Sets the appropriate hint after invalidating the style of a sibling.
@ -167,7 +170,9 @@ where
E: TElement,
{
debug_assert_eq!(element.as_node().parent_node(), of.as_node().parent_node(), "Should be siblings");
invalidated_self(element);
if !invalidated_self(element) {
return;
}
if element.traversal_parent() != of.traversal_parent() {
let parent = element.as_node().parent_element_or_host();
debug_assert!(parent.is_some(), "How can we have siblings without parent nodes?");