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

Side by Side Diff: Source/WebCore/dom/UserGestureIndicator.cpp

Issue 10907083: Merge 126609 (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1229/
Patch Set: Created 8 years, 3 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
« no previous file with comments | « Source/WebCore/dom/UserGestureIndicator.h ('k') | Source/WebKit/chromium/public/WebFrame.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « Source/WebCore/dom/UserGestureIndicator.h ('k') | Source/WebKit/chromium/public/WebFrame.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698