mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Do not set dirty out-of-doc nodes
This commit is contained in:
parent
e66438de48
commit
d7b6a6f509
5 changed files with 15 additions and 3 deletions
|
@ -313,6 +313,10 @@ impl<'ln> TNode for ServoLayoutNode<'ln> {
|
|||
self.node.downcast().map(ServoShadowRoot::from_layout_js)
|
||||
}
|
||||
|
||||
fn is_in_document(&self) -> bool {
|
||||
unsafe { self.node.get_flag(NodeFlags::IS_IN_DOC) }
|
||||
}
|
||||
|
||||
fn is_connected(&self) -> bool {
|
||||
unsafe { self.node.get_flag(NodeFlags::IS_CONNECTED) }
|
||||
}
|
||||
|
@ -555,7 +559,7 @@ impl<'le> TElement for ServoLayoutElement<'le> {
|
|||
}
|
||||
|
||||
unsafe fn set_dirty_descendants(&self) {
|
||||
debug_assert!(self.as_node().is_connected());
|
||||
debug_assert!(self.as_node().is_in_document());
|
||||
self.as_node()
|
||||
.node
|
||||
.set_flag(NodeFlags::HAS_DIRTY_DESCENDANTS, true)
|
||||
|
|
|
@ -644,7 +644,7 @@ impl Document {
|
|||
}
|
||||
|
||||
pub fn content_and_heritage_changed(&self, node: &Node) {
|
||||
if node.is_connected() {
|
||||
if node.is_in_doc() {
|
||||
node.note_dirty_descendants();
|
||||
}
|
||||
|
||||
|
|
|
@ -568,7 +568,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());
|
||||
debug_assert!(self.is_in_doc());
|
||||
|
||||
for ancestor in self.shadow_including_inclusive_ancestors() {
|
||||
if ancestor.get_flag(NodeFlags::HAS_DIRTY_DESCENDANTS) {
|
||||
|
|
|
@ -185,6 +185,9 @@ pub trait TNode: Sized + Copy + Clone + Debug + NodeInfo + PartialEq {
|
|||
DomChildren(self.first_child())
|
||||
}
|
||||
|
||||
/// Returns whether the node is attached to a document.
|
||||
fn is_in_document(&self) -> bool;
|
||||
|
||||
/// Returns whether the node is connected.
|
||||
fn is_connected(&self) -> bool;
|
||||
|
||||
|
|
|
@ -421,6 +421,11 @@ impl<'ln> TNode for GeckoNode<'ln> {
|
|||
self.get_bool_flag(nsINode_BooleanFlag::IsInDocument)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn is_connected(&self) -> bool {
|
||||
self.get_bool_flag(nsINode_BooleanFlag::IsConnected)
|
||||
}
|
||||
|
||||
fn traversal_parent(&self) -> Option<GeckoElement<'ln>> {
|
||||
self.flattened_tree_parent().and_then(|n| n.as_element())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue