OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011 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 14 matching lines...) Expand all Loading... |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "core/platform/mac/ScrollElasticityController.h" | 27 #include "core/platform/mac/ScrollElasticityController.h" |
28 | 28 |
29 #include <sys/sysctl.h> | 29 #include <sys/sysctl.h> |
30 #include <sys/time.h> | 30 #include <sys/time.h> |
31 #include "core/platform/PlatformWheelEvent.h" | 31 #include "core/platform/PlatformWheelEvent.h" |
32 | 32 |
33 #if ENABLE(RUBBER_BANDING) | 33 #if ENABLE(RUBBER_BANDING) |
34 | 34 |
35 #if __MAC_OS_X_VERSION_MIN_REQUIRED == 1050 | |
36 @interface NSProcessInfo (ScrollAnimatorMacExt) | |
37 - (NSTimeInterval)systemUptime; | |
38 @end | |
39 #endif | |
40 | |
41 #if ENABLE(RUBBER_BANDING) | |
42 static NSTimeInterval systemUptime() | 35 static NSTimeInterval systemUptime() |
43 { | 36 { |
44 if ([[NSProcessInfo processInfo] respondsToSelector:@selector(systemUptime)]
) | 37 if ([[NSProcessInfo processInfo] respondsToSelector:@selector(systemUptime)]
) |
45 return [[NSProcessInfo processInfo] systemUptime]; | 38 return [[NSProcessInfo processInfo] systemUptime]; |
46 | 39 |
47 // Get how long system has been up. Found by looking getting "boottime" from
the kernel. | 40 // Get how long system has been up. Found by looking getting "boottime" from
the kernel. |
48 static struct timeval boottime = {0, 0}; | 41 static struct timeval boottime = {0, 0}; |
49 if (!boottime.tv_sec) { | 42 if (!boottime.tv_sec) { |
50 int mib[2] = {CTL_KERN, KERN_BOOTTIME}; | 43 int mib[2] = {CTL_KERN, KERN_BOOTTIME}; |
51 size_t size = sizeof(boottime); | 44 size_t size = sizeof(boottime); |
52 if (-1 == sysctl(mib, 2, &boottime, &size, 0, 0)) | 45 if (-1 == sysctl(mib, 2, &boottime, &size, 0, 0)) |
53 boottime.tv_sec = 0; | 46 boottime.tv_sec = 0; |
54 } | 47 } |
55 struct timeval now; | 48 struct timeval now; |
56 if (boottime.tv_sec && -1 != gettimeofday(&now, 0)) { | 49 if (boottime.tv_sec && -1 != gettimeofday(&now, 0)) { |
57 struct timeval uptime; | 50 struct timeval uptime; |
58 timersub(&now, &boottime, &uptime); | 51 timersub(&now, &boottime, &uptime); |
59 NSTimeInterval result = uptime.tv_sec + (uptime.tv_usec / 1E+6); | 52 NSTimeInterval result = uptime.tv_sec + (uptime.tv_usec / 1E+6); |
60 return result; | 53 return result; |
61 } | 54 } |
62 return 0; | 55 return 0; |
63 } | 56 } |
64 #endif | |
65 | |
66 | 57 |
67 namespace WebCore { | 58 namespace WebCore { |
68 | 59 |
69 static const float scrollVelocityZeroingTimeout = 0.10f; | 60 static const float scrollVelocityZeroingTimeout = 0.10f; |
70 static const float rubberbandDirectionLockStretchRatio = 1; | 61 static const float rubberbandDirectionLockStretchRatio = 1; |
71 static const float rubberbandMinimumRequiredDeltaBeforeStretch = 10; | 62 static const float rubberbandMinimumRequiredDeltaBeforeStretch = 10; |
72 | 63 |
73 static const float rubberbandStiffness = 20; | 64 static const float rubberbandStiffness = 20; |
74 static const float rubberbandAmplitude = 0.31f; | 65 static const float rubberbandAmplitude = 0.31f; |
75 static const float rubberbandPeriod = 1.6f; | 66 static const float rubberbandPeriod = 1.6f; |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 return m_client->shouldRubberBandInDirection(ScrollLeft); | 404 return m_client->shouldRubberBandInDirection(ScrollLeft); |
414 if (wheelEvent.deltaX() < 0) | 405 if (wheelEvent.deltaX() < 0) |
415 return m_client->shouldRubberBandInDirection(ScrollRight); | 406 return m_client->shouldRubberBandInDirection(ScrollRight); |
416 | 407 |
417 return true; | 408 return true; |
418 } | 409 } |
419 | 410 |
420 } // namespace WebCore | 411 } // namespace WebCore |
421 | 412 |
422 #endif // ENABLE(RUBBER_BANDING) | 413 #endif // ENABLE(RUBBER_BANDING) |
OLD | NEW |