Say region and placement, not extent

The split box was named `region` and `placement` on 2026-09-17; `frame`
came back as a length and survived, `extent` did not. It stayed as the
name for both halves, distinguished only by prose: `draw_at` bound the
caller's `part` to a parameter called `extent`, and `ActiveData` held two
`UiRegion`s that `draw_at` wrote `part: extent` from.

The box a parent asks a widget in is now the region, and where its
drawing ends up is its placement. `Painter`'s four holds accumulators
become the one `LayoutHolds` they were assembled into, which also drops
the name mapping between them.

The cold dump of 400 depth-5 trees is byte-identical across the change.
This commit is contained in:
iris-ai committed 2026-09-19 14:49:56 -04:00
1 parent 84dad211f5
commit 5642f2010a
13 files changed
+212 -227

No files matched your search

+1 -1
View File
@@ -28,7 +28,7 @@ impl Widget for BranchesOnMeasurement {
.len(Axis::X);
let px = painter.to_px(measured.apply_leftover(), Axis::X);
let below = Place::Within(Part::From(UiSpan::new(cut, painter.extent_len(Axis::Y))));
let below = Place::Within(Part::From(UiSpan::new(cut, painter.region_len(Axis::Y))));
let place = [Place::Within(Part::All), below];
match px > Px::from_f32(self.threshold) {
true => painter.widget_at(&self.wide, [None; 2], place),
+3 -3
View File
@@ -124,7 +124,7 @@ fn padding_keeps_the_frame_distinct_from_the_room_left_in_a_row() {
h.set_root((icon, padded).span(Dir::RIGHT).width(rel(1.0)));
let active = &h.render.active[&text.id()];
let window = h.render.output_size().x;
let asked = active.part.x.len().to_px(window);
let asked = active.region.x.len().to_px(window);
assert_eq!(active.frame.x.to_px(window), Px::from_int(868));
assert_eq!(asked, Px::from_int(844));
}
@@ -171,7 +171,7 @@ fn padding_narrows_both_frame_and_box_inside_a_share() {
let active = &h.render.active[&text.id()];
let window = h.render.output_size().x;
assert_eq!(active.frame.x.to_px(window), Px::from_int(418));
assert_eq!(active.part.x.len().to_px(window), Px::from_int(418));
assert_eq!(active.region.x.len().to_px(window), Px::from_int(418));
}
#[test]
@@ -500,7 +500,7 @@ fn a_row_of_equal_shares_fills_it_exactly() {
/// a step of. Kept in step with `snap_floor` in `prelude.wgsl`.
fn drawn_edges(h: &Harness, id: WidgetId, axis: Axis) -> (f32, f32) {
let active = &h.render.active[&id];
let region = h.render.moves.resolve(active.move_idx, active.extent);
let region = h.render.moves.resolve(active.move_idx, active.placement);
let dim = h.size().axis(axis);
let snap = |v: f32| (v + Px::STEP.to_f32() * 0.5).floor();
let edge = |s: Len| snap(s.rel.to_f32() * dim + s.px.to_f32());
+27 -27
View File
@@ -797,7 +797,7 @@ fn primitive_bounds(h: &Harness, id: WidgetId) -> Vec<PixelRegion> {
}
#[test]
fn changing_an_inherited_extent_keeps_the_original_measurement_offer() {
fn changing_an_inherited_region_keeps_the_original_measurement_offer() {
fn build(h: &mut Harness, width: i32, text: &str) -> (WeakWidget<Text>, WeakWidget<Rect>) {
let first = rect(Color::RED).width(width).add(&mut h.rsc);
let words = wtext(text).size(20).wrap(true).add(&mut h.rsc);
@@ -959,17 +959,17 @@ fn glyph_origins_compose_identically_when_drawn_and_when_retained() {
}
struct Frame {
child: StrongWidget,
frame: UiRegion,
region: UiRegion,
extent: UiRegion,
}
impl Widget for Frame {
fn draw(&mut self, painter: &mut Painter) -> Size {
painter.widget_at(
&self.child,
[Some(self.region.x.len()), None],
[Some(self.frame.x.len()), None],
[
Place::Fill(Part::From(self.extent.x)),
Place::Fill(Part::From(self.extent.y)),
Place::Fill(Part::From(self.region.x)),
Place::Fill(Part::From(self.region.y)),
],
);
Size::LEFTOVER
@@ -986,15 +986,15 @@ fn glyph_origins_compose_identically_when_drawn_and_when_retained() {
h.rsc.widgets_mut().set_region_node(text, node);
let root = Frame {
child: text.add_strong(&mut h.rsc),
frame: UiRegion::FULL,
region: UiRegion::FULL,
extent: UiRegion::FULL,
}
.add(&mut h.rsc);
h.set_root(root);
for (start, end) in [(0.13, 0.83), (-0.17, 1.23), (0.31, 0.67)] {
let before = draws.get();
h.rsc[root].region.x = UiSpan::new(Len::px(13.125), Len::px(287.375));
h.rsc[root].extent = UiRegion::new(
h.rsc[root].frame.x = UiSpan::new(Len::px(13.125), Len::px(287.375));
h.rsc[root].region = UiRegion::new(
UiSpan::new(Len::rel(start), Len::rel(end)),
UiSpan::new(Len::px(7.25), Len::rel(end)),
);
@@ -1117,7 +1117,7 @@ fn widening_and_restoring_a_contract_does_not_invalidate_its_reader() {
assert_eq!(leaf_draws.get(), settled + 1);
}
#[test]
fn padding_and_stack_boxes_follow_the_extent_without_drawing_again() {
fn padding_and_stack_boxes_follow_the_region_without_drawing_again() {
struct Observed<W> {
widget: W,
draws: Rc<Cell<usize>>,
@@ -1130,7 +1130,7 @@ fn padding_and_stack_boxes_follow_the_extent_without_drawing_again() {
}
struct Frame {
child: StrongWidget,
extent: UiRegion,
region: UiRegion,
}
impl Widget for Frame {
fn draw(&mut self, painter: &mut Painter) -> Size {
@@ -1138,15 +1138,15 @@ fn padding_and_stack_boxes_follow_the_extent_without_drawing_again() {
&self.child,
[None; 2],
[
Place::Fill(Part::From(self.extent.x)),
Place::Fill(Part::From(self.extent.y)),
Place::Fill(Part::From(self.region.x)),
Place::Fill(Part::From(self.region.y)),
],
);
Size::LEFTOVER
}
}
for node in [false, true] {
let plant = |h: &mut Harness, extent| {
let plant = |h: &mut Harness, region| {
let draws = Rc::new(Cell::new(0));
let leaf = rect(Color::BLUE).masked().add(&mut h.rsc);
h.rsc.widgets_mut().set_region_node(leaf, node);
@@ -1167,7 +1167,7 @@ fn padding_and_stack_boxes_follow_the_extent_without_drawing_again() {
draws: draws.clone(),
}
.add_strong(&mut h.rsc);
let root = Frame { child: pad, extent }.add(&mut h.rsc);
let root = Frame { child: pad, region }.add(&mut h.rsc);
h.set_root(root);
(root, leaf, fixed, draws)
};
@@ -1182,13 +1182,13 @@ fn padding_and_stack_boxes_follow_the_extent_without_drawing_again() {
let mut warm = Harness::new((403, 211));
let (root, leaf, fixed, draws) = plant(&mut warm, at(0.13));
for start in [0.13, -0.17, 0.31] {
let extent = at(start);
let region = at(start);
let before = draws.get();
warm.rsc[root].extent = extent;
warm.rsc[root].region = region;
warm.frame();
assert_eq!(draws.get(), before);
let mut cold = Harness::new((403, 211));
let (_, other, other_fixed, _) = plant(&mut cold, extent);
let (_, other, other_fixed, _) = plant(&mut cold, region);
for (a, b) in [(leaf.id(), other.id()), (fixed.id(), other_fixed.id())] {
assert_eq!(warm.region(&a), cold.region(&b));
assert_eq!(primitive_bounds(&warm, a), primitive_bounds(&cold, b));
@@ -1207,7 +1207,7 @@ fn padding_and_stack_boxes_follow_the_extent_without_drawing_again() {
}
#[test]
fn moving_an_extent_child_preserves_the_slot_chosen_from_its_measurement() {
fn moving_a_childs_region_preserves_the_slot_chosen_from_its_measurement() {
struct Measured;
impl Widget for Measured {
fn draw(&mut self, painter: &mut Painter) -> Size {
@@ -1256,7 +1256,7 @@ fn moving_an_extent_child_preserves_the_slot_chosen_from_its_measurement() {
}
#[test]
fn extent_frames_keep_fractional_reports_and_numeric_dependencies_valid() {
fn changing_regions_keep_fractional_reports_and_numeric_dependencies_valid() {
struct Container {
child: StrongWidget,
region: UiRegion,
@@ -1277,7 +1277,7 @@ fn extent_frames_keep_fractional_reports_and_numeric_dependencies_valid() {
}
struct Frame {
child: StrongWidget,
extent: UiRegion,
region: UiRegion,
answer: Rc<Cell<Size>>,
}
impl Widget for Frame {
@@ -1288,8 +1288,8 @@ fn extent_frames_keep_fractional_reports_and_numeric_dependencies_valid() {
&self.child,
[None; 2],
[
Place::Fill(Part::From(self.extent.x)),
Place::Fill(Part::From(self.extent.y)),
Place::Fill(Part::From(self.region.x)),
Place::Fill(Part::From(self.region.y)),
],
)
.size(),
@@ -1302,7 +1302,7 @@ fn extent_frames_keep_fractional_reports_and_numeric_dependencies_valid() {
UiRegion::FULL,
UiRegion::new(UiSpan::new(Len::rel(0.13), Len::rel(0.79)), UiSpan::FULL),
] {
let plant = |h: &mut Harness, extent| {
let plant = |h: &mut Harness, outer| {
let size = if fractional {
Size {
x: rel(0.5),
@@ -1320,7 +1320,7 @@ fn extent_frames_keep_fractional_reports_and_numeric_dependencies_valid() {
let answer = Rc::new(Cell::new(Size::ZERO));
let root = Frame {
child,
extent,
region: outer,
answer: answer.clone(),
}
.add(&mut h.rsc);
@@ -1330,12 +1330,12 @@ fn extent_frames_keep_fractional_reports_and_numeric_dependencies_valid() {
let mut warm = Harness::new((403, 211));
let (root, leaf, answer) = plant(&mut warm, UiRegion::FULL);
for width in [191.125, 297.25, 83.75] {
let extent =
let region =
UiRegion::new(UiSpan::new(Len::px(13.125), Len::px(width)), UiSpan::FULL);
warm.rsc[root].extent = extent;
warm.rsc[root].region = region;
warm.frame();
let mut cold = Harness::new((403, 211));
let (_, other, other_answer) = plant(&mut cold, extent);
let (_, other, other_answer) = plant(&mut cold, region);
assert_eq!(answer.get(), other_answer.get());
assert_eq!(warm.region(&leaf), cold.region(&other));
}
+2 -2
View File
@@ -406,8 +406,8 @@ fn describe_widget(id: WidgetId, h: &Harness) -> String {
fn record(id: WidgetId, h: &Harness) -> String {
let active = &h.render.active[&id];
format!(
"frame {} ask {} box {} size {}",
active.frame, active.part, active.extent, active.size,
"frame {} region {} placement {} size {}",
active.frame, active.region, active.placement, active.size,
)
}