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

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

Issue 156413002: [WIP] Move layout states into the DocumentLifecycle state machine (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: uber patch 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
75 static bool isClean(DocumentLifecycle::State state)
76 {
77 return state == DocumentLifecycle::StyleClean || state == DocumentLifecycle: :LayoutClean;
78 }
79
48 bool DocumentLifecycle::canAdvanceTo(State state) const 80 bool DocumentLifecycle::canAdvanceTo(State state) const
49 { 81 {
82 // This transition is bogus, but we've whitelisted it anyway.
83 if (s_deprecatedTransitionStack && m_state == s_deprecatedTransitionStack->f rom() && state == s_deprecatedTransitionStack->to())
84 return true;
85
50 if (state > m_state) 86 if (state > m_state)
51 return true; 87 return true;
52 // FIXME: We can dispose a document multiple times. This seems wrong. 88 // FIXME: We can dispose a document multiple times. This seems wrong.
53 // See https://code.google.com/p/chromium/issues/detail?id=301668. 89 // See https://code.google.com/p/chromium/issues/detail?id=301668.
54 if (m_state == Disposed) 90 if (m_state == Disposed) {
55 return state == Disposed; 91 return state == Disposed;
56 if (m_state == Clean) { 92 } else if (isClean(m_state)) {
57 // We can synchronously enter recalc style without rewinding to 93 if (state == StyleRecalcPending)
58 // StyleRecalcPending. 94 return true;
59 return state == InStyleRecalc; 95 // We can synchronously recalc style.
96 if (state == InStyleRecalc)
97 return true;
98 // We can synchronously perform layout.
99 if (state == InPreLayout)
100 return true;
101 if (state == InPerformLayout)
102 return true;
103 if (isClean(state))
104 return true;
105 return false;
106 } else if (m_state == InPreLayout) {
107 if (state == InStyleRecalc)
108 return true;
109 if (state == StyleClean)
110 return true;
111 if (state == InPreLayout)
112 return true;
113 return false;
114 } else if (m_state == AfterPerformLayout) {
115 if (state == InPreLayout)
116 return true;
117 // If we're doing a partial layout, we won't actually end up cleaning
118 // out all the layout dirty bits. Instead, we'll return to StyleClean.
119 if (state == StyleClean)
120 return true;
121 return false;
60 } 122 }
61 return false; 123 return false;
62 } 124 }
63 125
126 #endif
127
64 void DocumentLifecycle::advanceTo(State state) 128 void DocumentLifecycle::advanceTo(State state)
65 { 129 {
66 ASSERT(canAdvanceTo(state)); 130 ASSERT(canAdvanceTo(state));
67 m_state = state; 131 m_state = state;
68 } 132 }
69 133
70 void DocumentLifecycle::rewindTo(State state) 134 void DocumentLifecycle::rewindTo(State state)
71 { 135 {
72 ASSERT(m_state == Clean); 136 advanceTo(state);
73 ASSERT(state < m_state);
74 m_state = state;
75 ASSERT(isActive());
76 } 137 }
77 138
78 } 139 }
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