Chromium Code Reviews| 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 18 matching lines...) Expand all Loading... | |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/dom/DocumentLifecycle.h" | 32 #include "core/dom/DocumentLifecycle.h" |
| 33 | 33 |
| 34 #include "wtf/Assertions.h" | 34 #include "wtf/Assertions.h" |
| 35 #include <stdio.h> | 35 #include <stdio.h> |
| 36 | 36 |
| 37 namespace WebCore { | 37 namespace WebCore { |
| 38 | 38 |
| 39 static DocumentLifecycle::DeprecatedTransition* s_deprecatedTransitionStack = 0; | |
| 40 | |
| 41 DocumentLifecycle::Scope::Scope(DocumentLifecycle& lifecycle, State finalState) | |
| 42 : m_lifecycle(lifecycle) | |
| 43 , m_finalState(finalState) | |
| 44 { | |
| 45 } | |
| 46 | |
| 47 DocumentLifecycle::Scope::~Scope() | |
| 48 { | |
| 49 m_lifecycle.advanceTo(m_finalState); | |
| 50 } | |
| 51 | |
| 52 DocumentLifecycle::DeprecatedTransition::DeprecatedTransition(State from, State to) | |
| 53 : m_previous(s_deprecatedTransitionStack) | |
| 54 , m_from(from) | |
| 55 , m_to(to) | |
| 56 { | |
| 57 s_deprecatedTransitionStack = this; | |
| 58 } | |
| 59 | |
| 60 DocumentLifecycle::DeprecatedTransition::~DeprecatedTransition() | |
| 61 { | |
| 62 s_deprecatedTransitionStack = m_previous; | |
| 63 } | |
| 64 | |
| 39 DocumentLifecycle::DocumentLifecycle() | 65 DocumentLifecycle::DocumentLifecycle() |
| 40 : m_state(Uninitialized) | 66 : m_state(Uninitialized) |
| 41 { | 67 { |
| 42 } | 68 } |
| 43 | 69 |
| 44 DocumentLifecycle::~DocumentLifecycle() | 70 DocumentLifecycle::~DocumentLifecycle() |
| 45 { | 71 { |
| 46 } | 72 } |
| 47 | 73 |
| 74 #if !ASSERT_DISABLED | |
| 75 | |
| 76 static bool isClean(DocumentLifecycle::State state) | |
| 77 { | |
| 78 return state == DocumentLifecycle::StyleClean || state == DocumentLifecycle: :LayoutClean; | |
| 79 } | |
| 80 | |
| 48 bool DocumentLifecycle::canAdvanceTo(State state) const | 81 bool DocumentLifecycle::canAdvanceTo(State state) const |
| 49 { | 82 { |
| 83 // This transition is bogus, but we've whitelisted it anyway. | |
| 84 if (s_deprecatedTransitionStack && m_state == s_deprecatedTransitionStack->f rom() && state == s_deprecatedTransitionStack->to()) | |
| 85 return true; | |
| 86 | |
| 50 if (state > m_state) | 87 if (state > m_state) |
| 51 return true; | 88 return true; |
| 52 // FIXME: We can dispose a document multiple times. This seems wrong. | 89 // FIXME: We can dispose a document multiple times. This seems wrong. |
| 53 // See https://code.google.com/p/chromium/issues/detail?id=301668. | 90 // See https://code.google.com/p/chromium/issues/detail?id=301668. |
| 54 if (m_state == Disposed) | 91 if (m_state == Disposed) { |
| 55 return state == Disposed; | 92 return state == Disposed; |
| 56 if (m_state == Clean) { | 93 } else if (isClean(m_state)) { |
| 57 // We can synchronously enter recalc style without rewinding to | 94 if (state == StyleRecalcPending) |
| 58 // StyleRecalcPending. | 95 return true; |
| 59 return state == InStyleRecalc; | 96 // We can synchronously recalc style. |
| 97 if (state == InStyleRecalc) | |
|
ojan
2014/02/06 05:11:39
Do we really go from LayoutClean to InStyleRecalc
abarth-chromium
2014/02/06 05:31:15
I'm not sure. We can split out those two states t
ojan
2014/02/06 20:36:10
Yeah, that was what I had in mind. It's was a bit
| |
| 98 return true; | |
| 99 // We can synchronously perform layout. | |
| 100 if (state == InPreLayout) | |
| 101 return true; | |
| 102 if (state == InPerformLayout) | |
| 103 return true; | |
| 104 if (isClean(state)) | |
| 105 return true; | |
| 106 return false; | |
| 107 } else if (m_state == InPreLayout) { | |
| 108 return state == InStyleRecalc || state == StyleClean; | |
| 109 } else if (m_state == AfterPerformLayout) { | |
| 110 return state == InPreLayout; | |
|
ojan
2014/02/06 05:11:39
This is for partialLayout?
abarth-chromium
2014/02/06 05:31:15
This case comes up for scroll bars. After layout,
| |
| 60 } | 111 } |
| 61 return false; | 112 return false; |
| 62 } | 113 } |
| 63 | 114 |
| 115 #endif | |
| 116 | |
| 64 void DocumentLifecycle::advanceTo(State state) | 117 void DocumentLifecycle::advanceTo(State state) |
| 65 { | 118 { |
| 66 ASSERT(canAdvanceTo(state)); | 119 ASSERT(canAdvanceTo(state)); |
| 67 m_state = state; | 120 m_state = state; |
| 68 } | 121 } |
| 69 | 122 |
| 70 void DocumentLifecycle::rewindTo(State state) | 123 void DocumentLifecycle::rewindTo(State state) |
| 71 { | 124 { |
| 72 ASSERT(m_state == Clean); | 125 advanceTo(state); |
| 73 ASSERT(state < m_state); | |
| 74 m_state = state; | |
| 75 ASSERT(isActive()); | |
| 76 } | 126 } |
| 77 | 127 |
| 78 } | 128 } |
| OLD | NEW |