diff options
Diffstat (limited to 'components/script/dom/node.rs')
-rw-r--r-- | components/script/dom/node.rs | 52 |
1 files changed, 40 insertions, 12 deletions
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 7a75ea51503..f17c22163d0 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -315,6 +315,8 @@ impl Node { /// Fails unless `child` is a child of this node. fn remove_child(&self, child: &Node, cached_index: Option<u32>) { assert!(child.parent_node.get().as_deref() == Some(self)); + self.note_dirty_descendants(); + let prev_sibling = child.GetPreviousSibling(); match prev_sibling { None => { @@ -627,17 +629,7 @@ impl Node { // FIXME(emilio): This and the function below should move to Element. pub fn note_dirty_descendants(&self) { - debug_assert!(self.is_connected()); - - for ancestor in self.inclusive_ancestors(ShadowIncluding::Yes) { - if ancestor.get_flag(NodeFlags::HAS_DIRTY_DESCENDANTS) { - return; - } - - if ancestor.is::<Element>() { - ancestor.set_flag(NodeFlags::HAS_DIRTY_DESCENDANTS, true); - } - } + self.owner_doc().note_node_with_dirty_descendants(self); } pub fn has_dirty_descendants(&self) -> bool { @@ -705,6 +697,22 @@ impl Node { } } + pub fn common_ancestor( + &self, + other: &Node, + shadow_including: ShadowIncluding, + ) -> DomRoot<Node> { + for ancestor in self.inclusive_ancestors(shadow_including) { + if other + .inclusive_ancestors(shadow_including) + .any(|node| node == ancestor) + { + return ancestor; + } + } + unreachable!(); + } + pub fn is_inclusive_ancestor_of(&self, parent: &Node) -> bool { self == parent || self.is_ancestor_of(parent) } @@ -1243,6 +1251,26 @@ impl Node { } } + pub fn is_styled(&self) -> bool { + self.style_and_layout_data.borrow().is_some() + } + + pub fn is_display_none(&self) -> bool { + self.style_and_layout_data + .borrow() + .as_ref() + .map_or(true, |data| { + data.style_data + .element_data + .borrow() + .styles + .primary() + .get_box() + .display + .is_none() + }) + } + pub fn style(&self) -> Option<Arc<ComputedValues>> { if !window_from_node(self).layout_reflow(QueryMsg::StyleQuery) { return None; @@ -1653,7 +1681,7 @@ where } /// Whether a tree traversal should pass shadow tree boundaries. -#[derive(PartialEq)] +#[derive(Clone, Copy, PartialEq)] pub enum ShadowIncluding { No, Yes, |