Skip to main content

Stylesheets

Struct Stylesheets 

Source
pub struct Stylesheets { /* private fields */ }
Expand description

Parsed stylesheets: the built-in sheet, then whatever the host added, ready to compile against a book.

Parsing is separate from compiling because a run styles several books from one set of sheets, and separate from font loading because loading is the one step that reaches outside the engine.

Implementations§

Source§

impl Stylesheets

Source

pub fn inspect( &self, book: &Book, tree: &StyleTree, node: NodeId, ) -> Option<Inspection>

What the cascade did for one node of book, whose styling tree is, compiled from these sheets. A text node answers for the element that holds it.

The id of a pseudo-element answers for the pseudo-element: the rules that match it and the style it computed to.

None for a node the book does not hold, for a pseudo-element no rule styles, and for the id the engine writes its own text under. The boxes are left empty, since only a laid-out book has them.

Source

pub fn inspect_margin_box( &self, tree: &StyleTree, query: PageQuery<'_>, which: MarginBox, ) -> Option<Inspection>

What the cascade did for one margin box of a page query describes, whose master tree resolved from these sheets.

None for a box no rule for that page names. The boxes are left empty, since only a laid-out book has them.

Source§

impl Stylesheets

Source

pub fn parse(sources: &[Source<'_>]) -> Stylesheets

Parses the built-in sheet, then sources in the order given.

Source

pub fn load_fonts( &mut self, registry: &mut FontRegistry, loader: &dyn FontLoader, )

Registers every @font-face the loader resolves, under the family the sheet gave it rather than the one inside the file: a stylesheet’s name for a face is the one its selectors use.

Run this before compiling — a face the registry does not have is a face no computed style can resolve to. Running it again replaces what the last run warned about.

Source

pub fn warnings(&self) -> &[Warning]

What parsing and font loading had to complain about.

Source

pub fn written(&self) -> Vec<WrittenSheet>

Every sheet as it was written, the built-in sheet first: what a writer reads that hands the CSS to a renderer of its own rather than laying it out.

Only what the parser accepted is here. A rule or a declaration outside the subset is in Stylesheets::warnings instead.

Source

pub fn compile(&self, book: &Book, registry: &FontRegistry) -> StyleTree

Compiles one book’s styling against the faces in the registry.

Trait Implementations§

Source§

impl Debug for Stylesheets

Source§

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

Formats the value using the given formatter. Read more

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
§

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.

§

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.