Retain frame and extent dependencies independently
Keep the original measurement placement separate from the assigned slot.
Validate frame and extent lengths before reusing an answer or drawing, and
represent hint-only records as having no measured answer.
Retain primitive and mask coordinates with their frame/extent reference.
Forwarded children follow a reused wrapper's placement without rerunning
valid draw bodies. Keep the single Widget::draw API.
Restore the eight failing suite cases from the region/placement prototype,
with regressions for mixed coordinate references, a changed inherited
extent, the sizing-stack fraction, and an undrawn share becoming visible.
This remains experimental: nested container updates do substantially more
work than e44dea3 despite restoring the leaf and wrapper reuse guarantees.
Do not merge it as a performance improvement.
This commit is contained in:
1 parent
5fcace1bfa
commit
efb416bbc3
14 files changed
+548
-166
No files matched your search
@@ -614,3 +614,61 @@ fn a_text_is_given_back_a_box_the_line_it_measured_fits_in() {
|
||||
|
||||
assert_eq!(warm.region(&text), cold.region(&cold_text));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn adding_text_to_a_reverse_row_keeps_its_shared_height() {
|
||||
fn build(
|
||||
h: &mut Harness,
|
||||
changed: bool,
|
||||
) -> (WeakWidget<Span>, WeakWidget<Text>, Vec<StrongWidget>) {
|
||||
let wrap = wtext("Wrapping shapes one source into as many lines as the box leaves room for, so a paragraph's height is an answer and not a setting.").size(16).wrap(true).add_strong(&mut h.rsc);
|
||||
let one = || {
|
||||
wtext("one line, overflowing whatever it is given")
|
||||
.size(16)
|
||||
.wrap(false)
|
||||
};
|
||||
let plain = one().add_strong(&mut h.rsc);
|
||||
let shared = one()
|
||||
.width(LayoutLen::LEFTOVER)
|
||||
.height(LayoutLen::LEFTOVER)
|
||||
.add(&mut h.rsc);
|
||||
let mut extra: Vec<StrongWidget> = vec![
|
||||
rect(Color::RED).add_strong(&mut h.rsc),
|
||||
one().add_strong(&mut h.rsc),
|
||||
one().add_strong(&mut h.rsc),
|
||||
];
|
||||
let children: Vec<StrongWidget> = if changed {
|
||||
let mut children: Vec<StrongWidget> = vec![plain, shared.add_strong(&mut h.rsc)];
|
||||
children.append(&mut extra);
|
||||
children
|
||||
} else {
|
||||
vec![wrap, plain, shared.add_strong(&mut h.rsc)]
|
||||
};
|
||||
let row = Span {
|
||||
children,
|
||||
dir: Dir::LEFT,
|
||||
gap: Px::ZERO,
|
||||
}
|
||||
.height(LayoutLen::rel(1.0))
|
||||
.add(&mut h.rsc);
|
||||
let fill: StrongWidget = rect(Color::BLUE).add_strong(&mut h.rsc);
|
||||
let children: Vec<StrongWidget> = vec![fill, row.add_strong(&mut h.rsc)];
|
||||
let root = Span {
|
||||
children,
|
||||
dir: Dir::RIGHT,
|
||||
gap: Px::from_int(4),
|
||||
}
|
||||
.height(LayoutLen::rel(1.0))
|
||||
.add(&mut h.rsc);
|
||||
h.set_root(root);
|
||||
(row, shared, extra)
|
||||
}
|
||||
let mut warm = Harness::new((900, 1200));
|
||||
let (row, shared, extra) = build(&mut warm, false);
|
||||
warm.rsc[row].children.remove(0);
|
||||
warm.rsc[row].children.extend(extra);
|
||||
warm.frame();
|
||||
let mut cold = Harness::new((900, 1200));
|
||||
let (_, other, _) = build(&mut cold, true);
|
||||
assert_eq!(warm.region(&shared), cold.region(&other));
|
||||
}
|
||||
Reference in new issue
Block a user