Skip to main content

Styled

Struct Styled 

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

Every element’s computed values.

Implementations§

Source§

impl Styled

Source

pub fn get_pseudo( &self, el: NodeId, p: &Pseudo, property: &str, ) -> Option<String>

property’s value on el’s pseudo-element p, as getComputedStyle(el, "::before") writes it; None for a node that isn’t an element or a property that isn’t.

use parsec_css::cascade::{Pseudo, Styler};

let doc = parsec::parse("<style>p::before { content: 'x'; color: green }</style><p>", false);
let styled = Styler::new(Default::default()).with_document_styles(&doc).style(&doc);
let p = parsec::css::SelectorList::parse("p").unwrap().select_first(&doc, doc.root()).unwrap();
assert_eq!(styled.get_pseudo(p, &Pseudo::Before, "color").as_deref(), Some("rgb(0, 128, 0)"));
assert_eq!(styled.get_pseudo(p, &Pseudo::After, "content").as_deref(), Some("none"));
assert_eq!(styled.pseudo_exists(p, &Pseudo::Before), Some(true));
Source

pub fn computed_pseudo(&self, el: NodeId, p: &Pseudo) -> Option<Computed>

Everything about the style of el’s pseudo-element p, worked out now: it inherits from el, ::first-letter from ::first-line, and a highlight from its parent element’s highlight.

Source

pub fn pseudo_exists(&self, el: NodeId, p: &Pseudo) -> Option<bool>

Whether el has the pseudo-element p at all: ::before and ::after when their content is something, ::marker on a list item with a marker to show, none of them under display: none. None for the others, whose being there depends on text, layout or state (the first line, a selection, the top layer), and for a node that isn’t an element.

Source§

impl Styled

Source

pub fn get(&self, el: NodeId, property: &str) -> Option<String>

property’s value on el, as getComputedStyle() writes it, or None for a node that isn’t an element or a property that isn’t.

Source

pub fn computed(&self, el: NodeId) -> Option<&Computed>

Everything about one element’s style.

Auto Trait Implementations§

§

impl Forget for Styled

§

impl Freeze for Styled

§

impl Move for Styled

§

impl RefUnwindSafe for Styled

§

impl Send for Styled

§

impl Sync for Styled

§

impl Unpin for Styled

§

impl UnsafeUnpin for Styled

§

impl UnwindSafe for Styled

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.