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

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

Issue 192473003: Move CSSRuleList to the garbage collected heap (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove outdated comment on CSSRule.h Created 6 years, 9 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 | Annotate | Revision Log
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 bool needsRepaint() const { return m_needsRepaint; } 64 bool needsRepaint() const { return m_needsRepaint; }
65 bool needsStyleRecalc() const { return m_needsStyleRecalc; } 65 bool needsStyleRecalc() const { return m_needsStyleRecalc; }
66 void setNeedsRepaint() { m_needsRepaint = true; } 66 void setNeedsRepaint() { m_needsRepaint = true; }
67 void setNeedsStyleRecalc() { m_needsStyleRecalc = true; } 67 void setNeedsStyleRecalc() { m_needsStyleRecalc = true; }
68 68
69 private: 69 private:
70 bool m_needsRepaint; 70 bool m_needsRepaint;
71 bool m_needsStyleRecalc; 71 bool m_needsStyleRecalc;
72 }; 72 };
73 73
74 class StyleEngine { 74 class StyleEngine : public NoBaseWillBeGarbageCollectedFinalized<StyleEngine> {
Mads Ager (chromium) 2014/03/10 12:32:57 This will lead to finalization-order issues. You n
Erik Corry 2014/03/12 10:36:41 Done.
75 WTF_MAKE_FAST_ALLOCATED; 75 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
76 public: 76 public:
77 77
78 class IgnoringPendingStylesheet : public TemporaryChange<bool> { 78 class IgnoringPendingStylesheet : public TemporaryChange<bool> {
79 public: 79 public:
80 IgnoringPendingStylesheet(StyleEngine* engine) 80 IgnoringPendingStylesheet(StyleEngine* engine)
81 : TemporaryChange<bool>(engine->m_ignorePendingStylesheets, true) 81 : TemporaryChange<bool>(engine->m_ignorePendingStylesheets, true)
82 { 82 {
83 } 83 }
84 }; 84 };
85 85
86 friend class IgnoringPendingStylesheet; 86 friend class IgnoringPendingStylesheet;
87 87
88 static PassOwnPtr<StyleEngine> create(Document& document) { return adoptPtr( new StyleEngine(document)); } 88 static PassOwnPtrWillBeRawPtr<StyleEngine> create(Document& document) { retu rn adoptPtrWillBeNoop(new StyleEngine(document)); }
89 89
90 ~StyleEngine(); 90 ~StyleEngine();
91 91
92 const Vector<RefPtr<StyleSheet> >& styleSheetsForStyleSheetList(TreeScope&); 92 const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> >& styleSheetsForStyle SheetList(TreeScope&);
93 const Vector<RefPtr<CSSStyleSheet> >& activeAuthorStyleSheets() const; 93 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& activeAuthorStyl eSheets() const;
94 94
95 const Vector<RefPtr<CSSStyleSheet> >& documentAuthorStyleSheets() const { re turn m_authorStyleSheets; } 95 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& documentAuthorSt yleSheets() const { return m_authorStyleSheets; }
96 const Vector<RefPtr<CSSStyleSheet> >& injectedAuthorStyleSheets() const; 96 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& injectedAuthorSt yleSheets() const;
97 97
98 const Vector<RefPtr<StyleSheet> > activeStyleSheetsForInspector() const; 98 const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > activeStyleSheetsFor Inspector() const;
99 99
100 void modifiedStyleSheet(StyleSheet*); 100 void modifiedStyleSheet(StyleSheet*);
101 void addStyleSheetCandidateNode(Node*, bool createdByParser); 101 void addStyleSheetCandidateNode(Node*, bool createdByParser);
102 void removeStyleSheetCandidateNode(Node*, ContainerNode* scopingNode = 0); 102 void removeStyleSheetCandidateNode(Node*, ContainerNode* scopingNode = 0);
103 void modifiedStyleSheetCandidateNode(Node*); 103 void modifiedStyleSheetCandidateNode(Node*);
104 104
105 void invalidateInjectedStyleSheetCache(); 105 void invalidateInjectedStyleSheetCache();
106 void updateInjectedStyleSheetCache() const; 106 void updateInjectedStyleSheetCache() const;
107 107
108 void addAuthorSheet(PassRefPtrWillBeRawPtr<StyleSheetContents> authorSheet); 108 void addAuthorSheet(PassRefPtrWillBeRawPtr<StyleSheetContents> authorSheet);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 void didDetach(); 177 void didDetach();
178 bool shouldClearResolver() const; 178 bool shouldClearResolver() const;
179 StyleResolverChange resolverChanged(RecalcStyleTime, StyleResolverUpdateMode ); 179 StyleResolverChange resolverChanged(RecalcStyleTime, StyleResolverUpdateMode );
180 unsigned resolverAccessCount() const; 180 unsigned resolverAccessCount() const;
181 181
182 void markDocumentDirty(); 182 void markDocumentDirty();
183 183
184 static PassRefPtr<CSSStyleSheet> createSheet(Element*, const String& text, T extPosition startPosition, bool createdByParser); 184 static PassRefPtr<CSSStyleSheet> createSheet(Element*, const String& text, T extPosition startPosition, bool createdByParser);
185 static void removeSheet(StyleSheetContents*); 185 static void removeSheet(StyleSheetContents*);
186 186
187 void trace(Visitor*);
188
187 private: 189 private:
188 StyleEngine(Document&); 190 StyleEngine(Document&);
189 191
190 TreeScopeStyleSheetCollection* ensureStyleSheetCollectionFor(TreeScope&); 192 TreeScopeStyleSheetCollection* ensureStyleSheetCollectionFor(TreeScope&);
191 TreeScopeStyleSheetCollection* styleSheetCollectionFor(TreeScope&); 193 TreeScopeStyleSheetCollection* styleSheetCollectionFor(TreeScope&);
192 bool shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdateMode); 194 bool shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdateMode);
193 195
194 void markTreeScopeDirty(TreeScope&); 196 void markTreeScopeDirty(TreeScope&);
195 197
196 bool isMaster() const { return m_isMaster; } 198 bool isMaster() const { return m_isMaster; }
(...skipping 12 matching lines...) Expand all
209 211
210 Document& m_document; 212 Document& m_document;
211 bool m_isMaster; 213 bool m_isMaster;
212 214
213 // Track the number of currently loading top-level stylesheets needed for re ndering. 215 // Track the number of currently loading top-level stylesheets needed for re ndering.
214 // Sheets loaded using the @import directive are not included in this count. 216 // Sheets loaded using the @import directive are not included in this count.
215 // We use this count of pending sheets to detect when we can begin attaching 217 // We use this count of pending sheets to detect when we can begin attaching
216 // elements and when it is safe to execute scripts. 218 // elements and when it is safe to execute scripts.
217 int m_pendingStylesheets; 219 int m_pendingStylesheets;
218 220
219 mutable Vector<RefPtr<CSSStyleSheet> > m_injectedAuthorStyleSheets; 221 mutable WillBePersistentHeapVector<RefPtrWillBeMember<CSSStyleSheet> > m_inj ectedAuthorStyleSheets;
zerny-chromium 2014/03/10 14:00:21 Why is this a persistent and not just a traced hea
Erik Corry 2014/03/12 10:36:41 fixed
220 mutable bool m_injectedStyleSheetCacheValid; 222 mutable bool m_injectedStyleSheetCacheValid;
221 223
222 Vector<RefPtr<CSSStyleSheet> > m_authorStyleSheets; 224 WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> > m_authorStyleSheets;
223 225
224 DocumentStyleSheetCollection m_documentStyleSheetCollection; 226 DocumentStyleSheetCollection m_documentStyleSheetCollection;
225 HashMap<TreeScope*, OwnPtr<TreeScopeStyleSheetCollection> > m_styleSheetColl ectionMap; 227 HashMap<TreeScope*, OwnPtr<TreeScopeStyleSheetCollection> > m_styleSheetColl ectionMap;
226 228
227 bool m_documentScopeDirty; 229 bool m_documentScopeDirty;
228 TreeScopeSet m_dirtyTreeScopes; 230 TreeScopeSet m_dirtyTreeScopes;
229 TreeScopeSet m_activeTreeScopes; 231 TreeScopeSet m_activeTreeScopes;
230 232
231 String m_preferredStylesheetSetName; 233 String m_preferredStylesheetSetName;
232 String m_selectedStylesheetSetName; 234 String m_selectedStylesheetSetName;
233 235
234 bool m_usesSiblingRules; 236 bool m_usesSiblingRules;
235 bool m_usesSiblingRulesOverride; 237 bool m_usesSiblingRulesOverride;
236 bool m_usesFirstLineRules; 238 bool m_usesFirstLineRules;
237 bool m_usesFirstLetterRules; 239 bool m_usesFirstLetterRules;
238 bool m_usesRemUnits; 240 bool m_usesRemUnits;
239 unsigned m_maxDirectAdjacentSelectors; 241 unsigned m_maxDirectAdjacentSelectors;
240 242
241 bool m_ignorePendingStylesheets; 243 bool m_ignorePendingStylesheets;
242 bool m_didCalculateResolver; 244 bool m_didCalculateResolver;
243 OwnPtr<StyleResolver> m_resolver; 245 OwnPtr<StyleResolver> m_resolver;
244 246
245 RefPtr<CSSFontSelector> m_fontSelector; 247 RefPtr<CSSFontSelector> m_fontSelector;
246 }; 248 };
247 249
248 } 250 }
249 251
250 #endif 252 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698