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

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

Issue 82583005: Use removeFontFace to avoid resetting fontSelector. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added 2 layout tests Created 7 years 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 cb944d876ee9af4f69910edc711a3e9dab4d2b3b..7a6f1dd5445e9c237699b150bc21e20d077ce82c 100644
--- a/Source/core/dom/StyleSheetCollection.cpp
+++ b/Source/core/dom/StyleSheetCollection.cpp
@@ -152,24 +152,19 @@ bool StyleSheetCollection::activeLoadingStyleSheetLoaded(const Vector<RefPtr<CSS
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 StyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateMode updateMode, const StyleSheetCollectionBase& newCollection, StyleSheetChange& change)
@@ -189,18 +184,10 @@ void StyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateMode updat
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;
}
}

Powered by Google App Engine
This is Rietveld 408576698