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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 ~DetachScope() | 121 ~DetachScope() |
122 { | 122 { |
123 m_documentLifecycle.decrementDetachCount(); | 123 m_documentLifecycle.decrementDetachCount(); |
124 } | 124 } |
125 | 125 |
126 private: | 126 private: |
127 DocumentLifecycle& m_documentLifecycle; | 127 DocumentLifecycle& m_documentLifecycle; |
128 }; | 128 }; |
129 | 129 |
| 130 enum class ThrottlingMode { Disallow, Allow }; |
| 131 |
130 DocumentLifecycle(); | 132 DocumentLifecycle(); |
131 ~DocumentLifecycle(); | 133 ~DocumentLifecycle(); |
132 | 134 |
133 bool isActive() const { return m_state > Inactive && m_state < Stopping; } | 135 bool isActive() const { return m_state > Inactive && m_state < Stopping; } |
134 State state() const { return m_state; } | 136 State state() const { return m_state; } |
135 | 137 |
136 bool stateAllowsTreeMutations() const; | 138 bool stateAllowsTreeMutations() const; |
137 bool stateAllowsLayoutTreeMutations() const; | 139 bool stateAllowsLayoutTreeMutations() const; |
138 bool stateAllowsDetach() const; | 140 bool stateAllowsDetach() const; |
139 bool stateAllowsLayoutInvalidation() const; | 141 bool stateAllowsLayoutInvalidation() const; |
140 bool stateAllowsLayoutTreeNotifications() const; | 142 bool stateAllowsLayoutTreeNotifications() const; |
141 | 143 |
142 void advanceTo(State); | 144 void advanceTo(State); |
143 void ensureStateAtMost(State); | 145 void ensureStateAtMost(State); |
144 | 146 |
145 bool inDetach() const { return m_detachCount; } | 147 bool inDetach() const { return m_detachCount; } |
146 void incrementDetachCount() { m_detachCount++; } | 148 void incrementDetachCount() { m_detachCount++; } |
147 void decrementDetachCount() | 149 void decrementDetachCount() |
148 { | 150 { |
149 ASSERT(m_detachCount > 0); | 151 ASSERT(m_detachCount > 0); |
150 m_detachCount--; | 152 m_detachCount--; |
151 } | 153 } |
152 | 154 |
| 155 void setThrottlingMode(ThrottlingMode); |
| 156 ThrottlingMode throttlingMode() const; |
| 157 |
153 private: | 158 private: |
154 #if ENABLE(ASSERT) | 159 #if ENABLE(ASSERT) |
155 bool canAdvanceTo(State) const; | 160 bool canAdvanceTo(State) const; |
156 bool canRewindTo(State) const; | 161 bool canRewindTo(State) const; |
157 #endif | 162 #endif |
158 | 163 |
159 State m_state; | 164 State m_state; |
160 int m_detachCount; | 165 int m_detachCount; |
| 166 ThrottlingMode m_throttlingMode; |
161 }; | 167 }; |
162 | 168 |
163 inline bool DocumentLifecycle::stateAllowsTreeMutations() const | 169 inline bool DocumentLifecycle::stateAllowsTreeMutations() const |
164 { | 170 { |
165 // FIXME: We should not allow mutations in InPreLayout or AfterPerformLayout
either, | 171 // FIXME: We should not allow mutations in InPreLayout or AfterPerformLayout
either, |
166 // but we need to fix MediaList listeners and plugins first. | 172 // but we need to fix MediaList listeners and plugins first. |
167 return m_state != InStyleRecalc | 173 return m_state != InStyleRecalc |
168 && m_state != InPerformLayout | 174 && m_state != InPerformLayout |
169 && m_state != InCompositingUpdate | 175 && m_state != InCompositingUpdate |
170 && m_state != InPaintForSlimmingPaintV2 | 176 && m_state != InPaintForSlimmingPaintV2 |
(...skipping 30 matching lines...) Expand all Loading... |
201 return m_state != InPerformLayout | 207 return m_state != InPerformLayout |
202 && m_state != InCompositingUpdate | 208 && m_state != InCompositingUpdate |
203 && m_state != InPaintInvalidation | 209 && m_state != InPaintInvalidation |
204 && m_state != InPaintForSlimmingPaintV2 | 210 && m_state != InPaintForSlimmingPaintV2 |
205 && m_state != InCompositingForSlimmingPaintV2; | 211 && m_state != InCompositingForSlimmingPaintV2; |
206 } | 212 } |
207 | 213 |
208 } // namespace blink | 214 } // namespace blink |
209 | 215 |
210 #endif | 216 #endif |
OLD | NEW |