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

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

Issue 27537009: Avoid always style recalc when removing stylesheets. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 months 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 242ccf6de6323bbf40aeae38fc8e11c2f5db57f6..ff87dd8405e2c58b03f17a1c7cd857d4032a7961 100644
--- a/Source/core/dom/StyleSheetCollection.cpp
+++ b/Source/core/dom/StyleSheetCollection.cpp
@@ -77,11 +77,9 @@ void StyleSheetCollection::removeStyleSheetCandidateNode(Node* node, ContainerNo
StyleSheetCollection::StyleResolverUpdateType StyleSheetCollection::compareStyleSheets(const Vector<RefPtr<CSSStyleSheet> >& oldStyleSheets, const Vector<RefPtr<CSSStyleSheet> >& newStylesheets, Vector<StyleSheetContents*>& addedSheets)
{
- // Find out which stylesheets are new.
unsigned newStylesheetCount = newStylesheets.size();
unsigned oldStylesheetCount = oldStyleSheets.size();
- if (newStylesheetCount < oldStylesheetCount)
- return Reconstruct;
+ ASSERT(newStylesheetCount >= oldStylesheetCount);
unsigned newIndex = 0;
for (unsigned oldIndex = 0; oldIndex < oldStylesheetCount; ++oldIndex) {
@@ -137,7 +135,12 @@ void StyleSheetCollection::analyzeStyleSheetChange(StyleResolverUpdateMode updat
// Find out which stylesheets are new.
Vector<StyleSheetContents*> addedSheets;
- styleResolverUpdateType = compareStyleSheets(oldStyleSheets, newStyleSheets, addedSheets);
+ if (oldStyleSheets.size() <= newStyleSheets.size()) {
+ styleResolverUpdateType = compareStyleSheets(oldStyleSheets, newStyleSheets, addedSheets);
+ } else {
+ StyleResolverUpdateType updateType = compareStyleSheets(newStyleSheets, oldStyleSheets, addedSheets);
+ styleResolverUpdateType = updateType != Additive ? updateType : Reset;
+ }
// FIXME: If styleResolverUpdateType is still Reconstruct, we could return early here
// as destroying the StyleResolver will recalc the whole document anyway?

Powered by Google App Engine
This is Rietveld 408576698