void setType (const RcStringOrRef &type )
Set the type of the stylesheet, currently only text/css is supported.
void setContents (std::string_view style)
Set the contents of the stylesheet.
RcString textContent () const
Return the raw CSS text the stylesheet was parsed from.
void setTextContent (std::string_view text)
Replace the text content of the <style> element with text and reparse the stylesheet, so the parsed rules and textContent stay coherent.
bool isCssType () const
Return true if the stylesheet is of type text/css .
SVGElement (const SVGElement &other)
Create another reference to the same SVGElement .
SVGElement (SVGElement &&other) noexcept
Move constructor.
~SVGElement () noexcept
Destructor.
SVGElement & operator= (const SVGElement &other)
Create another reference to the same SVGElement .
SVGElement & operator= (SVGElement &&other) noexcept
Move assignment operator.
ElementType type () const
Get the ElementType for known XML element types.
std::optional< ElementType > tryType () const
Get the ElementType if this handle still has SVG element identity.
xml::XMLQualifiedName tagName () const
Get the owning XML qualified tag name for this element.
std::optional< xml::XMLQualifiedName > tryTagName () const
Get the owning XML qualified tag name if this handle still has XML tree identity.
bool isKnownType () const
Returns true if this is a known element type, returns false if this is an donner::svg::SVGUnknownElement .
EntityHandle unsafeEntityHandle () const
Get the underlying donner::EntityHandle .
EntityHandle entityHandle () const
Get the underlying donner::EntityHandle , for advanced use-cases that require direct access to the ECS.
template<typename Callback>
decltype(auto) withReadAccess (Callback &&callback) const
Run a callback with scoped read access to this element's document and resolved entity handle.
template<typename Callback>
decltype(auto) withWriteAccess (Callback &&callback) const
Run a callback with scoped write access to this element's document and resolved entity handle.
RcString id () const
Get the element id, the value of the "id" attribute.
void setId (std::string_view id )
Set the element id, the value of the "id" attribute.
RcString className () const
Get the element class name, the value of the "class" attribute.
void setClassName (std::string_view name)
Set the element class name, the value of the "class" attribute.
void setStyle (std::string_view style)
Set the element style, the value of the "style" attribute.
void updateStyle (std::string_view style)
Update the element style, adding new attributes or overridding existing ones (without removing them).
ParseResult < bool > trySetPresentationAttribute (std::string_view name, std::string_view value)
Set the value of a presentation attribute, such as "fill" or "stroke".
bool hasAttribute (const xml::XMLQualifiedNameRef &name) const
Returns true if the element has an attribute with the given name.
std::optional< RcString > getAttribute (const xml::XMLQualifiedNameRef &name) const
Get the value of an attribute, if it exists.
SmallVector < xml::XMLQualifiedNameRef , 1 > findMatchingAttributes (const xml::XMLQualifiedNameRef &matcher) const
Find attributes matching the given name matcher.
SmallVector < xml::XMLQualifiedNameRef , 10 > attributes () const
Get the list of attributes for this element.
void setAttribute (const xml::XMLQualifiedNameRef &name, std::string_view value)
Set the value of a generic XML attribute, which may be either a presentation attribute or custom user-provided attribute.
void removeAttribute (const xml::XMLQualifiedNameRef &name)
Remove an attribute, which may be either a presentation attribute or custom user-provided attribute.
SVGDocument ownerDocument ()
Get an owning reference to the SVGDocument containing this element.
std::optional< SVGElement > parentElement () const
Get this element's parent, if it exists.
std::optional< SVGElement > firstChild () const
Get the first child of this element, if it exists.
std::optional< SVGElement > lastChild () const
Get the last child of this element, if it exists.
std::optional< SVGElement > previousSibling () const
Get the previous sibling of this element, if it exists.
std::optional< SVGElement > nextSibling () const
Get the next sibling of this element, if it exists.
void insertBefore (const SVGElement &newNode, std::optional< SVGElement > referenceNode)
Insert newNode as a child, before referenceNode.
void appendChild (const SVGElement &child)
Append child as a child of the current node.
void replaceChild (const SVGElement &newChild, const SVGElement &oldChild)
Replace oldChild with newChild in the tree, removing oldChild and inserting newChild in its place.
void removeChild (const SVGElement &child)
Remove child from this node.
void remove ()
Remove this node from its parent, if it has one.
bool operator== (const SVGElement &other) const
Returns true if the two SVGElement handles reference the same underlying document.
bool operator!= (const SVGElement &other) const
Returns true if the two SVGElement handles reference the same underlying document.
template<typename Derived>
bool isa () const
Return true if this element "is a" instance of type, if it be cast to a specific type with cast .
template<typename Derived>
Derived cast ()
Cast this element to its derived type.
template<typename Derived>
Derived cast () const
Cast this element to its derived type (const version).
template<typename Derived>
std::optional< Derived > tryCast ()
Cast this element to its derived type, if possible.
template<typename Derived>
std::optional< const Derived > tryCast () const
Cast this element to its derived type, if possible.
std::optional< SVGElement > querySelector (std::string_view selector)
Find the first element in the tree that matches the given CSS selector.
const PropertyRegistry & getComputedStyle () const
Get the computed CSS style of this element, after the CSS cascade has been applied.
const PropertyRegistry * specifiedStyle () const
The element's own specified style properties - the parsed style attribute plus presentation attributes, before the CSS cascade and inheritance - or nullptr when the element carries no style data.
const PropertyRegistry * computedStyleIfPresent () const
The cascaded computed style if it has already been computed (by rendering or a prior getComputedStyle call), otherwise nullptr .
std::optional< PaintServer > resolvedFillPaint () const
The renderer-resolved fill paint from this element's prepared rendering instance, or std::nullopt when the render tree has not been built or this element has no rendering instance.
DOM object for a <style> element, which contains a CSS stylesheet.
<style>
.rect {
fill: crimson;
stroke: darkred;
}
.circle:nth-child(3n+1) { fill: red; }
.circle:nth-child(3n+2) { fill: limegreen; }
.circle:nth-child(3n+3) { fill: blue; }
</style>
Attribute Default Description
type text/css Type of the stylesheets contents, currently only text/css is supported. Use SVGStyleElement::isCssType() to check.
media (empty) [unsupported] Specifies a media query that must be matched for the style sheet to apply.
title (empty) [unsupported] Specifies a title for the style sheet, which is used when selecting between alternate style sheets.
Note that type is defined to be a media type [rfc2046 ].
Setting Style
Use SVGStyleElement::setContents and pass a CSS stylesheet string.