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 | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All |
7 * rights reserved. | 7 * rights reserved. |
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. |
9 * (http://www.torchmobile.com/) | 9 * (http://www.torchmobile.com/) |
10 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 10 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 92 |
93 const HeapVector<TraceWrapperMember<StyleSheet>>& | 93 const HeapVector<TraceWrapperMember<StyleSheet>>& |
94 styleSheetsForStyleSheetList(TreeScope&); | 94 styleSheetsForStyleSheetList(TreeScope&); |
95 | 95 |
96 const HeapVector<TraceWrapperMember<CSSStyleSheet>>& | 96 const HeapVector<TraceWrapperMember<CSSStyleSheet>>& |
97 injectedAuthorStyleSheets() const { | 97 injectedAuthorStyleSheets() const { |
98 return m_injectedAuthorStyleSheets; | 98 return m_injectedAuthorStyleSheets; |
99 } | 99 } |
100 CSSStyleSheet* inspectorStyleSheet() const { return m_inspectorStyleSheet; } | 100 CSSStyleSheet* inspectorStyleSheet() const { return m_inspectorStyleSheet; } |
101 | 101 |
102 const ActiveStyleSheetVector activeStyleSheetsForInspector(); | 102 const HeapVector<Member<CSSStyleSheet>> activeStyleSheetsForInspector() const; |
103 | 103 |
104 bool needsActiveStyleUpdate() const; | 104 bool needsActiveStyleUpdate() const; |
105 void setNeedsActiveStyleUpdate(TreeScope&); | 105 void setNeedsActiveStyleUpdate(TreeScope&); |
106 void addStyleSheetCandidateNode(Node&); | 106 void addStyleSheetCandidateNode(Node&); |
107 void removeStyleSheetCandidateNode(Node&, ContainerNode& insertionPoint); | 107 void removeStyleSheetCandidateNode(Node&, ContainerNode& insertionPoint); |
108 void modifiedStyleSheetCandidateNode(Node&); | 108 void modifiedStyleSheetCandidateNode(Node&); |
109 void mediaQueriesChangedInScope(TreeScope&); | 109 void mediaQueriesChangedInScope(TreeScope&); |
110 void watchedSelectorsChanged(); | 110 void watchedSelectorsChanged(); |
111 void initialViewportChanged(); | 111 void initialViewportChanged(); |
112 void viewportRulesChanged(); | 112 void viewportRulesChanged(); |
113 void htmlImportAddedOrRemoved(); | 113 void htmlImportAddedOrRemoved(); |
114 | 114 |
115 void injectAuthorSheet(StyleSheetContents* authorSheet); | 115 void injectAuthorSheet(StyleSheetContents* authorSheet); |
116 CSSStyleSheet& ensureInspectorStyleSheet(); | 116 CSSStyleSheet& ensureInspectorStyleSheet(); |
117 RuleSet* watchedSelectorsRuleSet() { | 117 RuleSet* watchedSelectorsRuleSet() { |
118 return m_globalRuleSet.watchedSelectorsRuleSet(); | 118 return m_globalRuleSet.watchedSelectorsRuleSet(); |
119 } | 119 } |
120 | 120 |
121 RuleSet* ruleSetForSheet(CSSStyleSheet&); | 121 RuleSet* ruleSetForSheet(CSSStyleSheet&); |
122 void mediaQueryAffectingValueChanged(); | 122 void mediaQueryAffectingValueChanged(); |
123 void updateStyleSheetsInImport(DocumentStyleSheetCollector& parentCollector); | 123 void updateStyleSheetsInImport(DocumentStyleSheetCollector& parentCollector); |
| 124 void updateActiveStyleSheets(StyleResolverUpdateMode); |
124 void updateActiveStyle(); | 125 void updateActiveStyle(); |
125 void markAllTreeScopesDirty() { m_allTreeScopesDirty = true; } | 126 void markAllTreeScopesDirty() { m_allTreeScopesDirty = true; } |
126 | 127 |
127 enum ActiveSheetsUpdate { DontUpdateActiveSheets, UpdateActiveSheets }; | 128 enum ActiveSheetsUpdate { DontUpdateActiveSheets, UpdateActiveSheets }; |
128 String preferredStylesheetSetName() const { | 129 String preferredStylesheetSetName() const { |
129 return m_preferredStylesheetSetName; | 130 return m_preferredStylesheetSetName; |
130 } | 131 } |
131 String selectedStylesheetSetName() const { | 132 String selectedStylesheetSetName() const { |
132 return m_selectedStylesheetSetName; | 133 return m_selectedStylesheetSetName; |
133 } | 134 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 return m_treeBoundaryCrossingScopes; | 176 return m_treeBoundaryCrossingScopes; |
176 } | 177 } |
177 void resetAuthorStyle(TreeScope&); | 178 void resetAuthorStyle(TreeScope&); |
178 | 179 |
179 StyleResolver* resolver() const { return m_resolver; } | 180 StyleResolver* resolver() const { return m_resolver; } |
180 | 181 |
181 void setRuleUsageTracker(StyleRuleUsageTracker*); | 182 void setRuleUsageTracker(StyleRuleUsageTracker*); |
182 | 183 |
183 StyleResolver& ensureResolver() { | 184 StyleResolver& ensureResolver() { |
184 updateActiveStyle(); | 185 updateActiveStyle(); |
185 if (!m_resolver) | 186 if (!m_resolver) { |
186 createResolver(); | 187 createResolver(); |
| 188 } else if (m_resolver->hasPendingAuthorStyleSheets()) { |
| 189 m_resolver->appendPendingAuthorStyleSheets(); |
| 190 finishAppendAuthorStyleSheets(); |
| 191 } else if (m_globalRuleSet.isDirty()) { |
| 192 m_globalRuleSet.update(document()); |
| 193 } |
187 return *m_resolver; | 194 return *m_resolver; |
188 } | 195 } |
189 | 196 |
190 bool hasResolver() const { return m_resolver; } | 197 bool hasResolver() const { return m_resolver; } |
191 void clearResolver(); | 198 void clearResolver(); |
| 199 void clearMasterResolver(); |
192 | 200 |
193 StyleInvalidator& styleInvalidator() { return m_styleInvalidator; } | 201 StyleInvalidator& styleInvalidator() { return m_styleInvalidator; } |
194 bool mediaQueryAffectedByViewportChange(); | 202 bool mediaQueryAffectedByViewportChange(); |
195 bool mediaQueryAffectedByDeviceChange(); | 203 bool mediaQueryAffectedByDeviceChange(); |
196 bool hasViewportDependentMediaQueries() const { | 204 bool hasViewportDependentMediaQueries() const { |
197 return !m_globalRuleSet.ruleFeatureSet() | 205 return !m_globalRuleSet.ruleFeatureSet() |
198 .viewportDependentMediaQueryResults() | 206 .viewportDependentMediaQueryResults() |
199 .isEmpty(); | 207 .isEmpty(); |
200 } | 208 } |
201 | 209 |
202 CSSFontSelector* fontSelector() { return m_fontSelector; } | 210 CSSFontSelector* fontSelector() { return m_fontSelector; } |
203 void setFontSelector(CSSFontSelector*); | 211 void setFontSelector(CSSFontSelector*); |
204 | 212 |
205 void removeFontFaceRules(const HeapVector<Member<const StyleRuleFontFace>>&); | 213 void removeFontFaceRules(const HeapVector<Member<const StyleRuleFontFace>>&); |
206 void clearFontCache(); | 214 void clearFontCache(); |
207 // updateGenericFontFamilySettings is used from WebSettingsImpl. | 215 // updateGenericFontFamilySettings is used from WebSettingsImpl. |
208 void updateGenericFontFamilySettings(); | 216 void updateGenericFontFamilySettings(); |
209 | 217 |
210 void didDetach(); | 218 void didDetach(); |
211 void resolverChanged(StyleResolverUpdateMode) {} | 219 bool shouldClearResolver() const; |
| 220 void resolverChanged(StyleResolverUpdateMode); |
212 | 221 |
213 CSSStyleSheet* createSheet(Element&, | 222 CSSStyleSheet* createSheet(Element&, |
214 const String& text, | 223 const String& text, |
215 TextPosition startPosition, | 224 TextPosition startPosition, |
216 StyleEngineContext&); | 225 StyleEngineContext&); |
217 | 226 |
218 void collectScopedStyleFeaturesTo(RuleFeatureSet&) const; | 227 void collectScopedStyleFeaturesTo(RuleFeatureSet&) const; |
219 void ensureUAStyleForFullscreen(); | 228 void ensureUAStyleForFullscreen(); |
220 void ensureUAStyleForElement(const Element&); | 229 void ensureUAStyleForElement(const Element&); |
221 | 230 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 Document& document() const { return *m_document; } | 291 Document& document() const { return *m_document; } |
283 | 292 |
284 typedef HeapHashSet<Member<TreeScope>> UnorderedTreeScopeSet; | 293 typedef HeapHashSet<Member<TreeScope>> UnorderedTreeScopeSet; |
285 | 294 |
286 void mediaQueryAffectingValueChanged(UnorderedTreeScopeSet&); | 295 void mediaQueryAffectingValueChanged(UnorderedTreeScopeSet&); |
287 const RuleFeatureSet& ruleFeatureSet() const { | 296 const RuleFeatureSet& ruleFeatureSet() const { |
288 return m_globalRuleSet.ruleFeatureSet(); | 297 return m_globalRuleSet.ruleFeatureSet(); |
289 } | 298 } |
290 | 299 |
291 void createResolver(); | 300 void createResolver(); |
| 301 void appendActiveAuthorStyleSheets(); |
| 302 void finishAppendAuthorStyleSheets(); |
292 | 303 |
293 CSSStyleSheet* parseSheet(Element&, | 304 CSSStyleSheet* parseSheet(Element&, |
294 const String& text, | 305 const String& text, |
295 TextPosition startPosition); | 306 TextPosition startPosition); |
296 | 307 |
297 const DocumentStyleSheetCollection& documentStyleSheetCollection() const { | 308 const DocumentStyleSheetCollection& documentStyleSheetCollection() const { |
298 DCHECK(m_documentStyleSheetCollection); | 309 DCHECK(m_documentStyleSheetCollection); |
299 return *m_documentStyleSheetCollection; | 310 return *m_documentStyleSheetCollection; |
300 } | 311 } |
301 | 312 |
302 DocumentStyleSheetCollection& documentStyleSheetCollection() { | 313 DocumentStyleSheetCollection& documentStyleSheetCollection() { |
303 DCHECK(m_documentStyleSheetCollection); | 314 DCHECK(m_documentStyleSheetCollection); |
304 return *m_documentStyleSheetCollection; | 315 return *m_documentStyleSheetCollection; |
305 } | 316 } |
306 | 317 |
307 void updateActiveStyleSheetsInShadow( | 318 void updateActiveStyleSheetsInShadow( |
| 319 StyleResolverUpdateMode, |
308 TreeScope*, | 320 TreeScope*, |
309 UnorderedTreeScopeSet& treeScopesRemoved); | 321 UnorderedTreeScopeSet& treeScopesRemoved); |
310 | 322 |
311 bool shouldSkipInvalidationFor(const Element&) const; | 323 bool shouldSkipInvalidationFor(const Element&) const; |
312 void scheduleRuleSetInvalidationsForElement( | 324 void scheduleRuleSetInvalidationsForElement( |
313 Element&, | 325 Element&, |
314 const HeapHashSet<Member<RuleSet>>&); | 326 const HeapHashSet<Member<RuleSet>>&); |
315 void invalidateSlottedElements(HTMLSlotElement&); | 327 void invalidateSlottedElements(HTMLSlotElement&); |
316 | 328 |
317 void updateViewport(); | 329 void updateViewport(); |
(...skipping 11 matching lines...) Expand all Loading... |
329 int m_pendingRenderBlockingStylesheets = 0; | 341 int m_pendingRenderBlockingStylesheets = 0; |
330 | 342 |
331 HeapVector<TraceWrapperMember<CSSStyleSheet>> m_injectedAuthorStyleSheets; | 343 HeapVector<TraceWrapperMember<CSSStyleSheet>> m_injectedAuthorStyleSheets; |
332 Member<CSSStyleSheet> m_inspectorStyleSheet; | 344 Member<CSSStyleSheet> m_inspectorStyleSheet; |
333 | 345 |
334 TraceWrapperMember<DocumentStyleSheetCollection> | 346 TraceWrapperMember<DocumentStyleSheetCollection> |
335 m_documentStyleSheetCollection; | 347 m_documentStyleSheetCollection; |
336 | 348 |
337 Member<StyleRuleUsageTracker> m_tracker; | 349 Member<StyleRuleUsageTracker> m_tracker; |
338 | 350 |
339 using StyleSheetCollectionMap = | 351 typedef HeapHashMap<WeakMember<TreeScope>, |
340 HeapHashMap<WeakMember<TreeScope>, | 352 Member<ShadowTreeStyleSheetCollection>> |
341 Member<ShadowTreeStyleSheetCollection>>; | 353 StyleSheetCollectionMap; |
342 StyleSheetCollectionMap m_styleSheetCollectionMap; | 354 StyleSheetCollectionMap m_styleSheetCollectionMap; |
343 | 355 |
344 bool m_documentScopeDirty = true; | 356 bool m_documentScopeDirty = true; |
345 bool m_allTreeScopesDirty = false; | 357 bool m_allTreeScopesDirty = false; |
346 UnorderedTreeScopeSet m_dirtyTreeScopes; | 358 UnorderedTreeScopeSet m_dirtyTreeScopes; |
347 UnorderedTreeScopeSet m_activeTreeScopes; | 359 UnorderedTreeScopeSet m_activeTreeScopes; |
348 DocumentOrderedList m_treeBoundaryCrossingScopes; | 360 DocumentOrderedList m_treeBoundaryCrossingScopes; |
349 | 361 |
350 String m_preferredStylesheetSetName; | 362 String m_preferredStylesheetSetName; |
351 String m_selectedStylesheetSetName; | 363 String m_selectedStylesheetSetName; |
352 | 364 |
353 CSSGlobalRuleSet m_globalRuleSet; | 365 CSSGlobalRuleSet m_globalRuleSet; |
354 | 366 |
355 bool m_usesRemUnits = false; | 367 bool m_usesRemUnits = false; |
356 bool m_ignorePendingStylesheets = false; | 368 bool m_ignorePendingStylesheets = false; |
| 369 bool m_didCalculateResolver = false; |
357 | 370 |
358 Member<StyleResolver> m_resolver; | 371 Member<StyleResolver> m_resolver; |
359 Member<ViewportStyleResolver> m_viewportResolver; | 372 Member<ViewportStyleResolver> m_viewportResolver; |
360 Member<MediaQueryEvaluator> m_mediaQueryEvaluator; | 373 Member<MediaQueryEvaluator> m_mediaQueryEvaluator; |
361 StyleInvalidator m_styleInvalidator; | 374 StyleInvalidator m_styleInvalidator; |
362 | 375 |
363 Member<CSSFontSelector> m_fontSelector; | 376 Member<CSSFontSelector> m_fontSelector; |
364 | 377 |
365 HeapHashMap<AtomicString, WeakMember<StyleSheetContents>> m_textToSheetCache; | 378 HeapHashMap<AtomicString, WeakMember<StyleSheetContents>> m_textToSheetCache; |
366 HeapHashMap<WeakMember<StyleSheetContents>, AtomicString> m_sheetToTextCache; | 379 HeapHashMap<WeakMember<StyleSheetContents>, AtomicString> m_sheetToTextCache; |
367 | 380 |
368 std::unique_ptr<StyleResolverStats> m_styleResolverStats; | 381 std::unique_ptr<StyleResolverStats> m_styleResolverStats; |
369 unsigned m_styleForElementCount = 0; | 382 unsigned m_styleForElementCount = 0; |
370 | 383 |
371 friend class StyleEngineTest; | 384 friend class StyleEngineTest; |
372 }; | 385 }; |
373 | 386 |
374 } // namespace blink | 387 } // namespace blink |
375 | 388 |
376 #endif | 389 #endif |
OLD | NEW |