taffy/compute/common/
content_size.rs
1use crate::geometry::{Point, Size};
3use crate::style::Overflow;
4use crate::util::sys::f32_max;
5
6#[inline(always)]
7pub(crate) fn compute_content_size_contribution(
9 location: Point<f32>,
10 size: Size<f32>,
11 content_size: Size<f32>,
12 overflow: Point<Overflow>,
13) -> Size<f32> {
14 let size_content_size_contribution = Size {
15 width: match overflow.x {
16 Overflow::Visible => f32_max(size.width, content_size.width),
17 _ => size.width,
18 },
19 height: match overflow.y {
20 Overflow::Visible => f32_max(size.height, content_size.height),
21 _ => size.height,
22 },
23 };
24 if size_content_size_contribution.width > 0.0 && size_content_size_contribution.height > 0.0 {
25 Size {
26 width: location.x + size_content_size_contribution.width,
27 height: location.y + size_content_size_contribution.height,
28 }
29 } else {
30 Size::ZERO
31 }
32}