diff --git a/crates/ui-contract/src/contract/body/regions.rs b/crates/ui-contract/src/contract/body/regions.rs index 2511c5aa3..ede284284 100644 --- a/crates/ui-contract/src/contract/body/regions.rs +++ b/crates/ui-contract/src/contract/body/regions.rs @@ -426,13 +426,15 @@ impl<'b> BodyHooks<'b> { }); let taken = measured.unwrap_or(0.0); let cut = if taken > 0.0 { taken + self.end_gap + self.rules.end } else { 0.0 }; - let end_w = measured.unwrap_or(width); let end_bottom = if full { footer_top + across_h } else { footer_top }; - let mut end = if rtl { - Rect::from_min_max(Pos2::new(left, top), Pos2::new(left + end_w, end_bottom.max(top))) - } else { - Rect::from_min_max(Pos2::new(right - end_w, top), Pos2::new(right, end_bottom.max(top))) + // The line's own edges before the first measure: a line of unbounded room (a content-sized container measured + // in an unbounded flow) has no finite width to take from its other edge. + let (end_left, end_right) = match measured { + None => (left, right), + Some(end_w) if rtl => (left, left + end_w), + Some(end_w) => (right - end_w, right), }; + let mut end = Rect::from_min_max(Pos2::new(end_left, top), Pos2::new(end_right, end_bottom.max(top))); if rtl { body.min.x = (body.min.x + cut).min(body.max.x); } else { diff --git a/crates/ui-contract/src/testing/frames.rs b/crates/ui-contract/src/testing/frames.rs index 3fd41c154..6873f4786 100644 --- a/crates/ui-contract/src/testing/frames.rs +++ b/crates/ui-contract/src/testing/frames.rs @@ -187,7 +187,7 @@ impl Frames { /// One frame with no events; returns the shapes it painted, nested shapes flattened. pub fn frame_shapes(&mut self, mut ui: impl FnMut(&mut Ui)) -> Vec { set_input(&self.ctx, self.input()); - self.time += DT; + self.tick(); fixture::run_frame_shapes(&self.ctx, self.time, self.screen, &mut ui) } @@ -235,8 +235,14 @@ impl Frames { } } + /// Moves the clock on one frame from the later of its own time and the context's, so frames over a context the + /// caller also drives (an app's own, which another harness ran between these frames) never take its time back. + fn tick(&mut self) { + self.time = self.time.max(self.ctx.input(|i| i.time)) + DT; + } + fn run(&mut self, viewport: egui::ViewportId, mut events: Vec, ui: impl FnMut(&mut Ui)) -> bool { - self.time += DT; + self.tick(); if self.told != self.modifiers { self.told = self.modifiers; events.insert(0, fixture::modifiers_changed(self.modifiers));