Data for a <style> element.
More...
#include "donner/svg/components/StylesheetComponent.h"
|
|
std::uint64_t | contentRevision () const |
| | Identity of this revision of the document and imported rules.
|
|
std::size_t | selectorCacheBytes () const |
| | Bytes retained by ruleIndex, importedRuleIndexes and dependencySummary, charged with the stylesheet.
|
|
std::span< const css::FontFace > | cascadeFontFaces () const |
| | Font faces contributed by this active CSS sheet, including imported ones.
|
| void | setImportedStylesheets (std::vector< css::Stylesheet > &&imported, std::uint64_t generation, std::vector< StylesheetImportOrigin > origins={}) |
| | Install the resolved imports of stylesheet, updating the selector-dependency caches so that imported selectors also invalidate styles.
|
|
bool | isCssType () const |
| | Returns true if the <style> element has either no type attribute, or if it has been manually set to "text/css".
|
| bool | usesAttributeInSelector (std::string_view localName) const |
| | Returns true if this stylesheet contains an attribute selector that could match an attribute with the given local name, meaning writing that attribute can change which elements the stylesheet matches.
|
| void | parseStylesheet (const RcStringOrRef &str) |
| | Parse the contents of the <style> element.
|
| void | parseStylesheet (const RcStringOrRef &str, StylesheetSourceMap sourceMap) |
| | Parse the contents of the <style> element with source provenance.
|
| void | parseStylesheet (const RcStringOrRef &str, StylesheetSourceMap sourceMap, ParseWarningSink &warnings) |
| | Parse stylesheet contents while collecting CSS-local diagnostics.
|
| bool | applyTextEdit (const StylesheetComponent &previous, std::string_view updatedText, const StylesheetSourceMap &updatedSourceMap, std::size_t offset, std::size_t removedLength, std::size_t insertedLength, css::EditedRuleWindow *changed=nullptr) |
| | Install a prepared rule-window splice from the previous projection, when supported.
|
|
|
css::Stylesheet | stylesheet |
| | The parsed stylesheet from the <style> element.
|
|
RcString | text |
| | The raw CSS text the stylesheet was parsed from.
|
|
RcString | type |
| | The type attribute of the <style> element.
|
|
StylesheetSourceMap | sourceMap |
| | Optional mapping from CSS offsets to SVG document source.
|
|
bool | isUserAgentStylesheet = false |
| | True if this is a user agent stylesheet, which is defined by the SVG specification and applied by default by the document. If set, this component is attached to an <svg> element instead. The stylesheet within is applied at lower priority, and should be considered a constant for Donner (it can be overridden, but the base style cannot be changed by the user).
|
| std::vector< css::Stylesheet > | importedStylesheets |
| | Stylesheets loaded through @import, flattened in cascade order: each imported sheet follows the sheets it imports, and all of them precede stylesheet's own rules.
|
|
std::vector< StylesheetImportOrigin > | importOrigins |
| | Positions of successful loads in their original import streams.
|
|
RuleIndex | ruleIndex |
| | Candidate-rule index of stylesheet, rebuilt whenever it or its imports change.
|
|
std::vector< RuleIndex > | importedRuleIndexes |
| | Candidate-rule index of each sheet in importedStylesheets, in the same order.
|
|
SelectorDependencySummary | dependencySummary |
| | Which elements a change to each id, class and attribute name named by stylesheet or importedStylesheets can restyle, rebuilt whenever they change.
|
|
std::vector< css::FontFace > | combinedFontFaces |
| | Font faces of importedStylesheets followed by stylesheet, populated only when imports contributed any; see cascadeFontFaces().
|
|
std::uint64_t | fontFaceRevision = 0 |
| | Incremented whenever cascadeFontFaces may have changed, so font registration notices new contents even if their storage address and size are reused.
|
|
std::optional< std::uint64_t > | importGeneration |
| | Resource-manager generation for which importedStylesheets was resolved, or nullopt when the imports of the current stylesheet have not been resolved yet.
|
◆ applyTextEdit()
| bool donner::svg::components::StylesheetComponent::applyTextEdit |
( |
const StylesheetComponent & | previous, |
|
|
std::string_view | updatedText, |
|
|
const StylesheetSourceMap & | updatedSourceMap, |
|
|
std::size_t | offset, |
|
|
std::size_t | removedLength, |
|
|
std::size_t | insertedLength, |
|
|
css::EditedRuleWindow * | changed = nullptr ) |
Install a prepared rule-window splice from the previous projection, when supported.
- Parameters
-
| previous | Previous projection. |
| updatedText | New CSS text. |
| updatedSourceMap | New source mapping. |
| offset | Local CSS byte offset of the edit. |
| removedLength | Old byte count. |
| insertedLength | New byte count. |
| changed | Optional verified rule ranges, set only when the splice succeeds. |
- Returns
- True when the splice was installed, false when a full parse is needed.
◆ parseStylesheet() [1/3]
| void donner::svg::components::StylesheetComponent::parseStylesheet |
( |
const RcStringOrRef & | str | ) |
|
Parse the contents of the <style> element.
- Parameters
-
| str | The contents of the <style> element. |
◆ parseStylesheet() [2/3]
Parse the contents of the <style> element with source provenance.
- Parameters
-
| str | The contents of the <style> element. |
| sourceMap | Source map for local CSS offsets in str. |
◆ parseStylesheet() [3/3]
Parse stylesheet contents while collecting CSS-local diagnostics.
- Parameters
-
| str | Stylesheet contents. |
| sourceMap | Source provenance for the retained stylesheet. |
| warnings | Bounded sink receiving recoverable CSS diagnostics. |
◆ setImportedStylesheets()
| void donner::svg::components::StylesheetComponent::setImportedStylesheets |
( |
std::vector< css::Stylesheet > && | imported, |
|
|
std::uint64_t | generation, |
|
|
std::vector< StylesheetImportOrigin > | origins = {} ) |
Install the resolved imports of stylesheet, updating the selector-dependency caches so that imported selectors also invalidate styles.
- Parameters
-
| imported | Imported stylesheets in cascade order. |
| generation | Resource-manager generation the imports were resolved for. |
| origins | Original positions of the successful imports, parallel to imported. |
◆ usesAttributeInSelector()
| bool donner::svg::components::StylesheetComponent::usesAttributeInSelector |
( |
std::string_view | localName | ) |
const |
|
inline |
Returns true if this stylesheet contains an attribute selector that could match an attribute with the given local name, meaning writing that attribute can change which elements the stylesheet matches.
Deliberately per-name rather than a single "uses any attribute selector" flag: the user agent stylesheet always contains one (*[xml|space=preserve]), so a single flag would be set for every document.
- Parameters
-
| localName | Attribute local name, compared case-insensitively to over-approximate. |
◆ importedStylesheets
| std::vector<css::Stylesheet> donner::svg::components::StylesheetComponent::importedStylesheets |
Stylesheets loaded through @import, flattened in cascade order: each imported sheet follows the sheets it imports, and all of them precede stylesheet's own rules.
Populated by ResourceManagerContext::loadStylesheetImports when the document is prepared for rendering, and cleared whenever stylesheet is reparsed. Imported rules have no document source provenance, so source-mapped editor queries consider only stylesheet.
The documentation for this struct was generated from the following file: