Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "modules/device_orientation/DeviceOrientationDispatcher.h" | 32 #include "modules/device_orientation/DeviceOrientationDispatcher.h" |
| 33 | 33 |
| 34 #include "modules/device_orientation/DeviceOrientationController.h" | 34 #include "modules/device_orientation/DeviceOrientationController.h" |
| 35 #include "modules/device_orientation/DeviceOrientationData.h" | 35 #include "modules/device_orientation/DeviceOrientationData.h" |
| 36 #include "public/platform/Platform.h" | 36 #include "public/platform/Platform.h" |
| 37 | 37 |
| 38 namespace blink { | 38 namespace blink { |
| 39 | 39 |
| 40 DeviceOrientationDispatcher& DeviceOrientationDispatcher::instance() | 40 DeviceOrientationDispatcher& DeviceOrientationDispatcher::instance(bool absolute ) |
| 41 { | 41 { |
| 42 DEFINE_STATIC_LOCAL(Persistent<DeviceOrientationDispatcher>, deviceOrientati onDispatcher, (new DeviceOrientationDispatcher())); | 42 if (absolute) { |
| 43 DEFINE_STATIC_LOCAL(Persistent<DeviceOrientationDispatcher>, deviceOrien tationAbsoluteDispatcher, (new DeviceOrientationDispatcher(absolute))); | |
|
haraken
2015/10/28 18:18:38
Shouldn't this be DeviceOrientationAbsoluteDispatc
timvolodine
2015/10/29 13:49:18
no, we've only one dispatcher class (parameterized
| |
| 44 return *deviceOrientationAbsoluteDispatcher; | |
| 45 } | |
| 46 DEFINE_STATIC_LOCAL(Persistent<DeviceOrientationDispatcher>, deviceOrientati onDispatcher, (new DeviceOrientationDispatcher(absolute))); | |
| 43 return *deviceOrientationDispatcher; | 47 return *deviceOrientationDispatcher; |
| 44 } | 48 } |
| 45 | 49 |
| 46 DeviceOrientationDispatcher::DeviceOrientationDispatcher() | 50 DeviceOrientationDispatcher::DeviceOrientationDispatcher(bool absolute) : m_abso lute(absolute) |
| 47 { | 51 { |
| 48 } | 52 } |
| 49 | 53 |
| 50 DeviceOrientationDispatcher::~DeviceOrientationDispatcher() | 54 DeviceOrientationDispatcher::~DeviceOrientationDispatcher() |
| 51 { | 55 { |
| 52 } | 56 } |
| 53 | 57 |
| 54 DEFINE_TRACE(DeviceOrientationDispatcher) | 58 DEFINE_TRACE(DeviceOrientationDispatcher) |
| 55 { | 59 { |
| 56 visitor->trace(m_lastDeviceOrientationData); | 60 visitor->trace(m_lastDeviceOrientationData); |
| 57 PlatformEventDispatcher::trace(visitor); | 61 PlatformEventDispatcher::trace(visitor); |
| 58 } | 62 } |
| 59 | 63 |
| 60 void DeviceOrientationDispatcher::startListening() | 64 void DeviceOrientationDispatcher::startListening() |
| 61 { | 65 { |
| 62 Platform::current()->startListening(WebPlatformEventTypeDeviceOrientation, t his); | 66 Platform::current()->startListening(getWebPlatformEventType(), this); |
| 63 } | 67 } |
| 64 | 68 |
| 65 void DeviceOrientationDispatcher::stopListening() | 69 void DeviceOrientationDispatcher::stopListening() |
| 66 { | 70 { |
| 67 Platform::current()->stopListening(WebPlatformEventTypeDeviceOrientation); | 71 Platform::current()->stopListening(getWebPlatformEventType()); |
| 68 m_lastDeviceOrientationData.clear(); | 72 m_lastDeviceOrientationData.clear(); |
| 69 } | 73 } |
| 70 | 74 |
| 71 void DeviceOrientationDispatcher::didChangeDeviceOrientation(const WebDeviceOrie ntationData& motion) | 75 void DeviceOrientationDispatcher::didChangeDeviceOrientation(const WebDeviceOrie ntationData& motion) |
| 72 { | 76 { |
| 73 m_lastDeviceOrientationData = DeviceOrientationData::create(motion); | 77 m_lastDeviceOrientationData = DeviceOrientationData::create(motion); |
| 74 notifyControllers(); | 78 notifyControllers(); |
| 75 } | 79 } |
| 76 | 80 |
| 77 DeviceOrientationData* DeviceOrientationDispatcher::latestDeviceOrientationData( ) | 81 DeviceOrientationData* DeviceOrientationDispatcher::latestDeviceOrientationData( ) |
| 78 { | 82 { |
| 79 return m_lastDeviceOrientationData.get(); | 83 return m_lastDeviceOrientationData.get(); |
| 80 } | 84 } |
| 81 | 85 |
| 86 WebPlatformEventType DeviceOrientationDispatcher::getWebPlatformEventType() cons t | |
| 87 { | |
| 88 return (m_absolute) ? WebPlatformEventTypeDeviceOrientationAbsolute : WebPla tformEventTypeDeviceOrientation; | |
| 89 } | |
| 90 | |
| 82 } // namespace blink | 91 } // namespace blink |
| OLD | NEW |