Skip to main content

CoreStyle

Trait CoreStyle 

Source
pub trait CoreStyle {
    type CustomIdent: CheapCloneStr;

Show 19 methods // Provided methods fn box_generation_mode(&self) -> BoxGenerationMode { ... } fn is_block(&self) -> bool { ... } fn is_compressible_replaced(&self) -> bool { ... } fn is_replaced(&self) -> bool { ... } fn box_sizing(&self) -> BoxSizing { ... } fn direction(&self) -> Direction { ... } fn overflow(&self) -> Point<Overflow> { ... } fn scrollbar_width(&self) -> f32 { ... } fn position(&self) -> Position { ... } fn inset(&self) -> Rect<LengthPercentageAuto> { ... } fn is_containing_block(&self) -> ContainingBlockClaims { ... } fn size(&self) -> Size<Dimension> { ... } fn min_size(&self) -> Size<LengthPercentageAuto> { ... } fn max_size(&self) -> Size<LengthPercentageAuto> { ... } fn aspect_ratio(&self) -> Option<f32> { ... } fn margin(&self) -> Rect<LengthPercentageAuto> { ... } fn padding(&self) -> Rect<LengthPercentage> { ... } fn border(&self) -> Rect<LengthPercentage> { ... } fn contain(&self) -> Contain { ... }
}
Expand description

The core set of styles that are shared between all CSS layout nodes

Note that all methods come with a default implementation which simply returns the default value for that style property but this is a just a convenience to save on boilerplate for styles that your implementation doesn’t support. You will need to override the default implementation for each style property that your style type actually supports.

Required Associated Types§

Source

type CustomIdent: CheapCloneStr

The type of custom identifiers used to identify named grid lines and areas

Provided Methods§

Source

fn box_generation_mode(&self) -> BoxGenerationMode

Which box generation mode should be used

Source

fn is_block(&self) -> bool

Is block layout?

This should only return true for display: block, and NOT for display: flow-root. Flow-root boxes establish a new block formatting context and must not be treated as being part of their parent’s block formatting context (which is what this method controls).

Source

fn is_compressible_replaced(&self) -> bool

Is it a compressible replaced element: a replaced element (image, video, canvas, …) or a form control with an intrinsic size (input, select, textarea, meter, …)? Such boxes resolve an auto width to their intrinsic size rather than being stretched by block layout, and have a zero min-content contribution in grid layout. https://drafts.csswg.org/css-sizing-3/#compressible

Source

fn is_replaced(&self) -> bool

Is it a replaced element (image, video, canvas, …)? Unlike other compressible replaced elements (form controls), an auto-sized replaced element is not stretched between its insets under normal alignment. https://html.spec.whatwg.org/multipage/rendering.html#replaced-elements

Source

fn box_sizing(&self) -> BoxSizing

Which box do size styles apply to

Source

fn direction(&self) -> Direction

The direction of text, table and grid columns, and horizontal overflow.

Source

fn overflow(&self) -> Point<Overflow>

How children overflowing their container should affect layout

Source

fn scrollbar_width(&self) -> f32

How much space (in points) should be reserved for the scrollbars of Overflow::Scroll and Overflow::Auto nodes.

Source

fn position(&self) -> Position

What should the position value of this struct use as a base offset?

Source

fn inset(&self) -> Rect<LengthPercentageAuto>

How should the position of this element be tweaked relative to the layout defined?

Source

fn is_containing_block(&self) -> ContainingBlockClaims

Which out-of-flow (absolute/fixed) descendants this node establishes the containing block for.

This is the single policy point for containing-block establishment: it decides both which out-of-flow boxes a node claims and lays out, and (for grid containers) whether the static position of an out-of-flow child is derived from its grid area.

The default matches plain CSS positioning: a node is the containing block for absolute boxes when its own position is not static, and never for fixed boxes (which are claimed by the root). Implementations may override this so that other style properties (such as transform, filter or will-change in a full CSS implementation) establish a containing block.

Source

fn size(&self) -> Size<Dimension>

Sets the initial size of the item

Source

fn min_size(&self) -> Size<LengthPercentageAuto>

Controls the minimum size of the item

Source

fn max_size(&self) -> Size<LengthPercentageAuto>

Controls the maximum size of the item

Source

fn aspect_ratio(&self) -> Option<f32>

Sets the preferred aspect ratio for the item The ratio is calculated as width divided by height.

Source

fn margin(&self) -> Rect<LengthPercentageAuto>

How large should the margin be on each side?

Source

fn padding(&self) -> Rect<LengthPercentage>

How large should the padding be on each side?

Source

fn border(&self) -> Rect<LengthPercentage>

How large should the border be on each side?

Source

fn contain(&self) -> Contain

The layout-affecting parts of the CSS contain property that apply to this node

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: CoreStyle> CoreStyle for &T

Implementors§