| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/device_orientation/DeviceMotionController.h" | 5 #include "modules/device_orientation/DeviceMotionController.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/frame/Deprecation.h" | 8 #include "core/frame/Deprecation.h" |
| 9 #include "core/frame/OriginsUsingFeatures.h" | 9 #include "core/frame/OriginsUsingFeatures.h" |
| 10 #include "core/frame/Settings.h" | 10 #include "core/frame/Settings.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 #endif | 29 #endif |
| 30 } | 30 } |
| 31 | 31 |
| 32 const char* DeviceMotionController::supplementName() | 32 const char* DeviceMotionController::supplementName() |
| 33 { | 33 { |
| 34 return "DeviceMotionController"; | 34 return "DeviceMotionController"; |
| 35 } | 35 } |
| 36 | 36 |
| 37 DeviceMotionController& DeviceMotionController::from(Document& document) | 37 DeviceMotionController& DeviceMotionController::from(Document& document) |
| 38 { | 38 { |
| 39 DeviceMotionController* controller = static_cast<DeviceMotionController*>(Wi
llBeHeapSupplement<Document>::from(document, supplementName())); | 39 DeviceMotionController* controller = static_cast<DeviceMotionController*>(He
apSupplement<Document>::from(document, supplementName())); |
| 40 if (!controller) { | 40 if (!controller) { |
| 41 controller = new DeviceMotionController(document); | 41 controller = new DeviceMotionController(document); |
| 42 WillBeHeapSupplement<Document>::provideTo(document, supplementName(), ad
optPtrWillBeNoop(controller)); | 42 HeapSupplement<Document>::provideTo(document, supplementName(), adoptPtr
WillBeNoop(controller)); |
| 43 } | 43 } |
| 44 return *controller; | 44 return *controller; |
| 45 } | 45 } |
| 46 | 46 |
| 47 void DeviceMotionController::didAddEventListener(LocalDOMWindow* window, const A
tomicString& eventType) | 47 void DeviceMotionController::didAddEventListener(LocalDOMWindow* window, const A
tomicString& eventType) |
| 48 { | 48 { |
| 49 if (eventType != eventTypeName()) | 49 if (eventType != eventTypeName()) |
| 50 return; | 50 return; |
| 51 | 51 |
| 52 if (document().frame()) { | 52 if (document().frame()) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 75 void DeviceMotionController::registerWithDispatcher() | 75 void DeviceMotionController::registerWithDispatcher() |
| 76 { | 76 { |
| 77 DeviceMotionDispatcher::instance().addController(this); | 77 DeviceMotionDispatcher::instance().addController(this); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void DeviceMotionController::unregisterWithDispatcher() | 80 void DeviceMotionController::unregisterWithDispatcher() |
| 81 { | 81 { |
| 82 DeviceMotionDispatcher::instance().removeController(this); | 82 DeviceMotionDispatcher::instance().removeController(this); |
| 83 } | 83 } |
| 84 | 84 |
| 85 PassRefPtrWillBeRawPtr<Event> DeviceMotionController::lastEvent() const | 85 RawPtr<Event> DeviceMotionController::lastEvent() const |
| 86 { | 86 { |
| 87 return DeviceMotionEvent::create(EventTypeNames::devicemotion, DeviceMotionD
ispatcher::instance().latestDeviceMotionData()); | 87 return DeviceMotionEvent::create(EventTypeNames::devicemotion, DeviceMotionD
ispatcher::instance().latestDeviceMotionData()); |
| 88 } | 88 } |
| 89 | 89 |
| 90 bool DeviceMotionController::isNullEvent(Event* event) const | 90 bool DeviceMotionController::isNullEvent(Event* event) const |
| 91 { | 91 { |
| 92 DeviceMotionEvent* motionEvent = toDeviceMotionEvent(event); | 92 DeviceMotionEvent* motionEvent = toDeviceMotionEvent(event); |
| 93 return !motionEvent->getDeviceMotionData()->canProvideEventData(); | 93 return !motionEvent->getDeviceMotionData()->canProvideEventData(); |
| 94 } | 94 } |
| 95 | 95 |
| 96 const AtomicString& DeviceMotionController::eventTypeName() const | 96 const AtomicString& DeviceMotionController::eventTypeName() const |
| 97 { | 97 { |
| 98 return EventTypeNames::devicemotion; | 98 return EventTypeNames::devicemotion; |
| 99 } | 99 } |
| 100 | 100 |
| 101 DEFINE_TRACE(DeviceMotionController) | 101 DEFINE_TRACE(DeviceMotionController) |
| 102 { | 102 { |
| 103 DeviceSingleWindowEventController::trace(visitor); | 103 DeviceSingleWindowEventController::trace(visitor); |
| 104 WillBeHeapSupplement<Document>::trace(visitor); | 104 HeapSupplement<Document>::trace(visitor); |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace blink | 107 } // namespace blink |
| OLD | NEW |