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

Side by Side Diff: third_party/WebKit/Source/core/dom/StyleEngine.cpp

Issue 2880303002: Update styleSheets list in import without active style update. (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 StyleSheetCollectionMap::iterator it = 115 StyleSheetCollectionMap::iterator it =
116 style_sheet_collection_map_.find(&tree_scope); 116 style_sheet_collection_map_.find(&tree_scope);
117 if (it == style_sheet_collection_map_.end()) 117 if (it == style_sheet_collection_map_.end())
118 return nullptr; 118 return nullptr;
119 return it->value.Get(); 119 return it->value.Get();
120 } 120 }
121 121
122 const HeapVector<TraceWrapperMember<StyleSheet>>& 122 const HeapVector<TraceWrapperMember<StyleSheet>>&
123 StyleEngine::StyleSheetsForStyleSheetList(TreeScope& tree_scope) { 123 StyleEngine::StyleSheetsForStyleSheetList(TreeScope& tree_scope) {
124 // TODO(rune@opera.com): we could split styleSheets and active stylesheet
125 // update to have a lighter update while accessing the styleSheets list.
126 DCHECK(Master()); 124 DCHECK(Master());
127 if (Master()->IsActive()) { 125 if (Master()->IsActive()) {
128 if (IsMaster()) 126 if (IsMaster()) {
127 // TODO(rune@opera.com): Replace with UpdateStyleSheetList().
129 UpdateActiveStyle(); 128 UpdateActiveStyle();
130 else 129 } else {
131 Master()->GetStyleEngine().UpdateActiveStyle(); 130 UpdateStyleSheetList(tree_scope);
131 }
132 } 132 }
133 133
134 if (tree_scope == document_) 134 if (tree_scope == document_)
135 return GetDocumentStyleSheetCollection().StyleSheetsForStyleSheetList(); 135 return GetDocumentStyleSheetCollection().StyleSheetsForStyleSheetList();
136 136
137 DCHECK(IsMaster());
137 return EnsureStyleSheetCollectionFor(tree_scope) 138 return EnsureStyleSheetCollectionFor(tree_scope)
138 ->StyleSheetsForStyleSheetList(); 139 ->StyleSheetsForStyleSheetList();
139 } 140 }
140 141
142 void StyleEngine::UpdateStyleSheetList(TreeScope& tree_scope) {
143 // TODO(rune@opera.com): currently only for import documents.
144 DCHECK(!IsMaster());
145 DCHECK(tree_scope.GetDocument() == GetDocument());
146
147 if (tree_scope != GetDocument())
148 return;
149 if (!ShouldUpdateDocumentStyleSheetCollection())
150 return;
151
152 GetDocumentStyleSheetCollection().CollectStyleSheetsForList();
153 // Avoid updating the styleSheets list repeatedly. Only safe for imports.
154 document_scope_dirty_ = false;
155 DCHECK(!all_tree_scopes_dirty_);
156 }
157
141 void StyleEngine::InjectAuthorSheet(StyleSheetContents* author_sheet) { 158 void StyleEngine::InjectAuthorSheet(StyleSheetContents* author_sheet) {
142 injected_author_style_sheets_.push_back(TraceWrapperMember<CSSStyleSheet>( 159 injected_author_style_sheets_.push_back(TraceWrapperMember<CSSStyleSheet>(
143 this, CSSStyleSheet::Create(author_sheet, *document_))); 160 this, CSSStyleSheet::Create(author_sheet, *document_)));
144 MarkDocumentDirty(); 161 MarkDocumentDirty();
145 } 162 }
146 163
147 CSSStyleSheet& StyleEngine::EnsureInspectorStyleSheet() { 164 CSSStyleSheet& StyleEngine::EnsureInspectorStyleSheet() {
148 if (inspector_style_sheet_) 165 if (inspector_style_sheet_)
149 return *inspector_style_sheet_; 166 return *inspector_style_sheet_;
150 167
(...skipping 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
1208 } 1225 }
1209 1226
1210 DEFINE_TRACE_WRAPPERS(StyleEngine) { 1227 DEFINE_TRACE_WRAPPERS(StyleEngine) {
1211 for (auto sheet : injected_author_style_sheets_) { 1228 for (auto sheet : injected_author_style_sheets_) {
1212 visitor->TraceWrappers(sheet); 1229 visitor->TraceWrappers(sheet);
1213 } 1230 }
1214 visitor->TraceWrappers(document_style_sheet_collection_); 1231 visitor->TraceWrappers(document_style_sheet_collection_);
1215 } 1232 }
1216 1233
1217 } // namespace blink 1234 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/StyleEngine.h ('k') | third_party/WebKit/Source/core/dom/TreeScopeStyleSheetCollection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698