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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 85 } |
86 | 86 |
87 void UserGestureToken::userGestureUtilized() { | 87 void UserGestureToken::userGestureUtilized() { |
88 if (m_usageCallback) { | 88 if (m_usageCallback) { |
89 m_usageCallback->userGestureUtilized(); | 89 m_usageCallback->userGestureUtilized(); |
90 m_usageCallback = nullptr; | 90 m_usageCallback = nullptr; |
91 } | 91 } |
92 } | 92 } |
93 | 93 |
94 UserGestureToken* UserGestureIndicator::s_rootToken = nullptr; | 94 UserGestureToken* UserGestureIndicator::s_rootToken = nullptr; |
95 bool UserGestureIndicator::s_processedUserGestureSinceLoad = false; | |
96 | 95 |
97 UserGestureIndicator::UserGestureIndicator(PassRefPtr<UserGestureToken> token) | 96 UserGestureIndicator::UserGestureIndicator(PassRefPtr<UserGestureToken> token) |
98 : m_token(token) { | 97 : m_token(token) { |
99 // Silently ignore UserGestureIndicators on non-main threads. | 98 // Silently ignore UserGestureIndicators on non-main threads. |
100 if (!isMainThread() || !m_token) | 99 if (!isMainThread() || !m_token) |
101 return; | 100 return; |
102 | 101 |
103 if (!s_rootToken) | 102 if (!s_rootToken) |
104 s_rootToken = m_token.get(); | 103 s_rootToken = m_token.get(); |
105 else | 104 else |
106 m_token->transferGestureTo(s_rootToken); | 105 m_token->transferGestureTo(s_rootToken); |
107 s_processedUserGestureSinceLoad = true; | |
108 } | 106 } |
109 | 107 |
110 UserGestureIndicator::~UserGestureIndicator() { | 108 UserGestureIndicator::~UserGestureIndicator() { |
111 if (isMainThread() && m_token && m_token == s_rootToken) { | 109 if (isMainThread() && m_token && m_token == s_rootToken) { |
112 s_rootToken->setUserGestureUtilizedCallback(nullptr); | 110 s_rootToken->setUserGestureUtilizedCallback(nullptr); |
113 s_rootToken = nullptr; | 111 s_rootToken = nullptr; |
114 } | 112 } |
115 } | 113 } |
116 | 114 |
117 // static | 115 // static |
(...skipping 26 matching lines...) Expand all Loading... |
144 return false; | 142 return false; |
145 } | 143 } |
146 | 144 |
147 // static | 145 // static |
148 UserGestureToken* UserGestureIndicator::currentToken() { | 146 UserGestureToken* UserGestureIndicator::currentToken() { |
149 if (!isMainThread() || !s_rootToken) | 147 if (!isMainThread() || !s_rootToken) |
150 return nullptr; | 148 return nullptr; |
151 return s_rootToken; | 149 return s_rootToken; |
152 } | 150 } |
153 | 151 |
154 // static | |
155 void UserGestureIndicator::clearProcessedUserGestureSinceLoad() { | |
156 if (isMainThread()) | |
157 s_processedUserGestureSinceLoad = false; | |
158 } | |
159 | |
160 // static | |
161 bool UserGestureIndicator::processedUserGestureSinceLoad() { | |
162 if (!isMainThread()) | |
163 return false; | |
164 return s_processedUserGestureSinceLoad; | |
165 } | |
166 | |
167 } // namespace blink | 152 } // namespace blink |
OLD | NEW |