Struct rsvg::node::CascadedValues

source ·
pub struct CascadedValues<'a> {
    inner: CascadedInner<'a>,
    pub context_stroke: Option<Rc<PaintSource>>,
    pub context_fill: Option<Rc<PaintSource>>,
}
Expand description

Can obtain computed values from a node

In our tree of SVG elements (Node in our parlance), each node stores a ComputedValues that gets computed during the initial CSS cascade. However, sometimes nodes need to be rendered outside the normal hierarchy. For example, the <use> element can “instance” a subtree from elsewhere in the SVG; it causes the instanced subtree to re-cascade from the computed values for the <use> element.

You can then call the get() method on the resulting CascadedValues to get a &ComputedValues whose fields you can access.

Fields§

§inner: CascadedInner<'a>§context_stroke: Option<Rc<PaintSource>>§context_fill: Option<Rc<PaintSource>>

Implementations§

source§

impl<'a> CascadedValues<'a>

source

pub fn clone_with_node(&self, node: &'a Node<NodeData>) -> CascadedValues<'a>

Creates a CascadedValues that has the same cascading mode as &self

This is what nodes should normally use to draw their children from their draw() method. Nodes that need to override the cascade for their children can use new_from_values() instead.

source

pub fn new_from_node(node: &Node<NodeData>) -> CascadedValues<'_>

Creates a CascadedValues that will hold the node’s computed values

This is to be used only in the toplevel drawing function, or in elements like <marker> that don’t propagate their parent’s cascade to their children. All others should use new() to derive the cascade from an existing one.

source

pub fn new_from_values( node: &'a Node<NodeData>, values: &ComputedValues, fill: Option<Rc<PaintSource>>, stroke: Option<Rc<PaintSource>> ) -> CascadedValues<'a>

Creates a CascadedValues that will override the node’s cascade with the specified values

This is for the <use> element, which draws the element which it references with the <use>’s own cascade, not with the element’s original cascade.

source

pub fn get(&'a self) -> &'a ComputedValues

Returns the cascaded ComputedValues.

Nodes should use this from their Draw::draw() implementation to get the ComputedValues from the CascadedValues that got passed to draw().

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for CascadedValues<'a>

§

impl<'a> !Send for CascadedValues<'a>

§

impl<'a> !Sync for CascadedValues<'a>

§

impl<'a> Unpin for CascadedValues<'a>

§

impl<'a> !UnwindSafe for CascadedValues<'a>

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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.