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

Unified Diff: Source/core/dom/StyleSheetCollection.cpp

Issue 66483002: fontSelector should be reset when removing stylesheets which has @font-face rule. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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/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
« Source/core/dom/StyleSheetCollection.h ('K') | « Source/core/dom/StyleSheetCollection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698