Say what three retained-layout details mean
Reading this back, three things claim something they do not do. `OnResize::Translate` is returned by `TextView::on_resize` under a comment weighing anchored glyphs against reshaping ones, but nothing consumes it: `try_reuse` asks only whether the answer is `Scale`, so a widget saying `Translate` is redrawn. Say so on the variant, since the comment beside it reads as a description of behaviour. `depend_on_size(child, false)` and `depend_on_size(child, true)` are the difference between a hint, which is context-free, and a size the child produced by drawing, which carries every pixel axis the child read. That is the subtlest rule in the file and it was spelled as a bool; give the two cases their names. `draw_started` is the record of what has drawn during the pass under way, and it worked only because `redraw` removes an id before asking about it -- nothing emptied the set, so it accumulated the id of every widget ever drawn, including ones long gone. Empty it with the pass. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b1b3eca1c0
commit
f1a47e9b7b
3 files changed
+26
-13
No files matched your search
+18
-13
@@ -161,7 +161,7 @@ impl<'a> Painter<'a> {
|
||||
Some(hint) => {
|
||||
#[cfg(feature = "layout-diagnostics")]
|
||||
diag::bump(Counter::HintHits);
|
||||
self.depend_on_size(id, false);
|
||||
self.depend_on_hint(id);
|
||||
Some(hint)
|
||||
}
|
||||
None => {
|
||||
@@ -203,17 +203,22 @@ impl<'a> Painter<'a> {
|
||||
Some(size)
|
||||
}
|
||||
|
||||
fn depend_on_size<W: ?Sized>(&mut self, child: &StrongWidget<W>, inherit_inputs: bool) {
|
||||
let (box_inputs, output_inputs) = match inherit_inputs {
|
||||
true => self
|
||||
.state
|
||||
.active
|
||||
.get(&child.id())
|
||||
.map_or(([false; 2], [false; 2]), |active| {
|
||||
(active.size_box_inputs, active.size_output_inputs)
|
||||
}),
|
||||
false => ([false; 2], [false; 2]),
|
||||
};
|
||||
/// Depends on a length the child gave without being drawn. A hint is
|
||||
/// context-free, so this depends on the child but on no pixel axis.
|
||||
fn depend_on_hint<W: ?Sized>(&mut self, child: &StrongWidget<W>) {
|
||||
self.depend_on_size_inputs(child, [false; 2], [false; 2]);
|
||||
}
|
||||
|
||||
/// Depends on a size the child produced by drawing, which carries
|
||||
/// whatever the child read to produce it.
|
||||
fn depend_on_drawn_size<W: ?Sized>(&mut self, child: &StrongWidget<W>) {
|
||||
let (box_inputs, output_inputs) = self
|
||||
.state
|
||||
.active
|
||||
.get(&child.id())
|
||||
.map_or(([false; 2], [false; 2]), |active| {
|
||||
(active.size_box_inputs, active.size_output_inputs)
|
||||
});
|
||||
self.depend_on_size_inputs(child, box_inputs, output_inputs);
|
||||
}
|
||||
|
||||
@@ -351,7 +356,7 @@ impl<W: ?Sized> DrawResult<'_, '_, W> {
|
||||
diag::bump(Counter::SizeReads);
|
||||
diag::size_read(self.child.id(), self.painter.id, self.size);
|
||||
}
|
||||
self.painter.depend_on_size(self.child, true);
|
||||
self.painter.depend_on_drawn_size(self.child);
|
||||
self.size
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user