| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 67 } |
| 68 | 68 |
| 69 DocumentLifecycle::~DocumentLifecycle() | 69 DocumentLifecycle::~DocumentLifecycle() |
| 70 { | 70 { |
| 71 } | 71 } |
| 72 | 72 |
| 73 #if !ASSERT_DISABLED | 73 #if !ASSERT_DISABLED |
| 74 | 74 |
| 75 bool DocumentLifecycle::canAdvanceTo(State state) const | 75 bool DocumentLifecycle::canAdvanceTo(State state) const |
| 76 { | 76 { |
| 77 // This transition is bogus, but we've whitelisted it anyway. | |
| 78 if (s_deprecatedTransitionStack && m_state == s_deprecatedTransitionStack->f
rom() && state == s_deprecatedTransitionStack->to()) | |
| 79 return true; | |
| 80 if (state > m_state) | 77 if (state > m_state) |
| 81 return true; | 78 return true; |
| 82 if (m_state == Disposed) { | 79 if (m_state == Disposed) { |
| 83 // FIXME: We can dispose a document multiple times. This seems wrong. | 80 // FIXME: We can dispose a document multiple times. This seems wrong. |
| 84 // See https://code.google.com/p/chromium/issues/detail?id=301668. | 81 // See https://code.google.com/p/chromium/issues/detail?id=301668. |
| 85 return state == Disposed; | 82 return state == Disposed; |
| 86 } | 83 } |
| 87 if (m_state == StyleClean) { | 84 if (m_state == StyleClean) { |
| 88 if (state == StyleRecalcPending) | |
| 89 return true; | |
| 90 // We can synchronously recalc style. | 85 // We can synchronously recalc style. |
| 91 if (state == InStyleRecalc) | 86 if (state == InStyleRecalc) |
| 92 return true; | 87 return true; |
| 93 // We can synchronously perform layout. | 88 // We can synchronously perform layout. |
| 94 if (state == InPreLayout) | 89 if (state == InPreLayout) |
| 95 return true; | 90 return true; |
| 96 if (state == InPerformLayout) | 91 if (state == InPerformLayout) |
| 97 return true; | 92 return true; |
| 98 // We can redundant arrive in the style clean state. | 93 // We can redundant arrive in the style clean state. |
| 99 if (state == StyleClean) | 94 if (state == StyleClean) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 112 if (m_state == AfterPerformLayout) { | 107 if (m_state == AfterPerformLayout) { |
| 113 if (state == InPreLayout) | 108 if (state == InPreLayout) |
| 114 return true; | 109 return true; |
| 115 // If we're doing a partial layout, we won't actually end up cleaning | 110 // If we're doing a partial layout, we won't actually end up cleaning |
| 116 // out all the layout dirty bits. Instead, we'll return to StyleClean. | 111 // out all the layout dirty bits. Instead, we'll return to StyleClean. |
| 117 if (state == StyleClean) | 112 if (state == StyleClean) |
| 118 return true; | 113 return true; |
| 119 return false; | 114 return false; |
| 120 } | 115 } |
| 121 if (m_state == LayoutClean) { | 116 if (m_state == LayoutClean) { |
| 122 if (state == StyleRecalcPending) | |
| 123 return true; | |
| 124 // We can synchronously recalc style. | 117 // We can synchronously recalc style. |
| 125 if (state == InStyleRecalc) | 118 if (state == InStyleRecalc) |
| 126 return true; | 119 return true; |
| 127 // We can synchronously perform layout. | 120 // We can synchronously perform layout. |
| 128 if (state == InPreLayout) | 121 if (state == InPreLayout) |
| 129 return true; | 122 return true; |
| 130 if (state == InPerformLayout) | 123 if (state == InPerformLayout) |
| 131 return true; | 124 return true; |
| 132 // We can redundant arrive in the layout clean state. This situation | 125 // We can redundant arrive in the layout clean state. This situation |
| 133 // can happen when we call layout recursively and we unwind the stack. | 126 // can happen when we call layout recursively and we unwind the stack. |
| 134 if (state == LayoutClean) | 127 if (state == LayoutClean) |
| 135 return true; | 128 return true; |
| 136 if (state == StyleClean) | 129 if (state == StyleClean) |
| 137 return true; | 130 return true; |
| 138 return false; | 131 return false; |
| 139 } | 132 } |
| 140 if (m_state == CompositingClean) { | 133 if (m_state == CompositingClean) { |
| 141 if (state == StyleRecalcPending) | |
| 142 return true; | |
| 143 if (state == InStyleRecalc) | 134 if (state == InStyleRecalc) |
| 144 return true; | 135 return true; |
| 145 if (state == InPreLayout) | 136 if (state == InPreLayout) |
| 146 return true; | 137 return true; |
| 147 if (state == InCompositingUpdate) | 138 if (state == InCompositingUpdate) |
| 148 return true; | 139 return true; |
| 149 return false; | 140 return false; |
| 150 } | 141 } |
| 151 return false; | 142 return false; |
| 152 } | 143 } |
| 153 | 144 |
| 145 bool DocumentLifecycle::canRewindTo(State state) const |
| 146 { |
| 147 // This transition is bogus, but we've whitelisted it anyway. |
| 148 if (s_deprecatedTransitionStack && m_state == s_deprecatedTransitionStack->f
rom() && state == s_deprecatedTransitionStack->to()) |
| 149 return true; |
| 150 return m_state == StyleClean || m_state == AfterPerformLayout || m_state ==
LayoutClean || m_state == CompositingClean; |
| 151 } |
| 152 |
| 154 #endif | 153 #endif |
| 155 | 154 |
| 156 void DocumentLifecycle::advanceTo(State state) | 155 void DocumentLifecycle::advanceTo(State state) |
| 157 { | 156 { |
| 158 ASSERT(canAdvanceTo(state)); | 157 ASSERT(canAdvanceTo(state)); |
| 159 m_state = state; | 158 m_state = state; |
| 160 } | 159 } |
| 161 | 160 |
| 161 void DocumentLifecycle::ensureStateAtMost(State state) |
| 162 { |
| 163 ASSERT(state == VisualUpdatePending || state == StyleClean || state == Layou
tClean); |
| 164 if (m_state <= state) |
| 165 return; |
| 166 ASSERT(canRewindTo(state)); |
| 167 m_state = state; |
| 168 } |
| 169 |
| 162 } | 170 } |
| OLD | NEW |