Chromium Code Reviews| Index: third_party/WebKit/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp |
| diff --git a/third_party/WebKit/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp b/third_party/WebKit/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp |
| index bc997d8ed10ca7c0df767df68fb103c5d4dfd657..7b62cfe52f0dff7da26985c3946ef5f3abfc089f 100644 |
| --- a/third_party/WebKit/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp |
| +++ b/third_party/WebKit/Source/modules/device_orientation/DeviceOrientationDispatcher.cpp |
| @@ -35,15 +35,32 @@ |
| #include "modules/device_orientation/DeviceOrientationData.h" |
| #include "public/platform/Platform.h" |
| +namespace { |
| + |
| +blink::WebPlatformEventType getWebPlatformEventType(bool absolute) |
|
Rick Byers
2015/10/22 16:00:52
nit: make this a private const method of the class
timvolodine
2015/10/27 16:38:35
Done.
|
| +{ |
| + return (absolute) ? blink::WebPlatformEventTypeDeviceOrientationAbsolute : blink::WebPlatformEventTypeDeviceOrientation; |
| +} |
| + |
| +} // namespace |
| + |
| namespace blink { |
| -DeviceOrientationDispatcher& DeviceOrientationDispatcher::instance() |
| +template<> |
| +DeviceOrientationDispatcher& DeviceOrientationDispatcher::instance<true>() |
| +{ |
| + DEFINE_STATIC_LOCAL(Persistent<DeviceOrientationDispatcher>, deviceOrientationAbsoluteDispatcher, (new DeviceOrientationDispatcher(true))); |
|
Rick Byers
2015/10/22 16:00:52
rather than use template specialization here, woul
timvolodine
2015/10/27 16:38:35
yes, looks like using a template is a bit of overk
|
| + return *deviceOrientationAbsoluteDispatcher; |
| +} |
| + |
| +template<> |
| +DeviceOrientationDispatcher& DeviceOrientationDispatcher::instance<false>() |
| { |
| - DEFINE_STATIC_LOCAL(Persistent<DeviceOrientationDispatcher>, deviceOrientationDispatcher, (new DeviceOrientationDispatcher())); |
| + DEFINE_STATIC_LOCAL(Persistent<DeviceOrientationDispatcher>, deviceOrientationDispatcher, (new DeviceOrientationDispatcher(false))); |
| return *deviceOrientationDispatcher; |
| } |
| -DeviceOrientationDispatcher::DeviceOrientationDispatcher() |
| +DeviceOrientationDispatcher::DeviceOrientationDispatcher(bool absolute) : m_absolute(absolute) |
| { |
| } |
| @@ -59,12 +76,12 @@ DEFINE_TRACE(DeviceOrientationDispatcher) |
| void DeviceOrientationDispatcher::startListening() |
| { |
| - Platform::current()->startListening(WebPlatformEventTypeDeviceOrientation, this); |
| + Platform::current()->startListening(getWebPlatformEventType(m_absolute), this); |
| } |
| void DeviceOrientationDispatcher::stopListening() |
| { |
| - Platform::current()->stopListening(WebPlatformEventTypeDeviceOrientation); |
| + Platform::current()->stopListening(getWebPlatformEventType(m_absolute)); |
| m_lastDeviceOrientationData.clear(); |
| } |