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()) { |
159 static_cast<GestureToken*>(m_token.get())->addGesture(); | 160 static_cast<GestureToken*>(m_token.get())->addGesture(); |
160 static_cast<GestureToken*>(token.get())->consumeGesture(); | 161 static_cast<GestureToken*>(token.get())->consumeGesture(); |
161 } | 162 } |
162 } | 163 } |
163 s_state = DefinitelyProcessingUserGesture; | 164 s_state = DefinitelyProcessingUserGesture; |
164 s_processedUserGestureInPast = true; | |
165 } | 165 } |
166 | 166 |
167 ASSERT(isDefinite(s_state)); | 167 ASSERT(isDefinite(s_state)); |
168 } | 168 } |
169 | 169 |
170 UserGestureIndicator::~UserGestureIndicator() | 170 UserGestureIndicator::~UserGestureIndicator() |
171 { | 171 { |
172 if (!isMainThread()) | 172 if (!isMainThread()) |
173 return; | 173 return; |
174 s_state = m_previousState; | 174 s_state = m_previousState; |
(...skipping 19 matching lines...) Expand all Loading... |
194 UserGestureToken* UserGestureIndicator::currentToken() | 194 UserGestureToken* UserGestureIndicator::currentToken() |
195 { | 195 { |
196 if (!isMainThread() || !s_topmostIndicator) | 196 if (!isMainThread() || !s_topmostIndicator) |
197 return 0; | 197 return 0; |
198 return s_topmostIndicator->m_token.get(); | 198 return s_topmostIndicator->m_token.get(); |
199 } | 199 } |
200 | 200 |
201 void UserGestureIndicator::clearProcessedUserGestureInPast() | 201 void UserGestureIndicator::clearProcessedUserGestureInPast() |
202 { | 202 { |
203 if (isMainThread()) | 203 if (isMainThread()) |
204 s_processedUserGestureInPast = true; | 204 s_processedUserGestureInPast = false; |
205 } | 205 } |
206 | 206 |
207 bool UserGestureIndicator::processedUserGestureInPast() | 207 bool UserGestureIndicator::processedUserGestureInPast() |
208 { | 208 { |
209 if (!isMainThread()) | 209 if (!isMainThread()) |
210 return false; | 210 return false; |
211 return s_processedUserGestureInPast; | 211 return s_processedUserGestureInPast; |
212 } | 212 } |
213 | 213 |
214 UserGestureIndicatorDisabler::UserGestureIndicatorDisabler() | 214 UserGestureIndicatorDisabler::UserGestureIndicatorDisabler() |
215 : m_savedState(UserGestureIndicator::s_state) | 215 : m_savedState(UserGestureIndicator::s_state) |
216 , m_savedIndicator(UserGestureIndicator::s_topmostIndicator) | 216 , m_savedIndicator(UserGestureIndicator::s_topmostIndicator) |
217 { | 217 { |
218 RELEASE_ASSERT(isMainThread()); | 218 RELEASE_ASSERT(isMainThread()); |
219 UserGestureIndicator::s_state = DefinitelyNotProcessingUserGesture; | 219 UserGestureIndicator::s_state = DefinitelyNotProcessingUserGesture; |
220 UserGestureIndicator::s_topmostIndicator = 0; | 220 UserGestureIndicator::s_topmostIndicator = 0; |
221 } | 221 } |
222 | 222 |
223 UserGestureIndicatorDisabler::~UserGestureIndicatorDisabler() | 223 UserGestureIndicatorDisabler::~UserGestureIndicatorDisabler() |
224 { | 224 { |
225 RELEASE_ASSERT(isMainThread()); | 225 RELEASE_ASSERT(isMainThread()); |
226 UserGestureIndicator::s_state = m_savedState; | 226 UserGestureIndicator::s_state = m_savedState; |
227 UserGestureIndicator::s_topmostIndicator = m_savedIndicator; | 227 UserGestureIndicator::s_topmostIndicator = m_savedIndicator; |
228 } | 228 } |
229 | 229 |
230 } | 230 } |
OLD | NEW |