OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
Rick Byers
2015/10/21 18:54:46
Ditto on code duplication from DeviceOrientationDi
timvolodine
2015/10/22 15:06:28
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "config.h" | |
6 #include "modules/device_orientation/DeviceOrientationAbsoluteDispatcher.h" | |
7 | |
8 #include "modules/device_orientation/DeviceOrientationAbsoluteController.h" | |
9 #include "modules/device_orientation/DeviceOrientationData.h" | |
10 #include "public/platform/Platform.h" | |
11 | |
12 namespace blink { | |
13 | |
14 DeviceOrientationAbsoluteDispatcher& DeviceOrientationAbsoluteDispatcher::instan ce() | |
15 { | |
16 DEFINE_STATIC_LOCAL(Persistent<DeviceOrientationAbsoluteDispatcher>, deviceO rientationAbsoluteDispatcher, (new DeviceOrientationAbsoluteDispatcher())); | |
17 return *deviceOrientationAbsoluteDispatcher; | |
18 } | |
19 | |
20 DeviceOrientationAbsoluteDispatcher::DeviceOrientationAbsoluteDispatcher() | |
21 { | |
22 } | |
23 | |
24 DeviceOrientationAbsoluteDispatcher::~DeviceOrientationAbsoluteDispatcher() | |
25 { | |
26 } | |
27 | |
28 DEFINE_TRACE(DeviceOrientationAbsoluteDispatcher) | |
29 { | |
30 visitor->trace(m_lastDeviceOrientationData); | |
31 PlatformEventDispatcher::trace(visitor); | |
32 } | |
33 | |
34 void DeviceOrientationAbsoluteDispatcher::startListening() | |
35 { | |
36 Platform::current()->startListening(WebPlatformEventDeviceOrientationAbsolut e, this); | |
37 } | |
38 | |
39 void DeviceOrientationAbsoluteDispatcher::stopListening() | |
40 { | |
41 Platform::current()->stopListening(WebPlatformEventDeviceOrientationAbsolute ); | |
42 m_lastDeviceOrientationData.clear(); | |
43 } | |
44 | |
45 void DeviceOrientationAbsoluteDispatcher::didChangeDeviceOrientation(const WebDe viceOrientationData& motion) | |
46 { | |
47 m_lastDeviceOrientationData = DeviceOrientationData::create(motion); | |
48 notifyControllers(); | |
49 } | |
50 | |
51 DeviceOrientationData* DeviceOrientationAbsoluteDispatcher::latestDeviceOrientat ionData() | |
52 { | |
53 return m_lastDeviceOrientationData.get(); | |
54 } | |
55 | |
56 } // namespace blink | |
OLD | NEW |