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


C++ StyleSheetContents类代码示例

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


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

示例1: TEST_F

TEST_F(StyleEngineTest, AnalyzedInject) {
  document().body()->setInnerHTML(
      "<style>div { color: red }</style><div id='t1'>Green</div><div></div>");
  document().view()->updateAllLifecyclePhases();

  Element* t1 = document().getElementById("t1");
  ASSERT_TRUE(t1);
  ASSERT_TRUE(t1->computedStyle());
  EXPECT_EQ(makeRGB(255, 0, 0),
            t1->computedStyle()->visitedDependentColor(CSSPropertyColor));

  unsigned beforeCount = styleEngine().styleForElementCount();

  StyleSheetContents* parsedSheet =
      StyleSheetContents::create(CSSParserContext(document(), nullptr));
  parsedSheet->parseString("#t1 { color: green }");
  styleEngine().injectAuthorSheet(parsedSheet);
  document().view()->updateAllLifecyclePhases();

  unsigned afterCount = styleEngine().styleForElementCount();
  EXPECT_EQ(1u, afterCount - beforeCount);

  ASSERT_TRUE(t1->computedStyle());
  EXPECT_EQ(makeRGB(0, 128, 0),
            t1->computedStyle()->visitedDependentColor(CSSPropertyColor));
}
开发者ID:,项目名称:,代码行数:26,代码来源:

示例2: textContent

PassRefPtrWillBeRawPtr<CSSStyleSheet> StyleEngine::createSheet(Element* e, const String& text, TextPosition startPosition, bool createdByParser)
{
    RefPtrWillBeRawPtr<CSSStyleSheet> styleSheet = nullptr;

    e->document().styleEngine()->addPendingSheet();

    if (!e->document().inQuirksMode()) {
        AtomicString textContent(text);

        WillBeHeapHashMap<AtomicString, RawPtrWillBeMember<StyleSheetContents> >::AddResult result = m_textToSheetCache.add(textContent, nullptr);
        if (result.isNewEntry || !result.storedValue->value) {
            styleSheet = StyleEngine::parseSheet(e, text, startPosition, createdByParser);
            if (result.isNewEntry && isCacheableForStyleElement(*styleSheet->contents())) {
                result.storedValue->value = styleSheet->contents();
                m_sheetToTextCache.add(styleSheet->contents(), textContent);
            }
        } else {
            StyleSheetContents* contents = result.storedValue->value;
            ASSERT(contents);
            ASSERT(isCacheableForStyleElement(*contents));
            ASSERT(contents->singleOwnerDocument() == e->document());
            styleSheet = CSSStyleSheet::createInline(contents, e, startPosition);
        }
    } else {
        // FIXME: currently we don't cache StyleSheetContents inQuirksMode.
        styleSheet = StyleEngine::parseSheet(e, text, startPosition, createdByParser);
    }

    ASSERT(styleSheet);
    styleSheet->setTitle(e->title());
    return styleSheet;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:32,代码来源:StyleEngine.cpp

示例3: collectFeaturesTo

void ScopedStyleResolver::collectFeaturesTo(RuleFeatureSet& features, HashSet<const StyleSheetContents*>& visitedSharedStyleSheetContents)
{
    for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) {
        StyleSheetContents* contents = m_authorStyleSheets[i]->contents();
        if (contents->hasOneClient() || visitedSharedStyleSheetContents.add(contents).isNewEntry)
            features.add(contents->ruleSet().features());
    }
}
开发者ID:junmin-zhu,项目名称:blink,代码行数:8,代码来源:ScopedStyleResolver.cpp

示例4: createSheet

 static CSSStyleSheet* createSheet(const String& cssText = String()) {
   StyleSheetContents* contents =
       StyleSheetContents::create(CSSParserContext(HTMLStandardMode, nullptr));
   contents->parseString(cssText);
   contents->ensureRuleSet(MediaQueryEvaluator(),
                           RuleHasDocumentSecurityOrigin);
   return CSSStyleSheet::create(contents);
 }
开发者ID:ollie314,项目名称:chromium,代码行数:8,代码来源:ActiveStyleSheetsTest.cpp

示例5: DCHECK

void WebDocument::insertStyleSheet(const WebString& sourceCode) {
  Document* document = unwrap<Document>();
  DCHECK(document);
  StyleSheetContents* parsedSheet =
      StyleSheetContents::create(CSSParserContext(*document, nullptr));
  parsedSheet->parseString(sourceCode);
  document->styleEngine().injectAuthorSheet(parsedSheet);
}
开发者ID:mirror,项目名称:chromium,代码行数:8,代码来源:WebDocument.cpp

示例6: parentStyleSheet

bool StyleSheetContents::loadCompleted() const {
    StyleSheetContents* parentSheet = parentStyleSheet();
    if (parentSheet)
        return parentSheet->loadCompleted();

    StyleSheetContents* root = rootStyleSheet();
    return root->m_loadingClients.isEmpty();
}
开发者ID:mirror,项目名称:chromium,代码行数:8,代码来源:StyleSheetContents.cpp

示例7: rootStyleSheet

Node* StyleSheetContents::singleOwnerNode() const {
    StyleSheetContents* root = rootStyleSheet();
    if (!root->hasOneClient())
        return nullptr;
    if (root->m_loadingClients.size())
        return (*root->m_loadingClients.begin())->ownerNode();
    return (*root->m_completedClients.begin())->ownerNode();
}
开发者ID:mirror,项目名称:chromium,代码行数:8,代码来源:StyleSheetContents.cpp

示例8: clearMediaQueryRuleSetStyleSheets

void TreeScopeStyleSheetCollection::clearMediaQueryRuleSetStyleSheets()
{
    for (size_t i = 0; i < m_activeAuthorStyleSheets.size(); ++i) {
        StyleSheetContents* contents = m_activeAuthorStyleSheets[i]->contents();
        if (contents->hasMediaQueries())
            contents->clearRuleSet();
    }
}
开发者ID:kingysu,项目名称:blink-crosswalk,代码行数:8,代码来源:TreeScopeStyleSheetCollection.cpp

示例9: parseUASheet

static StyleSheetContents* parseUASheet(const String& str)
{
    StyleSheetContents* sheet = StyleSheetContents::create(CSSParserContext(UASheetMode, nullptr));
    sheet->parseString(str);
    // User Agent stylesheets are parsed once for the lifetime of the renderer
    // process and are intentionally leaked.
    LEAK_SANITIZER_IGNORE_OBJECT(sheet);
    return sheet;
}
开发者ID:endlessm,项目名称:chromium-browser,代码行数:9,代码来源:CSSDefaultStyleSheets.cpp

示例10: addRulesFromSheet

void ScopedStyleResolver::addRulesFromSheet(CSSStyleSheet* cssSheet, const MediaQueryEvaluator& medium, StyleResolver* resolver)
{
    m_authorStyleSheets.append(cssSheet);
    StyleSheetContents* sheet = cssSheet->contents();

    AddRuleFlags addRuleFlags = resolver->document().securityOrigin()->canRequest(sheet->baseURL()) ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState;
    const RuleSet& ruleSet = sheet->ensureRuleSet(medium, addRuleFlags);
    resolver->addMediaQueryResults(ruleSet.viewportDependentMediaQueryResults());
    resolver->processScopedRules(ruleSet, sheet->baseURL(), &m_scopingNode);
}
开发者ID:junmin-zhu,项目名称:blink,代码行数:10,代码来源:ScopedStyleResolver.cpp

示例11: isCacheableForStyleElement

static bool isCacheableForStyleElement(const StyleSheetContents& contents)
{
    // Until import rules are supported in cached sheets it's not possible for loading to fail.
    ASSERT(!contents.didLoadErrorOccur());
    // It is not the original sheet anymore.
    if (contents.isMutable())
        return false;
    if (!contents.hasSyntacticallyValidCSSHeader())
        return false;
    return true;
}
开发者ID:krockot,项目名称:mojo,代码行数:11,代码来源:StyleEngine.cpp

示例12: appendCSSStyleSheet

void ScopedStyleResolver::appendCSSStyleSheet(CSSStyleSheet& cssSheet, const MediaQueryEvaluator& medium)
{
    unsigned index = m_authorStyleSheets.size();
    m_authorStyleSheets.append(&cssSheet);
    StyleSheetContents* sheet = cssSheet.contents();
    AddRuleFlags addRuleFlags = treeScope().document().securityOrigin()->canRequest(sheet->baseURL()) ? RuleHasDocumentSecurityOrigin : RuleHasNoSpecialState;
    const RuleSet& ruleSet = sheet->ensureRuleSet(medium, addRuleFlags);

    addKeyframeRules(ruleSet);
    addFontFaceRules(ruleSet);
    addTreeBoundaryCrossingRules(ruleSet, &cssSheet, index);
    treeScope().document().styleResolver()->addMediaQueryResults(ruleSet.viewportDependentMediaQueryResults());
}
开发者ID:kingysu,项目名称:blink-crosswalk,代码行数:13,代码来源:ScopedStyleResolver.cpp

示例13: ASSERT

void ScopedStyleResolver::collectFeaturesTo(RuleFeatureSet& features, WillBeHeapHashSet<RawPtrWillBeMember<const StyleSheetContents>>& visitedSharedStyleSheetContents) const
{
    for (size_t i = 0; i < m_authorStyleSheets.size(); ++i) {
        ASSERT(m_authorStyleSheets[i]->ownerNode());
        StyleSheetContents* contents = m_authorStyleSheets[i]->contents();
        if (contents->hasOneClient() || visitedSharedStyleSheetContents.add(contents).isNewEntry)
            features.add(contents->ruleSet().features());
    }

    if (!m_treeBoundaryCrossingRuleSet)
        return;

    for (const auto& rules : *m_treeBoundaryCrossingRuleSet)
        features.add(rules->m_ruleSet->features());
}
开发者ID:astojilj,项目名称:chromium-crosswalk,代码行数:15,代码来源:ScopedStyleResolver.cpp

示例14: ASSERT

StyleSheetContents::StyleSheetContents(const StyleSheetContents& o)
    : RefCounted<StyleSheetContents>()
    , m_ownerRule(0)
    , m_originalURL(o.m_originalURL)
    , m_encodingFromCharsetRule(o.m_encodingFromCharsetRule)
    , m_importRules(o.m_importRules.size())
    , m_childRules(o.m_childRules.size())
    , m_namespaces(o.m_namespaces)
    , m_loadCompleted(true)
    , m_isUserStyleSheet(o.m_isUserStyleSheet)
    , m_hasSyntacticallyValidCSSHeader(o.m_hasSyntacticallyValidCSSHeader)
    , m_didLoadErrorOccur(false)
    , m_usesRemUnits(o.m_usesRemUnits)
    , m_isMutable(false)
    , m_isInMemoryCache(false)
    , m_parserContext(o.m_parserContext)
{
    ASSERT(o.isCacheable());

    // FIXME: Copy import rules.
    ASSERT(o.m_importRules.isEmpty());

    for (unsigned i = 0; i < m_childRules.size(); ++i)
        m_childRules[i] = o.m_childRules[i]->copy();
}
开发者ID:yoavweiss,项目名称:RespImg-WebKit,代码行数:25,代码来源:StyleSheetContents.cpp

示例15: ASSERT

StyleSheetContents::StyleSheetContents(const StyleSheetContents& o)
    : m_ownerRule(nullptr)
    , m_originalURL(o.m_originalURL)
    , m_encodingFromCharsetRule(o.m_encodingFromCharsetRule)
    , m_importRules(o.m_importRules.size())
    , m_childRules(o.m_childRules.size())
    , m_namespaces(o.m_namespaces)
    , m_hasSyntacticallyValidCSSHeader(o.m_hasSyntacticallyValidCSSHeader)
    , m_didLoadErrorOccur(false)
    , m_usesRemUnits(o.m_usesRemUnits)
    , m_isMutable(false)
    , m_isInMemoryCache(false)
    , m_hasFontFaceRule(o.m_hasFontFaceRule)
    , m_hasMediaQueries(o.m_hasMediaQueries)
    , m_hasSingleOwnerDocument(true)
    , m_parserContext(o.m_parserContext)
{
    ASSERT(o.isCacheable());

    // FIXME: Copy import rules.
    ASSERT(o.m_importRules.isEmpty());

    for (unsigned i = 0; i < m_childRules.size(); ++i)
        m_childRules[i] = o.m_childRules[i]->copy();
}
开发者ID:335969568,项目名称:Blink-1,代码行数:25,代码来源:StyleSheetContents.cpp


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