当前位置: 首页>>代码示例>>C++>>正文


C++ StyleRuleBase::isImportRule方法代码示例

本文整理汇总了C++中StyleRuleBase::isImportRule方法的典型用法代码示例。如果您正苦于以下问题:C++ StyleRuleBase::isImportRule方法的具体用法?C++ StyleRuleBase::isImportRule怎么用?C++ StyleRuleBase::isImportRule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StyleRuleBase的用法示例。


在下文中一共展示了StyleRuleBase::isImportRule方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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();
}
开发者ID:kcomkar,项目名称:webkit,代码行数:97,代码来源:RuleSet.cpp


注:本文中的StyleRuleBase::isImportRule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。