本文整理汇总了C++中StyleRuleBase类的典型用法代码示例。如果您正苦于以下问题:C++ StyleRuleBase类的具体用法?C++ StyleRuleBase怎么用?C++ StyleRuleBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StyleRuleBase类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void CSSStyleSheet::addSubresourceStyleURLs(ListHashSet<KURL>& urls)
{
Deque<CSSStyleSheet*> styleSheetQueue;
styleSheetQueue.append(this);
while (!styleSheetQueue.isEmpty()) {
CSSStyleSheet* styleSheet = styleSheetQueue.takeFirst();
for (unsigned i = 0; i < styleSheet->m_importRules.size(); ++i) {
StyleRuleImport* importRule = styleSheet->m_importRules[i].get();
if (importRule->styleSheet()) {
styleSheetQueue.append(importRule->styleSheet());
addSubresourceURL(urls, importRule->styleSheet()->baseURL());
}
}
for (unsigned i = 0; i < styleSheet->m_childRules.size(); ++i) {
StyleRuleBase* rule = styleSheet->m_childRules[i].get();
if (rule->isStyleRule())
static_cast<StyleRule*>(rule)->properties()->addSubresourceStyleURLs(urls, this);
else if (rule->isFontFaceRule())
static_cast<StyleRuleFontFace*>(rule)->properties()->addSubresourceStyleURLs(urls, this);
}
}
}
示例2: ensurePendingRules
void RuleSet::addRegionRule(StyleRuleRegion* regionRule, bool hasDocumentSecurityOrigin)
{
ensurePendingRules(); // So that m_regionSelectorsAndRuleSets.shrinkToFit() gets called.
OwnPtr<RuleSet> regionRuleSet = RuleSet::create();
// The region rule set should take into account the position inside the parent rule set.
// Otherwise, the rules inside region block might be incorrectly positioned before other similar rules from
// the stylesheet that contains the region block.
regionRuleSet->m_ruleCount = m_ruleCount;
// Collect the region rules into a rule set
// FIXME: Should this add other types of rules? (i.e. use addChildRules() directly?)
const Vector<RefPtr<StyleRuleBase> >& childRules = regionRule->childRules();
AddRuleFlags addRuleFlags = hasDocumentSecurityOrigin ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState;
addRuleFlags = static_cast<AddRuleFlags>(addRuleFlags | RuleIsInRegionRule | RuleCanUseFastCheckSelector);
for (unsigned i = 0; i < childRules.size(); ++i) {
StyleRuleBase* regionStylingRule = childRules[i].get();
if (regionStylingRule->isStyleRule())
regionRuleSet->addStyleRule(toStyleRule(regionStylingRule), addRuleFlags);
}
// Update the "global" rule count so that proper order is maintained
m_ruleCount = regionRuleSet->m_ruleCount;
m_regionSelectorsAndRuleSets.append(RuleSetSelectorPair(regionRule->selectorList().first(), regionRuleSet.release()));
}
示例3: addChildRules
void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase>>& rules, const MediaQueryEvaluator& medium, StyleResolver* resolver, bool hasDocumentSecurityOrigin, AddRuleFlags addRuleFlags)
{
for (unsigned i = 0; i < rules.size(); ++i) {
StyleRuleBase* rule = rules[i].get();
if (rule->isStyleRule()) {
StyleRule* styleRule = static_cast<StyleRule*>(rule);
addStyleRule(styleRule, addRuleFlags);
} else if (rule->isPageRule())
addPageRule(static_cast<StyleRulePage*>(rule));
else if (rule->isMediaRule()) {
StyleRuleMedia* mediaRule = static_cast<StyleRuleMedia*>(rule);
if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueries(), resolver)))
addChildRules(mediaRule->childRules(), medium, resolver, hasDocumentSecurityOrigin, addRuleFlags);
} else if (rule->isFontFaceRule() && resolver) {
// Add this font face to our set.
const StyleRuleFontFace* fontFaceRule = static_cast<StyleRuleFontFace*>(rule);
resolver->fontSelector()->addFontFaceRule(fontFaceRule);
resolver->invalidateMatchedPropertiesCache();
} else if (rule->isKeyframesRule() && resolver) {
resolver->addKeyframeStyle(static_cast<StyleRuleKeyframes*>(rule));
}
#if ENABLE(CSS_REGIONS)
else if (rule->isRegionRule() && resolver) {
addRegionRule(static_cast<StyleRuleRegion*>(rule), hasDocumentSecurityOrigin);
}
#endif
#if ENABLE(CSS_DEVICE_ADAPTATION)
else if (rule->isViewportRule() && resolver) {
resolver->viewportStyleResolver()->addViewportRule(static_cast<StyleRuleViewport*>(rule));
}
#endif
#if ENABLE(CSS3_CONDITIONAL_RULES)
else if (rule->isSupportsRule() && static_cast<StyleRuleSupports*>(rule)->conditionIsSupported())
addChildRules(static_cast<StyleRuleSupports*>(rule)->childRules(), medium, resolver, hasDocumentSecurityOrigin, addRuleFlags);
#endif
}
}
示例4: addChildRules
void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules, const MediaQueryEvaluator& medium, AddRuleFlags addRuleFlags)
{
for (unsigned i = 0; i < rules.size(); ++i) {
StyleRuleBase* rule = rules[i].get();
if (rule->isStyleRule()) {
StyleRule* styleRule = toStyleRule(rule);
const CSSSelectorList& selectorList = styleRule->selectorList();
for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorIndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) {
if (selectorList.hasCombinatorCrossingTreeBoundaryAt(selectorIndex)) {
m_treeBoundaryCrossingRules.append(MinimalRuleData(styleRule, selectorIndex, addRuleFlags));
} else if (selectorList.hasShadowDistributedAt(selectorIndex)) {
m_shadowDistributedRules.append(MinimalRuleData(styleRule, selectorIndex, addRuleFlags));
} else {
addRule(styleRule, selectorIndex, addRuleFlags);
}
}
} else if (rule->isPageRule()) {
addPageRule(toStyleRulePage(rule));
} else if (rule->isMediaRule()) {
StyleRuleMedia* mediaRule = toStyleRuleMedia(rule);
if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueries(), &m_viewportDependentMediaQueryResults)))
addChildRules(mediaRule->childRules(), medium, addRuleFlags);
} else if (rule->isFontFaceRule()) {
addFontFaceRule(toStyleRuleFontFace(rule));
} else if (rule->isKeyframesRule()) {
addKeyframesRule(toStyleRuleKeyframes(rule));
} else if (rule->isRegionRule()) {
addRegionRule(toStyleRuleRegion(rule), addRuleFlags & RuleHasDocumentSecurityOrigin);
} else if (rule->isViewportRule()) {
addViewportRule(toStyleRuleViewport(rule));
} else if (rule->isSupportsRule() && toStyleRuleSupports(rule)->conditionIsSupported()) {
addChildRules(toStyleRuleSupports(rule)->childRules(), medium, addRuleFlags);
}
}
}
示例5: addChildRules
void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules, const MediaQueryEvaluator& medium, AddRuleFlags addRuleFlags)
{
for (unsigned i = 0; i < rules.size(); ++i) {
StyleRuleBase* rule = rules[i].get();
if (rule->isStyleRule()) {
StyleRule* styleRule = toStyleRule(rule);
const CSSSelectorList& selectorList = styleRule->selectorList();
for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorIndex = selectorList.indexOfNextSelectorAfter(selectorIndex))
addRule(styleRule, selectorIndex, addRuleFlags);
} else if (rule->isMediaRule()) {
StyleRuleMedia* mediaRule = toStyleRuleMedia(rule);
if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueries(), &m_viewportDependentMediaQueryResults)))
addChildRules(mediaRule->childRules(), medium, addRuleFlags);
} else if (rule->isFontFaceRule()) {
addFontFaceRule(toStyleRuleFontFace(rule));
} else if (rule->isKeyframesRule()) {
addKeyframesRule(toStyleRuleKeyframes(rule));
} else if (rule->isSupportsRule() && toStyleRuleSupports(rule)->conditionIsSupported()) {
addChildRules(toStyleRuleSupports(rule)->childRules(), medium, addRuleFlags);
}
}
}
示例6: ASSERT
void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, const MediaQueryEvaluator& medium, StyleResolver* resolver, const ContainerNode* scope)
{
ASSERT(sheet);
const Vector<RefPtr<StyleRuleImport> >& importRules = sheet->importRules();
for (unsigned i = 0; i < importRules.size(); ++i) {
StyleRuleImport* importRule = importRules[i].get();
if (importRule->styleSheet() && (!importRule->mediaQueries() || medium.eval(importRule->mediaQueries(), resolver)))
addRulesFromSheet(importRule->styleSheet(), medium, resolver, scope);
}
bool hasDocumentSecurityOrigin = resolver && resolver->document()->securityOrigin()->canRequest(sheet->baseURL());
AddRuleFlags addRuleFlags = static_cast<AddRuleFlags>((hasDocumentSecurityOrigin ? RuleHasDocumentSecurityOrigin : 0) | (!scope ? RuleCanUseFastCheckSelector : 0));
const Vector<RefPtr<StyleRuleBase> >& rules = sheet->childRules();
for (unsigned i = 0; i < rules.size(); ++i) {
StyleRuleBase* rule = rules[i].get();
ASSERT(!rule->isImportRule());
if (rule->isStyleRule())
addStyleRule(static_cast<StyleRule*>(rule), addRuleFlags);
else if (rule->isPageRule())
addPageRule(static_cast<StyleRulePage*>(rule));
else if (rule->isMediaRule()) {
StyleRuleMedia* mediaRule = static_cast<StyleRuleMedia*>(rule);
if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueries(), resolver))) {
// Traverse child elements of the @media rule.
const Vector<RefPtr<StyleRuleBase> >& childRules = mediaRule->childRules();
for (unsigned j = 0; j < childRules.size(); ++j) {
StyleRuleBase* childRule = childRules[j].get();
if (childRule->isStyleRule())
addStyleRule(static_cast<StyleRule*>(childRule), addRuleFlags);
else if (childRule->isPageRule())
addPageRule(static_cast<StyleRulePage*>(childRule));
else if (childRule->isFontFaceRule() && resolver) {
// Add this font face to our set.
// FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets for the moment.
if (scope)
continue;
const StyleRuleFontFace* fontFaceRule = static_cast<StyleRuleFontFace*>(childRule);
resolver->fontSelector()->addFontFaceRule(fontFaceRule);
resolver->invalidateMatchedPropertiesCache();
} else if (childRule->isKeyframesRule() && resolver) {
// Add this keyframe rule to our set.
// FIXME(BUG 72462): We don't add @keyframe rules of scoped style sheets for the moment.
if (scope)
continue;
resolver->addKeyframeStyle(static_cast<StyleRuleKeyframes*>(childRule));
}
#if ENABLE(CSS_DEVICE_ADAPTATION)
else if (childRule->isViewportRule() && resolver && !resolver->affectedByViewportChange()) {
// @viewport should not be scoped.
if (scope)
continue;
resolver->viewportStyleResolver()->addViewportRule(static_cast<StyleRuleViewport*>(childRule));
}
#endif
} // for rules
} // if rules
} else if (rule->isFontFaceRule() && resolver) {
// Add this font face to our set.
// FIXME(BUG 72461): We don't add @font-face rules of scoped style sheets for the moment.
if (scope)
continue;
const StyleRuleFontFace* fontFaceRule = static_cast<StyleRuleFontFace*>(rule);
resolver->fontSelector()->addFontFaceRule(fontFaceRule);
resolver->invalidateMatchedPropertiesCache();
} else if (rule->isKeyframesRule() && resolver) {
// FIXME (BUG 72462): We don't add @keyframe rules of scoped style sheets for the moment.
if (scope)
continue;
resolver->addKeyframeStyle(static_cast<StyleRuleKeyframes*>(rule));
}
#if ENABLE(CSS_REGIONS)
else if (rule->isRegionRule() && resolver) {
// FIXME (BUG 72472): We don't add @-webkit-region rules of scoped style sheets for the moment.
if (scope)
continue;
addRegionRule(static_cast<StyleRuleRegion*>(rule), hasDocumentSecurityOrigin);
}
#endif
#if ENABLE(SHADOW_DOM)
else if (rule->isHostRule())
resolver->addHostRule(static_cast<StyleRuleHost*>(rule), hasDocumentSecurityOrigin, scope);
#endif
#if ENABLE(CSS_DEVICE_ADAPTATION)
else if (rule->isViewportRule() && resolver) {
// @viewport should not be scoped.
if (scope)
continue;
resolver->viewportStyleResolver()->addViewportRule(static_cast<StyleRuleViewport*>(rule));
}
#endif
}
if (m_autoShrinkToFitEnabled)
shrinkToFit();
}
示例7: reattach
void CSSKeyframesRule::reattach(StyleRuleBase& rule)
{
ASSERT_WITH_SECURITY_IMPLICATION(rule.isKeyframesRule());
m_keyframesRule = static_cast<StyleRuleKeyframes&>(rule);
}