diff --git a/float-pigment-layout/src/lib.rs b/float-pigment-layout/src/lib.rs index 83475da..122e4f0 100644 --- a/float-pigment-layout/src/lib.rs +++ b/float-pigment-layout/src/lib.rs @@ -199,6 +199,13 @@ pub trait LayoutTreeVisitor { /// Get the specified child. fn child_at(&self, index: usize) -> Option<&T>; + + /// A notifier that the node has been marked dirty. + /// + /// When `LayoutNode::mark_dirty` is called, some related nodes (e.g. the ancestors) are also marked dirty automatically. + /// These calls tells which nodes are marked dirty. + fn dirty_marked(&self) { + } } /// The styles of a tree node. @@ -284,7 +291,9 @@ impl LayoutNode { /// Informs the node styles been changed. #[inline] pub fn mark_dirty(&self, node: &T::TreeVisitor) -> bool { - self.unit.borrow_mut().mark_dirty(node) + let ret = self.unit.borrow_mut().mark_dirty(node); + node.dirty_marked(); + ret } /// Get the size and position results (border rect). diff --git a/float-pigment-layout/src/unit.rs b/float-pigment-layout/src/unit.rs index c3ac0b4..f4ae630 100644 --- a/float-pigment-layout/src/unit.rs +++ b/float-pigment-layout/src/unit.rs @@ -27,6 +27,7 @@ impl LayoutUnit { } let mut cur = node_tree_visitor; while let Some(parent) = cur.parent() { + parent.tree_visitor().dirty_marked(); if !parent.layout_node().unit().mark_self_dirty() { break; }