OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CSSGlobalRuleSet_h | 5 #ifndef CSSGlobalRuleSet_h |
6 #define CSSGlobalRuleSet_h | 6 #define CSSGlobalRuleSet_h |
7 | 7 |
8 #include "core/css/RuleFeature.h" | 8 #include "core/css/RuleFeature.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 class Document; | 12 class Document; |
13 class RuleSet; | 13 class RuleSet; |
14 | 14 |
15 // A per Document collection of CSS metadata used for style matching and | 15 // A per Document collection of CSS metadata used for style matching and |
16 // invalidation. The data is aggregated from author rulesets from all TreeScopes | 16 // invalidation. The data is aggregated from author rulesets from all TreeScopes |
17 // in the whole Document as well as UA stylesheets and watched selectors which | 17 // in the whole Document as well as UA stylesheets and watched selectors which |
18 // apply to elements in all TreeScopes. | 18 // apply to elements in all TreeScopes. |
19 // | 19 // |
20 // TODO(rune@opera.com): We would like to move as much of this data as possible | 20 // TODO(rune@opera.com): We would like to move as much of this data as possible |
21 // to the ScopedStyleResolver as possible to avoid full reconstruction of these | 21 // to the ScopedStyleResolver as possible to avoid full reconstruction of these |
22 // rulesets on shadow tree changes. See https://crbug.com/401359 | 22 // rulesets on shadow tree changes. See https://crbug.com/401359 |
23 | 23 |
24 class CSSGlobalRuleSet { | 24 class CSSGlobalRuleSet : public GarbageCollectedFinalized<CSSGlobalRuleSet> { |
25 DISALLOW_NEW(); | |
26 WTF_MAKE_NONCOPYABLE(CSSGlobalRuleSet); | 25 WTF_MAKE_NONCOPYABLE(CSSGlobalRuleSet); |
27 | 26 |
28 public: | 27 public: |
29 CSSGlobalRuleSet() {} | 28 static CSSGlobalRuleSet* Create() { return new CSSGlobalRuleSet(); } |
30 | 29 |
31 void Dispose(); | 30 void Dispose(); |
32 void InitWatchedSelectorsRuleSet(Document&); | 31 void InitWatchedSelectorsRuleSet(Document&); |
33 void MarkDirty() { is_dirty_ = true; } | 32 void MarkDirty() { is_dirty_ = true; } |
34 bool IsDirty() const { return is_dirty_; } | 33 bool IsDirty() const { return is_dirty_; } |
35 void Update(Document&); | 34 void Update(Document&); |
36 | 35 |
37 const RuleFeatureSet& GetRuleFeatureSet() const { | 36 const RuleFeatureSet& GetRuleFeatureSet() const { |
38 CHECK(features_.IsAlive()); | 37 CHECK(features_.IsAlive()); |
39 return features_; | 38 return features_; |
40 } | 39 } |
41 RuleSet* SiblingRuleSet() const { return sibling_rule_set_; } | 40 RuleSet* SiblingRuleSet() const { return sibling_rule_set_; } |
42 RuleSet* UncommonAttributeRuleSet() const { | 41 RuleSet* UncommonAttributeRuleSet() const { |
43 return uncommon_attribute_rule_set_; | 42 return uncommon_attribute_rule_set_; |
44 } | 43 } |
45 RuleSet* WatchedSelectorsRuleSet() const { | 44 RuleSet* WatchedSelectorsRuleSet() const { |
46 return watched_selectors_rule_set_; | 45 return watched_selectors_rule_set_; |
47 } | 46 } |
48 bool HasFullscreenUAStyle() const { return has_fullscreen_ua_style_; } | 47 bool HasFullscreenUAStyle() const { return has_fullscreen_ua_style_; } |
49 | 48 |
50 DECLARE_TRACE(); | 49 DECLARE_TRACE(); |
51 | 50 |
52 private: | 51 private: |
| 52 CSSGlobalRuleSet() {} |
53 // Constructed from rules in all TreeScopes including UA style and style | 53 // Constructed from rules in all TreeScopes including UA style and style |
54 // injected from extensions. | 54 // injected from extensions. |
55 RuleFeatureSet features_; | 55 RuleFeatureSet features_; |
56 Member<RuleSet> sibling_rule_set_; | 56 Member<RuleSet> sibling_rule_set_; |
57 Member<RuleSet> uncommon_attribute_rule_set_; | 57 Member<RuleSet> uncommon_attribute_rule_set_; |
58 | 58 |
59 // Rules injected from extensions. | 59 // Rules injected from extensions. |
60 Member<RuleSet> watched_selectors_rule_set_; | 60 Member<RuleSet> watched_selectors_rule_set_; |
61 | 61 |
62 bool has_fullscreen_ua_style_ = false; | 62 bool has_fullscreen_ua_style_ = false; |
63 bool is_dirty_ = true; | 63 bool is_dirty_ = true; |
64 }; | 64 }; |
65 | 65 |
66 } // namespace blink | 66 } // namespace blink |
67 | 67 |
68 #endif // CSSGlobalRuleSet_h | 68 #endif // CSSGlobalRuleSet_h |
OLD | NEW |