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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 | 74 |
75 #if !ENABLE(OILPAN) | 75 #if !ENABLE(OILPAN) |
76 void detachFromDocument(); | 76 void detachFromDocument(); |
77 #endif | 77 #endif |
78 | 78 |
79 const WillBeHeapVector<RefPtrWillBeMember<StyleSheet>>& styleSheetsForStyleS heetList(TreeScope&); | 79 const WillBeHeapVector<RefPtrWillBeMember<StyleSheet>>& styleSheetsForStyleS heetList(TreeScope&); |
80 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>>& activeAuthorStyle Sheets() const; | 80 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>>& activeAuthorStyle Sheets() const; |
81 | 81 |
82 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>>& documentAuthorSty leSheets() const { return m_authorStyleSheets; } | 82 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>>& documentAuthorSty leSheets() const { return m_authorStyleSheets; } |
83 | 83 |
84 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>> activeStyleSheetsF orInspector() const; | 84 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>> activeStyleSheetsF orInspector(); |
kochi
2015/05/26 01:52:34
Why unconst'ing is necessary here?
kojii
2015/05/26 05:21:58
Original code was using const_cast(), and this pat
| |
85 | 85 |
86 void modifiedStyleSheet(StyleSheet*); | 86 void modifiedStyleSheet(StyleSheet*); |
87 void addStyleSheetCandidateNode(Node*, bool createdByParser); | 87 void addStyleSheetCandidateNode(Node*, bool createdByParser); |
88 void removeStyleSheetCandidateNode(Node*); | 88 void removeStyleSheetCandidateNode(Node*); |
89 void removeStyleSheetCandidateNode(Node*, TreeScope&); | 89 void removeStyleSheetCandidateNode(Node*, TreeScope&); |
90 void modifiedStyleSheetCandidateNode(Node*); | 90 void modifiedStyleSheetCandidateNode(Node*); |
91 void setExitTransitionStylesheetsEnabled(bool); | 91 void setExitTransitionStylesheetsEnabled(bool); |
92 | 92 |
93 void addAuthorSheet(PassRefPtrWillBeRawPtr<StyleSheetContents> authorSheet); | 93 void addAuthorSheet(PassRefPtrWillBeRawPtr<StyleSheetContents> authorSheet); |
94 | 94 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 DECLARE_VIRTUAL_TRACE(); | 183 DECLARE_VIRTUAL_TRACE(); |
184 | 184 |
185 private: | 185 private: |
186 // CSSFontSelectorClient implementation. | 186 // CSSFontSelectorClient implementation. |
187 virtual void fontsNeedUpdate(CSSFontSelector*) override; | 187 virtual void fontsNeedUpdate(CSSFontSelector*) override; |
188 | 188 |
189 private: | 189 private: |
190 StyleEngine(Document&); | 190 StyleEngine(Document&); |
191 | 191 |
192 TreeScopeStyleSheetCollection* ensureStyleSheetCollectionFor(TreeScope&); | 192 TreeScopeStyleSheetCollection* ensureStyleSheetCollectionFor(TreeScope&); |
193 public: | |
193 TreeScopeStyleSheetCollection* styleSheetCollectionFor(TreeScope&); | 194 TreeScopeStyleSheetCollection* styleSheetCollectionFor(TreeScope&); |
kochi
2015/05/26 01:52:34
Please append this declaration to public: section
kojii
2015/05/26 05:21:58
Done.
| |
195 private: | |
194 bool shouldUpdateDocumentStyleSheetCollection(StyleResolverUpdateMode) const ; | 196 bool shouldUpdateDocumentStyleSheetCollection(StyleResolverUpdateMode) const ; |
195 bool shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdateMode) con st; | 197 bool shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdateMode) con st; |
196 | 198 |
197 void markTreeScopeDirty(TreeScope&); | 199 void markTreeScopeDirty(TreeScope&); |
198 | 200 |
199 bool isMaster() const { return m_isMaster; } | 201 bool isMaster() const { return m_isMaster; } |
200 Document* master(); | 202 Document* master(); |
201 Document& document() const { return *m_document; } | 203 Document& document() const { return *m_document; } |
202 | 204 |
203 void scheduleInvalidationSetsForElement(const InvalidationSetVector&, Elemen t&); | 205 void scheduleInvalidationSetsForElement(const InvalidationSetVector&, Elemen t&); |
204 | 206 |
205 typedef WillBeHeapHashSet<RawPtrWillBeMember<TreeScope>> UnorderedTreeScopeS et; | |
206 | |
207 // A class which holds document-ordered treescopes which have stylesheets. | |
208 // ListHashSet allows only sequential access, not random access. | |
209 // So it gets slow when the size of treescopes gets larger when finding | |
210 // the best place to insert a treescope into the document-ordered | |
211 // treescopes (requires linear search). | |
212 // To solve this, use a vector for the document-ordered treescopes and | |
213 // use a hashset for quickly checking whether a given treescope is | |
214 // in the document-ordered treescopes or not. | |
215 class OrderedTreeScopeSet final { | |
216 DISALLOW_ALLOCATION(); | |
217 WTF_MAKE_NONCOPYABLE(OrderedTreeScopeSet); | |
218 public: | |
219 OrderedTreeScopeSet() { } | |
220 | |
221 void insert(TreeScope*); | |
222 void remove(TreeScope*); | |
223 | |
224 // When we don't need to consider document-order, use this iterator. | |
225 // Otherwise, use [] operator. | |
226 UnorderedTreeScopeSet::iterator beginUnordered() { return m_hash.begin() ; } | |
227 UnorderedTreeScopeSet::iterator endUnordered() { return m_hash.end(); } | |
228 | |
229 bool isEmpty() const { return m_treeScopes.isEmpty(); } | |
230 void clear() | |
231 { | |
232 m_treeScopes.clear(); | |
233 m_hash.clear(); | |
234 } | |
235 | |
236 size_t size() const { return m_treeScopes.size(); } | |
237 | |
238 TreeScope* operator[](size_t i) { return m_treeScopes[i]; } | |
239 const TreeScope* operator[](size_t i) const { return m_treeScopes[i]; } | |
240 | |
241 DECLARE_TRACE(); | |
242 | |
243 private: | |
244 WillBeHeapVector<RawPtrWillBeMember<TreeScope>, 16> m_treeScopes; | |
245 UnorderedTreeScopeSet m_hash; | |
246 }; | |
247 | |
248 static void insertTreeScopeInDocumentOrder(OrderedTreeScopeSet&, TreeScope*) ; | |
249 void clearMediaQueryRuleSetOnTreeScopeStyleSheets(UnorderedTreeScopeSet::ite rator begin, UnorderedTreeScopeSet::iterator end); | |
250 | |
251 void createResolver(); | 207 void createResolver(); |
252 | 208 |
253 static PassRefPtrWillBeRawPtr<CSSStyleSheet> parseSheet(Element*, const Stri ng& text, TextPosition startPosition, bool createdByParser); | 209 static PassRefPtrWillBeRawPtr<CSSStyleSheet> parseSheet(Element*, const Stri ng& text, TextPosition startPosition, bool createdByParser); |
254 | 210 |
255 const DocumentStyleSheetCollection* documentStyleSheetCollection() const | 211 const DocumentStyleSheetCollection* documentStyleSheetCollection() const |
256 { | 212 { |
257 return m_documentStyleSheetCollection.get(); | 213 return m_documentStyleSheetCollection.get(); |
258 } | 214 } |
259 | 215 |
260 DocumentStyleSheetCollection* documentStyleSheetCollection() | 216 DocumentStyleSheetCollection* documentStyleSheetCollection() |
261 { | 217 { |
262 return m_documentStyleSheetCollection.get(); | 218 return m_documentStyleSheetCollection.get(); |
263 } | 219 } |
264 | 220 |
265 void updateActiveStyleSheetsInShadow(StyleResolverUpdateMode, TreeScope*, Un orderedTreeScopeSet& treeScopesRemoved); | 221 void updateActiveStyleSheetsInShadow(StyleResolverUpdateMode, TreeScope*, Tr eeScope::UnorderedTreeScopeSet& treeScopesRemoved); |
266 | 222 |
267 RawPtrWillBeMember<Document> m_document; | 223 RawPtrWillBeMember<Document> m_document; |
268 bool m_isMaster; | 224 bool m_isMaster; |
269 | 225 |
270 // Track the number of currently loading top-level stylesheets needed for la yout. | 226 // Track the number of currently loading top-level stylesheets needed for la yout. |
271 // Sheets loaded using the @import directive are not included in this count. | 227 // Sheets loaded using the @import directive are not included in this count. |
272 // We use this count of pending sheets to detect when we can begin attaching | 228 // We use this count of pending sheets to detect when we can begin attaching |
273 // elements and when it is safe to execute scripts. | 229 // elements and when it is safe to execute scripts. |
274 int m_pendingStylesheets; | 230 int m_pendingStylesheets; |
275 | 231 |
276 WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>> m_authorStyleSheets; | 232 WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>> m_authorStyleSheets; |
277 | 233 |
278 OwnPtrWillBeMember<DocumentStyleSheetCollection> m_documentStyleSheetCollect ion; | 234 OwnPtrWillBeMember<DocumentStyleSheetCollection> m_documentStyleSheetCollect ion; |
279 | 235 |
280 typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<TreeScope>, OwnPtrWillBeMem ber<ShadowTreeStyleSheetCollection>> StyleSheetCollectionMap; | 236 typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<TreeScope>, OwnPtrWillBeMem ber<ShadowTreeStyleSheetCollection>> StyleSheetCollectionMap; |
281 StyleSheetCollectionMap m_styleSheetCollectionMap; | 237 StyleSheetCollectionMap m_styleSheetCollectionMap; |
282 | 238 |
283 bool m_documentScopeDirty; | 239 bool m_documentScopeDirty; |
284 UnorderedTreeScopeSet m_dirtyTreeScopes; | 240 TreeScope::UnorderedTreeScopeSet m_dirtyTreeScopes; |
285 OrderedTreeScopeSet m_activeTreeScopes; | |
286 | 241 |
287 String m_preferredStylesheetSetName; | 242 String m_preferredStylesheetSetName; |
288 String m_selectedStylesheetSetName; | 243 String m_selectedStylesheetSetName; |
289 | 244 |
290 bool m_usesSiblingRules; | 245 bool m_usesSiblingRules; |
291 bool m_usesFirstLineRules; | 246 bool m_usesFirstLineRules; |
292 bool m_usesWindowInactiveSelector; | 247 bool m_usesWindowInactiveSelector; |
293 bool m_usesFirstLetterRules; | 248 bool m_usesFirstLetterRules; |
294 bool m_usesRemUnits; | 249 bool m_usesRemUnits; |
295 unsigned m_maxDirectAdjacentSelectors; | 250 unsigned m_maxDirectAdjacentSelectors; |
296 | 251 |
297 bool m_ignorePendingStylesheets; | 252 bool m_ignorePendingStylesheets; |
298 bool m_didCalculateResolver; | 253 bool m_didCalculateResolver; |
299 OwnPtrWillBeMember<StyleResolver> m_resolver; | 254 OwnPtrWillBeMember<StyleResolver> m_resolver; |
300 StyleInvalidator m_styleInvalidator; | 255 StyleInvalidator m_styleInvalidator; |
301 | 256 |
302 RefPtrWillBeMember<CSSFontSelector> m_fontSelector; | 257 RefPtrWillBeMember<CSSFontSelector> m_fontSelector; |
303 | 258 |
304 WillBeHeapHashMap<AtomicString, RawPtrWillBeMember<StyleSheetContents>> m_te xtToSheetCache; | 259 WillBeHeapHashMap<AtomicString, RawPtrWillBeMember<StyleSheetContents>> m_te xtToSheetCache; |
305 WillBeHeapHashMap<RawPtrWillBeMember<StyleSheetContents>, AtomicString> m_sh eetToTextCache; | 260 WillBeHeapHashMap<RawPtrWillBeMember<StyleSheetContents>, AtomicString> m_sh eetToTextCache; |
306 }; | 261 }; |
307 | 262 |
308 } | 263 } |
309 | 264 |
310 #endif | 265 #endif |
OLD | NEW |