pub struct Styled { /* private fields */ }Expand description
Every element’s computed values.
Implementations§
Source§impl Styled
impl Styled
Sourcepub fn get_pseudo(
&self,
el: NodeId,
p: &Pseudo,
property: &str,
) -> Option<String>
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));Sourcepub fn computed_pseudo(&self, el: NodeId, p: &Pseudo) -> Option<Computed>
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.
Sourcepub fn pseudo_exists(&self, el: NodeId, p: &Pseudo) -> Option<bool>
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.
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> 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