Donner SVG main
0.8.0 ยท 382bd0190.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::svg::components::StylesheetSourceMap Class Reference

Source map for stylesheet text produced by concatenating <style> text/CDATA children. More...

#include "donner/svg/components/StylesheetComponent.h"

Public Member Functions

void addSegment (std::size_t cssStartOffset, std::size_t cssEndOffset, FileOffset documentStartOffset)
 Add one local-CSS to document-source mapping segment.
void setCssLength (std::size_t cssLength)
 Record the length of the concatenated CSS text this map describes.
bool empty () const
 Return true when no local CSS offsets can be mapped to document source.
std::optional< SourceRange > mapToDocumentSource (const SourceRange &localRange) const
 Map a local CSS source range back to the SVG document source.
std::optional< FileOffset > mapPointToDocumentSource (FileOffset localOffset) const
 Map a point diagnostic, preferring the next chunk at a shared CSS boundary.
std::optional< std::size_t > mapToLocalCssOffset (std::size_t documentOffset) const
 Map a document source offset back to this stylesheet's local CSS offset.
std::span< const StylesheetSourceMapSegment > segments () const
 Get the stored mapping segments.

Detailed Description

Source map for stylesheet text produced by concatenating <style> text/CDATA children.

Member Function Documentation

◆ addSegment()

void donner::svg::components::StylesheetSourceMap::addSegment ( std::size_t cssStartOffset,
std::size_t cssEndOffset,
FileOffset documentStartOffset )

Add one local-CSS to document-source mapping segment.

Parameters
cssStartOffsetFirst local CSS byte covered by this segment.
cssEndOffsetFirst local CSS byte after this segment.
documentStartOffsetDocument source offset for cssStartOffset.

◆ mapPointToDocumentSource()

std::optional< FileOffset > donner::svg::components::StylesheetSourceMap::mapPointToDocumentSource ( FileOffset localOffset) const

Map a point diagnostic, preferring the next chunk at a shared CSS boundary.

The stylesheet end maps to the end of the last segment only when setCssLength recorded that the last segment reaches it.

Parameters
localOffsetPoint in the parsed CSS string.
Returns
Document offset, or nullopt when no source segment covers the point.

◆ mapToDocumentSource()

std::optional< SourceRange > donner::svg::components::StylesheetSourceMap::mapToDocumentSource ( const SourceRange & localRange) const

Map a local CSS source range back to the SVG document source.

Parameters
localRangeRange in the parsed CSS string.
Returns
Document source range, or std::nullopt when either endpoint is unmappable.

◆ mapToLocalCssOffset()

std::optional< std::size_t > donner::svg::components::StylesheetSourceMap::mapToLocalCssOffset ( std::size_t documentOffset) const

Map a document source offset back to this stylesheet's local CSS offset.

Parameters
documentOffsetOffset in the SVG document source.
Returns
Local CSS offset, or std::nullopt if documentOffset is outside this stylesheet.

◆ setCssLength()

void donner::svg::components::StylesheetSourceMap::setCssLength ( std::size_t cssLength)
inline

Record the length of the concatenated CSS text this map describes.

Point diagnostics at the end of the last mapped segment map to that segment's end only when it is also the end of the stylesheet; a later chunk without source provenance makes that point unmappable instead.

Parameters
cssLengthLength in bytes of the concatenated CSS text.

The documentation for this class was generated from the following file: