Skip to main content

Styler

Struct Styler 

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

Collects stylesheets and styles documents with them.

Implementations§

Source§

impl Styler

Source

pub fn new(env: Environment) -> Styler

A styler with the HTML user agent stylesheet, style="" counted.

Source

pub fn bare(env: Environment) -> Styler

A styler with no stylesheet at all, not even the user agent’s.

Source

pub fn environment(&self) -> &Environment

Source

pub fn add(&mut self, css: &str, origin: Origin) -> &mut Styler

Adds a stylesheet.

Source

pub fn add_with_media( &mut self, css: &str, origin: Origin, media: &str, ) -> &mut Styler

Adds a stylesheet that applies only where media matches, as a <style media> or <link media> does.

Source

pub fn fetch( self, fetch: impl Fn(&str) -> Option<String> + Send + Sync + 'static, ) -> Styler

Fetches @imported stylesheets with fetch, given each URL as written; without it, @import is ignored.

Source

pub fn container_sizes( self, size: impl Fn(NodeId, &Computed) -> Option<(f64, f64)> + Send + Sync + 'static, ) -> Styler

Gives each container’s size, for @container and the cq* units: size is asked for an element whose container-type makes it a container, with its computed values, and gives its width and height in CSS pixels. A query on a container with no size given is false, and cq* units look past it to the next container out, or the viewport.

Source

pub fn with_document_styles(self, doc: &Document) -> Styler

Adds the document’s own <style> elements, with their media, as author stylesheets.

Source

pub fn style_attributes(self, on: bool) -> Styler

Whether style="" attributes count; they do unless this says not.

Source

pub fn style(&self, doc: &Document) -> Styled

Styles every element of doc.

Source

pub fn style_element(&self, doc: &Document, el: NodeId) -> Option<Computed>

Styles one element, and the ancestors it inherits from, but no other: the cheap way to one element’s computed values.

Source

pub fn at_rules(&self) -> AtRules

The @keyframes, @counter-style and @property rules in force: for each name, the one the cascade’s order puts last.

Trait Implementations§

Source§

impl Default for Styler

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Styler

§

impl !UnwindSafe for Styler

§

impl Forget for Styler

§

impl Freeze for Styler

§

impl Move for Styler

§

impl Send for Styler

§

impl Sync for Styler

§

impl Unpin for Styler

§

impl UnsafeUnpin for Styler

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.