| 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(); |
| 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 | 91 |
| 92 void addAuthorSheet(PassRefPtrWillBeRawPtr<StyleSheetContents> authorSheet); | 92 void addAuthorSheet(PassRefPtrWillBeRawPtr<StyleSheetContents> authorSheet); |
| 93 | 93 |
| 94 void clearMediaQueryRuleSetStyleSheets(); | 94 void clearMediaQueryRuleSetStyleSheets(); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 void collectScopedStyleFeaturesTo(RuleFeatureSet&) const; | 170 void collectScopedStyleFeaturesTo(RuleFeatureSet&) const; |
| 171 | 171 |
| 172 void platformColorsChanged(); | 172 void platformColorsChanged(); |
| 173 | 173 |
| 174 void classChangedForElement(const SpaceSplitString& changedClasses, Element&
); | 174 void classChangedForElement(const SpaceSplitString& changedClasses, Element&
); |
| 175 void classChangedForElement(const SpaceSplitString& oldClasses, const SpaceS
plitString& newClasses, Element&); | 175 void classChangedForElement(const SpaceSplitString& oldClasses, const SpaceS
plitString& newClasses, Element&); |
| 176 void attributeChangedForElement(const QualifiedName& attributeName, Element&
); | 176 void attributeChangedForElement(const QualifiedName& attributeName, Element&
); |
| 177 void idChangedForElement(const AtomicString& oldId, const AtomicString& newI
d, Element&); | 177 void idChangedForElement(const AtomicString& oldId, const AtomicString& newI
d, Element&); |
| 178 void pseudoStateChangedForElement(CSSSelector::PseudoType, Element&); | 178 void pseudoStateChangedForElement(CSSSelector::PseudoType, Element&); |
| 179 | 179 |
| 180 TreeScopeStyleSheetCollection* styleSheetCollectionFor(TreeScope&); |
| 181 |
| 180 DECLARE_VIRTUAL_TRACE(); | 182 DECLARE_VIRTUAL_TRACE(); |
| 181 | 183 |
| 182 private: | 184 private: |
| 183 // CSSFontSelectorClient implementation. | 185 // CSSFontSelectorClient implementation. |
| 184 virtual void fontsNeedUpdate(CSSFontSelector*) override; | 186 virtual void fontsNeedUpdate(CSSFontSelector*) override; |
| 185 | 187 |
| 186 private: | 188 private: |
| 187 StyleEngine(Document&); | 189 StyleEngine(Document&); |
| 188 | 190 |
| 189 TreeScopeStyleSheetCollection* ensureStyleSheetCollectionFor(TreeScope&); | 191 TreeScopeStyleSheetCollection* ensureStyleSheetCollectionFor(TreeScope&); |
| 190 TreeScopeStyleSheetCollection* styleSheetCollectionFor(TreeScope&); | |
| 191 bool shouldUpdateDocumentStyleSheetCollection(StyleResolverUpdateMode) const
; | 192 bool shouldUpdateDocumentStyleSheetCollection(StyleResolverUpdateMode) const
; |
| 192 bool shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdateMode) con
st; | 193 bool shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdateMode) con
st; |
| 193 | 194 |
| 194 void markTreeScopeDirty(TreeScope&); | 195 void markTreeScopeDirty(TreeScope&); |
| 195 | 196 |
| 196 bool isMaster() const { return m_isMaster; } | 197 bool isMaster() const { return m_isMaster; } |
| 197 Document* master(); | 198 Document* master(); |
| 198 Document& document() const { return *m_document; } | 199 Document& document() const { return *m_document; } |
| 199 | 200 |
| 200 void scheduleInvalidationSetsForElement(const InvalidationSetVector&, Elemen
t&); | 201 void scheduleInvalidationSetsForElement(const InvalidationSetVector&, Elemen
t&); |
| 201 | 202 |
| 202 typedef WillBeHeapHashSet<RawPtrWillBeMember<TreeScope>> UnorderedTreeScopeS
et; | |
| 203 | |
| 204 // A class which holds document-ordered treescopes which have stylesheets. | |
| 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 | |
| 248 void createResolver(); | 203 void createResolver(); |
| 249 | 204 |
| 250 static PassRefPtrWillBeRawPtr<CSSStyleSheet> parseSheet(Element*, const Stri
ng& text, TextPosition startPosition, bool createdByParser); | 205 static PassRefPtrWillBeRawPtr<CSSStyleSheet> parseSheet(Element*, const Stri
ng& text, TextPosition startPosition, bool createdByParser); |
| 251 | 206 |
| 252 const DocumentStyleSheetCollection* documentStyleSheetCollection() const | 207 const DocumentStyleSheetCollection* documentStyleSheetCollection() const |
| 253 { | 208 { |
| 254 return m_documentStyleSheetCollection.get(); | 209 return m_documentStyleSheetCollection.get(); |
| 255 } | 210 } |
| 256 | 211 |
| 257 DocumentStyleSheetCollection* documentStyleSheetCollection() | 212 DocumentStyleSheetCollection* documentStyleSheetCollection() |
| 258 { | 213 { |
| 259 return m_documentStyleSheetCollection.get(); | 214 return m_documentStyleSheetCollection.get(); |
| 260 } | 215 } |
| 261 | 216 |
| 262 void updateActiveStyleSheetsInShadow(StyleResolverUpdateMode, TreeScope*, Un
orderedTreeScopeSet& treeScopesRemoved); | 217 void updateActiveStyleSheetsInShadow(StyleResolverUpdateMode, TreeScope*, Tr
eeScope::UnorderedTreeScopeSet& treeScopesRemoved); |
| 263 | 218 |
| 264 RawPtrWillBeMember<Document> m_document; | 219 RawPtrWillBeMember<Document> m_document; |
| 265 bool m_isMaster; | 220 bool m_isMaster; |
| 266 | 221 |
| 267 // Track the number of currently loading top-level stylesheets needed for la
yout. | 222 // Track the number of currently loading top-level stylesheets needed for la
yout. |
| 268 // Sheets loaded using the @import directive are not included in this count. | 223 // Sheets loaded using the @import directive are not included in this count. |
| 269 // We use this count of pending sheets to detect when we can begin attaching | 224 // We use this count of pending sheets to detect when we can begin attaching |
| 270 // elements and when it is safe to execute scripts. | 225 // elements and when it is safe to execute scripts. |
| 271 int m_pendingStylesheets; | 226 int m_pendingStylesheets; |
| 272 | 227 |
| 273 WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>> m_authorStyleSheets; | 228 WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>> m_authorStyleSheets; |
| 274 | 229 |
| 275 OwnPtrWillBeMember<DocumentStyleSheetCollection> m_documentStyleSheetCollect
ion; | 230 OwnPtrWillBeMember<DocumentStyleSheetCollection> m_documentStyleSheetCollect
ion; |
| 276 | 231 |
| 277 typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<TreeScope>, OwnPtrWillBeMem
ber<ShadowTreeStyleSheetCollection>> StyleSheetCollectionMap; | 232 typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<TreeScope>, OwnPtrWillBeMem
ber<ShadowTreeStyleSheetCollection>> StyleSheetCollectionMap; |
| 278 StyleSheetCollectionMap m_styleSheetCollectionMap; | 233 StyleSheetCollectionMap m_styleSheetCollectionMap; |
| 279 | 234 |
| 280 bool m_documentScopeDirty; | 235 bool m_documentScopeDirty; |
| 281 UnorderedTreeScopeSet m_dirtyTreeScopes; | 236 TreeScope::UnorderedTreeScopeSet m_dirtyTreeScopes; |
| 282 OrderedTreeScopeSet m_activeTreeScopes; | |
| 283 | 237 |
| 284 String m_preferredStylesheetSetName; | 238 String m_preferredStylesheetSetName; |
| 285 String m_selectedStylesheetSetName; | 239 String m_selectedStylesheetSetName; |
| 286 | 240 |
| 287 bool m_usesSiblingRules; | 241 bool m_usesSiblingRules; |
| 288 bool m_usesFirstLineRules; | 242 bool m_usesFirstLineRules; |
| 289 bool m_usesWindowInactiveSelector; | 243 bool m_usesWindowInactiveSelector; |
| 290 bool m_usesRemUnits; | 244 bool m_usesRemUnits; |
| 291 unsigned m_maxDirectAdjacentSelectors; | 245 unsigned m_maxDirectAdjacentSelectors; |
| 292 | 246 |
| 293 bool m_ignorePendingStylesheets; | 247 bool m_ignorePendingStylesheets; |
| 294 bool m_didCalculateResolver; | 248 bool m_didCalculateResolver; |
| 295 OwnPtrWillBeMember<StyleResolver> m_resolver; | 249 OwnPtrWillBeMember<StyleResolver> m_resolver; |
| 296 StyleInvalidator m_styleInvalidator; | 250 StyleInvalidator m_styleInvalidator; |
| 297 | 251 |
| 298 RefPtrWillBeMember<CSSFontSelector> m_fontSelector; | 252 RefPtrWillBeMember<CSSFontSelector> m_fontSelector; |
| 299 | 253 |
| 300 WillBeHeapHashMap<AtomicString, RawPtrWillBeMember<StyleSheetContents>> m_te
xtToSheetCache; | 254 WillBeHeapHashMap<AtomicString, RawPtrWillBeMember<StyleSheetContents>> m_te
xtToSheetCache; |
| 301 WillBeHeapHashMap<RawPtrWillBeMember<StyleSheetContents>, AtomicString> m_sh
eetToTextCache; | 255 WillBeHeapHashMap<RawPtrWillBeMember<StyleSheetContents>, AtomicString> m_sh
eetToTextCache; |
| 302 }; | 256 }; |
| 303 | 257 |
| 304 } | 258 } |
| 305 | 259 |
| 306 #endif | 260 #endif |
| OLD | NEW |