pub struct LayoutGeometry {
pub content_box: Rect,
pub padding_box: Rect,
pub border_box: Rect,
pub margin_box: Rect,
pub scroll_bounds: Size,
pub scroll_offset: Point,
pub has_scroll: (bool, bool),
}Expand description
The concentric boxes and scroll metrics forming the CSS Box Model for an element.
Fields§
§content_box: RectContent box (where inner text and child elements reside).
padding_box: RectPadding box (content box expanded by padding insets).
border_box: RectBorder box (padding box expanded by border widths). This is the primary rectangle used for element rendering and layout bounds.
margin_box: RectMargin box (border box expanded by margin insets).
scroll_bounds: SizeTotal scrollable content extent (width, height) enclosing all overflowing children.
scroll_offset: PointCurrent scroll offset (scroll_x, scroll_y).
has_scroll: (bool, bool)Whether element has scrollable overflow along (horizontal, vertical) axes.
Implementations§
Source§impl LayoutGeometry
impl LayoutGeometry
Sourcepub fn is_finite(&self) -> bool
pub fn is_finite(&self) -> bool
Returns true if all concentric boxes contain strictly finite coordinates.
Sourcepub fn max_scroll(&self) -> Point
pub fn max_scroll(&self) -> Point
Returns the maximum allowable scroll offset (max_x, max_y).
Sourcepub fn is_scroll_container(&self) -> bool
pub fn is_scroll_container(&self) -> bool
Returns true if this element is an active scroll container.
Sourcepub fn clamp_scroll_offset(&self, offset: Point) -> Point
pub fn clamp_scroll_offset(&self, offset: Point) -> Point
Clamps a candidate scroll offset to valid bounds [0, max_scroll].
Sourcepub fn from_border_box(
border_box: Rect,
padding: EdgeInsets<f32>,
border: EdgeInsets<f32>,
margin: EdgeInsets<f32>,
) -> Self
pub fn from_border_box( border_box: Rect, padding: EdgeInsets<f32>, border: EdgeInsets<f32>, margin: EdgeInsets<f32>, ) -> Self
Computes concentric boxes from a given border_box and padding/border/margin insets.
Sourcepub fn from_border_box_with_scroll(
border_box: Rect,
padding: EdgeInsets<f32>,
border: EdgeInsets<f32>,
margin: EdgeInsets<f32>,
scroll_offset: Point,
) -> Self
pub fn from_border_box_with_scroll( border_box: Rect, padding: EdgeInsets<f32>, border: EdgeInsets<f32>, margin: EdgeInsets<f32>, scroll_offset: Point, ) -> Self
Computes concentric boxes while preserving the specified scroll offset.
Sourcepub fn translate(&mut self, dx: f32, dy: f32)
pub fn translate(&mut self, dx: f32, dy: f32)
Translates all concentric rectangles by (dx, dy).
Sourcepub fn snap_to_pixel(&mut self)
pub fn snap_to_pixel(&mut self)
Snaps all concentric rectangles to Chromium subpixel coordinates.
Sourcepub fn snap_to_scale(&mut self, scale: f32)
pub fn snap_to_scale(&mut self, scale: f32)
Snaps all concentric rectangles against a device scale factor.