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

Side by Side Diff: Source/core/dom/StyleEngine.h

Issue 1162533005: Stop sorting StyleEngine::m_activeTreeScopes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | Source/core/dom/StyleEngine.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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, 2010, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
9 * Copyright (C) 2011 Google Inc. All rights reserved. 9 * Copyright (C) 2011 Google Inc. All rights reserved.
10 * 10 *
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 void markTreeScopeDirty(TreeScope&); 194 void markTreeScopeDirty(TreeScope&);
195 195
196 bool isMaster() const { return m_isMaster; } 196 bool isMaster() const { return m_isMaster; }
197 Document* master(); 197 Document* master();
198 Document& document() const { return *m_document; } 198 Document& document() const { return *m_document; }
199 199
200 void scheduleInvalidationSetsForElement(const InvalidationSetVector&, Elemen t&); 200 void scheduleInvalidationSetsForElement(const InvalidationSetVector&, Elemen t&);
201 201
202 typedef WillBeHeapHashSet<RawPtrWillBeMember<TreeScope>> UnorderedTreeScopeS et; 202 typedef WillBeHeapHashSet<RawPtrWillBeMember<TreeScope>> UnorderedTreeScopeS et;
203 203
204 // A class which holds document-ordered treescopes which have stylesheets. 204 void clearMediaQueryRuleSetOnTreeScopeStyleSheets(UnorderedTreeScopeSet&);
205 // ListHashSet allows only sequential access, not random access.
206 // So it gets slow when the size of treescopes gets larger when finding
207 // the best place to insert a treescope into the document-ordered
208 // treescopes (requires linear search).
209 // To solve this, use a vector for the document-ordered treescopes and
210 // use a hashset for quickly checking whether a given treescope is
211 // in the document-ordered treescopes or not.
212 class OrderedTreeScopeSet final {
213 DISALLOW_ALLOCATION();
214 WTF_MAKE_NONCOPYABLE(OrderedTreeScopeSet);
215 public:
216 OrderedTreeScopeSet() { }
217
218 void insert(TreeScope*);
219 void remove(TreeScope*);
220
221 // When we don't need to consider document-order, use this iterator.
222 // Otherwise, use [] operator.
223 UnorderedTreeScopeSet::iterator beginUnordered() { return m_hash.begin() ; }
224 UnorderedTreeScopeSet::iterator endUnordered() { return m_hash.end(); }
225
226 bool isEmpty() const { return m_treeScopes.isEmpty(); }
227 void clear()
228 {
229 m_treeScopes.clear();
230 m_hash.clear();
231 }
232
233 size_t size() const { return m_treeScopes.size(); }
234
235 TreeScope* operator[](size_t i) { return m_treeScopes[i]; }
236 const TreeScope* operator[](size_t i) const { return m_treeScopes[i]; }
237
238 DECLARE_TRACE();
239
240 private:
241 WillBeHeapVector<RawPtrWillBeMember<TreeScope>, 16> m_treeScopes;
242 UnorderedTreeScopeSet m_hash;
243 };
244
245 static void insertTreeScopeInDocumentOrder(OrderedTreeScopeSet&, TreeScope*) ;
246 void clearMediaQueryRuleSetOnTreeScopeStyleSheets(UnorderedTreeScopeSet::ite rator begin, UnorderedTreeScopeSet::iterator end);
247 205
248 void createResolver(); 206 void createResolver();
249 207
250 static PassRefPtrWillBeRawPtr<CSSStyleSheet> parseSheet(Element*, const Stri ng& text, TextPosition startPosition, bool createdByParser); 208 static PassRefPtrWillBeRawPtr<CSSStyleSheet> parseSheet(Element*, const Stri ng& text, TextPosition startPosition, bool createdByParser);
251 209
252 const DocumentStyleSheetCollection* documentStyleSheetCollection() const 210 const DocumentStyleSheetCollection* documentStyleSheetCollection() const
253 { 211 {
254 return m_documentStyleSheetCollection.get(); 212 return m_documentStyleSheetCollection.get();
255 } 213 }
256 214
(...skipping 15 matching lines...) Expand all
272 230
273 WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>> m_authorStyleSheets; 231 WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>> m_authorStyleSheets;
274 232
275 OwnPtrWillBeMember<DocumentStyleSheetCollection> m_documentStyleSheetCollect ion; 233 OwnPtrWillBeMember<DocumentStyleSheetCollection> m_documentStyleSheetCollect ion;
276 234
277 typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<TreeScope>, OwnPtrWillBeMem ber<ShadowTreeStyleSheetCollection>> StyleSheetCollectionMap; 235 typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<TreeScope>, OwnPtrWillBeMem ber<ShadowTreeStyleSheetCollection>> StyleSheetCollectionMap;
278 StyleSheetCollectionMap m_styleSheetCollectionMap; 236 StyleSheetCollectionMap m_styleSheetCollectionMap;
279 237
280 bool m_documentScopeDirty; 238 bool m_documentScopeDirty;
281 UnorderedTreeScopeSet m_dirtyTreeScopes; 239 UnorderedTreeScopeSet m_dirtyTreeScopes;
282 OrderedTreeScopeSet m_activeTreeScopes; 240 UnorderedTreeScopeSet m_activeTreeScopes;
283 241
284 String m_preferredStylesheetSetName; 242 String m_preferredStylesheetSetName;
285 String m_selectedStylesheetSetName; 243 String m_selectedStylesheetSetName;
286 244
287 bool m_usesSiblingRules; 245 bool m_usesSiblingRules;
288 bool m_usesFirstLineRules; 246 bool m_usesFirstLineRules;
289 bool m_usesWindowInactiveSelector; 247 bool m_usesWindowInactiveSelector;
290 bool m_usesRemUnits; 248 bool m_usesRemUnits;
291 unsigned m_maxDirectAdjacentSelectors; 249 unsigned m_maxDirectAdjacentSelectors;
292 250
293 bool m_ignorePendingStylesheets; 251 bool m_ignorePendingStylesheets;
294 bool m_didCalculateResolver; 252 bool m_didCalculateResolver;
295 OwnPtrWillBeMember<StyleResolver> m_resolver; 253 OwnPtrWillBeMember<StyleResolver> m_resolver;
296 StyleInvalidator m_styleInvalidator; 254 StyleInvalidator m_styleInvalidator;
297 255
298 RefPtrWillBeMember<CSSFontSelector> m_fontSelector; 256 RefPtrWillBeMember<CSSFontSelector> m_fontSelector;
299 257
300 WillBeHeapHashMap<AtomicString, RawPtrWillBeMember<StyleSheetContents>> m_te xtToSheetCache; 258 WillBeHeapHashMap<AtomicString, RawPtrWillBeMember<StyleSheetContents>> m_te xtToSheetCache;
301 WillBeHeapHashMap<RawPtrWillBeMember<StyleSheetContents>, AtomicString> m_sh eetToTextCache; 259 WillBeHeapHashMap<RawPtrWillBeMember<StyleSheetContents>, AtomicString> m_sh eetToTextCache;
302 }; 260 };
303 261
304 } 262 }
305 263
306 #endif 264 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/StyleEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698