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 27 matching lines...) Expand all Loading... |
38 const double userGestureTimeout = 1.0; | 38 const double userGestureTimeout = 1.0; |
39 | 39 |
40 // For out of process tokens we allow a 10 second delay. | 40 // For out of process tokens we allow a 10 second delay. |
41 const double userGestureOutOfProcessTimeout = 10.0; | 41 const double userGestureOutOfProcessTimeout = 10.0; |
42 | 42 |
43 class GestureToken : public UserGestureToken { | 43 class GestureToken : public UserGestureToken { |
44 public: | 44 public: |
45 static PassRefPtr<UserGestureToken> create() { return adoptRef(new GestureTo
ken); } | 45 static PassRefPtr<UserGestureToken> create() { return adoptRef(new GestureTo
ken); } |
46 | 46 |
47 virtual ~GestureToken() { } | 47 virtual ~GestureToken() { } |
48 virtual bool hasGestures() const OVERRIDE | 48 virtual bool hasGestures() const override |
49 { | 49 { |
50 // Do not enforce timeouts for gestures which spawned javascript prompts
. | 50 // Do not enforce timeouts for gestures which spawned javascript prompts
. |
51 if (m_consumableGestures < 1 || (WTF::currentTime() - m_timestamp > (m_o
utOfProcess ? userGestureOutOfProcessTimeout : userGestureTimeout) && !m_javascr
iptPrompt)) | 51 if (m_consumableGestures < 1 || (WTF::currentTime() - m_timestamp > (m_o
utOfProcess ? userGestureOutOfProcessTimeout : userGestureTimeout) && !m_javascr
iptPrompt)) |
52 return false; | 52 return false; |
53 return true; | 53 return true; |
54 } | 54 } |
55 | 55 |
56 void addGesture() | 56 void addGesture() |
57 { | 57 { |
58 m_consumableGestures++; | 58 m_consumableGestures++; |
59 m_timestamp = WTF::currentTime(); | 59 m_timestamp = WTF::currentTime(); |
60 } | 60 } |
61 | 61 |
62 void resetTimestamp() | 62 void resetTimestamp() |
63 { | 63 { |
64 m_timestamp = WTF::currentTime(); | 64 m_timestamp = WTF::currentTime(); |
65 } | 65 } |
66 | 66 |
67 bool consumeGesture() | 67 bool consumeGesture() |
68 { | 68 { |
69 if (!m_consumableGestures) | 69 if (!m_consumableGestures) |
70 return false; | 70 return false; |
71 m_consumableGestures--; | 71 m_consumableGestures--; |
72 return true; | 72 return true; |
73 } | 73 } |
74 | 74 |
75 virtual void setOutOfProcess() OVERRIDE | 75 virtual void setOutOfProcess() override |
76 { | 76 { |
77 if (WTF::currentTime() - m_timestamp > userGestureTimeout) | 77 if (WTF::currentTime() - m_timestamp > userGestureTimeout) |
78 return; | 78 return; |
79 if (hasGestures()) | 79 if (hasGestures()) |
80 m_outOfProcess = true; | 80 m_outOfProcess = true; |
81 } | 81 } |
82 | 82 |
83 virtual void setJavascriptPrompt() OVERRIDE | 83 virtual void setJavascriptPrompt() override |
84 { | 84 { |
85 if (WTF::currentTime() - m_timestamp > userGestureTimeout) | 85 if (WTF::currentTime() - m_timestamp > userGestureTimeout) |
86 return; | 86 return; |
87 if (hasGestures()) | 87 if (hasGestures()) |
88 m_javascriptPrompt = true; | 88 m_javascriptPrompt = true; |
89 } | 89 } |
90 | 90 |
91 private: | 91 private: |
92 GestureToken() | 92 GestureToken() |
93 : m_consumableGestures(0) | 93 : m_consumableGestures(0) |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |