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 13 matching lines...) Expand all Loading... |
24 * along with this library; see the file COPYING.LIB. If not, write to | 24 * along with this library; see the file COPYING.LIB. If not, write to |
25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 25 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
26 * Boston, MA 02110-1301, USA. | 26 * Boston, MA 02110-1301, USA. |
27 * | 27 * |
28 */ | 28 */ |
29 | 29 |
30 #ifndef StyleEngine_h | 30 #ifndef StyleEngine_h |
31 #define StyleEngine_h | 31 #define StyleEngine_h |
32 | 32 |
33 #include <memory> | 33 #include <memory> |
| 34 #include <utility> |
34 #include "core/CoreExport.h" | 35 #include "core/CoreExport.h" |
35 #include "core/css/ActiveStyleSheets.h" | 36 #include "core/css/ActiveStyleSheets.h" |
36 #include "core/css/CSSFontSelectorClient.h" | 37 #include "core/css/CSSFontSelectorClient.h" |
37 #include "core/css/CSSGlobalRuleSet.h" | 38 #include "core/css/CSSGlobalRuleSet.h" |
38 #include "core/css/invalidation/StyleInvalidator.h" | 39 #include "core/css/invalidation/StyleInvalidator.h" |
39 #include "core/css/resolver/StyleResolver.h" | 40 #include "core/css/resolver/StyleResolver.h" |
40 #include "core/css/resolver/StyleResolverStats.h" | 41 #include "core/css/resolver/StyleResolverStats.h" |
41 #include "core/dom/Document.h" | 42 #include "core/dom/Document.h" |
42 #include "core/dom/DocumentOrderedList.h" | 43 #include "core/dom/DocumentOrderedList.h" |
43 #include "core/dom/DocumentStyleSheetCollection.h" | 44 #include "core/dom/DocumentStyleSheetCollection.h" |
44 #include "core/dom/StyleEngineContext.h" | 45 #include "core/dom/StyleEngineContext.h" |
45 #include "platform/bindings/ScriptWrappable.h" | 46 #include "platform/bindings/ScriptWrappable.h" |
46 #include "platform/bindings/TraceWrapperMember.h" | 47 #include "platform/bindings/TraceWrapperMember.h" |
47 #include "platform/heap/Handle.h" | 48 #include "platform/heap/Handle.h" |
48 #include "platform/wtf/Allocator.h" | 49 #include "platform/wtf/Allocator.h" |
49 #include "platform/wtf/AutoReset.h" | 50 #include "platform/wtf/AutoReset.h" |
50 #include "platform/wtf/ListHashSet.h" | 51 #include "platform/wtf/ListHashSet.h" |
51 #include "platform/wtf/Vector.h" | 52 #include "platform/wtf/Vector.h" |
52 #include "platform/wtf/text/WTFString.h" | 53 #include "platform/wtf/text/WTFString.h" |
| 54 #include "public/web/WebDocument.h" |
53 | 55 |
54 namespace blink { | 56 namespace blink { |
55 | 57 |
56 class CSSFontSelector; | 58 class CSSFontSelector; |
57 class CSSStyleSheet; | 59 class CSSStyleSheet; |
58 class MediaQueryEvaluator; | 60 class MediaQueryEvaluator; |
59 class Node; | 61 class Node; |
60 class RuleFeatureSet; | 62 class RuleFeatureSet; |
61 class ShadowTreeStyleSheetCollection; | 63 class ShadowTreeStyleSheetCollection; |
62 class StyleRuleFontFace; | 64 class StyleRuleFontFace; |
(...skipping 23 matching lines...) Expand all Loading... |
86 | 88 |
87 static StyleEngine* Create(Document& document) { | 89 static StyleEngine* Create(Document& document) { |
88 return new StyleEngine(document); | 90 return new StyleEngine(document); |
89 } | 91 } |
90 | 92 |
91 ~StyleEngine(); | 93 ~StyleEngine(); |
92 | 94 |
93 const HeapVector<TraceWrapperMember<StyleSheet>>& | 95 const HeapVector<TraceWrapperMember<StyleSheet>>& |
94 StyleSheetsForStyleSheetList(TreeScope&); | 96 StyleSheetsForStyleSheetList(TreeScope&); |
95 | 97 |
96 const HeapVector<TraceWrapperMember<CSSStyleSheet>>& | 98 const HeapVector< |
| 99 std::pair<WebStyleSheetId, TraceWrapperMember<CSSStyleSheet>>>& |
97 InjectedAuthorStyleSheets() const { | 100 InjectedAuthorStyleSheets() const { |
98 return injected_author_style_sheets_; | 101 return injected_author_style_sheets_; |
99 } | 102 } |
100 CSSStyleSheet* InspectorStyleSheet() const { return inspector_style_sheet_; } | 103 CSSStyleSheet* InspectorStyleSheet() const { return inspector_style_sheet_; } |
101 | 104 |
102 const ActiveStyleSheetVector ActiveStyleSheetsForInspector(); | 105 const ActiveStyleSheetVector ActiveStyleSheetsForInspector(); |
103 | 106 |
104 bool NeedsActiveStyleUpdate() const; | 107 bool NeedsActiveStyleUpdate() const; |
105 void SetNeedsActiveStyleUpdate(TreeScope&); | 108 void SetNeedsActiveStyleUpdate(TreeScope&); |
106 void AddStyleSheetCandidateNode(Node&); | 109 void AddStyleSheetCandidateNode(Node&); |
107 void RemoveStyleSheetCandidateNode(Node&, ContainerNode& insertion_point); | 110 void RemoveStyleSheetCandidateNode(Node&, ContainerNode& insertion_point); |
108 void ModifiedStyleSheetCandidateNode(Node&); | 111 void ModifiedStyleSheetCandidateNode(Node&); |
109 void MediaQueriesChangedInScope(TreeScope&); | 112 void MediaQueriesChangedInScope(TreeScope&); |
110 void WatchedSelectorsChanged(); | 113 void WatchedSelectorsChanged(); |
111 void InitialViewportChanged(); | 114 void InitialViewportChanged(); |
112 void ViewportRulesChanged(); | 115 void ViewportRulesChanged(); |
113 void HtmlImportAddedOrRemoved(); | 116 void HtmlImportAddedOrRemoved(); |
114 | 117 |
115 void InjectAuthorSheet(StyleSheetContents* author_sheet); | 118 WebStyleSheetId InjectAuthorSheet(StyleSheetContents* author_sheet); |
| 119 void RemoveInjectedAuthorSheet(WebStyleSheetId author_sheet_id); |
116 CSSStyleSheet& EnsureInspectorStyleSheet(); | 120 CSSStyleSheet& EnsureInspectorStyleSheet(); |
117 RuleSet* WatchedSelectorsRuleSet() { | 121 RuleSet* WatchedSelectorsRuleSet() { |
118 DCHECK(IsMaster()); | 122 DCHECK(IsMaster()); |
119 DCHECK(global_rule_set_); | 123 DCHECK(global_rule_set_); |
120 return global_rule_set_->WatchedSelectorsRuleSet(); | 124 return global_rule_set_->WatchedSelectorsRuleSet(); |
121 } | 125 } |
122 bool HasStyleSheets() const { | 126 bool HasStyleSheets() const { |
123 return GetDocumentStyleSheetCollection().HasStyleSheets(); | 127 return GetDocumentStyleSheetCollection().HasStyleSheets(); |
124 } | 128 } |
125 | 129 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 bool is_master_; | 353 bool is_master_; |
350 | 354 |
351 // Track the number of currently loading top-level stylesheets needed for | 355 // Track the number of currently loading top-level stylesheets needed for |
352 // layout. Sheets loaded using the @import directive are not included in this | 356 // layout. Sheets loaded using the @import directive are not included in this |
353 // count. We use this count of pending sheets to detect when we can begin | 357 // count. We use this count of pending sheets to detect when we can begin |
354 // attaching elements and when it is safe to execute scripts. | 358 // attaching elements and when it is safe to execute scripts. |
355 int pending_script_blocking_stylesheets_ = 0; | 359 int pending_script_blocking_stylesheets_ = 0; |
356 int pending_render_blocking_stylesheets_ = 0; | 360 int pending_render_blocking_stylesheets_ = 0; |
357 int pending_body_stylesheets_ = 0; | 361 int pending_body_stylesheets_ = 0; |
358 | 362 |
359 HeapVector<TraceWrapperMember<CSSStyleSheet>> injected_author_style_sheets_; | 363 HeapVector<std::pair<WebStyleSheetId, TraceWrapperMember<CSSStyleSheet>>> |
| 364 injected_author_style_sheets_; |
360 Member<CSSStyleSheet> inspector_style_sheet_; | 365 Member<CSSStyleSheet> inspector_style_sheet_; |
361 | 366 |
362 TraceWrapperMember<DocumentStyleSheetCollection> | 367 TraceWrapperMember<DocumentStyleSheetCollection> |
363 document_style_sheet_collection_; | 368 document_style_sheet_collection_; |
364 | 369 |
365 Member<StyleRuleUsageTracker> tracker_; | 370 Member<StyleRuleUsageTracker> tracker_; |
366 | 371 |
367 using StyleSheetCollectionMap = | 372 using StyleSheetCollectionMap = |
368 HeapHashMap<WeakMember<TreeScope>, | 373 HeapHashMap<WeakMember<TreeScope>, |
369 Member<ShadowTreeStyleSheetCollection>>; | 374 Member<ShadowTreeStyleSheetCollection>>; |
(...skipping 21 matching lines...) Expand all Loading... |
391 Member<CSSFontSelector> font_selector_; | 396 Member<CSSFontSelector> font_selector_; |
392 | 397 |
393 HeapHashMap<AtomicString, WeakMember<StyleSheetContents>> | 398 HeapHashMap<AtomicString, WeakMember<StyleSheetContents>> |
394 text_to_sheet_cache_; | 399 text_to_sheet_cache_; |
395 HeapHashMap<WeakMember<StyleSheetContents>, AtomicString> | 400 HeapHashMap<WeakMember<StyleSheetContents>, AtomicString> |
396 sheet_to_text_cache_; | 401 sheet_to_text_cache_; |
397 | 402 |
398 std::unique_ptr<StyleResolverStats> style_resolver_stats_; | 403 std::unique_ptr<StyleResolverStats> style_resolver_stats_; |
399 unsigned style_for_element_count_ = 0; | 404 unsigned style_for_element_count_ = 0; |
400 | 405 |
| 406 WebStyleSheetId injected_author_sheets_id_count_ = 0; |
| 407 |
401 friend class StyleEngineTest; | 408 friend class StyleEngineTest; |
402 }; | 409 }; |
403 | 410 |
404 } // namespace blink | 411 } // namespace blink |
405 | 412 |
406 #endif | 413 #endif |
OLD | NEW |