Donner SVG main
0.8.0 ยท 766e862a0.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
ECS Systems

Systems hold the logic of the ECS architecture and are responsible for updating the components of entities. More...

Classes

class  donner::svg::components::FilterSystem
 Handles parsing and instantiating SVG filter effects from the SVG DOM. More...
class  donner::svg::components::LayoutSystem
 Handles layout and bounds calculations for SVG elements. More...
class  donner::svg::components::PaintSystem
 Manages Paint Servers for gradients and patterns, handling style and structural inheritance and creating "computed" state and shadow trees for these elements. More...
class  donner::svg::components::ShadowTreeSystem
 Instantiates shadow trees for elements that are not part of the main render graph, such as <use> and <pattern> elements. More...
class  donner::svg::components::ShapeSystem
 Creates computed path for shapes such as <circle>, <line>, and <path>. More...
class  donner::svg::components::StyleSystem
 Computes stylesheet information for elements, applying the CSS cascade and inheritance rules. More...
class  donner::svg::components::TextSystem
 System to compute text layout spans from raw text and positioning attributes. More...

Detailed Description

Systems hold the logic of the ECS architecture and are responsible for updating the components of entities.

  • Systems contain logic and interact with components.
  • Components are the data layer and contain the state, but no logic.

Systems may depend on other systems, but there are no circular dependencies.

graph LR
    LayoutSystem
    ShapeSystem
    StyleSystem
    PaintSystem
    ShadowTreeSystem
    FilterSystem

    ShapeSystem --> LayoutSystem
    ShapeSystem --> StyleSystem
    LayoutSystem --> StyleSystem
    PaintSystem --> StyleSystem

Class Documentation

◆ donner::svg::components::FilterSystem

class donner::svg::components::FilterSystem

Handles parsing and instantiating SVG filter effects from the SVG DOM.

See also
https://drafts.fxtf.org/filter-effects/

Public Member Functions

void createComputedFilter (EntityHandle handle, const FilterComponent &component, ParseWarningSink &warningSink)
 Create ComputedFilterComponent for the given entity, applying style information and style inheritance.
void instantiateAllComputedComponents (Registry &registry, ParseWarningSink &warningSink)
 Create all ComputedFilterComponent in the tree.

Member Function Documentation

◆ createComputedFilter()

void donner::svg::components::FilterSystem::createComputedFilter ( EntityHandle handle,
const FilterComponent & component,
ParseWarningSink & warningSink )

Create ComputedFilterComponent for the given entity, applying style information and style inheritance.

Parameters
handleEntity handle to apply the filter to.
componentFilter effect for the current entity, so that this may only be called if one is present.
warningSinkWarnings generated during parsing.

◆ instantiateAllComputedComponents()

void donner::svg::components::FilterSystem::instantiateAllComputedComponents ( Registry & registry,
ParseWarningSink & warningSink )

Create all ComputedFilterComponent in the tree.

Parameters
registryRegistry to operate on.
warningSinkWarnings generated during parsing.

◆ donner::svg::components::LayoutSystem

class donner::svg::components::LayoutSystem

Handles layout and bounds calculations for SVG elements.

This system is responsible for calculating the the document size, viewBoxes, and the bounds for elements.

See also
https://www.w3.org/TR/SVG2/coords.html

Public Types

enum class  InvalidSizeBehavior {
  ZeroSize ,
  ReturnDefault
}
 Controls the behavior of LayoutSystem::calculateCanvasScaledDocumentSize for invalid sizes. More...

Public Member Functions

Regular properties
std::optional< float > intrinsicAspectRatio (EntityHandle entity) const
 Calculate the intrinsic aspect ratio per https://svgwg.org/svg2-draft/coords.html#SizingSVGInCSS, which defines how content is scaled to fit the viewport.
Vector2i calculateDocumentSize (Registry &registry) const
 Calculate the document size of the current entity.
Box2d getViewBox (EntityHandle entity)
 Get the viewBox affecting the current entity.
bool overridesViewBox (EntityHandle entity) const
 Returns true if the given entity overrides the viewBox.
Vector2i calculateCanvasScaledDocumentSize (Registry &registry, InvalidSizeBehavior behavior) const
 Get the document size scaled to fit the canvas.
Transform2d getRawEntityFromParentTransform (EntityHandle entity)
 Returns the parentFromEntity transform without modifiers (e.g.
Transform2d getEntityFromParentTransform (EntityHandle entity)
 Returns the parentFromEntity transform with modifiers.
Transform2d getCanvasFromDocumentTransform (Registry &registry)
 Get the transform that maps viewBox-space points to canvas-scaled output space, baking in the root preserveAspectRatio fit.
Transform2d getEntityContentFromEntityTransform (EntityHandle entity)
 Get the transform for entityContent-from-entity, which is an additional transform for specific elements that define their own coordinate system, such as nested <svg> and <use> elements.
Transform2d getEntityContentFromParentTransform (EntityHandle entity)
 Get the entityContent-from-parent transform: getEntityContentFromEntityTransform composed with the entity's own transform, or with no transform for elements whose rendering behavior ignores it.
void setRawEntityFromParentTransform (EntityHandle entity, const Transform2d &parentFromEntity)
 Set the parentFromEntity transform for the current entity.
const ComputedAbsoluteTransformComponent & getAbsoluteTransformComponent (EntityHandle entity)
 Get the computed absolute transform for the current entity.
Transform2d getEntityFromWorldTransform (EntityHandle entity)
 Get the entity-from-world transform for the current entity, representing the entity position relative to the world after applying all parent transformations.
void invalidate (EntityHandle entity, bool viewportChanged=false)
 Invalidate cached state for the current entity, such as the computed viewBox and entity-from-world transform.
void invalidateAbsoluteTransforms (EntityHandle entity)
 Drop the cached absolute transforms of entity and its descendants, which depend on where the entity is placed, while keeping its computed size, viewBox and local transform.
Computed properties
void instantiateAllComputedComponents (Registry &registry, ParseWarningSink &warningSink)
 Create all computed components, such as ComputedViewBoxComponent and ComputedSizedElementComponent.
void recomputeInvalidatedLayout (EntityHandle entity, ParseWarningSink &warningSink)
 Recreate the computed layout of one entity that invalidate dropped while its viewport stayed the same (for example after a transform write), matching what instantiateAllComputedComponents computes for it: its computed size, local transform and viewBox.
SizedElementProperties resolveSizeProperties (const SizedElementProperties &sizeProperties, const std::map< RcString, parser::UnparsedProperty > &unparsedProperties, ParseWarningSink &warningSink)
 Apply the size-property cascade while preserving unresolved lengths.
Box2d computeSizeProperties (EntityHandle entity, const SizedElementProperties &sizeProperties, const std::map< RcString, parser::UnparsedProperty > &unparsedProperties, const Box2d &viewBox, FontMetrics fontMetrics, ParseWarningSink &warningSink)
 Evaluates SizedElementProperties and returns the resulting bounds, using precomputed style information.
bool createShadowSizedElementComponent (Registry &registry, Entity shadowEntity, EntityHandle useEntity, Entity symbolEntity, ShadowBranchType branchType, ParseWarningSink &warningSink)
 Creates a ComputedShadowSizedElementComponent for shadow trees where a parent element's size properties should override target element's size properties (e.g., use element overriding symbol element's size).
const ComputedSizedElementComponent & createComputedSizedElementComponentWithStyle (EntityHandle handle, const ComputedStyleComponent &style, FontMetrics fontMetrics, ParseWarningSink &warningSink)
 Creates a ComputedSizedElementComponent for the linked entity, using precomputed style information.
const ComputedLocalTransformComponent & createComputedLocalTransformComponentWithStyle (EntityHandle handle, const ComputedStyleComponent &style, const FontMetrics &fontMetrics, ParseWarningSink &warningSink)
 Creates a ComputedLocalTransformComponent for the linked entity, using precomputed style information.
std::optional< Box2d > clipRect (EntityHandle handle) const
 If this element establishes a clipping context, returns the clip rect in the parent's coordinate system.
Transform2d elementContentFromViewBoxTransform (EntityHandle handle, const ComputedSizedElementComponent &computedSizedElement) const
 Computes the elementContent-from-viewBox transform (using dest-from-source notation), from the from the parent's coordinate system (resized to the viewBox of this element) to the element's coordinate system for children (content).

Member Enumeration Documentation

◆ InvalidSizeBehavior

Controls the behavior of LayoutSystem::calculateCanvasScaledDocumentSize for invalid sizes.

Enumerator
ZeroSize 

Return a size of 0x0.

ReturnDefault 

Return the default document size (512x512).

Member Function Documentation

◆ calculateCanvasScaledDocumentSize()

Vector2i donner::svg::components::LayoutSystem::calculateCanvasScaledDocumentSize ( Registry & registry,
InvalidSizeBehavior behavior ) const

Get the document size scaled to fit the canvas.

Parameters
registryECS registry
behaviorControls the behavior when the document size is invalid, either returning a default size or empty box.

◆ calculateDocumentSize()

Vector2i donner::svg::components::LayoutSystem::calculateDocumentSize ( Registry & registry) const

Calculate the document size of the current entity.

This is the size of the document viewBox (the area that the SVG content is rendered into).

Parameters
registryECS registry

◆ clipRect()

std::optional< Box2d > donner::svg::components::LayoutSystem::clipRect ( EntityHandle handle) const

If this element establishes a clipping context, returns the clip rect in the parent's coordinate system.

Parameters
handleEntity handle.
Returns
std::optional<Box2d> Clip rect, or std::nullopt if this element does not establish a clipping context.

◆ computeSizeProperties()

Box2d donner::svg::components::LayoutSystem::computeSizeProperties ( EntityHandle entity,
const SizedElementProperties & sizeProperties,
const std::map< RcString, parser::UnparsedProperty > & unparsedProperties,
const Box2d & viewBox,
FontMetrics fontMetrics,
ParseWarningSink & warningSink )

Evaluates SizedElementProperties and returns the resulting bounds, using precomputed style information.

Parameters
entityEntity handle.
sizePropertiesSize properties to evaluate.
unparsedPropertiesUnparsed properties to evaluate.
viewBoxViewBox to use when converting size percentages.
fontMetricsFont metrics, used to scale lengths.
warningSinkOutput vector of parse errors, if any.
Returns
Computed bounds.

◆ createComputedLocalTransformComponentWithStyle()

const ComputedLocalTransformComponent & donner::svg::components::LayoutSystem::createComputedLocalTransformComponentWithStyle ( EntityHandle handle,
const ComputedStyleComponent & style,
const FontMetrics & fontMetrics,
ParseWarningSink & warningSink )

Creates a ComputedLocalTransformComponent for the linked entity, using precomputed style information.

Parameters
handleEntity handle.
stylePrecomputed style information for this element
fontMetricsFont metrics, used to scale lengths
warningSinkOutput vector of parse errors, if any.

◆ createComputedSizedElementComponentWithStyle()

const ComputedSizedElementComponent & donner::svg::components::LayoutSystem::createComputedSizedElementComponentWithStyle ( EntityHandle handle,
const ComputedStyleComponent & style,
FontMetrics fontMetrics,
ParseWarningSink & warningSink )

Creates a ComputedSizedElementComponent for the linked entity, using precomputed style information.

Parameters
handleEntity handle.
stylePrecomputed style information for this element
fontMetricsFont metrics, used to scale lengths
warningSinkOutput vector of parse errors, if any.
Returns
reference to the computed component

◆ createShadowSizedElementComponent()

bool donner::svg::components::LayoutSystem::createShadowSizedElementComponent ( Registry & registry,
Entity shadowEntity,
EntityHandle useEntity,
Entity symbolEntity,
ShadowBranchType branchType,
ParseWarningSink & warningSink )

Creates a ComputedShadowSizedElementComponent for shadow trees where a parent element's size properties should override target element's size properties (e.g., use element overriding symbol element's size).

Parameters
registryECS registry.
shadowEntityThe shadow entity to create a computed component for.
useEntityThe source <use> that may provide size override.
symbolEntityThe target <symbol> entity whose properties might be overridden.
branchTypeThe type of branch being created.
warningSinkOutput vector of parse errors, if any.
Returns
true if a component was created, false otherwise.

◆ elementContentFromViewBoxTransform()

Transform2d donner::svg::components::LayoutSystem::elementContentFromViewBoxTransform ( EntityHandle handle,
const ComputedSizedElementComponent & computedSizedElement ) const

Computes the elementContent-from-viewBox transform (using dest-from-source notation), from the from the parent's coordinate system (resized to the viewBox of this element) to the element's coordinate system for children (content).

Parameters
handleEntity handle.
computedSizedElementPrecomputed sized element information.
Returns
Transform2d Transformation from viewBox (source) to element content (destination).

◆ getAbsoluteTransformComponent()

const ComputedAbsoluteTransformComponent & donner::svg::components::LayoutSystem::getAbsoluteTransformComponent ( EntityHandle entity)

Get the computed absolute transform for the current entity.

This is the same as getEntityFromWorldTransform except it returns the component containing additional flags as well.

Parameters
entityCurrent entity.

◆ getCanvasFromDocumentTransform()

Transform2d donner::svg::components::LayoutSystem::getCanvasFromDocumentTransform ( Registry & registry)

Get the transform that maps viewBox-space points to canvas-scaled output space, baking in the root preserveAspectRatio fit.

Despite the previous getDocumentFromCanvasTransform name, this is a canvasFromDocument transform (input = document/viewBox, output = canvas).

Parameters
registryECS registry

◆ getEntityContentFromEntityTransform()

Transform2d donner::svg::components::LayoutSystem::getEntityContentFromEntityTransform ( EntityHandle entity)

Get the transform for entityContent-from-entity, which is an additional transform for specific elements that define their own coordinate system, such as nested <svg> and <use> elements.

This transform is used to convert coordinates from the entity's coordinate system to the coordinate system of its content.

For example, a nested SVG element, where for the inner SVG element the content transform is scale(2) translate(50 50):

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 200">
<svg x="50" y="50" width="100" height="100" viewBox="0 0 50 50">
<rect x="0" y="0" width="50" height="50" fill="red"/>
</svg>
</svg>
Parameters
entityCurrent entity.

◆ getEntityContentFromParentTransform()

Transform2d donner::svg::components::LayoutSystem::getEntityContentFromParentTransform ( EntityHandle entity)

Get the entityContent-from-parent transform: getEntityContentFromEntityTransform composed with the entity's own transform, or with no transform for elements whose rendering behavior ignores it.

Each ancestor contributes this factor to an absolute transform.

Parameters
entityCurrent entity.

◆ getEntityFromParentTransform()

Transform2d donner::svg::components::LayoutSystem::getEntityFromParentTransform ( EntityHandle entity)

Returns the parentFromEntity transform with modifiers.

Parameters
entityCurrent entity.

◆ getEntityFromWorldTransform()

Transform2d donner::svg::components::LayoutSystem::getEntityFromWorldTransform ( EntityHandle entity)

Get the entity-from-world transform for the current entity, representing the entity position relative to the world after applying all parent transformations.

Parameters
entityCurrent entity.

◆ getRawEntityFromParentTransform()

Transform2d donner::svg::components::LayoutSystem::getRawEntityFromParentTransform ( EntityHandle entity)

Returns the parentFromEntity transform without modifiers (e.g.

not including transform-origin)

Parameters
entityCurrent entity.

◆ getViewBox()

Box2d donner::svg::components::LayoutSystem::getViewBox ( EntityHandle entity)

Get the viewBox affecting the current entity.

This may be the viewBox of a viewBox-defining parent element or the document viewBox.

Parameters
entityCurrent entity.

◆ instantiateAllComputedComponents()

void donner::svg::components::LayoutSystem::instantiateAllComputedComponents ( Registry & registry,
ParseWarningSink & warningSink )

Create all computed components, such as ComputedViewBoxComponent and ComputedSizedElementComponent.

Parameters
registryECS registry.
warningSinkOutput vector of parse errors, if any.

◆ intrinsicAspectRatio()

std::optional< float > donner::svg::components::LayoutSystem::intrinsicAspectRatio ( EntityHandle entity) const

Calculate the intrinsic aspect ratio per https://svgwg.org/svg2-draft/coords.html#SizingSVGInCSS, which defines how content is scaled to fit the viewport.

This may return std::nullopt if the aspect ratio is not defined.

Parameters
entityCurrent entity.

◆ invalidate()

void donner::svg::components::LayoutSystem::invalidate ( EntityHandle entity,
bool viewportChanged = false )

Invalidate cached state for the current entity, such as the computed viewBox and entity-from-world transform.

Parameters
entityCurrent entity.
viewportChangedAlso invalidate descendant viewport-dependent layout caches.

◆ invalidateAbsoluteTransforms()

void donner::svg::components::LayoutSystem::invalidateAbsoluteTransforms ( EntityHandle entity)

Drop the cached absolute transforms of entity and its descendants, which depend on where the entity is placed, while keeping its computed size, viewBox and local transform.

Marks nothing dirty.

Parameters
entityRoot of the subtree.

◆ overridesViewBox()

bool donner::svg::components::LayoutSystem::overridesViewBox ( EntityHandle entity) const

Returns true if the given entity overrides the viewBox.

Parameters
entityCurrent entity.

◆ recomputeInvalidatedLayout()

void donner::svg::components::LayoutSystem::recomputeInvalidatedLayout ( EntityHandle entity,
ParseWarningSink & warningSink )

Recreate the computed layout of one entity that invalidate dropped while its viewport stayed the same (for example after a transform write), matching what instantiateAllComputedComponents computes for it: its computed size, local transform and viewBox.

Descendants keep their computed layout; only their absolute transforms were dropped, and those are recomputed on demand.

Parameters
entityEntity whose layout was invalidated. Must have a computed style.
warningSinkOutput vector of parse errors, if any.

◆ resolveSizeProperties()

SizedElementProperties donner::svg::components::LayoutSystem::resolveSizeProperties ( const SizedElementProperties & sizeProperties,
const std::map< RcString, parser::UnparsedProperty > & unparsedProperties,
ParseWarningSink & warningSink )

Apply the size-property cascade while preserving unresolved lengths.

Parameters
sizePropertiesTyped properties, including their cascade specificity.
unparsedPropertiesCSS declarations to apply.
warningSinkDestination for invalid-property diagnostics.
Returns
Resolved properties with authored length units retained.

◆ setRawEntityFromParentTransform()

void donner::svg::components::LayoutSystem::setRawEntityFromParentTransform ( EntityHandle entity,
const Transform2d & parentFromEntity )

Set the parentFromEntity transform for the current entity.

This will be transformed with modifiers such as transform-origin before being applied to the entity.

Parameters
entityCurrent entity.
parentFromEntityNew transform.

◆ donner::svg::components::PaintSystem

class donner::svg::components::PaintSystem

Manages Paint Servers for gradients and patterns, handling style and structural inheritance and creating "computed" state and shadow trees for these elements.

See also
https://www.w3.org/TR/SVG2/pservers.html

Public Member Functions

const ComputedStopComponent & createComputedStop (EntityHandle handle, const StopComponent &stop, ParseWarningSink &warningSink)
 Create a ComputedStopComponent for the given entity handle and its attached StopComponent, which applies CSS styling information and presentation attributes.
void instantiateAllComputedComponents (Registry &registry, ParseWarningSink &warningSink)
 Create ComputedGradientComponent for all entities in the registry that have a GradientComponent.
void createShadowTrees (Registry &registry, ParseWarningSink &warningSink)
 Create shadow trees for all gradient and pattern elements in the registry that have a valid href="" attribute.

Member Function Documentation

◆ createComputedStop()

const ComputedStopComponent & donner::svg::components::PaintSystem::createComputedStop ( EntityHandle handle,
const StopComponent & stop,
ParseWarningSink & warningSink )

Create a ComputedStopComponent for the given entity handle and its attached StopComponent, which applies CSS styling information and presentation attributes.

Parameters
handleEntity handle to create the computed gradient for
stopStop component attached to handle
warningSinkContaining any warnings found

◆ createShadowTrees()

void donner::svg::components::PaintSystem::createShadowTrees ( Registry & registry,
ParseWarningSink & warningSink )

Create shadow trees for all gradient and pattern elements in the registry that have a valid href="" attribute.

This must be called before instantiateAllComputedComponents.

Parameters
registryRegistry used to find all GradientComponent and PatternComponent components to compute shadow trees
warningSinkContaining any warnings found

◆ instantiateAllComputedComponents()

void donner::svg::components::PaintSystem::instantiateAllComputedComponents ( Registry & registry,
ParseWarningSink & warningSink )

Create ComputedGradientComponent for all entities in the registry that have a GradientComponent.

This assumes that createShadowTrees has already been called.

Note that this function does not produce any warnings, its signature is used to create a common API pattern.

Parameters
registryRegistry used to find all GradientComponent
warningSinkContaining any warnings found

◆ donner::svg::components::ShadowTreeSystem

class donner::svg::components::ShadowTreeSystem

Instantiates shadow trees for elements that are not part of the main render graph, such as <use> and <pattern> elements.

See also
https://www.w3.org/TR/SVG2/struct.html#UseShadowTree
https://www.w3.org/TR/SVG2/pservers.html#PaintServerTemplates

Public Member Functions

 ShadowTreeSystem (ShadowSizedElementHandler sizedElementHandler=nullptr)
 Constructor.
void teardown (Registry &registry, ComputedShadowTreeComponent &shadow)
 Destroy the instantiated shadow tree.
void teardownInstances (EntityHandle handle)
 Destroy every shadow tree instantiated on handle, if any.
std::optional< size_t > populateInstance (EntityHandle entity, ComputedShadowTreeComponent &shadow, ShadowBranchType branchType, Entity lightTarget, const RcString &href, ParseWarningSink &warningSink)
 Create a new computed shadow tree instance, such as the shadow tree for a <use> element or a <pattern> element.

Static Public Member Functions

static void beginRebuild (Registry &registry)
 Reset aggregate shadow admission before a full render-tree rebuild.
static bool appendStyleOccurrences (Registry &registry, std::vector< Entity > &entities)
 Include the live in-document copies of affected sources and their shadow descendants.

Constructor & Destructor Documentation

◆ ShadowTreeSystem()

donner::svg::components::ShadowTreeSystem::ShadowTreeSystem ( ShadowSizedElementHandler sizedElementHandler = nullptr)
inlineexplicit

Constructor.

Parameters
sizedElementHandlerOptional callback for handling sized elements in shadow trees.

Member Function Documentation

◆ appendStyleOccurrences()

bool donner::svg::components::ShadowTreeSystem::appendStyleOccurrences ( Registry & registry,
std::vector< Entity > & entities )
staticnodiscard

Include the live in-document copies of affected sources and their shadow descendants.

The caller validates the selector dependency and old computed style of every returned entity before it removes any computed styles.

Parameters
registryDocument registry, held for mutation.
entitiesAffected light entities. Shadow entities are appended on success.
Returns
False if an affected source reaches an unsupported or incomplete branch.

◆ populateInstance()

std::optional< size_t > donner::svg::components::ShadowTreeSystem::populateInstance ( EntityHandle entity,
ComputedShadowTreeComponent & shadow,
ShadowBranchType branchType,
Entity lightTarget,
const RcString & href,
ParseWarningSink & warningSink )

Create a new computed shadow tree instance, such as the shadow tree for a <use> element or a <pattern> element.

For <pattern> paint servers, there may be multiple shadow trees originating from the same entity, for both a 'fill' and a 'stroke', so this component can hold multiple shadow trees simultaneously.

Parameters
entityThe entity to create the shadow tree for.
shadowThe computed shadow tree component to populate.
branchTypeDetermines which branch of the tree to attach to. There may be multiple instances with a shadow tree, but only ShadowBranchType::Main will be traversed in the render tree.
lightTargetTarget entity to reflect in the shadow tree.
hrefThe value of the href attribute for the shadow tree, for diagnostics.
warningSinkIf provided, warnings will be added to this vector.
Returns
The index of the offscreen shadow tree, if branchType is not the ShadowBranchType::Main branch. Returns std::nullopt if it is.

◆ teardown()

void donner::svg::components::ShadowTreeSystem::teardown ( Registry & registry,
ComputedShadowTreeComponent & shadow )

Destroy the instantiated shadow tree.

Parameters
registryThe registry.
shadowThe computed shadow tree component to tear down.

◆ teardownInstances()

void donner::svg::components::ShadowTreeSystem::teardownInstances ( EntityHandle handle)

Destroy every shadow tree instantiated on handle, if any.

Call this before removing an entity's ComputedShadowTreeComponent to force its shadow trees to be regenerated. Removing the component on its own orphans the cloned entities: they stay parented into the tree with nothing left recording them, so the next render instantiates a second copy that draws on top of the first.

Parameters
handleThe shadow host whose instances should be destroyed.

◆ donner::svg::components::ShapeSystem

class donner::svg::components::ShapeSystem

Creates computed path for shapes such as <circle>, <line>, and <path>.

See also
https://www.w3.org/TR/SVG2/shapes.html

Public Member Functions

void instantiateShadowComputedPaths (Registry &registry, std::span< const Entity > entities, ParseWarningSink &warningSink)
 Prepare newly created shadow instances without resampling the rest of the document.
template<typename T>
ComputedPathComponent * createComputedPath (EntityHandle handle, const T &component, const FontMetrics &fontMetrics, ParseWarningSink &warningSink)
 Convert the given shape to a path, evaluating CSS styling information and presentation attributes.
ComputedPathComponent * createComputedPathIfShape (EntityHandle handle, const FontMetrics &fontMetrics, ParseWarningSink &warningSink)
 Convert the given shape to a path, if the provided entity contains a shape.
void instantiateAllComputedPaths (Registry &registry, ParseWarningSink &warningSink)
 Create ComputedPathComponent for all entities in the registry that have a shape component.
bool recomputeStyledPaths (Registry &registry, std::span< const Entity > entities, ParseWarningSink &warningSink)
 Recompute the prepared authored and instance paths whose styles changed in a retained edit.
std::optional< Box2d > getShapeBounds (EntityHandle handle)
 Get the bounds for the given entity in the entity's local space, if it has a shape component.
bool collectShapeGeometry (EntityHandle handle, const Transform2d &spaceFromEntity, const BoundsGeometryCollector &collector)
 Collect the geometry getShapeBounds bounds, placed in a measurement space, so that its bounds in any later target space follow from BoundGeometryPieces without visiting the entity again.
std::optional< Box2d > getStrokeBounds (EntityHandle handle)
 Return the SVG stroke-shape bounds, including descendant object and stroke geometry.
Path circleClipPath (EntityHandle handle, const CircleClipPath &circle, CircleClipGeometryBudget &budget)
 Resolve a circle clipping shape in element-local coordinates; invalid geometry is empty.
Path ellipseClipPath (EntityHandle handle, const EllipseClipPath &ellipse, CircleClipGeometryBudget &budget)
 Resolve an ellipse clipping shape in element-local coordinates.
Path polygonClipPath (EntityHandle handle, const PolygonClipPath &polygon, CircleClipGeometryBudget &budget)
 Resolve a polygon clipping shape in element-local coordinates.
Path insetClipPath (EntityHandle handle, const InsetClipPath &inset, CircleClipGeometryBudget &budget)
 Resolve a non-rounded inset clipping shape in element-local coordinates.
Path pathClipPath (EntityHandle handle, const PathClipPath &path, CircleClipGeometryBudget &budget)
 Resolve an SVG path clipping shape in element-local coordinates.
std::optional< Box2d > getShapeWorldBounds (EntityHandle handle)
 Get the bounds for the given entity in world space, if it has a shape component.
bool pathFillIntersects (EntityHandle handle, const Vector2d &point, FillRule fillRule)
 Returns true if the shape's path fill intersects the given point.
bool pathStrokeIntersects (EntityHandle handle, const Vector2d &point, double strokeWidth)
 Returns true if the shape's path stroke intersects the given point, using an approximate computation from the stroke-width.

Static Public Member Functions

static EntityHandle geometryHandle (EntityHandle instance)
 Select path/cache ownership without changing the instance's transform or resource owner.

Member Function Documentation

◆ circleClipPath()

Path donner::svg::components::ShapeSystem::circleClipPath ( EntityHandle handle,
const CircleClipPath & circle,
CircleClipGeometryBudget & budget )

Resolve a circle clipping shape in element-local coordinates; invalid geometry is empty.

Parameters
handleStyled element supplying reference geometry and length metrics.
circleParsed circle and reference-box selection.
budgetShared admission budget for the render preparation.

◆ collectShapeGeometry()

bool donner::svg::components::ShapeSystem::collectShapeGeometry ( EntityHandle handle,
const Transform2d & spaceFromEntity,
const BoundsGeometryCollector & collector )

Collect the geometry getShapeBounds bounds, placed in a measurement space, so that its bounds in any later target space follow from BoundGeometryPieces without visiting the entity again.

Parameters
handleEntity handle to collect the geometry of
spaceFromEntityTransform from the entity's local space to the measurement space
collectorReceives the geometry. A path whose copy does not fit its allowance is collected as its bounding box
Returns
False, leaving the collected pieces unchanged, when the geometry cannot be bounded

◆ createComputedPath()

template<typename T>
ComputedPathComponent * donner::svg::components::ShapeSystem::createComputedPath ( EntityHandle handle,
const T & component,
const FontMetrics & fontMetrics,
ParseWarningSink & warningSink )
inline

Convert the given shape to a path, evaluating CSS styling information and presentation attributes.

Returns the ComputedPathComponent if the path was successfully created, or nullptr if the path could not be created.

Paths may not be created if the shape is invalid, such as a circle with a negative radius.

Suported components:

Parameters
handleEntity handle to create the computed path for
componentShape component attached to handle
fontMetricsFont metrics, used to scale lengths
warningSinkContaining any warnings found

◆ createComputedPathIfShape()

ComputedPathComponent * donner::svg::components::ShapeSystem::createComputedPathIfShape ( EntityHandle handle,
const FontMetrics & fontMetrics,
ParseWarningSink & warningSink )

Convert the given shape to a path, if the provided entity contains a shape.

Returns the ComputedPathComponent if the path was successfully created, or nullptr if the path could not be created.

Paths may not be created if the shape is invalid, such as a circle with a negative radius.

Parameters
handleEntity handle to create the computed path for
fontMetricsFont metrics, used to scale lengths
warningSinkContaining any warnings found

◆ ellipseClipPath()

Path donner::svg::components::ShapeSystem::ellipseClipPath ( EntityHandle handle,
const EllipseClipPath & ellipse,
CircleClipGeometryBudget & budget )

Resolve an ellipse clipping shape in element-local coordinates.

Parameters
handleStyled element supplying reference geometry and length metrics.
ellipseParsed ellipse and reference-box selection.
budgetShared admission budget for the render preparation.

◆ geometryHandle()

EntityHandle donner::svg::components::ShapeSystem::geometryHandle ( EntityHandle instance)
static

Select path/cache ownership without changing the instance's transform or resource owner.

Parameters
instanceStyle/tree entity.
Returns
Instance geometry or its light-tree fallback.

◆ getShapeBounds()

std::optional< Box2d > donner::svg::components::ShapeSystem::getShapeBounds ( EntityHandle handle)

Get the bounds for the given entity in the entity's local space, if it has a shape component.

Parameters
handleEntity handle to get the bounds for

◆ getShapeWorldBounds()

std::optional< Box2d > donner::svg::components::ShapeSystem::getShapeWorldBounds ( EntityHandle handle)

Get the bounds for the given entity in world space, if it has a shape component.

Parameters
handleEntity handle to get the bounds for

◆ getStrokeBounds()

std::optional< Box2d > donner::svg::components::ShapeSystem::getStrokeBounds ( EntityHandle handle)

Return the SVG stroke-shape bounds, including descendant object and stroke geometry.

Parameters
handleElement whose local reference box is required.

◆ insetClipPath()

Path donner::svg::components::ShapeSystem::insetClipPath ( EntityHandle handle,
const InsetClipPath & inset,
CircleClipGeometryBudget & budget )

Resolve a non-rounded inset clipping shape in element-local coordinates.

Parameters
handleStyled element supplying reference geometry and length metrics.
insetParsed offsets and reference-box selection.
budgetShared admission budget for render preparation.

◆ instantiateAllComputedPaths()

void donner::svg::components::ShapeSystem::instantiateAllComputedPaths ( Registry & registry,
ParseWarningSink & warningSink )

Create ComputedPathComponent for all entities in the registry that have a shape component.

This assumes that StyleSystem::computeAllStyles has already been called.

Parameters
registryRegistry used to find all shape components
warningSinkContaining any warnings found

◆ instantiateShadowComputedPaths()

void donner::svg::components::ShapeSystem::instantiateShadowComputedPaths ( Registry & registry,
std::span< const Entity > entities,
ParseWarningSink & warningSink )

Prepare newly created shadow instances without resampling the rest of the document.

Parameters
registryDocument storage.
entitiesAdmitted shadow entity span.
warningSinkDiagnostic sink.

◆ pathClipPath()

Path donner::svg::components::ShapeSystem::pathClipPath ( EntityHandle handle,
const PathClipPath & path,
CircleClipGeometryBudget & budget )

Resolve an SVG path clipping shape in element-local coordinates.

Parameters
handleStyled element supplying reference geometry.
pathParsed path and reference-box selection.
budgetShared admission budget for render preparation.

◆ pathFillIntersects()

bool donner::svg::components::ShapeSystem::pathFillIntersects ( EntityHandle handle,
const Vector2d & point,
FillRule fillRule )

Returns true if the shape's path fill intersects the given point.

Parameters
handleEntity handle containing the shape
pointPoint to intersect
fillRuleFill rule to use for the intersection test

◆ pathStrokeIntersects()

bool donner::svg::components::ShapeSystem::pathStrokeIntersects ( EntityHandle handle,
const Vector2d & point,
double strokeWidth )

Returns true if the shape's path stroke intersects the given point, using an approximate computation from the stroke-width.

Parameters
handleEntity handle containing the shape
pointPoint to intersect
strokeWidthStroke width to use for the intersection test

◆ polygonClipPath()

Path donner::svg::components::ShapeSystem::polygonClipPath ( EntityHandle handle,
const PolygonClipPath & polygon,
CircleClipGeometryBudget & budget )

Resolve a polygon clipping shape in element-local coordinates.

Parameters
handleStyled element supplying reference geometry and length metrics.
polygonParsed vertices and reference-box selection.
budgetShared admission budget for render preparation.

◆ recomputeStyledPaths()

bool donner::svg::components::ShapeSystem::recomputeStyledPaths ( Registry & registry,
std::span< const Entity > entities,
ParseWarningSink & warningSink )
nodiscard

Recompute the prepared authored and instance paths whose styles changed in a retained edit.

Parameters
registryDocument registry with freshly computed styles.
entitiesEntities selected by the retained update plan.
warningSinkDestination for geometry diagnostics.
Returns
False when the prepared paths cannot be committed without the full shape pass.

◆ donner::svg::components::StyleSystem

class donner::svg::components::StyleSystem

Computes stylesheet information for elements, applying the CSS cascade and inheritance rules.

See also
https://www.w3.org/TR/SVG2/shapes.html

Public Types

enum class  FullRestyle {
  DiscardAndRecompute ,
  ComputeMissing
}
 What computeAllStyles does with existing computed styles when the whole document needs restyling (RenderTreeState::needsFullStyleRecompute on a built document). More...
using ApplyRetainedStyle
 Apply styles through the retained renderer after a selective edit scan.

Public Member Functions

const ComputedStyleComponent & computeStyle (EntityHandle handle, ParseWarningSink &warningSink)
 Compute the style for the given entity handle, applying the CSS cascade and inheritance rules.
void computeAllStyles (Registry &registry, ParseWarningSink &warningSink, FullRestyle fullRestyle=FullRestyle::DiscardAndRecompute, StylePassScheduler scheduler={})
 Computes the style for all entities in the registry.
void computeStylesFor (Registry &registry, std::span< const Entity > entities, ParseWarningSink &warningSink)
 Computes the style for the given entities in the registry.
bool updateStyle (EntityHandle handle, std::string_view style, bool invalidateCachedStyle=true)
 Update the style attribute on an element, merging new declarations with existing ones.
std::vector< MatchedStyleRule > collectMatchedStyleRules (EntityHandle handle, bool includeDeclarations=true) const
 Collect stylesheet rules that match handle using the same selector matching and specificity adjustments used by computeStyle.
std::optional< SourceRange > mapStylesheetSourceRange (Registry &registry, Entity stylesheetEntity, const SourceRange &cssRange) const
 Map a decoded range in one embedded stylesheet to original document bytes.
CustomPropertyDeclarationBatchResult findCustomPropertyDeclarations (EntityHandle handle, std::span< const std::string_view > names, std::size_t maxWork) const
 Resolve source provenance for multiple prepared custom properties with one work allowance.
std::optional< StyleRuleAtSourceOffset > findStyleRuleAtSourceOffset (Registry &registry, std::size_t documentSourceOffset) const
 Find the author stylesheet rule at documentSourceOffset.
void invalidateComputed (EntityHandle handle)
 Invalidate the computed style for a given entity.
bool anyStylesheetUsesAttributeInSelector (Registry &registry, std::string_view localName) const
 Returns true if any stylesheet loaded into registry contains an attribute selector that could match an attribute with the given local name.
void invalidateAll (EntityHandle handle)
 Invalidate the full style and reparse attributes.

Static Public Member Functions

static std::size_t CandidateListCapacityForTesting ()
 Capacity of the calling thread's candidate list, in entries, for tests of the retention cap.
static void computePreparedStyle (const Registry &registry, Entity entity, ComputedStyleComponent &output, CascadePass &pass, ParseWarningSink &warnings)
 Cascade a static element after its parent and the document root have been published.
static std::size_t StylesheetSourceIndexBuildsForTesting ()
 Number of stylesheet source indices constructed on this thread.
static std::optional< bool > preparedCustomPropertyHasValue (EntityHandle handle, std::string_view name)
 Check whether the prepared cascade contains a usable custom property.
static void synchronizeDocumentFontFaces (Registry &registry)
 Register document fonts and compute their active ordering when cascade layers apply.
static void discardComputedStyles (Registry &registry)
 Discard every cached computed style and its retained style budget, for changes that affect selector matching across the whole document, such as reloaded stylesheet imports.
static void discardComputedStylesForFullRestyle (Registry &registry)
 Discard every computed style and its retained style budget to restyle the whole document, counted in StyleCascadeCounters::fullClears.
static ResolvedPaintServer externalHostPaint (Registry &registry, bool stroke)
 Inherit fallback values from an external-use computed parent without transferring specificity. Resolved ordinary host paint, retained only during the guarded occurrence.
static void rejectExternalHostResource (Registry &registry)
 Record a refused inherited resource for the occurrence's static diagnostic.
static std::optional< PaintServer > localPaintForInstantiation (const ComputedStyleComponent &style, bool stroke)
 Local paints alone create child-registry resource shadow trees.
static void inheritExternalParent (PropertyRegistry &properties, const PropertyRegistry &parent)
 Apply inherited values from an external parent in place while retaining local declaration precedence.
static bool computeEditedFrameStyles (Registry &registry, ParseWarningSink &warningSink, StylePassScheduler scheduler, bool(*compute)(Registry &, ParseWarningSink &, StylePassScheduler, bool(*)(const Registry &)))
 Run one selective frame against a tentative warning sink.
static void markEditedStyleTargets (Registry &registry, std::span< const Entity > affected, ApplyRetainedStyle applyRetained)
 Mark an admitted list of edited styles, recording the last rendered order when available.
static bool invalidateStylesheetRules (Registry &registry, std::span< const css::SelectorRule > removed, std::span< const css::SelectorRule > added, ApplyRetainedStyle applyRetained)
 Schedule a bounded selective style pass for the union of old and new rule matches.
static std::uint8_t styleEditDependencies (const Registry &registry, std::string_view attribute, std::span< const std::string_view > changedClasses)
 Relations affected by an attribute and any changed class tokens. Ancestors requires a full restyle because a relative selector can reach beyond the edited branch.
static bool isStyleEditSubtreeBoundary (const Registry &registry, Entity entity)
 Whether this element can be restyled without rebuilding resource or text subtrees.
static std::optional< uint32_t > retainedStyleOrder (const Registry &registry, Entity entity)
 Comparable order inputs for local geometry and paint, or nullopt for a nonlocal style.

Static Public Attributes

static constexpr std::size_t kRetainedCandidateCapacity = 4096
 Candidate rule positions the per-thread list used by the cascade keeps between elements, in entries: an element's cascade that needed more releases the list afterwards, so a large stylesheet does not pin its memory for the life of the thread. Equal to the stylesheet parser's rule limit, the most candidates one sheet has once duplicates are removed.
static constexpr std::size_t kMaximumCustomPropertyDeclarationQueryWork = 16 * 1024 * 1024
 Maximum defensive work accepted by the legacy one-name query.

Member Typedef Documentation

◆ ApplyRetainedStyle

Initial value:
bool (*)(Registry& registry, ParseWarningSink& warningSink,
StylePassScheduler scheduler)
Collects parse warnings during parsing.
Definition ParseWarningSink.h:30
A borrowed scheduler for style preparation. An empty value keeps serial-only clients independent of t...
Definition StylePassScheduler.h:29
entt::basic_registry< Entity > Registry
Registry type for the SVG ECS, which is the entry point for storing all data.
Definition EcsRegistry.h:52

Apply styles through the retained renderer after a selective edit scan.

Parameters
registryDocument registry containing the marked style targets.
warningSinkDestination for accepted diagnostics.
schedulerScheduler available to the style pass.
Returns
False when the edit requires a full render-tree rebuild.

Member Enumeration Documentation

◆ FullRestyle

What computeAllStyles does with existing computed styles when the whole document needs restyling (RenderTreeState::needsFullStyleRecompute on a built document).

Enumerator
DiscardAndRecompute 

Discard every computed style, then compute the whole document.

ComputeMissing 

Compute only entities without a computed style. For a caller that already discarded the stale styles with discardComputedStylesForFullRestyle and runs several passes over one rebuild, so each entity is cascaded once.

Member Function Documentation

◆ anyStylesheetUsesAttributeInSelector()

bool donner::svg::components::StyleSystem::anyStylesheetUsesAttributeInSelector ( Registry & registry,
std::string_view localName ) const

Returns true if any stylesheet loaded into registry contains an attribute selector that could match an attribute with the given local name.

Writing such an attribute changes selector matching, and can do so for elements other than the one written (sibling combinators, descendant selectors), which per-entity dirty flags do not track. Callers use this to decide whether an attribute write needs a whole-tree restyle.

Parameters
registryDocument registry.
localNameAttribute local name that is about to be written.

◆ collectMatchedStyleRules()

std::vector< MatchedStyleRule > donner::svg::components::StyleSystem::collectMatchedStyleRules ( EntityHandle handle,
bool includeDeclarations = true ) const

Collect stylesheet rules that match handle using the same selector matching and specificity adjustments used by computeStyle.

Only rules of each <style> element's own stylesheet are reported; rules loaded through @import have no document source and are not indexed by MatchedStyleRule::ruleIndex. Match collection is complete, but source-range projection is resource-bounded. A matched rule can therefore retain its stylesheet-local CSS ranges while its document source ranges are absent. Individual source mapping through mapStylesheetSourceRange remains exact.

Parameters
handleEntity handle to trace stylesheet matches for.
includeDeclarationsProject declarations in addition to rule and selector ranges.
Returns
Matched stylesheet rules in cascade scan order.

◆ computeAllStyles()

void donner::svg::components::StyleSystem::computeAllStyles ( Registry & registry,
ParseWarningSink & warningSink,
FullRestyle fullRestyle = FullRestyle::DiscardAndRecompute,
StylePassScheduler scheduler = {} )

Computes the style for all entities in the registry.

Parameters
registryRegistry to compute the styles, used to query for all entities in the tree.
warningSinkContaining any warnings found
fullRestyleWhat a whole-document restyle does with existing computed styles.
schedulerOptional scheduler borrowed for this invocation.

◆ computeEditedFrameStyles()

bool donner::svg::components::StyleSystem::computeEditedFrameStyles ( Registry & registry,
ParseWarningSink & warningSink,
StylePassScheduler scheduler,
bool(* compute )(Registry &, ParseWarningSink &, StylePassScheduler, bool(*)(const Registry &)) )
static

Run one selective frame against a tentative warning sink.

Parameters
registryPrepared document registry containing the style budget and dirty style slots.
warningSinkDestination for warnings, updated only after the callback succeeds.
schedulerScheduler forwarded to the style callback.
computeNon-null callback that computes the dirty frame styles and returns false when its pass must be abandoned, including budget refusal.
Returns
True after the callback succeeds and its warnings are committed. Returns false without committing tentative warnings when the callback declines the pass.

◆ computePreparedStyle()

void donner::svg::components::StyleSystem::computePreparedStyle ( const Registry & registry,
Entity entity,
ComputedStyleComponent & output,
CascadePass & pass,
ParseWarningSink & warnings )
static

Cascade a static element after its parent and the document root have been published.

The caller holds document access, initializes the component types before dispatch, and keeps the pools stable until the join. The cache belongs to this document and stylesheet generation. Animated documents and external occurrences use the serial cascade.

Parameters
registryRead-only document storage.
entityElement whose slot the caller owns exclusively.
outputPreviously emplaced computed-style slot for the element.
passMutable work and cache state exclusive to this worker.
warningsWorker-owned diagnostic sink.

◆ computeStyle()

const ComputedStyleComponent & donner::svg::components::StyleSystem::computeStyle ( EntityHandle handle,
ParseWarningSink & warningSink )

Compute the style for the given entity handle, applying the CSS cascade and inheritance rules.

Parameters
handleEntity handle to compute the style for
warningSinkContaining any warnings found
Returns
Computed style component for the entity

◆ computeStylesFor()

void donner::svg::components::StyleSystem::computeStylesFor ( Registry & registry,
std::span< const Entity > entities,
ParseWarningSink & warningSink )

Computes the style for the given entities in the registry.

Parameters
registryRegistry containing the entities
entitiesEntities to compute
warningSinkContaining any warnings found

◆ discardComputedStyles()

void donner::svg::components::StyleSystem::discardComputedStyles ( Registry & registry)
static

Discard every cached computed style and its retained style budget, for changes that affect selector matching across the whole document, such as reloaded stylesheet imports.

Unlike RenderTreeState::needsFullStyleRecompute, this also covers styles computed by queries before the render tree was first built.

Parameters
registryRegistry containing the document.

◆ discardComputedStylesForFullRestyle()

void donner::svg::components::StyleSystem::discardComputedStylesForFullRestyle ( Registry & registry)
static

Discard every computed style and its retained style budget to restyle the whole document, counted in StyleCascadeCounters::fullClears.

Style passes that follow with FullRestyle::ComputeMissing then compute every entity again, once.

Parameters
registryRegistry containing the document.

◆ findCustomPropertyDeclarations()

CustomPropertyDeclarationBatchResult donner::svg::components::StyleSystem::findCustomPropertyDeclarations ( EntityHandle handle,
std::span< const std::string_view > names,
std::size_t maxWork ) const

Resolve source provenance for multiple prepared custom properties with one work allowance.

Parameters
handleElement whose computed style supplies the values.
namesCustom-property identifiers in request order.
maxWorkRemaining query work available to the caller.
Returns
Declaration name ranges and the batch query status.

◆ findStyleRuleAtSourceOffset()

std::optional< StyleRuleAtSourceOffset > donner::svg::components::StyleSystem::findStyleRuleAtSourceOffset ( Registry & registry,
std::size_t documentSourceOffset ) const

Find the author stylesheet rule at documentSourceOffset.

If the offset is inside one selector-list entry, StyleRuleAtSourceOffset::selectorEntryIndex is set so callers can focus that selector branch. If the offset is elsewhere inside the rule, such as a declaration block, the entry is unset and the whole selector list is considered active.

Parameters
registrySVG document registry to inspect.
documentSourceOffsetOffset in the SVG document source.
Returns
Stylesheet rule at documentSourceOffset, or std::nullopt.

◆ inheritExternalParent()

void donner::svg::components::StyleSystem::inheritExternalParent ( PropertyRegistry & properties,
const PropertyRegistry & parent )
static

Apply inherited values from an external parent in place while retaining local declaration precedence.

Parameters
propertiesDeclarations in the referenced document, which receive the external-parent fallback values.
parentComputed declarations inherited from the referencing element.

◆ invalidateAll()

void donner::svg::components::StyleSystem::invalidateAll ( EntityHandle handle)

Invalidate the full style and reparse attributes.

Parameters
handleEntity handle to invalidate

◆ invalidateComputed()

void donner::svg::components::StyleSystem::invalidateComputed ( EntityHandle handle)

Invalidate the computed style for a given entity.

Parameters
handleEntity handle to invalidate

◆ invalidateStylesheetRules()

bool donner::svg::components::StyleSystem::invalidateStylesheetRules ( Registry & registry,
std::span< const css::SelectorRule > removed,
std::span< const css::SelectorRule > added,
ApplyRetainedStyle applyRetained )
static

Schedule a bounded selective style pass for the union of old and new rule matches.

Parameters
registryBuilt document registry eligible for a selective edit scan. A pending full rebuild/restyle, prior budget refusal, unsupported subtree boundary, or oversized scan makes the call decline.
removedPrevious rules replaced or removed by the source edit.
addedReplacement or inserted rules from the updated stylesheet.
applyRetainedOptional retained-update callback forwarded to markEditedStyleTargets. A null callback selects ordinary style-cascade invalidation.
Returns
True after the complete old-and-new scan marks every affected subtree. Returns false without clearing the matched-properties cache or marking styles when the caller must fully restyle.

◆ markEditedStyleTargets()

void donner::svg::components::StyleSystem::markEditedStyleTargets ( Registry & registry,
std::span< const Entity > affected,
ApplyRetainedStyle applyRetained )
static

Mark an admitted list of edited styles, recording the last rendered order when available.

Parameters
registryBuilt document registry containing RenderTreeState and every affected entity.
affectedValid tree entities admitted by the edit analysis. An empty span is a no-op.
applyRetainedOptional retained-update callback. A null callback selects ordinary style-cascade invalidation. An entity without a retained order also selects that path.

◆ preparedCustomPropertyHasValue()

std::optional< bool > donner::svg::components::StyleSystem::preparedCustomPropertyHasValue ( EntityHandle handle,
std::string_view name )
static

Check whether the prepared cascade contains a usable custom property.

Parameters
handleElement whose computed style is inspected.
nameDecoded, case-sensitive custom-property identifier.
Returns
Whether the value exists, or std::nullopt if the source or style is unavailable.

◆ updateStyle()

bool donner::svg::components::StyleSystem::updateStyle ( EntityHandle handle,
std::string_view style,
bool invalidateCachedStyle = true )

Update the style attribute on an element, merging new declarations with existing ones.

Declarations in style override existing declarations with the same property name. The merged result is written back to the style attribute and the PropertyRegistry is updated.

Parameters
handleEntity handle to update.
styleCSS style string to merge, e.g. "fill: red; opacity: 0.5".
invalidateCachedStyleFalse when the caller needs the old style for edit routing.
Returns
Whether a style was successfully merged.

◆ donner::svg::components::TextSystem

class donner::svg::components::TextSystem

System to compute text layout spans from raw text and positioning attributes.

Public Member Functions

void instantiateAllComputedComponents (Registry &registry, ParseWarningSink &warningSink)
 Instantiate computed text spans for all entities with TextComponent.
void instantiateComputedComponent (EntityHandle handle, ParseWarningSink &warningSink)
 Instantiate computed text spans for a specific text root.

Member Function Documentation

◆ instantiateAllComputedComponents()

void donner::svg::components::TextSystem::instantiateAllComputedComponents ( Registry & registry,
ParseWarningSink & warningSink )

Instantiate computed text spans for all entities with TextComponent.

Parameters
registryThe registry to instantiate the computed text spans for.
warningSinkIf non-null, a vector to store any warnings that occur during the instantiation.

◆ instantiateComputedComponent()

void donner::svg::components::TextSystem::instantiateComputedComponent ( EntityHandle handle,
ParseWarningSink & warningSink )

Instantiate computed text spans for a specific text root.

Parameters
handleText root handle.
warningSinkIf non-null, warnings are appended here.