Donner SVG main
0.8.0 ยท 766e862a0.8.0 main
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::css::parser::StylesheetParser Class Reference

Parse a CSS stylesheet into a list of selectors and their associated declarations. More...

#include "donner/css/parser/StylesheetParser.h"

Classes

struct  TextEdit
 A single replacement in the original stylesheet text. More...

Static Public Member Functions

static Stylesheet Parse (std::string_view str, ParseWarningSink &warningSink)
 Parse a CSS stylesheet into a list of selectors and their associated declarations, as well as @font-face rules.
static std::optional< Stylesheet > TryReparseTextEdit (const Stylesheet &old, std::string_view before, std::string_view after, TextEdit edit, EditedRuleWindow *changed=nullptr)
 Reparse a bounded qualified-rule window, or return nullopt for a full parse.

Detailed Description

Parse a CSS stylesheet into a list of selectors and their associated declarations.


Class Documentation

◆ donner::css::parser::StylesheetParser::TextEdit

struct donner::css::parser::StylesheetParser::TextEdit

A single replacement in the original stylesheet text.

Class Members
size_t insertedLength
size_t offset
size_t removedLength

Member Function Documentation

◆ Parse()

Stylesheet donner::css::parser::StylesheetParser::Parse ( std::string_view str,
ParseWarningSink & warningSink )
static

Parse a CSS stylesheet into a list of selectors and their associated declarations, as well as @font-face rules.

Unconditional @import rules are retained in Stylesheet::imports, in source order, with their URLs exactly as authored; the parser never resolves or fetches them. Following the CSS Cascade 5 grammar, an import is valid only before every other retained rule except @layer statements that precede the first import (@charset is consumed first). A bare layer modifier creates a distinct anonymous layer and layer(name) references the named layer. Imports that appear later, have a malformed or empty target, or carry unsupported conditions receive a bounded warning at the @ token that never includes the target URL.

CSS @media and @supports blocks are unsupported. Their complete blocks, including nested styles and font faces, are ignored with a bounded warning at the outer @ token.

Parameters
strInput stylesheet string.
warningSinkSink to collect warnings (e.g. invalid selectors).
Returns
Parsed stylesheet.

◆ TryReparseTextEdit()

std::optional< Stylesheet > donner::css::parser::StylesheetParser::TryReparseTextEdit ( const Stylesheet & old,
std::string_view before,
std::string_view after,
TextEdit edit,
EditedRuleWindow * changed = nullptr )
static

Reparse a bounded qualified-rule window, or return nullopt for a full parse.

Parameters
oldFully parsed stylesheet before the edit.
beforeOriginal stylesheet text.
afterUpdated stylesheet text.
editByte replacement in the original stylesheet.
changedOptional rule-window output, set only on success.

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