| 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 16 matching lines...) Expand all Loading... |
| 27 #include "UserGestureIndicator.h" | 27 #include "UserGestureIndicator.h" |
| 28 | 28 |
| 29 namespace WebCore { | 29 namespace WebCore { |
| 30 | 30 |
| 31 static bool isDefinite(ProcessingUserGestureState state) | 31 static bool isDefinite(ProcessingUserGestureState state) |
| 32 { | 32 { |
| 33 return state == DefinitelyProcessingUserGesture || state == DefinitelyNotPro
cessingUserGesture; | 33 return state == DefinitelyProcessingUserGesture || state == DefinitelyNotPro
cessingUserGesture; |
| 34 } | 34 } |
| 35 | 35 |
| 36 ProcessingUserGestureState UserGestureIndicator::s_state = DefinitelyNotProcessi
ngUserGesture; | 36 ProcessingUserGestureState UserGestureIndicator::s_state = DefinitelyNotProcessi
ngUserGesture; |
| 37 size_t UserGestureIndicator::s_consumableGestures = 0; |
| 37 | 38 |
| 38 UserGestureIndicator::UserGestureIndicator(ProcessingUserGestureState state) | 39 UserGestureIndicator::UserGestureIndicator(ProcessingUserGestureState state) |
| 39 : m_previousState(s_state) | 40 : m_previousState(s_state) |
| 40 { | 41 { |
| 41 // We overwrite s_state only if the caller is definite about the gesture sta
te. | 42 // We overwrite s_state only if the caller is definite about the gesture sta
te. |
| 42 if (isDefinite(state)) | 43 if (isDefinite(state)) |
| 43 s_state = state; | 44 s_state = state; |
| 45 |
| 46 if (s_state == DefinitelyProcessingUserGesture) |
| 47 s_consumableGestures++; |
| 44 ASSERT(isDefinite(s_state)); | 48 ASSERT(isDefinite(s_state)); |
| 45 } | 49 } |
| 46 | 50 |
| 47 UserGestureIndicator::~UserGestureIndicator() | 51 UserGestureIndicator::~UserGestureIndicator() |
| 48 { | 52 { |
| 53 if (s_consumableGestures && s_state == DefinitelyProcessingUserGesture) |
| 54 s_consumableGestures--; |
| 49 s_state = m_previousState; | 55 s_state = m_previousState; |
| 50 ASSERT(isDefinite(s_state)); | 56 ASSERT(isDefinite(s_state)); |
| 51 } | 57 } |
| 52 | 58 |
| 59 bool UserGestureIndicator::consumeUserGesture() |
| 60 { |
| 61 if (!s_consumableGestures) |
| 62 return false; |
| 63 s_consumableGestures--; |
| 64 return true; |
| 53 } | 65 } |
| 66 |
| 67 } |
| OLD | NEW |