Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(578)

Unified Diff: Source/core/css/RuleSet.cpp

Issue 42543007: StyleResolver should update RuleSets lazily. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Filter @viewport and @font-face in lazyAppend Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/css/RuleSet.cpp
diff --git a/Source/core/css/RuleSet.cpp b/Source/core/css/RuleSet.cpp
index cce6f4779fb6bdb97fb27e522ce5ceccf0d31c91..3740807f61dc3c1aaad4c994d3e59f122cedfbf5 100644
--- a/Source/core/css/RuleSet.cpp
+++ b/Source/core/css/RuleSet.cpp
@@ -52,11 +52,6 @@ using namespace HTMLNames;
// -----------------------------------------------------------------
-static inline bool isDocumentScope(const ContainerNode* scope)
-{
- return !scope || scope->isDocumentNode();
-}
-
static inline bool isScopingNodeInShadowTree(const ContainerNode* scopingNode)
{
return scopingNode && scopingNode->isInShadowTree();
@@ -384,7 +379,7 @@ void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules, const M
StyleRuleMedia* mediaRule = static_cast<StyleRuleMedia*>(rule);
if ((!mediaRule->mediaQueries() || medium.eval(mediaRule->mediaQueries(), resolver->viewportDependentMediaQueryResults())))
addChildRules(mediaRule->childRules(), medium, resolver, scope, hasDocumentSecurityOrigin, addRuleFlags);
- } else if (rule->isFontFaceRule() && resolver) {
+ } else if (rule->isFontFaceRule() && resolver && !(addRuleFlags & RuleSkipsFontFaceAndViewportRule)) {
// 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 (!isDocumentScope(scope))
@@ -404,7 +399,7 @@ void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules, const M
resolver->setBuildScopedStyleTreeInDocumentOrder(false);
resolver->ensureScopedStyleResolver(scope->shadowHost())->addHostRule(static_cast<StyleRuleHost*>(rule), hasDocumentSecurityOrigin, scope);
resolver->setBuildScopedStyleTreeInDocumentOrder(enabled);
- } else if (rule->isViewportRule()) {
+ } else if (rule->isViewportRule() && !(addRuleFlags & RuleSkipsFontFaceAndViewportRule)) {
eseidel 2013/11/06 01:39:10 The double negative reads a bit odd. But I guess
tasak 2013/11/06 05:42:26 Yes, 0 means "no special handling". The 0 is used
// @viewport should not be scoped.
if (!isDocumentScope(scope))
continue;
@@ -415,7 +410,7 @@ void RuleSet::addChildRules(const Vector<RefPtr<StyleRuleBase> >& rules, const M
}
}
-void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, const MediaQueryEvaluator& medium, StyleResolver* resolver, const ContainerNode* scope)
+void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, const MediaQueryEvaluator& medium, StyleResolver* resolver, const ContainerNode* scope, bool processFontFaceAndViewportRule)
{
ASSERT(sheet);
@@ -423,11 +418,11 @@ void RuleSet::addRulesFromSheet(StyleSheetContents* sheet, const MediaQueryEvalu
for (unsigned i = 0; i < importRules.size(); ++i) {
StyleRuleImport* importRule = importRules[i].get();
if (importRule->styleSheet() && (!importRule->mediaQueries() || medium.eval(importRule->mediaQueries(), resolver->viewportDependentMediaQueryResults())))
- addRulesFromSheet(importRule->styleSheet(), medium, resolver, scope);
+ addRulesFromSheet(importRule->styleSheet(), medium, resolver, scope, processFontFaceAndViewportRule);
}
bool hasDocumentSecurityOrigin = resolver && resolver->document().securityOrigin()->canRequest(sheet->baseURL());
- AddRuleFlags addRuleFlags = static_cast<AddRuleFlags>((hasDocumentSecurityOrigin ? RuleHasDocumentSecurityOrigin : 0) | (!scope ? RuleCanUseFastCheckSelector : 0));
+ AddRuleFlags addRuleFlags = static_cast<AddRuleFlags>((hasDocumentSecurityOrigin ? RuleHasDocumentSecurityOrigin : 0) | (!scope ? RuleCanUseFastCheckSelector : 0) | (processFontFaceAndViewportRule ? 0 : RuleSkipsFontFaceAndViewportRule));
addChildRules(sheet->childRules(), medium, resolver, scope, hasDocumentSecurityOrigin, addRuleFlags);
}

Powered by Google App Engine
This is Rietveld 408576698