⎇ c86f9223e8262ae2d25cdca10fa569c15881dcd2
src/compute/common/content_size.rs
History
Who touched what
raw
Compute content size, padding and border for each node (#573)
1//! Generic CSS content size code that is shared between all CSS algorithms.
2use crate::geometry::{Point, Size};
3use crate::style::Overflow;
4use crate::util::sys::f32_max;
5
6#[inline(always)]
7/// Determine how much width/height a given node contributes to it's parent's content size
8pub(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}