Do not set dirty out-of-doc nodes

This commit is contained in:
Fernando Jiménez Moreno 2019-02-19 19:00:29 +01:00
parent e66438de48
commit d7b6a6f509
5 changed files with 15 additions and 3 deletions

View file

@ -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)

View file

@ -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();
}

View file

@ -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) {

View file

@ -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;

View file

@ -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())
}