OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "wtf/Allocator.h" | 35 #include "wtf/Allocator.h" |
36 #include "wtf/Assertions.h" | 36 #include "wtf/Assertions.h" |
37 #include "wtf/Noncopyable.h" | 37 #include "wtf/Noncopyable.h" |
38 | 38 |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 class CORE_EXPORT DocumentLifecycle { | 41 class CORE_EXPORT DocumentLifecycle { |
42 DISALLOW_NEW(); | 42 DISALLOW_NEW(); |
43 WTF_MAKE_NONCOPYABLE(DocumentLifecycle); | 43 WTF_MAKE_NONCOPYABLE(DocumentLifecycle); |
44 public: | 44 public: |
45 enum State { | 45 enum LifecycleState { |
46 Uninitialized, | 46 Uninitialized, |
47 Inactive, | 47 Inactive, |
48 | 48 |
49 // When the document is active, it traverses these states. | 49 // When the document is active, it traverses these states. |
50 | 50 |
51 VisualUpdatePending, | 51 VisualUpdatePending, |
52 | 52 |
53 InStyleRecalc, | 53 InStyleRecalc, |
54 StyleClean, | 54 StyleClean, |
55 | 55 |
(...skipping 24 matching lines...) Expand all Loading... |
80 // to the style/layout/compositing states. | 80 // to the style/layout/compositing states. |
81 Stopping, | 81 Stopping, |
82 Stopped, | 82 Stopped, |
83 Disposed, | 83 Disposed, |
84 }; | 84 }; |
85 | 85 |
86 class Scope { | 86 class Scope { |
87 STACK_ALLOCATED(); | 87 STACK_ALLOCATED(); |
88 WTF_MAKE_NONCOPYABLE(Scope); | 88 WTF_MAKE_NONCOPYABLE(Scope); |
89 public: | 89 public: |
90 Scope(DocumentLifecycle&, State finalState); | 90 Scope(DocumentLifecycle&, LifecycleState finalState); |
91 ~Scope(); | 91 ~Scope(); |
92 | 92 |
93 private: | 93 private: |
94 DocumentLifecycle& m_lifecycle; | 94 DocumentLifecycle& m_lifecycle; |
95 State m_finalState; | 95 LifecycleState m_finalState; |
96 }; | 96 }; |
97 | 97 |
98 class DeprecatedTransition { | 98 class DeprecatedTransition { |
99 DISALLOW_NEW(); | 99 DISALLOW_NEW(); |
100 WTF_MAKE_NONCOPYABLE(DeprecatedTransition); | 100 WTF_MAKE_NONCOPYABLE(DeprecatedTransition); |
101 public: | 101 public: |
102 DeprecatedTransition(State from, State to); | 102 DeprecatedTransition(LifecycleState from, LifecycleState to); |
103 ~DeprecatedTransition(); | 103 ~DeprecatedTransition(); |
104 | 104 |
105 State from() const { return m_from; } | 105 LifecycleState from() const { return m_from; } |
106 State to() const { return m_to; } | 106 LifecycleState to() const { return m_to; } |
107 | 107 |
108 private: | 108 private: |
109 DeprecatedTransition* m_previous; | 109 DeprecatedTransition* m_previous; |
110 State m_from; | 110 LifecycleState m_from; |
111 State m_to; | 111 LifecycleState m_to; |
112 }; | 112 }; |
113 | 113 |
114 class DetachScope { | 114 class DetachScope { |
115 STACK_ALLOCATED(); | 115 STACK_ALLOCATED(); |
116 WTF_MAKE_NONCOPYABLE(DetachScope); | 116 WTF_MAKE_NONCOPYABLE(DetachScope); |
117 public: | 117 public: |
118 explicit DetachScope(DocumentLifecycle& documentLifecycle) | 118 explicit DetachScope(DocumentLifecycle& documentLifecycle) |
119 : m_documentLifecycle(documentLifecycle) | 119 : m_documentLifecycle(documentLifecycle) |
120 { | 120 { |
121 m_documentLifecycle.incrementDetachCount(); | 121 m_documentLifecycle.incrementDetachCount(); |
(...skipping 13 matching lines...) Expand all Loading... |
135 WTF_MAKE_NONCOPYABLE(AllowThrottlingScope); | 135 WTF_MAKE_NONCOPYABLE(AllowThrottlingScope); |
136 public: | 136 public: |
137 AllowThrottlingScope(DocumentLifecycle&); | 137 AllowThrottlingScope(DocumentLifecycle&); |
138 ~AllowThrottlingScope(); | 138 ~AllowThrottlingScope(); |
139 }; | 139 }; |
140 | 140 |
141 DocumentLifecycle(); | 141 DocumentLifecycle(); |
142 ~DocumentLifecycle(); | 142 ~DocumentLifecycle(); |
143 | 143 |
144 bool isActive() const { return m_state > Inactive && m_state < Stopping; } | 144 bool isActive() const { return m_state > Inactive && m_state < Stopping; } |
145 State state() const { return m_state; } | 145 LifecycleState state() const { return m_state; } |
146 | 146 |
147 bool stateAllowsTreeMutations() const; | 147 bool stateAllowsTreeMutations() const; |
148 bool stateAllowsLayoutTreeMutations() const; | 148 bool stateAllowsLayoutTreeMutations() const; |
149 bool stateAllowsDetach() const; | 149 bool stateAllowsDetach() const; |
150 bool stateAllowsLayoutInvalidation() const; | 150 bool stateAllowsLayoutInvalidation() const; |
151 bool stateAllowsLayoutTreeNotifications() const; | 151 bool stateAllowsLayoutTreeNotifications() const; |
152 | 152 |
153 void advanceTo(State); | 153 void advanceTo(LifecycleState); |
154 void ensureStateAtMost(State); | 154 void ensureStateAtMost(LifecycleState); |
155 | 155 |
156 bool inDetach() const { return m_detachCount; } | 156 bool inDetach() const { return m_detachCount; } |
157 void incrementDetachCount() { m_detachCount++; } | 157 void incrementDetachCount() { m_detachCount++; } |
158 void decrementDetachCount() | 158 void decrementDetachCount() |
159 { | 159 { |
160 ASSERT(m_detachCount > 0); | 160 ASSERT(m_detachCount > 0); |
161 m_detachCount--; | 161 m_detachCount--; |
162 } | 162 } |
163 | 163 |
164 bool throttlingAllowed() const; | 164 bool throttlingAllowed() const; |
165 | 165 |
166 #if ENABLE(ASSERT) | 166 #if ENABLE(ASSERT) |
167 static const char* stateAsDebugString(const State); | 167 static const char* stateAsDebugString(const LifecycleState); |
168 #endif | 168 #endif |
169 | 169 |
170 private: | 170 private: |
171 #if ENABLE(ASSERT) | 171 #if ENABLE(ASSERT) |
172 bool canAdvanceTo(State) const; | 172 bool canAdvanceTo(LifecycleState) const; |
173 bool canRewindTo(State) const; | 173 bool canRewindTo(LifecycleState) const; |
174 #endif | 174 #endif |
175 | 175 |
176 State m_state; | 176 LifecycleState m_state; |
177 int m_detachCount; | 177 int m_detachCount; |
178 }; | 178 }; |
179 | 179 |
180 inline bool DocumentLifecycle::stateAllowsTreeMutations() const | 180 inline bool DocumentLifecycle::stateAllowsTreeMutations() const |
181 { | 181 { |
182 // FIXME: We should not allow mutations in InPreLayout or AfterPerformLayout
either, | 182 // FIXME: We should not allow mutations in InPreLayout or AfterPerformLayout
either, |
183 // but we need to fix MediaList listeners and plugins first. | 183 // but we need to fix MediaList listeners and plugins first. |
184 return m_state != InStyleRecalc | 184 return m_state != InStyleRecalc |
185 && m_state != InPerformLayout | 185 && m_state != InPerformLayout |
186 && m_state != InCompositingUpdate | 186 && m_state != InCompositingUpdate |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 return m_state != InPerformLayout | 218 return m_state != InPerformLayout |
219 && m_state != InCompositingUpdate | 219 && m_state != InCompositingUpdate |
220 && m_state != InPaintInvalidation | 220 && m_state != InPaintInvalidation |
221 && m_state != InUpdatePaintProperties | 221 && m_state != InUpdatePaintProperties |
222 && m_state != InPaint; | 222 && m_state != InPaint; |
223 } | 223 } |
224 | 224 |
225 } // namespace blink | 225 } // namespace blink |
226 | 226 |
227 #endif | 227 #endif |
OLD | NEW |