pub struct SvgNode<'a, 'input: 'a> {
id: NodeId,
doc: &'a Document<'input>,
d: &'a NodeData,
}
Expand description
An SVG node.
Fields§
§id: NodeId
§doc: &'a Document<'input>
§d: &'a NodeData
Implementations§
Source§impl<'a, 'input: 'a> SvgNode<'a, 'input>
impl<'a, 'input: 'a> SvgNode<'a, 'input>
pub(crate) fn convert_length( &self, aid: AId, object_units: Units, state: &State<'_>, def: Length, ) -> f32
pub fn convert_user_length( &self, aid: AId, state: &State<'_>, def: Length, ) -> f32
pub fn parse_viewbox(&self) -> Option<NonZeroRect>
pub fn resolve_length(&self, aid: AId, state: &State<'_>, def: f32) -> f32
pub fn resolve_valid_length( &self, aid: AId, state: &State<'_>, def: f32, ) -> Option<NonZeroPositiveF32>
pub(crate) fn try_convert_length( &self, aid: AId, object_units: Units, state: &State<'_>, ) -> Option<f32>
pub fn has_valid_transform(&self, aid: AId) -> bool
pub fn is_visible_element(&self, opt: &Options<'_>) -> bool
Source§impl SvgNode<'_, '_>
impl SvgNode<'_, '_>
pub(crate) fn resolve_transform( &self, transform_aid: AId, state: &State<'_>, ) -> Transform
Source§impl<'a, 'input: 'a> SvgNode<'a, 'input>
impl<'a, 'input: 'a> SvgNode<'a, 'input>
fn id(&self) -> NodeId
Sourcepub fn is_element(&self) -> bool
pub fn is_element(&self) -> bool
Checks if the current node is an element.
Sourcepub fn tag_name(&self) -> Option<EId>
pub fn tag_name(&self) -> Option<EId>
Returns element’s tag name, unless the current node is text.
Sourcepub fn element_id(&self) -> &'a str
pub fn element_id(&self) -> &'a str
Returns element’s id
attribute value.
Returns an empty string otherwise.
Sourcepub fn attribute<T: FromValue<'a, 'input>>(&self, aid: AId) -> Option<T>
pub fn attribute<T: FromValue<'a, 'input>>(&self, aid: AId) -> Option<T>
Returns an attribute value.
Sourcepub fn try_attribute<T: FromValue<'a, 'input>>(&self, aid: AId) -> Option<T>
pub fn try_attribute<T: FromValue<'a, 'input>>(&self, aid: AId) -> Option<T>
Returns an attribute value.
Same as SvgNode::attribute
, but doesn’t show a warning.
fn node_attribute(&self, aid: AId) -> Option<SvgNode<'a, 'input>>
Sourcepub fn has_attribute(&self, aid: AId) -> bool
pub fn has_attribute(&self, aid: AId) -> bool
Checks if an attribute is present.
Sourcepub fn attributes(&self) -> &'a [Attribute<'input>]
pub fn attributes(&self) -> &'a [Attribute<'input>]
Returns a list of all element’s attributes.
fn attribute_id(&self, aid: AId) -> Option<usize>
Sourcepub fn find_attribute<T: FromValue<'a, 'input>>(&self, aid: AId) -> Option<T>
pub fn find_attribute<T: FromValue<'a, 'input>>(&self, aid: AId) -> Option<T>
Finds a [Node
] that contains the required attribute.
For inheritable attributes walks over ancestors until a node with the specified attribute is found.
For non-inheritable attributes checks only the current node and the parent one. As per SVG spec.
fn find_attribute_impl(&self, aid: AId) -> Option<SvgNode<'a, 'input>>
Sourcepub fn text(&self) -> &'a str
pub fn text(&self) -> &'a str
Returns node’s text data.
For text nodes returns its content. For elements returns the first child node text.
Sourcepub fn parent_element(&self) -> Option<Self>
pub fn parent_element(&self) -> Option<Self>
Returns the parent element.
Sourcepub fn next_sibling(&self) -> Option<Self>
pub fn next_sibling(&self) -> Option<Self>
Returns the next sibling.
Sourcepub fn first_child(&self) -> Option<Self>
pub fn first_child(&self) -> Option<Self>
Returns the first child.
Sourcepub fn first_element_child(&self) -> Option<Self>
pub fn first_element_child(&self) -> Option<Self>
Returns the first child element.
Sourcepub fn last_child(&self) -> Option<Self>
pub fn last_child(&self) -> Option<Self>
Returns the last child.
Sourcepub fn has_children(&self) -> bool
pub fn has_children(&self) -> bool
Checks if the node has child nodes.
Sourcepub fn ancestors(&self) -> Ancestors<'a, 'input> ⓘ
pub fn ancestors(&self) -> Ancestors<'a, 'input> ⓘ
Returns an iterator over ancestor nodes starting at this node.
Sourcefn traverse(&self) -> Traverse<'a, 'input> ⓘ
fn traverse(&self) -> Traverse<'a, 'input> ⓘ
Returns an iterator which traverses the subtree starting at this node.
Sourcepub fn descendants(&self) -> Descendants<'a, 'input> ⓘ
pub fn descendants(&self) -> Descendants<'a, 'input> ⓘ
Returns an iterator over this node and its descendants.