42 CSSProperty(
const std::string &name,
const std::string &value);
48 const std::string&
getName()
const;
49 void setName(
const std::string &name);
52 void setValue(
const std::string &value);
67 void addProperty(
const std::string &name,
const std::string &value);
76 void parse(
const std::string &input);
80 std::vector<CSSProperty> _Properties;
86 CSSRule(
const std::string &selector);
98 std::string
serialize(
bool formatted =
false)
const;
101 std::string _Selector;
155 void parse(
const std::string &input);
163 const std::vector<CSSRule>&
getRules()
const;
165 std::string
serialize(
bool formatted =
false)
const;
222 const std::string &tag,
223 const std::vector<std::string> &classes,
224 const std::string &
id,
225 const std::vector<AncestorFrame> *ancestors =
nullptr);
271 const std::string &cssClass,
272 const std::string &
id,
273 std::map<std::string,std::string> &props,
274 std::string &mediaRules,
275 std::set<std::string> &seenMediaBlocks,
276 const std::vector<AncestorFrame> *ancestors =
nullptr,
277 const std::map<std::string,std::string> *targetAttributes =
nullptr)
const;
280 void _skipWhitespace(
const std::string &input,
size_t &pos)
const;
281 void _skipComment(
const std::string &input,
size_t &pos)
const;
282 std::vector<CSSRule> _Rules;
296 struct _CompoundCacheBranch {
299 std::string atWrapper;
300 std::string trimmedSelector;
302 std::vector<std::string> classes;
308 std::vector<AttributeCondition> attrConditions;
328 std::vector<AncestorCompound> ancestorCompounds;
336 std::array<int,3> specificity{0,0,0};
338 mutable std::vector<std::vector<_CompoundCacheBranch>> _compoundCache;
339 mutable bool _compoundCacheValid =
false;
340 void _rebuildCompoundCache()
const;
369 const std::map<std::string,std::string> &customProperties,
370 bool *unresolved =
nullptr);
void addProperty(const std::string &name, const std::string &value)
void removeProperty(const std::string &name)
const std::vector< CSSProperty > & getProperties() const
std::string serialize() const
const CSSProperty * getProperty(const std::string &name) const
void parse(const std::string &input)
CSSDeclaration & operator=(const CSSDeclaration &decl)
void setName(const std::string &name)
const std::string & getName() const
void setValue(const std::string &value)
CSSProperty & operator=(const CSSProperty &prop)
const std::string & getValue() const
CSSDeclaration & getDeclaration()
std::string serialize(bool formatted=false) const
void setSelector(const std::string &selector)
CSSRule & operator=(const CSSRule &rule)
const std::string & getSelector() const
void parse(const std::string &input)
const std::vector< CSSRule > & getRules() const
void 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 std::vector< AncestorFrame > *ancestors=nullptr, const std::map< std::string, std::string > *targetAttributes=nullptr) const
Runs every rule in this sheet through approximateSelectorMatch against the element identified by tag/...
CSSStyleSheet & operator=(const CSSStyleSheet &sheet)
static CSSDeclaration parseInlineStyle(const std::string &style)
std::string serialize(bool formatted=false) const
const CSSRule * getRule(size_t index) const
static bool approximateSelectorMatch(const std::string &selector, const std::string &tag, const std::vector< std::string > &classes, const std::string &id, const std::vector< AncestorFrame > *ancestors=nullptr)
Conservative, NOT spec-complete selector match: selector (a single selector, or a comma-separated lis...
void addRule(const CSSRule &rule)
void removeRule(size_t index)
size_t getRuleCount() const
Core namespace for the libhtmlpp HTML parsing and printing library.
std::string resolveCSSVariables(const std::string &value, const std::map< std::string, std::string > &customProperties, bool *unresolved=nullptr)
Resolves every var(--name) / var(--name, fallback) reference in value using customProperties (custom-...
One ancestor of the element being matched, for the optional ancestor chain approximateSelectorMatch/c...
std::vector< std::string > classes
std::map< std::string, std::string > attributes
One "[name]"/"[name=value]"/"[name~=value]"/etc.
std::vector< std::string > classes
std::vector< AttributeCondition > attrConditions