Chromium Code Reviews| Index: Source/core/dom/DocumentLifecycle.cpp |
| diff --git a/Source/core/dom/DocumentLifecycle.cpp b/Source/core/dom/DocumentLifecycle.cpp |
| index d53e0bc9bede645eb3c4b02477a488f283a14232..2f7b818d6452f29b99632b65407a514c14c64dfb 100644 |
| --- a/Source/core/dom/DocumentLifecycle.cpp |
| +++ b/Source/core/dom/DocumentLifecycle.cpp |
| @@ -36,6 +36,32 @@ |
| namespace WebCore { |
| +static DocumentLifecycle::DeprecatedTransition* s_deprecatedTransitionStack = 0; |
| + |
| +DocumentLifecycle::Scope::Scope(DocumentLifecycle& lifecycle, State finalState) |
| + : m_lifecycle(lifecycle) |
| + , m_finalState(finalState) |
| +{ |
| +} |
| + |
| +DocumentLifecycle::Scope::~Scope() |
| +{ |
| + m_lifecycle.advanceTo(m_finalState); |
| +} |
| + |
| +DocumentLifecycle::DeprecatedTransition::DeprecatedTransition(State from, State to) |
| + : m_previous(s_deprecatedTransitionStack) |
| + , m_from(from) |
| + , m_to(to) |
| +{ |
| + s_deprecatedTransitionStack = this; |
| +} |
| + |
| +DocumentLifecycle::DeprecatedTransition::~DeprecatedTransition() |
| +{ |
| + s_deprecatedTransitionStack = m_previous; |
| +} |
| + |
| DocumentLifecycle::DocumentLifecycle() |
| : m_state(Uninitialized) |
| { |
| @@ -45,34 +71,79 @@ DocumentLifecycle::~DocumentLifecycle() |
| { |
| } |
| +#if !ASSERT_DISABLED |
| + |
| bool DocumentLifecycle::canAdvanceTo(State state) const |
| { |
| + // This transition is bogus, but we've whitelisted it anyway. |
| + if (s_deprecatedTransitionStack && m_state == s_deprecatedTransitionStack->from() && state == s_deprecatedTransitionStack->to()) |
| + return true; |
| if (state > m_state) |
| return true; |
| - // FIXME: We can dispose a document multiple times. This seems wrong. |
| - // See https://code.google.com/p/chromium/issues/detail?id=301668. |
| - if (m_state == Disposed) |
| + if (m_state == Disposed) { |
|
ojan
2014/02/07 02:08:46
Nit: should these if-statements be a switch statem
|
| + // FIXME: We can dispose a document multiple times. This seems wrong. |
| + // See https://code.google.com/p/chromium/issues/detail?id=301668. |
| return state == Disposed; |
| - if (m_state == Clean) { |
| - // We can synchronously enter recalc style without rewinding to |
| - // StyleRecalcPending. |
| - return state == InStyleRecalc; |
| + } |
| + if (m_state == StyleClean) { |
| + if (state == StyleRecalcPending) |
| + return true; |
| + // We can synchronously recalc style. |
| + if (state == InStyleRecalc) |
| + return true; |
| + // We can synchronously perform layout. |
| + if (state == InPreLayout) |
| + return true; |
| + if (state == InPerformLayout) |
| + return true; |
| + // We can redundant arrive in the style clean state. |
|
ojan
2014/02/07 02:08:46
This is a little weird to me. I guess Document::re
abarth-chromium
2014/02/07 02:18:51
Yeah. It just doesn't do any work.
|
| + if (state == StyleClean) |
| + return true; |
| + return false; |
| + } |
| + if (m_state == InPreLayout) { |
| + if (state == InStyleRecalc) |
| + return true; |
| + if (state == StyleClean) |
| + return true; |
| + if (state == InPreLayout) |
| + return true; |
| + return false; |
| + } |
| + if (m_state == AfterPerformLayout) { |
| + if (state == InPreLayout) |
| + return true; |
| + // If we're doing a partial layout, we won't actually end up cleaning |
| + // out all the layout dirty bits. Instead, we'll return to StyleClean. |
| + if (state == StyleClean) |
| + return true; |
| + return false; |
| + } |
| + if (m_state == LayoutClean) { |
| + if (state == StyleRecalcPending) |
| + return true; |
| + // We can synchronously recalc style. |
| + if (state == InStyleRecalc) |
| + return true; |
| + // We can synchronously perform layout. |
| + if (state == InPreLayout) |
| + return true; |
| + if (state == InPerformLayout) |
| + return true; |
| + // We can redundant arrive in the layout clean state. |
|
ojan
2014/02/07 02:08:46
Ditto...FrameView::layout doesn't early return eit
abarth-chromium
2014/02/07 02:18:51
It's because layout is recursive. As you walk up
|
| + if (state == LayoutClean) |
| + return true; |
| + return false; |
| } |
| return false; |
| } |
| +#endif |
| + |
| void DocumentLifecycle::advanceTo(State state) |
| { |
| ASSERT(canAdvanceTo(state)); |
| m_state = state; |
| } |
| -void DocumentLifecycle::rewindTo(State state) |
| -{ |
| - ASSERT(m_state == Clean); |
| - ASSERT(state < m_state); |
| - m_state = state; |
| - ASSERT(isActive()); |
| -} |
| - |
| } |