本文整理汇总了C++中StyleRule::Merge方法的典型用法代码示例。如果您正苦于以下问题:C++ StyleRule::Merge方法的具体用法?C++ StyleRule::Merge怎么用?C++ StyleRule::Merge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StyleRule
的用法示例。
在下文中一共展示了StyleRule::Merge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ComputeStyleRule
StyleRule HtmlFormatter::ComputeStyleRule(HtmlToken* t) {
StyleRule rule;
// get style rules ordered by specificity
StyleRule* prevRule = FindStyleRule(Tag_Body, nullptr, 0);
if (prevRule)
rule.Merge(*prevRule);
prevRule = FindStyleRule(Tag_Any, nullptr, 0);
if (prevRule)
rule.Merge(*prevRule);
prevRule = FindStyleRule(t->tag, nullptr, 0);
if (prevRule)
rule.Merge(*prevRule);
// TODO: support multiple class names
AttrInfo* attr = t->GetAttrByName("class");
if (attr) {
prevRule = FindStyleRule(Tag_Any, attr->val, attr->valLen);
if (prevRule)
rule.Merge(*prevRule);
prevRule = FindStyleRule(t->tag, attr->val, attr->valLen);
if (prevRule)
rule.Merge(*prevRule);
}
attr = t->GetAttrByName("style");
if (attr) {
StyleRule newRule = StyleRule::Parse(attr->val, attr->valLen);
rule.Merge(newRule);
}
return rule;
}
示例2: ParseStyleSheet
void HtmlFormatter::ParseStyleSheet(const char* data, size_t len) {
CssPullParser parser(data, len);
while (parser.NextRule()) {
StyleRule rule = StyleRule::Parse(&parser);
const CssSelector* sel;
while ((sel = parser.NextSelector()) != nullptr) {
if (Tag_NotFound == sel->tag)
continue;
StyleRule* prevRule = FindStyleRule(sel->tag, sel->clazz, sel->clazzLen);
if (prevRule) {
prevRule->Merge(rule);
} else {
rule.tag = sel->tag;
rule.classHash = sel->clazz ? MurmurHash2(sel->clazz, sel->clazzLen) : 0;
styleRules.Append(rule);
}
}
}
}