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