• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //! Generic CSS content size code that is shared between all CSS algorithms.
2 use crate::geometry::{Point, Size};
3 use crate::style::Overflow;
4 use 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
compute_content_size_contribution( location: Point<f32>, size: Size<f32>, content_size: Size<f32>, overflow: Point<Overflow>, ) -> Size<f32>8 pub(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 }
33