pub struct Styled { /* private fields */ }Expand description
Every element’s computed values.
Implementations§
Source§impl Styled
impl Styled
Sourcepub fn get_pseudo(&self, el: u32, p: &Pseudo, property: &str) -> Option<String>
pub fn get_pseudo(&self, el: u32, 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));Sourcepub fn computed_pseudo(&self, el: u32, p: &Pseudo) -> Option<Computed>
pub fn computed_pseudo(&self, el: u32, 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.
Sourcepub fn pseudo_exists(&self, el: u32, p: &Pseudo) -> Option<bool>
pub fn pseudo_exists(&self, el: u32, 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.
Auto Trait Implementations§
impl Forget for Styled
impl Freeze for Styledwhere
*const u8 is !null: Freeze,
PhantomData<(u32, Computed)>: Freeze,
PhantomData<PseudoRule>: Freeze,
PhantomData<(usize, Key)>: Freeze,
PhantomData<(u32, Vec<(usize, Key)>)>: Freeze,
PhantomData<(u32, Vec<(String, String)>)>: Freeze,
PhantomData<(&'static str, &'static str)>: Freeze,
PhantomData<(String, (PropertyRule, Syntax))>: Freeze,
impl Move for Styled
impl RefUnwindSafe for Styledwhere
OnceLock<Target>: RefUnwindSafe,
OnceLock<First>: RefUnwindSafe,
OnceLock<Option<(&'static PropertyData, &'static Grammar)>>: RefUnwindSafe,
impl Send for Styled
impl Sync for Styled
impl Unpin for Styled
impl UnsafeUnpin for Styledwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<(u32, Computed)>: UnsafeUnpin,
PhantomData<PseudoRule>: UnsafeUnpin,
PhantomData<(usize, Key)>: UnsafeUnpin,
PhantomData<(u32, Vec<(usize, Key)>)>: UnsafeUnpin,
PhantomData<(u32, Vec<(String, String)>)>: UnsafeUnpin,
PhantomData<(&'static str, &'static str)>: UnsafeUnpin,
PhantomData<(String, (PropertyRule, Syntax))>: UnsafeUnpin,
impl UnwindSafe for Styledwhere
HashMap<u32, Computed>: UnwindSafe,
RawVecInner: UnwindSafe,
HashMap<u32, Vec<(usize, Key)>>: UnwindSafe,
HashMap<u32, Vec<(String, String)>>: UnwindSafe,
&'static str: UnwindSafe,
HashMap<String, (PropertyRule, Syntax)>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more