| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 class CSSFontSelector; | 49 class CSSFontSelector; |
| 50 class CSSStyleSheet; | 50 class CSSStyleSheet; |
| 51 class Node; | 51 class Node; |
| 52 class RuleFeatureSet; | 52 class RuleFeatureSet; |
| 53 class ShadowTreeStyleSheetCollection; | 53 class ShadowTreeStyleSheetCollection; |
| 54 class StyleRuleFontFace; | 54 class StyleRuleFontFace; |
| 55 class StyleSheet; | 55 class StyleSheet; |
| 56 class StyleSheetContents; | 56 class StyleSheetContents; |
| 57 | 57 |
| 58 class CORE_EXPORT StyleEngine final : public NoBaseWillBeGarbageCollectedFinaliz
ed<StyleEngine>, public CSSFontSelectorClient { | 58 class CORE_EXPORT StyleEngine final : public GarbageCollectedFinalized<StyleEngi
ne>, public CSSFontSelectorClient { |
| 59 USING_FAST_MALLOC_WILL_BE_REMOVED(StyleEngine); | 59 USING_GARBAGE_COLLECTED_MIXIN(StyleEngine); |
| 60 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(StyleEngine); | |
| 61 public: | 60 public: |
| 62 | 61 |
| 63 class IgnoringPendingStylesheet : public TemporaryChange<bool> { | 62 class IgnoringPendingStylesheet : public TemporaryChange<bool> { |
| 64 DISALLOW_NEW(); | 63 DISALLOW_NEW(); |
| 65 public: | 64 public: |
| 66 IgnoringPendingStylesheet(StyleEngine& engine) | 65 IgnoringPendingStylesheet(StyleEngine& engine) |
| 67 : TemporaryChange<bool>(engine.m_ignorePendingStylesheets, true) | 66 : TemporaryChange<bool>(engine.m_ignorePendingStylesheets, true) |
| 68 { | 67 { |
| 69 } | 68 } |
| 70 }; | 69 }; |
| 71 | 70 |
| 72 friend class IgnoringPendingStylesheet; | 71 friend class IgnoringPendingStylesheet; |
| 73 | 72 |
| 74 static PassOwnPtrWillBeRawPtr<StyleEngine> create(Document& document) { retu
rn adoptPtrWillBeNoop(new StyleEngine(document)); } | 73 static RawPtr<StyleEngine> create(Document& document) { return (new StyleEng
ine(document)); } |
| 75 | 74 |
| 76 ~StyleEngine(); | 75 ~StyleEngine(); |
| 77 | 76 |
| 78 #if !ENABLE(OILPAN) | 77 #if !ENABLE(OILPAN) |
| 79 void detachFromDocument(); | 78 void detachFromDocument(); |
| 80 #endif | 79 #endif |
| 81 | 80 |
| 82 const WillBeHeapVector<RefPtrWillBeMember<StyleSheet>>& styleSheetsForStyleS
heetList(TreeScope&); | 81 const HeapVector<Member<StyleSheet>>& styleSheetsForStyleSheetList(TreeScope
&); |
| 83 | 82 |
| 84 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>>& injectedAuthorSty
leSheets() const { return m_injectedAuthorStyleSheets; } | 83 const HeapVector<Member<CSSStyleSheet>>& injectedAuthorStyleSheets() const {
return m_injectedAuthorStyleSheets; } |
| 85 | 84 |
| 86 const WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>> activeStyleSheetsF
orInspector() const; | 85 const HeapVector<Member<CSSStyleSheet>> activeStyleSheetsForInspector() cons
t; |
| 87 | 86 |
| 88 void modifiedStyleSheet(StyleSheet*); | 87 void modifiedStyleSheet(StyleSheet*); |
| 89 void addStyleSheetCandidateNode(Node*, bool createdByParser); | 88 void addStyleSheetCandidateNode(Node*, bool createdByParser); |
| 90 void removeStyleSheetCandidateNode(Node*); | 89 void removeStyleSheetCandidateNode(Node*); |
| 91 void removeStyleSheetCandidateNode(Node*, TreeScope&); | 90 void removeStyleSheetCandidateNode(Node*, TreeScope&); |
| 92 void modifiedStyleSheetCandidateNode(Node*); | 91 void modifiedStyleSheetCandidateNode(Node*); |
| 93 | 92 |
| 94 void injectAuthorSheet(PassRefPtrWillBeRawPtr<StyleSheetContents> authorShee
t); | 93 void injectAuthorSheet(RawPtr<StyleSheetContents> authorSheet); |
| 95 | 94 |
| 96 void clearMediaQueryRuleSetStyleSheets(); | 95 void clearMediaQueryRuleSetStyleSheets(); |
| 97 void updateStyleSheetsInImport(DocumentStyleSheetCollector& parentCollector)
; | 96 void updateStyleSheetsInImport(DocumentStyleSheetCollector& parentCollector)
; |
| 98 void updateActiveStyleSheets(StyleResolverUpdateMode); | 97 void updateActiveStyleSheets(StyleResolverUpdateMode); |
| 99 | 98 |
| 100 String preferredStylesheetSetName() const { return m_preferredStylesheetSetN
ame; } | 99 String preferredStylesheetSetName() const { return m_preferredStylesheetSetN
ame; } |
| 101 String selectedStylesheetSetName() const { return m_selectedStylesheetSetNam
e; } | 100 String selectedStylesheetSetName() const { return m_selectedStylesheetSetNam
e; } |
| 102 void setPreferredStylesheetSetName(const String& name) { m_preferredStyleshe
etSetName = name; } | 101 void setPreferredStylesheetSetName(const String& name) { m_preferredStyleshe
etSetName = name; } |
| 103 void setSelectedStylesheetSetName(const String& name) { m_selectedStylesheet
SetName = name; } | 102 void setSelectedStylesheetSetName(const String& name) { m_selectedStylesheet
SetName = name; } |
| 104 | 103 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 return *m_resolver.get(); | 144 return *m_resolver.get(); |
| 146 } | 145 } |
| 147 | 146 |
| 148 bool hasResolver() const { return m_resolver.get(); } | 147 bool hasResolver() const { return m_resolver.get(); } |
| 149 void clearResolver(); | 148 void clearResolver(); |
| 150 void clearMasterResolver(); | 149 void clearMasterResolver(); |
| 151 | 150 |
| 152 StyleInvalidator& styleInvalidator() { return m_styleInvalidator; } | 151 StyleInvalidator& styleInvalidator() { return m_styleInvalidator; } |
| 153 | 152 |
| 154 CSSFontSelector* fontSelector() { return m_fontSelector.get(); } | 153 CSSFontSelector* fontSelector() { return m_fontSelector.get(); } |
| 155 void setFontSelector(PassRefPtrWillBeRawPtr<CSSFontSelector>); | 154 void setFontSelector(RawPtr<CSSFontSelector>); |
| 156 | 155 |
| 157 void removeFontFaceRules(const WillBeHeapVector<RawPtrWillBeMember<const Sty
leRuleFontFace>>&); | 156 void removeFontFaceRules(const HeapVector<Member<const StyleRuleFontFace>>&)
; |
| 158 void clearFontCache(); | 157 void clearFontCache(); |
| 159 // updateGenericFontFamilySettings is used from WebSettingsImpl. | 158 // updateGenericFontFamilySettings is used from WebSettingsImpl. |
| 160 void updateGenericFontFamilySettings(); | 159 void updateGenericFontFamilySettings(); |
| 161 | 160 |
| 162 void didDetach(); | 161 void didDetach(); |
| 163 bool shouldClearResolver() const; | 162 bool shouldClearResolver() const; |
| 164 void resolverChanged(StyleResolverUpdateMode); | 163 void resolverChanged(StyleResolverUpdateMode); |
| 165 | 164 |
| 166 void markDocumentDirty(); | 165 void markDocumentDirty(); |
| 167 | 166 |
| 168 PassRefPtrWillBeRawPtr<CSSStyleSheet> createSheet(Element*, const String& te
xt, TextPosition startPosition); | 167 RawPtr<CSSStyleSheet> createSheet(Element*, const String& text, TextPosition
startPosition); |
| 169 void removeSheet(StyleSheetContents*); | 168 void removeSheet(StyleSheetContents*); |
| 170 | 169 |
| 171 void collectScopedStyleFeaturesTo(RuleFeatureSet&) const; | 170 void collectScopedStyleFeaturesTo(RuleFeatureSet&) const; |
| 172 | 171 |
| 173 void platformColorsChanged(); | 172 void platformColorsChanged(); |
| 174 | 173 |
| 175 void classChangedForElement(const SpaceSplitString& changedClasses, Element&
); | 174 void classChangedForElement(const SpaceSplitString& changedClasses, Element&
); |
| 176 void classChangedForElement(const SpaceSplitString& oldClasses, const SpaceS
plitString& newClasses, Element&); | 175 void classChangedForElement(const SpaceSplitString& oldClasses, const SpaceS
plitString& newClasses, Element&); |
| 177 void attributeChangedForElement(const QualifiedName& attributeName, Element&
); | 176 void attributeChangedForElement(const QualifiedName& attributeName, Element&
); |
| 178 void idChangedForElement(const AtomicString& oldId, const AtomicString& newI
d, Element&); | 177 void idChangedForElement(const AtomicString& oldId, const AtomicString& newI
d, Element&); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 197 TreeScopeStyleSheetCollection* styleSheetCollectionFor(TreeScope&); | 196 TreeScopeStyleSheetCollection* styleSheetCollectionFor(TreeScope&); |
| 198 bool shouldUpdateDocumentStyleSheetCollection(StyleResolverUpdateMode) const
; | 197 bool shouldUpdateDocumentStyleSheetCollection(StyleResolverUpdateMode) const
; |
| 199 bool shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdateMode) con
st; | 198 bool shouldUpdateShadowTreeStyleSheetCollection(StyleResolverUpdateMode) con
st; |
| 200 | 199 |
| 201 void markTreeScopeDirty(TreeScope&); | 200 void markTreeScopeDirty(TreeScope&); |
| 202 | 201 |
| 203 bool isMaster() const { return m_isMaster; } | 202 bool isMaster() const { return m_isMaster; } |
| 204 Document* master(); | 203 Document* master(); |
| 205 Document& document() const { return *m_document; } | 204 Document& document() const { return *m_document; } |
| 206 | 205 |
| 207 typedef WillBeHeapHashSet<RawPtrWillBeMember<TreeScope>> UnorderedTreeScopeS
et; | 206 typedef HeapHashSet<Member<TreeScope>> UnorderedTreeScopeSet; |
| 208 | 207 |
| 209 void clearMediaQueryRuleSetOnTreeScopeStyleSheets(UnorderedTreeScopeSet&); | 208 void clearMediaQueryRuleSetOnTreeScopeStyleSheets(UnorderedTreeScopeSet&); |
| 210 | 209 |
| 211 void createResolver(); | 210 void createResolver(); |
| 212 | 211 |
| 213 static PassRefPtrWillBeRawPtr<CSSStyleSheet> parseSheet(Element*, const Stri
ng& text, TextPosition startPosition); | 212 static RawPtr<CSSStyleSheet> parseSheet(Element*, const String& text, TextPo
sition startPosition); |
| 214 | 213 |
| 215 const DocumentStyleSheetCollection* documentStyleSheetCollection() const | 214 const DocumentStyleSheetCollection* documentStyleSheetCollection() const |
| 216 { | 215 { |
| 217 return m_documentStyleSheetCollection.get(); | 216 return m_documentStyleSheetCollection.get(); |
| 218 } | 217 } |
| 219 | 218 |
| 220 DocumentStyleSheetCollection* documentStyleSheetCollection() | 219 DocumentStyleSheetCollection* documentStyleSheetCollection() |
| 221 { | 220 { |
| 222 return m_documentStyleSheetCollection.get(); | 221 return m_documentStyleSheetCollection.get(); |
| 223 } | 222 } |
| 224 | 223 |
| 225 void updateActiveStyleSheetsInShadow(StyleResolverUpdateMode, TreeScope*, Un
orderedTreeScopeSet& treeScopesRemoved); | 224 void updateActiveStyleSheetsInShadow(StyleResolverUpdateMode, TreeScope*, Un
orderedTreeScopeSet& treeScopesRemoved); |
| 226 | 225 |
| 227 bool shouldSkipInvalidationFor(const Element&) const; | 226 bool shouldSkipInvalidationFor(const Element&) const; |
| 228 | 227 |
| 229 RawPtrWillBeMember<Document> m_document; | 228 Member<Document> m_document; |
| 230 bool m_isMaster; | 229 bool m_isMaster; |
| 231 | 230 |
| 232 // Track the number of currently loading top-level stylesheets needed for la
yout. | 231 // Track the number of currently loading top-level stylesheets needed for la
yout. |
| 233 // Sheets loaded using the @import directive are not included in this count. | 232 // Sheets loaded using the @import directive are not included in this count. |
| 234 // We use this count of pending sheets to detect when we can begin attaching | 233 // We use this count of pending sheets to detect when we can begin attaching |
| 235 // elements and when it is safe to execute scripts. | 234 // elements and when it is safe to execute scripts. |
| 236 int m_pendingStylesheets = 0; | 235 int m_pendingStylesheets = 0; |
| 237 | 236 |
| 238 WillBeHeapVector<RefPtrWillBeMember<CSSStyleSheet>> m_injectedAuthorStyleShe
ets; | 237 HeapVector<Member<CSSStyleSheet>> m_injectedAuthorStyleSheets; |
| 239 | 238 |
| 240 OwnPtrWillBeMember<DocumentStyleSheetCollection> m_documentStyleSheetCollect
ion; | 239 Member<DocumentStyleSheetCollection> m_documentStyleSheetCollection; |
| 241 | 240 |
| 242 typedef WillBeHeapHashMap<RawPtrWillBeWeakMember<TreeScope>, OwnPtrWillBeMem
ber<ShadowTreeStyleSheetCollection>> StyleSheetCollectionMap; | 241 typedef HeapHashMap<WeakMember<TreeScope>, Member<ShadowTreeStyleSheetCollec
tion>> StyleSheetCollectionMap; |
| 243 StyleSheetCollectionMap m_styleSheetCollectionMap; | 242 StyleSheetCollectionMap m_styleSheetCollectionMap; |
| 244 | 243 |
| 245 bool m_documentScopeDirty = true; | 244 bool m_documentScopeDirty = true; |
| 246 UnorderedTreeScopeSet m_dirtyTreeScopes; | 245 UnorderedTreeScopeSet m_dirtyTreeScopes; |
| 247 UnorderedTreeScopeSet m_activeTreeScopes; | 246 UnorderedTreeScopeSet m_activeTreeScopes; |
| 248 | 247 |
| 249 String m_preferredStylesheetSetName; | 248 String m_preferredStylesheetSetName; |
| 250 String m_selectedStylesheetSetName; | 249 String m_selectedStylesheetSetName; |
| 251 | 250 |
| 252 bool m_usesSiblingRules = false; | 251 bool m_usesSiblingRules = false; |
| 253 bool m_usesFirstLineRules = false; | 252 bool m_usesFirstLineRules = false; |
| 254 bool m_usesWindowInactiveSelector = false; | 253 bool m_usesWindowInactiveSelector = false; |
| 255 bool m_usesRemUnits = false; | 254 bool m_usesRemUnits = false; |
| 256 unsigned m_maxDirectAdjacentSelectors = 0; | 255 unsigned m_maxDirectAdjacentSelectors = 0; |
| 257 | 256 |
| 258 bool m_ignorePendingStylesheets = false; | 257 bool m_ignorePendingStylesheets = false; |
| 259 bool m_didCalculateResolver = false; | 258 bool m_didCalculateResolver = false; |
| 260 OwnPtrWillBeMember<StyleResolver> m_resolver; | 259 Member<StyleResolver> m_resolver; |
| 261 StyleInvalidator m_styleInvalidator; | 260 StyleInvalidator m_styleInvalidator; |
| 262 | 261 |
| 263 RefPtrWillBeMember<CSSFontSelector> m_fontSelector; | 262 Member<CSSFontSelector> m_fontSelector; |
| 264 | 263 |
| 265 WillBeHeapHashMap<AtomicString, RawPtrWillBeMember<StyleSheetContents>> m_te
xtToSheetCache; | 264 HeapHashMap<AtomicString, Member<StyleSheetContents>> m_textToSheetCache; |
| 266 WillBeHeapHashMap<RawPtrWillBeMember<StyleSheetContents>, AtomicString> m_sh
eetToTextCache; | 265 HeapHashMap<Member<StyleSheetContents>, AtomicString> m_sheetToTextCache; |
| 267 | 266 |
| 268 OwnPtr<StyleResolverStats> m_styleResolverStats; | 267 OwnPtr<StyleResolverStats> m_styleResolverStats; |
| 269 unsigned m_styleForElementCount = 0; | 268 unsigned m_styleForElementCount = 0; |
| 270 }; | 269 }; |
| 271 | 270 |
| 272 } // namespace blink | 271 } // namespace blink |
| 273 | 272 |
| 274 #endif | 273 #endif |
| OLD | NEW |