#include <css.h>
|
| static CSSDeclaration | parseInlineStyle (const std::string &style) |
| |
| static bool | approximateSelectorMatch (const std::string &selector, const std::string &tag, const std::vector< std::string > &classes, const std::string &id) |
| | Conservative, NOT spec-complete selector match: selector (a single selector, or a comma-separated list of them – matches if ANY branch matches) is matched against a single element identified by tag/classes/id only – there is no ancestor/parent context available, so any selector this can't safely evaluate without seeing more than that one element is REJECTED (returns false) rather than guessed.
|
| |
Definition at line 104 of file css.h.
◆ CSSStyleSheet() [1/2]
| libhtmlpp::CSSStyleSheet::CSSStyleSheet |
( |
| ) |
|
◆ CSSStyleSheet() [2/2]
| libhtmlpp::CSSStyleSheet::CSSStyleSheet |
( |
const CSSStyleSheet & |
sheet | ) |
|
◆ ~CSSStyleSheet()
| libhtmlpp::CSSStyleSheet::~CSSStyleSheet |
( |
| ) |
|
◆ addRule()
| void libhtmlpp::CSSStyleSheet::addRule |
( |
const CSSRule & |
rule | ) |
|
◆ approximateSelectorMatch()
| bool libhtmlpp::CSSStyleSheet::approximateSelectorMatch |
( |
const std::string & |
selector, |
|
|
const std::string & |
tag, |
|
|
const std::vector< std::string > & |
classes, |
|
|
const std::string & |
id |
|
) |
| |
|
static |
Conservative, NOT spec-complete selector match: selector (a single selector, or a comma-separated list of them – matches if ANY branch matches) is matched against a single element identified by tag/classes/id only – there is no ancestor/parent context available, so any selector this can't safely evaluate without seeing more than that one element is REJECTED (returns false) rather than guessed.
Rejected outright: attribute selectors ("[href]"), pseudo-classes and pseudo-elements (":hover", "::before"), the universal selector ("*"), and – after a combinator (space/">"/"+"/"~") is stripped down to its trailing compound selector – a bare tag left with no class/id qualifier of its own (e.g. "[data-x]>div" reduces to a bare "div", which would otherwise match every element of that tag in the whole document; a qualified compound like "div.foo" is still specific enough to check). A compound selector like "div.card.featured#hero" matches only if the tag (when given), every class listed (all of them, not just one), and the id (when given) are all present on the element. This is intentionally an approximation of real CSS selector matching, not an implementation of it – there is no specificity calculation and no combinator/ancestor verification – built to be safe against false positives on real-world scraped markup rather than complete; treat a false result as "not proven to match", not "definitely doesn't".
Definition at line 632 of file css.cpp.
◆ clear()
| void libhtmlpp::CSSStyleSheet::clear |
( |
| ) |
|
◆ collectApproximateMatches()
| void libhtmlpp::CSSStyleSheet::collectApproximateMatches |
( |
const std::string & |
tag, |
|
|
const std::string & |
cssClass, |
|
|
const std::string & |
id, |
|
|
std::map< std::string, std::string > & |
props, |
|
|
std::string & |
mediaRules, |
|
|
std::set< std::string > & |
seenMediaBlocks |
|
) |
| const |
Runs every rule in this sheet through approximateSelectorMatch against the element identified by tag/cssClass (a whitespace-separated class list)/id, folding matching declarations into props under an approximation of the real CSS cascade: a property already present in props when this is called (e.g.
the element's own inline style, set by the caller before calling this) outranks a later plain rule unless that rule's value carries "!important" (stripped from the stored value either way); among this sheet's own rules, a later rule beats an earlier one at equal priority. This is "last rule of
equal-or-higher precedence wins", not full CSS specificity. Each matching @media/other at-rule block's raw text is appended to mediaRules, skipped if its exact text is already present in seenMediaBlocks (both are caller-owned, so a caller processing many elements from one document/sheet can share one instance of each across all of them and avoid repeating an identical block once per matching element).
Definition at line 659 of file css.cpp.
◆ getRule()
◆ getRuleCount()
| size_t libhtmlpp::CSSStyleSheet::getRuleCount |
( |
| ) |
const |
◆ getRules()
◆ operator=()
◆ parse()
| void libhtmlpp::CSSStyleSheet::parse |
( |
const std::string & |
input | ) |
|
◆ parseInlineStyle()
◆ removeRule()
| void libhtmlpp::CSSStyleSheet::removeRule |
( |
size_t |
index | ) |
|
◆ serialize()
| std::string libhtmlpp::CSSStyleSheet::serialize |
( |
bool |
formatted = false | ) |
const |
The documentation for this class was generated from the following files:
- /build/jan.koester@intranet.tuxist.de/debian/libhtmlpp/src/css.h
- /build/jan.koester@intranet.tuxist.de/debian/libhtmlpp/src/css.cpp