本文整理汇总了C++中MediaQueryEvaluator类的典型用法代码示例。如果您正苦于以下问题:C++ MediaQueryEvaluator类的具体用法?C++ MediaQueryEvaluator怎么用?C++ MediaQueryEvaluator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MediaQueryEvaluator类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addChildRules
void RuleSet::addChildRules(const WillBeHeapVector<RefPtrWillBeMember<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.selectorCrossesTreeScopes(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->isViewportRule()) {
addViewportRule(toStyleRuleViewport(rule));
} else if (rule->isSupportsRule() && toStyleRuleSupports(rule)->conditionIsSupported()) {
addChildRules(toStyleRuleSupports(rule)->childRules(), medium, addRuleFlags);
}
}
}
示例2: addChildRules
void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase>>& rules, const MediaQueryEvaluator& medium, StyleResolver* resolver, bool hasDocumentSecurityOrigin, bool isInitiatingElementInUserAgentShadowTree, AddRuleFlags addRuleFlags)
{
for (auto& rule : rules) {
if (is<StyleRule>(*rule))
addStyleRule(downcast<StyleRule>(rule.get()), addRuleFlags);
else if (is<StyleRulePage>(*rule))
addPageRule(downcast<StyleRulePage>(rule.get()));
else if (is<StyleRuleMedia>(*rule)) {
auto& mediaRule = downcast<StyleRuleMedia>(*rule);
if ((!mediaRule.mediaQueries() || medium.eval(mediaRule.mediaQueries(), resolver)))
addChildRules(mediaRule.childRules(), medium, resolver, hasDocumentSecurityOrigin, isInitiatingElementInUserAgentShadowTree, addRuleFlags);
} else if (is<StyleRuleFontFace>(*rule) && resolver) {
// Add this font face to our set.
resolver->document().fontSelector().addFontFaceRule(downcast<StyleRuleFontFace>(*rule.get()), isInitiatingElementInUserAgentShadowTree);
resolver->invalidateMatchedPropertiesCache();
} else if (is<StyleRuleKeyframes>(*rule) && resolver)
resolver->addKeyframeStyle(downcast<StyleRuleKeyframes>(rule.get()));
else if (is<StyleRuleSupports>(*rule) && downcast<StyleRuleSupports>(*rule).conditionIsSupported())
addChildRules(downcast<StyleRuleSupports>(*rule).childRules(), medium, resolver, hasDocumentSecurityOrigin, isInitiatingElementInUserAgentShadowTree, addRuleFlags);
#if ENABLE(CSS_REGIONS)
else if (is<StyleRuleRegion>(*rule) && resolver) {
addRegionRule(downcast<StyleRuleRegion>(rule.get()), hasDocumentSecurityOrigin);
}
#endif
#if ENABLE(CSS_DEVICE_ADAPTATION)
else if (is<StyleRuleViewport>(*rule) && resolver) {
resolver->viewportStyleResolver()->addViewportRule(downcast<StyleRuleViewport>(rule.get()));
}
#endif
}
}
示例3: testMQEvaluator
void testMQEvaluator(TestCase* testCases, const MediaQueryEvaluator& mediaQueryEvaluator)
{
for (unsigned i = 0; testCases[i].input; ++i) {
RefPtrWillBeRawPtr<MediaQuerySet> querySet = MediaQuerySet::create(testCases[i].input);
ASSERT_EQ(testCases[i].output, mediaQueryEvaluator.eval(querySet.get()));
}
}
示例4: testMQEvaluator
void testMQEvaluator(TestCase* testCases,
const MediaQueryEvaluator& mediaQueryEvaluator) {
Persistent<MediaQuerySet> querySet = nullptr;
for (unsigned i = 0; testCases[i].input; ++i) {
querySet = MediaQuerySet::create(testCases[i].input);
EXPECT_EQ(testCases[i].output, mediaQueryEvaluator.eval(querySet.get()));
}
}
示例5: addChildRules
void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase>>& rules, const MediaQueryEvaluator& medium, StyleResolver* resolver, const ContainerNode* scope, 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, scope, hasDocumentSecurityOrigin, addRuleFlags);
} 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 ENABLE(CSS3_CONDITIONAL_RULES)
else if (rule->isSupportsRule() && static_cast<StyleRuleSupports*>(rule)->conditionIsSupported())
addChildRules(static_cast<StyleRuleSupports*>(rule)->childRules(), medium, resolver, scope, hasDocumentSecurityOrigin, addRuleFlags);
#endif
}
}
示例6: addRulesFromSheet
void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, const MediaQueryEvaluator& medium, AddRuleFlags addRuleFlags)
{
TRACE_EVENT0("blink", "RuleSet::addRulesFromSheet");
ASSERT(sheet);
const WillBeHeapVector<RefPtrWillBeMember<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(), &m_viewportDependentMediaQueryResults)))
addRulesFromSheet(importRule->styleSheet(), medium, addRuleFlags);
}
addChildRules(sheet->childRules(), medium, addRuleFlags);
}
示例7: addRulesFromSheet
void RuleSet::addRulesFromSheet(StyleSheetContents& sheet, const MediaQueryEvaluator& medium, StyleResolver* resolver)
{
for (auto& rule : sheet.importRules()) {
if (rule->styleSheet() && (!rule->mediaQueries() || medium.eval(rule->mediaQueries(), resolver)))
addRulesFromSheet(*rule->styleSheet(), medium, resolver);
}
bool hasDocumentSecurityOrigin = resolver && resolver->document().securityOrigin()->canRequest(sheet.baseURL());
AddRuleFlags addRuleFlags = static_cast<AddRuleFlags>((hasDocumentSecurityOrigin ? RuleHasDocumentSecurityOrigin : 0));
// FIXME: Skip Content Security Policy check when stylesheet is in a user agent shadow tree.
// See <https://bugs.webkit.org/show_bug.cgi?id=146663>.
bool isInitiatingElementInUserAgentShadowTree = false;
addChildRules(sheet.childRules(), medium, resolver, hasDocumentSecurityOrigin, isInitiatingElementInUserAgentShadowTree, addRuleFlags);
if (m_autoShrinkToFitEnabled)
shrinkToFit();
}
示例8: 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
}
}
示例9: 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);
}
}
}
示例10: addRulesFromSheet
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();
}