mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: fix invalidation of sibling combinators in different slots
This extends the code to deal with sibling invalidation to handle the case where the flat tree doesn't match the DOM tree. In the test-case for example, dom is: * details * summary id=a * summary But flat tree is: * details * slot * summary id=a * slot * summary Differential Revision: https://phabricator.services.mozilla.com/D159150
This commit is contained in:
parent
6cb665df95
commit
f14f1fa440
6 changed files with 66 additions and 11 deletions
|
@ -130,4 +130,8 @@ where
|
|||
fn invalidated_self(&mut self, element: E) {
|
||||
state_and_attributes::invalidated_self(element);
|
||||
}
|
||||
|
||||
fn invalidated_sibling(&mut self, sibling: E, of: E) {
|
||||
state_and_attributes::invalidated_sibling(sibling, of);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,10 @@ where
|
|||
/// Executes an action when `Self` is invalidated.
|
||||
fn invalidated_self(&mut self, element: E);
|
||||
|
||||
/// Executes an action when `sibling` is invalidated as a sibling of
|
||||
/// `of`.
|
||||
fn invalidated_sibling(&mut self, sibling: E, of: E);
|
||||
|
||||
/// Executes an action when any descendant of `Self` is invalidated.
|
||||
fn invalidated_descendants(&mut self, element: E, child: E);
|
||||
}
|
||||
|
@ -397,7 +401,7 @@ where
|
|||
);
|
||||
|
||||
if invalidated_sibling {
|
||||
sibling_invalidator.processor.invalidated_self(sibling);
|
||||
sibling_invalidator.processor.invalidated_sibling(sibling, self.element);
|
||||
}
|
||||
|
||||
any_invalidated |= invalidated_sibling;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
use crate::context::SharedStyleContext;
|
||||
use crate::data::ElementData;
|
||||
use crate::dom::TElement;
|
||||
use crate::dom::{TElement, TNode};
|
||||
use crate::invalidation::element::element_wrapper::{ElementSnapshot, ElementWrapper};
|
||||
use crate::invalidation::element::invalidation_map::*;
|
||||
use crate::invalidation::element::invalidator::{DescendantInvalidationLists, InvalidationVector};
|
||||
|
@ -118,14 +118,10 @@ pub fn should_process_descendants(data: &ElementData) -> bool {
|
|||
}
|
||||
|
||||
/// Propagates the bits after invalidating a descendant child.
|
||||
pub fn invalidated_descendants<E>(element: E, child: E)
|
||||
pub fn propagate_dirty_bit_up_to<E>(ancestor: E, child: E)
|
||||
where
|
||||
E: TElement,
|
||||
{
|
||||
if !child.has_data() {
|
||||
return;
|
||||
}
|
||||
|
||||
// The child may not be a flattened tree child of the current element,
|
||||
// but may be arbitrarily deep.
|
||||
//
|
||||
|
@ -136,10 +132,22 @@ where
|
|||
unsafe { parent.set_dirty_descendants() };
|
||||
current = parent.traversal_parent();
|
||||
|
||||
if parent == element {
|
||||
break;
|
||||
if parent == ancestor {
|
||||
return;
|
||||
}
|
||||
}
|
||||
debug_assert!(false, "Should've found {:?} as an ancestor of {:?}", ancestor, child);
|
||||
}
|
||||
|
||||
/// Propagates the bits after invalidating a descendant child, if needed.
|
||||
pub fn invalidated_descendants<E>(element: E, child: E)
|
||||
where
|
||||
E: TElement,
|
||||
{
|
||||
if !child.has_data() {
|
||||
return;
|
||||
}
|
||||
propagate_dirty_bit_up_to(element, child)
|
||||
}
|
||||
|
||||
/// Sets the appropriate restyle hint after invalidating the style of a given
|
||||
|
@ -153,6 +161,22 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
/// Sets the appropriate hint after invalidating the style of a sibling.
|
||||
pub fn invalidated_sibling<E>(element: E, of: E)
|
||||
where
|
||||
E: TElement,
|
||||
{
|
||||
debug_assert_eq!(element.as_node().parent_node(), of.as_node().parent_node(), "Should be siblings");
|
||||
invalidated_self(element);
|
||||
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?");
|
||||
if let Some(e) = parent {
|
||||
propagate_dirty_bit_up_to(e, element)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b: 'a, E: 'a> InvalidationProcessor<'a, E>
|
||||
for StateAndAttrInvalidationProcessor<'a, 'b, E>
|
||||
where
|
||||
|
@ -366,6 +390,11 @@ where
|
|||
debug_assert_ne!(element, self.element);
|
||||
invalidated_self(element);
|
||||
}
|
||||
|
||||
fn invalidated_sibling(&mut self, element: E, of: E) {
|
||||
debug_assert_ne!(element, self.element);
|
||||
invalidated_sibling(element, of);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b, 'selectors, E> Collector<'a, 'b, 'selectors, E>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue