本文整理汇总了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));
}
示例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;
}
示例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());
}
}
示例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);
}
示例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);
}
示例6: parentStyleSheet
bool StyleSheetContents::loadCompleted() const {
StyleSheetContents* parentSheet = parentStyleSheet();
if (parentSheet)
return parentSheet->loadCompleted();
StyleSheetContents* root = rootStyleSheet();
return root->m_loadingClients.isEmpty();
}
示例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();
}
示例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();
}
}
示例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;
}
示例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);
}
示例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;
}
示例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());
}
示例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());
}
示例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();
}
示例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();
}