Skip to content

Commit a042fee

Browse files
authored
Merge pull request #21 from wechat-miniprogram/feat-dirty-marked-event
feat(layout): add dirty_marked event
2 parents ca78580 + 8dd19e5 commit a042fee

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

float-pigment-layout/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,13 @@ pub trait LayoutTreeVisitor<T: LayoutTreeNode> {
199199

200200
/// Get the specified child.
201201
fn child_at(&self, index: usize) -> Option<&T>;
202+
203+
/// A notifier that the node has been marked dirty.
204+
///
205+
/// When `LayoutNode::mark_dirty` is called, some related nodes (e.g. the ancestors) are also marked dirty automatically.
206+
/// These calls tells which nodes are marked dirty.
207+
fn dirty_marked(&self) {
208+
}
202209
}
203210

204211
/// The styles of a tree node.
@@ -284,7 +291,9 @@ impl<T: LayoutTreeNode> LayoutNode<T> {
284291
/// Informs the node styles been changed.
285292
#[inline]
286293
pub fn mark_dirty(&self, node: &T::TreeVisitor) -> bool {
287-
self.unit.borrow_mut().mark_dirty(node)
294+
let ret = self.unit.borrow_mut().mark_dirty(node);
295+
node.dirty_marked();
296+
ret
288297
}
289298

290299
/// Get the size and position results (border rect).

float-pigment-layout/src/unit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ impl<T: LayoutTreeNode> LayoutUnit<T> {
2727
}
2828
let mut cur = node_tree_visitor;
2929
while let Some(parent) = cur.parent() {
30+
parent.tree_visitor().dirty_marked();
3031
if !parent.layout_node().unit().mark_self_dirty() {
3132
break;
3233
}

0 commit comments

Comments
 (0)