Index: third_party/WebKit/Source/core/dom/StyleEngine.cpp |
diff --git a/third_party/WebKit/Source/core/dom/StyleEngine.cpp b/third_party/WebKit/Source/core/dom/StyleEngine.cpp |
index bf671333e975d391cfe623922caf6ceff93347f2..6164c458ac8c8edd982872412c36bd472440d274 100644 |
--- a/third_party/WebKit/Source/core/dom/StyleEngine.cpp |
+++ b/third_party/WebKit/Source/core/dom/StyleEngine.cpp |
@@ -121,23 +121,40 @@ TreeScopeStyleSheetCollection* StyleEngine::StyleSheetCollectionFor( |
const HeapVector<TraceWrapperMember<StyleSheet>>& |
StyleEngine::StyleSheetsForStyleSheetList(TreeScope& tree_scope) { |
- // TODO(rune@opera.com): we could split styleSheets and active stylesheet |
- // update to have a lighter update while accessing the styleSheets list. |
DCHECK(Master()); |
if (Master()->IsActive()) { |
- if (IsMaster()) |
+ if (IsMaster()) { |
+ // TODO(rune@opera.com): Replace with UpdateStyleSheetList(). |
UpdateActiveStyle(); |
- else |
- Master()->GetStyleEngine().UpdateActiveStyle(); |
+ } else { |
+ UpdateStyleSheetList(tree_scope); |
+ } |
} |
if (tree_scope == document_) |
return GetDocumentStyleSheetCollection().StyleSheetsForStyleSheetList(); |
+ DCHECK(IsMaster()); |
return EnsureStyleSheetCollectionFor(tree_scope) |
->StyleSheetsForStyleSheetList(); |
} |
+void StyleEngine::UpdateStyleSheetList(TreeScope& tree_scope) { |
+ // TODO(rune@opera.com): currently only for import documents. |
+ DCHECK(!IsMaster()); |
+ DCHECK(tree_scope.GetDocument() == GetDocument()); |
+ |
+ if (tree_scope != GetDocument()) |
+ return; |
+ if (!ShouldUpdateDocumentStyleSheetCollection()) |
+ return; |
+ |
+ GetDocumentStyleSheetCollection().CollectStyleSheetsForList(); |
+ // Avoid updating the styleSheets list repeatedly. Only safe for imports. |
+ document_scope_dirty_ = false; |
+ DCHECK(!all_tree_scopes_dirty_); |
+} |
+ |
void StyleEngine::InjectAuthorSheet(StyleSheetContents* author_sheet) { |
injected_author_style_sheets_.push_back(TraceWrapperMember<CSSStyleSheet>( |
this, CSSStyleSheet::Create(author_sheet, *document_))); |