Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: Source/core/dom/DocumentLifecycle.cpp

Issue 146023008: Add layout states to DocumentLifecycle state machine (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Whitelist one more transition' Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 14 matching lines...) Expand all
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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>
36 35
37 namespace WebCore { 36 namespace WebCore {
38 37
38 static DocumentLifecycle::DeprecatedTransition* s_deprecatedTransitionStack = 0;
39
40 DocumentLifecycle::Scope::Scope(DocumentLifecycle& lifecycle, State finalState)
41 : m_lifecycle(lifecycle)
42 , m_finalState(finalState)
43 {
44 }
45
46 DocumentLifecycle::Scope::~Scope()
47 {
48 m_lifecycle.advanceTo(m_finalState);
49 }
50
51 DocumentLifecycle::DeprecatedTransition::DeprecatedTransition(State from, State to)
52 : m_previous(s_deprecatedTransitionStack)
53 , m_from(from)
54 , m_to(to)
55 {
56 s_deprecatedTransitionStack = this;
57 }
58
59 DocumentLifecycle::DeprecatedTransition::~DeprecatedTransition()
60 {
61 s_deprecatedTransitionStack = m_previous;
62 }
63
39 DocumentLifecycle::DocumentLifecycle() 64 DocumentLifecycle::DocumentLifecycle()
40 : m_state(Uninitialized) 65 : m_state(Uninitialized)
41 { 66 {
42 } 67 }
43 68
44 DocumentLifecycle::~DocumentLifecycle() 69 DocumentLifecycle::~DocumentLifecycle()
45 { 70 {
46 } 71 }
47 72
73 #if !ASSERT_DISABLED
74
48 bool DocumentLifecycle::canAdvanceTo(State state) const 75 bool DocumentLifecycle::canAdvanceTo(State state) const
49 { 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;
50 if (state > m_state) 80 if (state > m_state)
51 return true; 81 return true;
52 // FIXME: We can dispose a document multiple times. This seems wrong. 82 if (m_state == Disposed) {
53 // See https://code.google.com/p/chromium/issues/detail?id=301668. 83 // FIXME: We can dispose a document multiple times. This seems wrong.
54 if (m_state == Disposed) 84 // See https://code.google.com/p/chromium/issues/detail?id=301668.
55 return state == Disposed; 85 return state == Disposed;
56 if (m_state == Clean) { 86 }
57 // We can synchronously enter recalc style without rewinding to 87 if (m_state == StyleClean) {
58 // StyleRecalcPending. 88 if (state == StyleRecalcPending)
59 return state == InStyleRecalc; 89 return true;
90 // We can synchronously recalc style.
91 if (state == InStyleRecalc)
92 return true;
93 // We can synchronously perform layout.
94 if (state == InPreLayout)
95 return true;
96 if (state == InPerformLayout)
97 return true;
98 // We can redundant arrive in the style clean state.
99 if (state == StyleClean)
100 return true;
101 return false;
102 }
103 if (m_state == InPreLayout) {
104 if (state == InStyleRecalc)
105 return true;
106 if (state == StyleClean)
107 return true;
108 if (state == InPreLayout)
109 return true;
110 return false;
111 }
112 if (m_state == AfterPerformLayout) {
113 if (state == InPreLayout)
114 return true;
115 // 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.
117 if (state == StyleClean)
118 return true;
119 return false;
120 }
121 if (m_state == LayoutClean) {
122 if (state == StyleRecalcPending)
123 return true;
124 // We can synchronously recalc style.
125 if (state == InStyleRecalc)
126 return true;
127 // We can synchronously perform layout.
128 if (state == InPreLayout)
129 return true;
130 if (state == InPerformLayout)
131 return true;
132 // We can redundant arrive in the layout clean state. This situation
133 // can happen when we call layout recursively and we unwind the stack.
134 if (state == LayoutClean)
135 return true;
136 if (state == StyleClean)
137 return true;
138 return false;
60 } 139 }
61 return false; 140 return false;
62 } 141 }
63 142
143 #endif
144
64 void DocumentLifecycle::advanceTo(State state) 145 void DocumentLifecycle::advanceTo(State state)
65 { 146 {
66 ASSERT(canAdvanceTo(state)); 147 ASSERT(canAdvanceTo(state));
67 m_state = state; 148 m_state = state;
68 } 149 }
69 150
70 void DocumentLifecycle::rewindTo(State state)
71 {
72 ASSERT(m_state == Clean);
73 ASSERT(state < m_state);
74 m_state = state;
75 ASSERT(isActive());
76 } 151 }
77
78 }
OLDNEW
« no previous file with comments | « Source/core/dom/DocumentLifecycle.h ('k') | Source/core/frame/DeprecatedScheduleStyleRecalcDuringLayout.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698