diff --git a/core/src/ui/painter.rs b/core/src/ui/painter.rs index c625923..0531147 100644 --- a/core/src/ui/painter.rs +++ b/core/src/ui/painter.rs @@ -267,36 +267,32 @@ impl<'a> Painter<'a> { let widgets = self.rsc.widgets(); // A rule is the answer where there is one: it wins over whatever the // widget would draw, so it has to win over what the widget says too. - let hint = widgets - .size_rules(id.id()) - .axis(axis) - .exact() - .or_else(|| { - widgets - .get_dyn(id.id()) - .and_then(|widget| widget.size_hint(axis)) - }) - .map(|hint| hint.within_len(self.frame.axis(axis))); + let hint = widgets.size_rules(id.id()).axis(axis).exact().or_else(|| { + widgets + .get_dyn(id.id()) + .and_then(|widget| widget.size_hint(axis)) + }); + let frame = self.frame.axis(axis); + let resolved = hint.map(|hint| hint.within_len(frame)); #[cfg(feature = "layout-diagnostics")] - diag::hint_read(id.id(), self.id, axis, hint); - match hint { - Some(hint) => { - #[cfg(feature = "layout-diagnostics")] - diag::bump(Counter::HintHits); - self.depend_on(id); - // A fraction was just resolved against this frame, so what - // this draw does with it is a function of the frame's length. - if hint.rel != Rel::ZERO { - self.frame_own_len[axis as usize] = Some(self.frame.axis(axis)); - } - Some(hint) - } - None => { - #[cfg(feature = "layout-diagnostics")] - diag::bump(Counter::HintMisses); - None + { + diag::hint_read(id.id(), self.id, axis, resolved); + diag::bump(match resolved { + Some(_) => Counter::HintHits, + None => Counter::HintMisses, + }); + } + if let Some(hint) = hint { + self.depend_on(id); + // Resolving a fraction against this frame makes this draw a + // function of the frame's length. The fraction to ask about is + // the child's own: resolved against a frame of pixels, none is + // left to see it by. + if hint.rel != Rel::ZERO { + self.frame_own_len[axis as usize] = Some(frame); } } + resolved } fn depend_on(&mut self, child: &StrongWidget) {