Index: Source/core/dom/TreeScopeStyleSheetCollection.cpp |
diff --git a/Source/core/dom/TreeScopeStyleSheetCollection.cpp b/Source/core/dom/TreeScopeStyleSheetCollection.cpp |
index e53f441b87272714a1a8b1bfeb950b8e7d651263..ea7eef7709c80b88fa40a953614228201983e27e 100644 |
--- a/Source/core/dom/TreeScopeStyleSheetCollection.cpp |
+++ b/Source/core/dom/TreeScopeStyleSheetCollection.cpp |
@@ -121,24 +121,19 @@ bool TreeScopeStyleSheetCollection::activeLoadingStyleSheetLoaded(const Vector<R |
return false; |
} |
-static bool styleSheetContentsHasFontFaceRule(Vector<StyleSheetContents*> sheets) |
+static bool findFontFaceRulesFromStyleSheetContents(Vector<StyleSheetContents*> sheets, Vector<const StyleRuleFontFace*>& fontFaceRules) |
{ |
- for (unsigned i = 0; i < sheets.size(); ++i) { |
- ASSERT(sheets[i]); |
- if (sheets[i]->hasFontFaceRule()) |
- return true; |
- } |
- return false; |
-} |
+ bool hasFontFaceRule = false; |
-static bool cssStyleSheetHasFontFaceRule(const Vector<RefPtr<CSSStyleSheet> > sheets) |
-{ |
for (unsigned i = 0; i < sheets.size(); ++i) { |
ASSERT(sheets[i]); |
- if (sheets[i]->contents()->hasFontFaceRule()) |
- return true; |
+ if (sheets[i]->hasFontFaceRule()) { |
+ // FIXME: We don't need this for styles in shadow tree. |
+ sheets[i]->findFontFaceRules(fontFaceRules); |
+ hasFontFaceRule = true; |
+ } |
} |
- return false; |
+ return hasFontFaceRule; |
} |
void TreeScopeStyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateMode updateMode, const StyleSheetCollection& newCollection, StyleSheetChange& change) |
@@ -158,18 +153,10 @@ void TreeScopeStyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateM |
if (updateType != Additive) { |
change.styleResolverUpdateType = updateType; |
} else { |
- if (styleSheetContentsHasFontFaceRule(addedSheets)) { |
- change.styleResolverUpdateType = ResetStyleResolverAndFontSelector; |
+ change.styleResolverUpdateType = Reset; |
+ // If @font-face is removed, needs full style recalc. |
+ if (findFontFaceRulesFromStyleSheetContents(addedSheets, change.fontFaceRulesToRemove)) |
return; |
- } |
- // FIXME: since currently all stylesheets are re-added after reseting styleresolver, |
- // fontSelector should be always reset. After creating RuleSet for each StyleSheetContents, |
- // we can avoid appending all stylesheetcontents in reset case. |
- // So we can remove "styleSheetContentsHasFontFaceRule(newSheets)". |
- if (cssStyleSheetHasFontFaceRule(newCollection.activeAuthorStyleSheets())) |
- change.styleResolverUpdateType = ResetStyleResolverAndFontSelector; |
- else |
- change.styleResolverUpdateType = Reset; |
} |
} |