Contains properties the style="" attribute for an element, local to the element. More...
#include "donner/svg/components/style/StyleComponent.h"
Public Member Functions | |
| const PropertyRegistry & | properties () const |
| Parsed local declarations, including presentation attributes. | |
| std::optional< std::size_t > | declarationHash () const |
| Hash of the exact local declaration key; oversize local keys bypass the cache. | |
| bool | hasEmptyDeclarations () const |
| Whether the local declaration key is identical to an absent style component. | |
| template<typename F> | |
| void | editProperties (F &&edit) |
| Change typed declarations and update the lookup hash after the mutation. | |
| PropertyRegistry::PresentationAttributeClear | clearPresentationAttribute (std::string_view name) |
| Remove one presentation declaration and update the lookup hash when it changes. | |
| void | discardPendingPresentationVariable (std::string_view name) |
| Remove the prior variable when a typed presentation setter replaces it. | |
| bool | setStyle (std::string_view style) |
| Sets the properties from the value of the element's style="" attribute, replacing the prior style="" contribution on this element. | |
| bool | updateStyle (std::string_view style) |
| Updates the properties from the value of the element's style="" attribute, adding new properties or updating existing ones. | |
| ParseResult< bool > | trySetPresentationAttribute (EntityHandle handle, std::string_view name, std::string_view value) |
| Tries to set a common presentation attribute (fill, stroke, opacity, transform, etc.). | |
Public Attributes | |
| bool | styleParseRejected = false |
| True when the most recent inline-style parse exceeded its resource budget. | |
Static Public Attributes | |
| static constexpr std::size_t | page_size = 64 |
| Limit initial storage for this large component while retaining paged pointer stability. | |
Contains properties the style="" attribute for an element, local to the element.
This is used during the CSS cascade, which stores the final element style in ComputedStyleComponent.
|
inline |
Sets the properties from the value of the element's style="" attribute, replacing the prior style="" contribution on this element.
Presentation-attribute-origin properties (e.g. fill="red") and author-stylesheet properties are left intact - the replacement is scoped to declarations previously tagged with css::Specificity::StyleAttribute().
Safe to call from the SVG parse pipeline (where presentation attributes may already be in the registry) and from the editor's text-edit rewrite path.
Callers that want to merge new declarations into an existing style="" - e.g. a tool that toggles one property - should use updateStyle instead.
| style | The value of the style attribute. |
|
inline |
Tries to set a common presentation attribute (fill, stroke, opacity, transform, etc.).
For element-specific attributes (cx, cy, r, d, etc.), callers should also invoke parser::ParsePresentationAttribute separately.
| handle | The entity to set the attribute on. |
| name | The name of the attribute. |
| value | The value of the attribute. |
true if the attribute was set, false if the attribute was not recognized.
|
inline |
Updates the properties from the value of the element's style="" attribute, adding new properties or updating existing ones.
Does not remove existing style="" attribute information.
| style | The update style to apply, as a CSS style string (e.g. "fill:red;"). |