OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 | 123 |
124 // We overwrite s_state only if the caller is definite about the gesture sta te. | 124 // We overwrite s_state only if the caller is definite about the gesture sta te. |
125 if (isDefinite(state)) { | 125 if (isDefinite(state)) { |
126 if (!s_topmostIndicator) { | 126 if (!s_topmostIndicator) { |
127 s_topmostIndicator = this; | 127 s_topmostIndicator = this; |
128 m_token = GestureToken::create(); | 128 m_token = GestureToken::create(); |
129 } else { | 129 } else { |
130 m_token = s_topmostIndicator->currentToken(); | 130 m_token = s_topmostIndicator->currentToken(); |
131 } | 131 } |
132 s_state = state; | 132 s_state = state; |
133 if (state == DefinitelyProcessingNewUserGesture || state == DefinitelyPr ocessingUserGesture) | |
134 s_processedUserGestureInPast = true; | |
135 } | 133 } |
136 | 134 |
137 if (state == DefinitelyProcessingNewUserGesture) | 135 if (state == DefinitelyProcessingNewUserGesture) { |
138 static_cast<GestureToken*>(m_token.get())->addGesture(); | 136 static_cast<GestureToken*>(m_token.get())->addGesture(); |
139 else if (state == DefinitelyProcessingUserGesture && s_topmostIndicator == t his) | 137 s_processedUserGestureInPast = true; |
138 } else if (state == DefinitelyProcessingUserGesture && s_topmostIndicator == this) { | |
140 static_cast<GestureToken*>(m_token.get())->addGesture(); | 139 static_cast<GestureToken*>(m_token.get())->addGesture(); |
140 s_processedUserGestureInPast = true; | |
141 } | |
141 ASSERT(isDefinite(s_state)); | 142 ASSERT(isDefinite(s_state)); |
142 } | 143 } |
143 | 144 |
144 UserGestureIndicator::UserGestureIndicator(PassRefPtr<UserGestureToken> token) | 145 UserGestureIndicator::UserGestureIndicator(PassRefPtr<UserGestureToken> token) |
145 : m_previousState(s_state) | 146 : m_previousState(s_state) |
146 { | 147 { |
147 // Silently ignore UserGestureIndicators on non-main threads. | 148 // Silently ignore UserGestureIndicators on non-main threads. |
148 if (!isMainThread()) | 149 if (!isMainThread()) |
149 return; | 150 return; |
150 | 151 |
151 if (token) { | 152 if (token) { |
152 static_cast<GestureToken*>(token.get())->resetTimestamp(); | 153 static_cast<GestureToken*>(token.get())->resetTimestamp(); |
153 if (!s_topmostIndicator) { | 154 if (!s_topmostIndicator) { |
154 s_topmostIndicator = this; | 155 s_topmostIndicator = this; |
155 m_token = token; | 156 m_token = token; |
156 } else { | 157 } else { |
157 m_token = s_topmostIndicator->currentToken(); | 158 m_token = s_topmostIndicator->currentToken(); |
158 if (static_cast<GestureToken*>(token.get())->hasGestures()) { | 159 if (static_cast<GestureToken*>(token.get())->hasGestures()) { |
160 s_processedUserGestureInPast = true; | |
jochen (gone - plz use gerrit)
2014/04/17 08:25:38
here we're not really adding a gesture, we're just
vabr (Chromium)
2014/04/17 13:55:56
Good point, I will remove the line.
The flag was f
| |
159 static_cast<GestureToken*>(m_token.get())->addGesture(); | 161 static_cast<GestureToken*>(m_token.get())->addGesture(); |
160 static_cast<GestureToken*>(token.get())->consumeGesture(); | 162 static_cast<GestureToken*>(token.get())->consumeGesture(); |
161 } | 163 } |
162 } | 164 } |
163 s_state = DefinitelyProcessingUserGesture; | 165 s_state = DefinitelyProcessingUserGesture; |
164 s_processedUserGestureInPast = true; | |
165 } | 166 } |
166 | 167 |
167 ASSERT(isDefinite(s_state)); | 168 ASSERT(isDefinite(s_state)); |
168 } | 169 } |
169 | 170 |
170 UserGestureIndicator::~UserGestureIndicator() | 171 UserGestureIndicator::~UserGestureIndicator() |
171 { | 172 { |
172 if (!isMainThread()) | 173 if (!isMainThread()) |
173 return; | 174 return; |
174 s_state = m_previousState; | 175 s_state = m_previousState; |
(...skipping 19 matching lines...) Expand all Loading... | |
194 UserGestureToken* UserGestureIndicator::currentToken() | 195 UserGestureToken* UserGestureIndicator::currentToken() |
195 { | 196 { |
196 if (!isMainThread() || !s_topmostIndicator) | 197 if (!isMainThread() || !s_topmostIndicator) |
197 return 0; | 198 return 0; |
198 return s_topmostIndicator->m_token.get(); | 199 return s_topmostIndicator->m_token.get(); |
199 } | 200 } |
200 | 201 |
201 void UserGestureIndicator::clearProcessedUserGestureInPast() | 202 void UserGestureIndicator::clearProcessedUserGestureInPast() |
202 { | 203 { |
203 if (isMainThread()) | 204 if (isMainThread()) |
204 s_processedUserGestureInPast = true; | 205 s_processedUserGestureInPast = false; |
205 } | 206 } |
206 | 207 |
207 bool UserGestureIndicator::processedUserGestureInPast() | 208 bool UserGestureIndicator::processedUserGestureInPast() |
208 { | 209 { |
209 if (!isMainThread()) | 210 if (!isMainThread()) |
210 return false; | 211 return false; |
211 return s_processedUserGestureInPast; | 212 return s_processedUserGestureInPast; |
212 } | 213 } |
213 | 214 |
214 UserGestureIndicatorDisabler::UserGestureIndicatorDisabler() | 215 UserGestureIndicatorDisabler::UserGestureIndicatorDisabler() |
215 : m_savedState(UserGestureIndicator::s_state) | 216 : m_savedState(UserGestureIndicator::s_state) |
216 , m_savedIndicator(UserGestureIndicator::s_topmostIndicator) | 217 , m_savedIndicator(UserGestureIndicator::s_topmostIndicator) |
217 { | 218 { |
218 RELEASE_ASSERT(isMainThread()); | 219 RELEASE_ASSERT(isMainThread()); |
219 UserGestureIndicator::s_state = DefinitelyNotProcessingUserGesture; | 220 UserGestureIndicator::s_state = DefinitelyNotProcessingUserGesture; |
220 UserGestureIndicator::s_topmostIndicator = 0; | 221 UserGestureIndicator::s_topmostIndicator = 0; |
221 } | 222 } |
222 | 223 |
223 UserGestureIndicatorDisabler::~UserGestureIndicatorDisabler() | 224 UserGestureIndicatorDisabler::~UserGestureIndicatorDisabler() |
224 { | 225 { |
225 RELEASE_ASSERT(isMainThread()); | 226 RELEASE_ASSERT(isMainThread()); |
226 UserGestureIndicator::s_state = m_savedState; | 227 UserGestureIndicator::s_state = m_savedState; |
227 UserGestureIndicator::s_topmostIndicator = m_savedIndicator; | 228 UserGestureIndicator::s_topmostIndicator = m_savedIndicator; |
228 } | 229 } |
229 | 230 |
230 } | 231 } |
OLD | NEW |