Holds global state of an SVG document, such as the root element, id-to-element mapping, and the document size. More...
#include "donner/svg/components/SVGDocumentContext.h"
Public Member Functions | |
| SVGDocumentContext (InternalCtorTag ctorTag, SVGDocumentHandle documentState) | |
| Internal constructor, creates a context on the given SVGDocument. | |
| Entity | getEntityById (const RcString &id) const |
| Get the entity with the given ID, using the internal id-to-entity mapping. | |
| void | bumpMutationRevision () const |
| Mark the backing document state as mutated. | |
| bool | currentThreadHasWriteAccess () const |
| Returns true if the current thread holds write access to the backing document. | |
| DocumentWriteAccess | writeAccess () const |
| Acquire write access to the backing document. | |
| DetachedNodeState & | detachedNodeState () const |
| Get detached-node collection state for the backing document. | |
| bool | hasActiveDetachedNodeCollectionDeferral () const |
| Returns true when detached-node collection is deferred for a snapshot or observer epoch. | |
| std::uint64_t | activeDetachedNodeCollectionEpoch () const |
| Current detached-node collection epoch high-water. | |
Public Attributes | |
| std::optional< Vector2i > | canvasSize |
| Current canvas size, if set. Equivalent to the window size, which controls how the SVG contents are rendered. | |
| double | documentTime = 0.0 |
| Current document time in seconds, advanced by SVGDocument::setTime(). Used by the animation system to evaluate animation state. | |
| std::vector< RcString > | userLanguages = {RcString("en")} |
| User's preferred languages, in priority order, used to evaluate the systemLanguage conditional processing attribute (see donner::svg::components::ConditionalProcessingComponent and <switch>). Defaults to {"en"}. Configure via SVGDocument::setUserLanguages. | |
| Entity | rootEntity = entt::null |
| Root entity of the document, which contains the <svg> element. | |
| std::size_t | maximumContentProjectionChunks = 4096 |
| Maximum direct content chunks projected by later incremental source edits. | |
| bool | experimentalElementsEnabled = false |
| Whether the parse that built this document created experimental element types. Incremental source edits build the same element types as that parse. | |
| std::function< std::optional< ParseDiagnostic >(std::string_view, const SVGElement &, const xml::XMLNode &)> | parseBuiltElement |
| Parses an element that an incremental source edit has just built the way the parser that built this document does: its attributes, including type-specific ones such as an <image> element's href that the generic attribute projection only stores, and the text of a <title>, <desc> or <metadata> element. | |
| std::function< std::optional< ParseDiagnostic >(std::string_view, const SVGElement &, const xml::XMLNode &)> | parseEditedElementContents |
| Parses the contents that only the parser projects, the text of a <title>, <desc> or <metadata> element, after a source edit has changed them, the way the parser that built this document does. | |
Friends | |
| class | ::donner::svg::ElementAnchor |
| class | ::donner::svg::SVGDocument |
| class | ::donner::svg::SVGElement |
Holds global state of an SVG document, such as the root element, id-to-element mapping, and the document size.
One instance of this class is created per SVG document.
Access the document context via the Registry::ctx API:
|
explicit |
Internal constructor, creates a context on the given SVGDocument.
To use this class, access it via the Registry::ctx API.
| ctorTag | Internal tag to allow construction. |
| documentState | Shared state for the document. |
|
inline |
Get the entity with the given ID, using the internal id-to-entity mapping.
A newly registered attached element replaces a detached mapping. Otherwise, duplicate IDs retain the first registered mapping; use attached lookup when a held element may detach.
| id | ID to find the entity for. |
| std::function<std::optional<ParseDiagnostic>(std::string_view, const SVGElement&, const xml::XMLNode&)> donner::svg::components::SVGDocumentContext::parseBuiltElement |
Parses an element that an incremental source edit has just built the way the parser that built this document does: its attributes, including type-specific ones such as an <image> element's href that the generic attribute projection only stores, and the text of a <title>, <desc> or <metadata> element.
Unset for documents the parser did not build.
Takes the current document source, the built element, and its XML node, and returns the first error.
| std::function<std::optional<ParseDiagnostic>(std::string_view, const SVGElement&, const xml::XMLNode&)> donner::svg::components::SVGDocumentContext::parseEditedElementContents |
Parses the contents that only the parser projects, the text of a <title>, <desc> or <metadata> element, after a source edit has changed them, the way the parser that built this document does.
The new text replaces the old. Unset for documents the parser did not build.
Takes the current document source, the edited element, and its XML node, and returns an error, keeping the old text and its reservation, if the new text exceeds the document's content-projection budget.