mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Implement concept of dirty root
This commit is contained in:
parent
518c0660c6
commit
036f123c4e
11 changed files with 251 additions and 64 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue