Index: Source/core/dom/StyleSheetCollection.cpp |
diff --git a/Source/core/dom/StyleSheetCollection.cpp b/Source/core/dom/StyleSheetCollection.cpp |
index ff87dd8405e2c58b03f17a1c7cd857d4032a7961..5805d818e2fe89c1e5a331a8e1b435d2b5579f93 100644 |
--- a/Source/core/dom/StyleSheetCollection.cpp |
+++ b/Source/core/dom/StyleSheetCollection.cpp |
@@ -29,6 +29,7 @@ |
#include "core/css/CSSStyleSheet.h" |
#include "core/css/StyleInvalidationAnalysis.h" |
+#include "core/css/StyleRuleImport.h" |
#include "core/css/StyleSheetContents.h" |
#include "core/css/resolver/StyleResolver.h" |
#include "core/dom/Document.h" |
@@ -120,10 +121,47 @@ bool StyleSheetCollection::activeLoadingStyleSheetLoaded(const Vector<RefPtr<CSS |
return false; |
} |
-void StyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateMode updateMode, const Vector<RefPtr<CSSStyleSheet> >& oldStyleSheets, const Vector<RefPtr<CSSStyleSheet> >& newStyleSheets, StyleResolverUpdateType& styleResolverUpdateType, bool& requiresFullStyleRecalc) |
+static bool rulesHaveFontFaceRule(const Vector<RefPtr<StyleRuleBase> >& rules) |
+{ |
+ for (unsigned i = 0; i < rules.size(); ++i) { |
+ StyleRuleBase* rule = rules[i].get(); |
+ ASSERT(rule); |
+ if (rule->isFontFaceRule()) |
+ return true; |
+ } |
+ return false; |
+} |
+ |
+static bool styleSheetContentsHasFontFaceRule(StyleSheetContents* sheet) |
+{ |
+ if (!sheet) |
+ return false; |
+ |
+ if (sheet->importRules().size() > 0) { |
+ const Vector<RefPtr<StyleRuleImport> >& importRules = sheet->importRules(); |
+ for (unsigned i = 0; i < importRules.size(); ++i) { |
+ StyleRuleImport* importRule = importRules[i].get(); |
+ if (styleSheetContentsHasFontFaceRule(importRule->styleSheet())) |
+ return true; |
+ } |
+ } |
+ return rulesHaveFontFaceRule(sheet->childRules()); |
+} |
+ |
+static bool styleSheetContentsHasFontFaceRule(Vector<StyleSheetContents*> sheets) |
+{ |
+ for (unsigned i = 0; i < sheets.size(); ++i) { |
+ if (styleSheetContentsHasFontFaceRule(sheets[i])) |
+ return true; |
+ } |
+ return false; |
+} |
+ |
+void StyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateMode updateMode, const Vector<RefPtr<CSSStyleSheet> >& oldStyleSheets, const Vector<RefPtr<CSSStyleSheet> >& newStyleSheets, StyleResolverUpdateType& styleResolverUpdateType, bool& requiresFullStyleRecalc, bool& requiresResetFontSelector) |
{ |
styleResolverUpdateType = Reconstruct; |
requiresFullStyleRecalc = true; |
+ requiresResetFontSelector = true; |
if (activeLoadingStyleSheetLoaded(newStyleSheets)) |
return; |
@@ -137,9 +175,11 @@ void StyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateMode updat |
Vector<StyleSheetContents*> addedSheets; |
if (oldStyleSheets.size() <= newStyleSheets.size()) { |
styleResolverUpdateType = compareStyleSheets(oldStyleSheets, newStyleSheets, addedSheets); |
+ requiresResetFontSelector = false; |
} else { |
StyleResolverUpdateType updateType = compareStyleSheets(newStyleSheets, oldStyleSheets, addedSheets); |
styleResolverUpdateType = updateType != Additive ? updateType : Reset; |
+ requiresResetFontSelector = updateType != Additive ? true : styleSheetContentsHasFontFaceRule(addedSheets); |
dglazkov
2013/11/08 18:05:34
I am not super-thrilled about adding this recursiv
tasak
2013/11/12 04:13:11
Done.
|
} |
// FIXME: If styleResolverUpdateType is still Reconstruct, we could return early here |