Skip to main content

ComputedStyle

Struct ComputedStyle 

Source
pub struct ComputedStyle {
Show 56 fields pub font_id: u16, pub font_family: Vec<Family>, pub font_size: f32, pub font_style: FontStyle, pub font_weight: u16, pub color: Color, pub line_height: f32, pub letter_spacing: f32, pub font_variant_caps: FontVariantCaps, pub font_feature_settings: Vec<FeatureSetting>, pub font_variant_ligatures: FontVariantLigatures, pub font_variant_numeric: FontVariantNumeric, pub font_variant_alternates: FontVariantAlternates, pub text_transform: TextTransform, pub text_decoration_line: DecorationLine, pub text_decoration_color: Option<Color>, pub text_decoration_style: DecorationStyle, pub text_decoration_thickness: Option<f32>, pub text_align: TextAlign, pub text_justify: TextJustify, pub hanging_punctuation: HangingPunctuation, pub text_indent: f32, pub hyphens: Hyphens, pub orphans: u16, pub widows: u16, pub page: Option<String>, pub content: Content, pub string_set: Vec<StringSet>, pub counter_reset: Option<u32>, pub note_reset: Option<u32>, pub initial_letter: u16, pub position: Position, pub inset: Edges<Inset>, pub z_index: i32, pub opacity: f32, pub wrap_flow: WrapFlow, pub shape_outside: ShapeOutside, pub shape_margin: f32, pub margin: Edges, pub padding: Edges, pub border: Edges<Border>, pub border_radius: BorderRadius, pub background: Background, pub box_decoration_break: BoxDecorationBreak, pub width: Width, pub height: Width, pub min_height: Width, pub max_width: Width, pub max_height: Width, pub border_collapse: BorderCollapse, pub list_style_type: ListStyleType, pub break_before: Break, pub break_after: Break, pub break_inside: Break, pub column_span: ColumnSpan, pub custom: BTreeMap<String, String>,
}
Expand description

One node’s resolved style: what every downstream pass reads.

Fields§

§font_id: u16

The face this style shapes with, resolved against the registry. Family, slope and weight chose it; layout only needs the answer.

§font_family: Vec<Family>

The families asked for, in order, kept for diagnostics and for the snapshot the style tree is reviewed through.

§font_size: f32

Font size in points.

§font_style: FontStyle

Upright or italic.

§font_weight: u16

Weight on the CSS 1–1000 scale.

§color: Color

What text and rules are painted in.

§line_height: f32

Line height as a unitless multiple of the font size.

§letter_spacing: f32

Extra advance after every glyph, in points, from letter-spacing.

§font_variant_caps: FontVariantCaps

Which capitals the run is drawn with.

§font_feature_settings: Vec<FeatureSetting>

The features the sheet asked the face for, from font-feature-settings. They are asked for after the ones the font-variant longhands name, so a tag in both is set here.

§font_variant_ligatures: FontVariantLigatures

Which ligatures the run is set with.

§font_variant_numeric: FontVariantNumeric

Which figures the run is set with.

§font_variant_alternates: FontVariantAlternates

Which alternate glyphs the run is set with.

§text_transform: TextTransform

What the run’s letters are transformed to before shaping.

§text_decoration_line: DecorationLine

Which rules are drawn across the run, from text-decoration-line.

§text_decoration_color: Option<Color>

What those rules are painted in, from text-decoration-color. None is the colour of the text.

§text_decoration_style: DecorationStyle

How each rule is drawn, from text-decoration-style.

§text_decoration_thickness: Option<f32>

How thick each rule is, in points, from text-decoration-thickness. None is the thickness the face declares.

§text_align: TextAlign

How lines fill the measure.

§text_justify: TextJustify

What justification opens up to fill it.

§hanging_punctuation: HangingPunctuation

Which marks may hang past the measure.

§text_indent: f32

First-line indent in points.

§hyphens: Hyphens

Whether words may break at syllable boundaries.

§orphans: u16

Lines that must be left at the bottom of a fragment.

§widows: u16

Lines that must be moved to the top of the next one.

§page: Option<String>

The named page this element’s pages take, from page.

§content: Content

What the element paints in place of children it has none of: the ornament a thematic break is set with.

§string_set: Vec<StringSet>

The named strings this element sets when the flow reaches it, from string-set. This is where a running head’s text comes from.

§counter_reset: Option<u32>

The folio the page this element opens takes, from counter-reset: page.

§note_reset: Option<u32>

The number the first note under this element takes, from counter-reset: note. On the footnote area it restarts the numbering on every page.

§initial_letter: u16

Lines an initial letter is sunk over, from initial-letter. Fewer than two is no drop cap.

§position: Position

Whether the element sits in the flow or against the page.

§inset: Edges<Inset>

What the insets say, for an element that is against the page.

§z_index: i32

Which layer the block paints in, from z-index. Higher paints later, and auto is layer 0.

§opacity: f32

How much of what the block paints shows, from opacity: 1 is all of it and 0 is none. The blocks inside it show that much of their own.

§wrap_flow: WrapFlow

Which side of this element the prose sets on, from wrap-flow.

§shape_outside: ShapeOutside

The contour the prose sets around, from shape-outside.

§shape_margin: f32

How far the prose keeps off that contour, in points, from shape-margin.

§margin: Edges

Margins in points.

§padding: Edges

Padding in points, between the border and the content.

§border: Edges<Border>

The four border edges.

§border_radius: BorderRadius

How far each corner of the border box is rounded, from border-radius. The background and the border follow the corners.

§background: Background

What is painted behind the block: a tint, and an image over it.

§box_decoration_break: BoxDecorationBreak

What the decoration does where a page break splits the block.

§width: Width

The width the box is asked to take, from width. A table reads it off the cells of its first row to size its columns.

§height: Width

The height the content box is asked to take, from height.

§min_height: Width

The least height the content box takes, from min-height.

§max_width: Width

The most width an image takes, from max-width. Auto is none.

§max_height: Width

The most height an image takes, from max-height. Auto is none.

§border_collapse: BorderCollapse

Whether a table’s cells share their borders, from border-collapse.

§list_style_type: ListStyleType

The marker a list item is set with, from list-style-type.

§break_before: Break

Where a page break falls before this element.

§break_after: Break

Where one falls after it.

§break_inside: Break

Whether this element may be split across pages.

§column_span: ColumnSpan

Whether this element is set across every column of a divided page, from column-span.

§custom: BTreeMap<String, String>

The custom properties in force, by name, each with every var() in its value already replaced. A child inherits them.

Implementations§

Source§

impl ComputedStyle

Source

pub fn initial() -> ComputedStyle

The initial value of every property: what the root computes to before any rule matches it.

Source

pub fn inherit(&self) -> ComputedStyle

A child’s starting point: inherited properties as they stand, the rest back at their initial values.

Source

pub fn apply( &mut self, declaration: &Declaration, parent_size: f32, root_size: f32, )

Applies one declaration. parent_size is what em and percentages in font-size measure against; root_size is what rem does.

Source

pub fn sized(&self) -> bool

Whether the block asks for a height of its own content box.

Source

pub fn first_line_over(&self, element: &ComputedStyle) -> FirstLine

What this style, computed for ::first-line, changes about the element it was computed beside.

Source

pub fn border_box(&self, x: f32, measure: f32) -> (f32, f32)

This block’s border box inside measure, laid out at x from the enclosing content box’s leading edge: (leading edge, width), with only the margins taken off.

Source

pub fn excludes(&self) -> bool

Whether prose is set around this element rather than over it: the sheet has taken it out of the flow, and it excludes a side.

This is the one place a contour is read, so it is also what decides whether one is traced. An element still in the flow takes a band of its own and nothing sets beside it, so a contour on it would answer a question nobody asks.

Source

pub fn content_box(&self, x: f32, measure: f32) -> (f32, f32)

This block’s content box inside measure: (leading edge, the measure its lines break to). Margin, border and padding come off both edges, and the leading edge moves in by what they take on the left.

Source

pub fn inline_box(&self) -> Option<InlineBox>

The box this style paints around the runs of an inline element, and None where it paints none and takes no width.

Padding counts even where nothing is painted over it: it is width, and the line breaks against it.

Source

pub fn paragraph(&self) -> ParagraphStyle

Everything line layout needs from a style.

Source

pub fn features(&self) -> Vec<FeatureSetting>

Every feature this style asks the face for, in the order the shaper reads them: what the font-variant longhands name, then what font-feature-settings spells out. A tag in both takes the value written last, which is the one the sheet spelled.

Source

pub fn decoration(&self) -> TextDecoration

What is drawn across this style’s runs, the four longhands gathered into one value.

Trait Implementations§

Source§

impl Clone for ComputedStyle

Source§

fn clone(&self) -> ComputedStyle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ComputedStyle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for ComputedStyle

Source§

fn eq(&self, other: &ComputedStyle) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ComputedStyle

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ComputedStyle

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Finish for T

§

fn finish(self)

Does nothing but move self, equivalent to drop.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

§

fn to_owned_table(&self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.