OLD | NEW |
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 Loading... |
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> { |
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 void detachFromDocument(); |
93 const Vector<RefPtr<CSSStyleSheet> >& activeAuthorStyleSheets() const; | |
94 | 93 |
95 const Vector<RefPtr<CSSStyleSheet> >& documentAuthorStyleSheets() const { re
turn m_authorStyleSheets; } | 94 const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> >& styleSheetsForStyle
SheetList(TreeScope&); |
96 const Vector<RefPtr<CSSStyleSheet> >& injectedAuthorStyleSheets() const; | 95 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& activeAuthorStyl
eSheets() const; |
97 | 96 |
98 const Vector<RefPtr<StyleSheet> > activeStyleSheetsForInspector() const; | 97 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& documentAuthorSt
yleSheets() const { return m_authorStyleSheets; } |
| 98 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> >& injectedAuthorSt
yleSheets() const; |
| 99 |
| 100 const WillBeHeapVector<RefPtrWillBeMember<StyleSheet> > activeStyleSheetsFor
Inspector() const; |
99 | 101 |
100 void modifiedStyleSheet(StyleSheet*); | 102 void modifiedStyleSheet(StyleSheet*); |
101 void addStyleSheetCandidateNode(Node*, bool createdByParser); | 103 void addStyleSheetCandidateNode(Node*, bool createdByParser); |
102 void removeStyleSheetCandidateNode(Node*, ContainerNode* scopingNode = 0); | 104 void removeStyleSheetCandidateNode(Node*, ContainerNode* scopingNode = 0); |
103 void modifiedStyleSheetCandidateNode(Node*); | 105 void modifiedStyleSheetCandidateNode(Node*); |
104 | 106 |
105 void invalidateInjectedStyleSheetCache(); | 107 void invalidateInjectedStyleSheetCache(); |
106 void updateInjectedStyleSheetCache() const; | 108 void updateInjectedStyleSheetCache() const; |
107 | 109 |
108 void addAuthorSheet(PassRefPtrWillBeRawPtr<StyleSheetContents> authorSheet); | 110 void addAuthorSheet(PassRefPtrWillBeRawPtr<StyleSheetContents> authorSheet); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 void didDetach(); | 179 void didDetach(); |
178 bool shouldClearResolver() const; | 180 bool shouldClearResolver() const; |
179 StyleResolverChange resolverChanged(RecalcStyleTime, StyleResolverUpdateMode
); | 181 StyleResolverChange resolverChanged(RecalcStyleTime, StyleResolverUpdateMode
); |
180 unsigned resolverAccessCount() const; | 182 unsigned resolverAccessCount() const; |
181 | 183 |
182 void markDocumentDirty(); | 184 void markDocumentDirty(); |
183 | 185 |
184 static PassRefPtr<CSSStyleSheet> createSheet(Element*, const String& text, T
extPosition startPosition, bool createdByParser); | 186 static PassRefPtr<CSSStyleSheet> createSheet(Element*, const String& text, T
extPosition startPosition, bool createdByParser); |
185 static void removeSheet(StyleSheetContents*); | 187 static void removeSheet(StyleSheetContents*); |
186 | 188 |
| 189 void trace(Visitor*); |
| 190 |
187 private: | 191 private: |
188 StyleEngine(Document&); | 192 StyleEngine(Document&); |
189 | 193 |
190 TreeScopeStyleSheetCollection* ensureStyleSheetCollectionFor(TreeScope&); | 194 TreeScopeStyleSheetCollection* ensureStyleSheetCollectionFor(TreeScope&); |
191 TreeScopeStyleSheetCollection* styleSheetCollectionFor(TreeScope&); | 195 TreeScopeStyleSheetCollection* styleSheetCollectionFor(TreeScope&); |
192 bool shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdateMode); | 196 bool shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdateMode); |
193 | 197 |
194 void markTreeScopeDirty(TreeScope&); | 198 void markTreeScopeDirty(TreeScope&); |
195 | 199 |
196 bool isMaster() const { return m_isMaster; } | 200 bool isMaster() const { return m_isMaster; } |
(...skipping 12 matching lines...) Expand all Loading... |
209 | 213 |
210 Document& m_document; | 214 Document& m_document; |
211 bool m_isMaster; | 215 bool m_isMaster; |
212 | 216 |
213 // Track the number of currently loading top-level stylesheets needed for re
ndering. | 217 // 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. | 218 // 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 | 219 // We use this count of pending sheets to detect when we can begin attaching |
216 // elements and when it is safe to execute scripts. | 220 // elements and when it is safe to execute scripts. |
217 int m_pendingStylesheets; | 221 int m_pendingStylesheets; |
218 | 222 |
219 mutable Vector<RefPtr<CSSStyleSheet> > m_injectedAuthorStyleSheets; | 223 mutable WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> > m_injectedAutho
rStyleSheets; |
220 mutable bool m_injectedStyleSheetCacheValid; | 224 mutable bool m_injectedStyleSheetCacheValid; |
221 | 225 |
222 Vector<RefPtr<CSSStyleSheet> > m_authorStyleSheets; | 226 WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet> > m_authorStyleSheets; |
223 | 227 |
224 DocumentStyleSheetCollection m_documentStyleSheetCollection; | 228 DocumentStyleSheetCollection m_documentStyleSheetCollection; |
225 HashMap<TreeScope*, OwnPtr<TreeScopeStyleSheetCollection> > m_styleSheetColl
ectionMap; | 229 HashMap<TreeScope*, OwnPtr<TreeScopeStyleSheetCollection> > m_styleSheetColl
ectionMap; |
226 | 230 |
227 bool m_documentScopeDirty; | 231 bool m_documentScopeDirty; |
228 TreeScopeSet m_dirtyTreeScopes; | 232 TreeScopeSet m_dirtyTreeScopes; |
229 TreeScopeSet m_activeTreeScopes; | 233 TreeScopeSet m_activeTreeScopes; |
230 | 234 |
231 String m_preferredStylesheetSetName; | 235 String m_preferredStylesheetSetName; |
232 String m_selectedStylesheetSetName; | 236 String m_selectedStylesheetSetName; |
233 | 237 |
234 bool m_usesSiblingRules; | 238 bool m_usesSiblingRules; |
235 bool m_usesSiblingRulesOverride; | 239 bool m_usesSiblingRulesOverride; |
236 bool m_usesFirstLineRules; | 240 bool m_usesFirstLineRules; |
237 bool m_usesFirstLetterRules; | 241 bool m_usesFirstLetterRules; |
238 bool m_usesRemUnits; | 242 bool m_usesRemUnits; |
239 unsigned m_maxDirectAdjacentSelectors; | 243 unsigned m_maxDirectAdjacentSelectors; |
240 | 244 |
241 bool m_ignorePendingStylesheets; | 245 bool m_ignorePendingStylesheets; |
242 bool m_didCalculateResolver; | 246 bool m_didCalculateResolver; |
243 OwnPtr<StyleResolver> m_resolver; | 247 OwnPtr<StyleResolver> m_resolver; |
244 | 248 |
245 RefPtr<CSSFontSelector> m_fontSelector; | 249 RefPtr<CSSFontSelector> m_fontSelector; |
246 }; | 250 }; |
247 | 251 |
248 } | 252 } |
249 | 253 |
250 #endif | 254 #endif |
OLD | NEW |