| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 // spinning too busily and provides a balance between CPU spinning and | 44 // spinning too busily and provides a balance between CPU spinning and |
| 45 // the smallest possible interval timer. | 45 // the smallest possible interval timer. |
| 46 static const double minimumInterval = 0.004; | 46 static const double minimumInterval = 0.004; |
| 47 | 47 |
| 48 static int timerNestingLevel = 0; | 48 static int timerNestingLevel = 0; |
| 49 | 49 |
| 50 static inline bool shouldForwardUserGesture(int interval, int nestingLevel) | 50 static inline bool shouldForwardUserGesture(int interval, int nestingLevel) |
| 51 { | 51 { |
| 52 return UserGestureIndicator::processingUserGesture() | 52 return UserGestureIndicator::processingUserGesture() |
| 53 && interval <= maxIntervalForUserGestureForwarding | 53 && interval <= maxIntervalForUserGestureForwarding |
| 54 && nestingLevel == 1; // Gestures should not be forwarded to nested time
rs. | 54 && nestingLevel == 1 |
| 55 && !UserGestureIndicator::currentToken()->wasForwarded(); |
| 55 } | 56 } |
| 56 | 57 |
| 57 double DOMTimer::hiddenPageAlignmentInterval() | 58 double DOMTimer::hiddenPageAlignmentInterval() |
| 58 { | 59 { |
| 59 // Timers on hidden pages are aligned so that they fire once per | 60 // Timers on hidden pages are aligned so that they fire once per |
| 60 // second at most. | 61 // second at most. |
| 61 return 1.0; | 62 return 1.0; |
| 62 } | 63 } |
| 63 | 64 |
| 64 double DOMTimer::visiblePageAlignmentInterval() | 65 double DOMTimer::visiblePageAlignmentInterval() |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 { | 108 { |
| 108 return m_timeoutID; | 109 return m_timeoutID; |
| 109 } | 110 } |
| 110 | 111 |
| 111 void DOMTimer::fired() | 112 void DOMTimer::fired() |
| 112 { | 113 { |
| 113 ExecutionContext* context = executionContext(); | 114 ExecutionContext* context = executionContext(); |
| 114 timerNestingLevel = m_nestingLevel; | 115 timerNestingLevel = m_nestingLevel; |
| 115 ASSERT(!context->activeDOMObjectsAreSuspended()); | 116 ASSERT(!context->activeDOMObjectsAreSuspended()); |
| 116 // Only the first execution of a multi-shot timer should get an affirmative
user gesture indicator. | 117 // Only the first execution of a multi-shot timer should get an affirmative
user gesture indicator. |
| 118 if (m_userGestureToken) |
| 119 m_userGestureToken->setForwarded(); |
| 117 UserGestureIndicator gestureIndicator(m_userGestureToken.release()); | 120 UserGestureIndicator gestureIndicator(m_userGestureToken.release()); |
| 118 | 121 |
| 119 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireTi
mer(context, m_timeoutID); | 122 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireTi
mer(context, m_timeoutID); |
| 120 | 123 |
| 121 // Simple case for non-one-shot timers. | 124 // Simple case for non-one-shot timers. |
| 122 if (isActive()) { | 125 if (isActive()) { |
| 123 if (repeatInterval() && repeatInterval() < minimumInterval) { | 126 if (repeatInterval() && repeatInterval() < minimumInterval) { |
| 124 m_nestingLevel++; | 127 m_nestingLevel++; |
| 125 if (m_nestingLevel >= maxTimerNestingLevel) | 128 if (m_nestingLevel >= maxTimerNestingLevel) |
| 126 augmentRepeatInterval(minimumInterval - repeatInterval()); | 129 augmentRepeatInterval(minimumInterval - repeatInterval()); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 if (fireTime - alignedTimeRoundedDown < minimumInterval) | 194 if (fireTime - alignedTimeRoundedDown < minimumInterval) |
| 192 return alignedTimeRoundedDown; | 195 return alignedTimeRoundedDown; |
| 193 | 196 |
| 194 return alignedTimeRoundedUp; | 197 return alignedTimeRoundedUp; |
| 195 } | 198 } |
| 196 | 199 |
| 197 return fireTime; | 200 return fireTime; |
| 198 } | 201 } |
| 199 | 202 |
| 200 } // namespace WebCore | 203 } // namespace WebCore |
| OLD | NEW |