script: Fix Servo relying on descendants being visited when there's a reframe.

This commit is contained in:
Emilio Cobos Álvarez 2017-11-10 01:29:41 +01:00
parent 6704122927
commit 5200ded17c
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 22 additions and 3 deletions

View file

@ -573,8 +573,14 @@ impl Document {
self.encoding.set(encoding); self.encoding.set(encoding);
} }
pub fn content_and_heritage_changed(&self, node: &Node, damage: NodeDamage) { pub fn content_and_heritage_changed(&self, node: &Node) {
node.dirty(damage); if node.is_in_doc() {
node.note_dirty_descendants();
}
// FIXME(emilio): This is very inefficient, ideally the flag above would
// be enough and incremental layout could figure out from there.
node.dirty(NodeDamage::OtherNodeDamage);
} }
/// Reflows and disarms the timer if the reflow timer has expired. /// Reflows and disarms the timer if the reflow timer has expired.

View file

@ -483,6 +483,19 @@ impl Node {
self.flags.set(flags); self.flags.set(flags);
} }
// FIXME(emilio): This and the function below should move to Element.
pub fn note_dirty_descendants(&self) {
debug_assert!(self.is_in_doc());
for ancestor in self.inclusive_ancestors() {
if ancestor.get_flag(NodeFlags::HAS_DIRTY_DESCENDANTS) {
return;
}
ancestor.set_flag(NodeFlags::HAS_DIRTY_DESCENDANTS, true);
}
}
pub fn has_dirty_descendants(&self) -> bool { pub fn has_dirty_descendants(&self) -> bool {
self.get_flag(NodeFlags::HAS_DIRTY_DESCENDANTS) self.get_flag(NodeFlags::HAS_DIRTY_DESCENDANTS)
} }
@ -2499,7 +2512,7 @@ impl VirtualMethods for Node {
if let Some(list) = self.child_list.get() { if let Some(list) = self.child_list.get() {
list.as_children_list().children_changed(mutation); list.as_children_list().children_changed(mutation);
} }
self.owner_doc().content_and_heritage_changed(self, NodeDamage::OtherNodeDamage); self.owner_doc().content_and_heritage_changed(self);
} }
// This handles the ranges mentioned in steps 2-3 when removing a node. // This handles the ranges mentioned in steps 2-3 when removing a node.