| 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/DeviceOrientationController.h" | 5 #include "modules/device_orientation/DeviceOrientationController.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 25 matching lines...) Expand all Loading... |
| 36 dispatchDeviceEvent(lastEvent()); | 36 dispatchDeviceEvent(lastEvent()); |
| 37 } | 37 } |
| 38 | 38 |
| 39 const char* DeviceOrientationController::supplementName() | 39 const char* DeviceOrientationController::supplementName() |
| 40 { | 40 { |
| 41 return "DeviceOrientationController"; | 41 return "DeviceOrientationController"; |
| 42 } | 42 } |
| 43 | 43 |
| 44 DeviceOrientationController& DeviceOrientationController::from(Document& documen
t) | 44 DeviceOrientationController& DeviceOrientationController::from(Document& documen
t) |
| 45 { | 45 { |
| 46 DeviceOrientationController* controller = static_cast<DeviceOrientationContr
oller*>(WillBeHeapSupplement<Document>::from(document, supplementName())); | 46 DeviceOrientationController* controller = static_cast<DeviceOrientationContr
oller*>(HeapSupplement<Document>::from(document, supplementName())); |
| 47 if (!controller) { | 47 if (!controller) { |
| 48 controller = new DeviceOrientationController(document); | 48 controller = new DeviceOrientationController(document); |
| 49 WillBeHeapSupplement<Document>::provideTo(document, supplementName(), ad
optPtrWillBeNoop(controller)); | 49 HeapSupplement<Document>::provideTo(document, supplementName(), adoptPtr
WillBeNoop(controller)); |
| 50 } | 50 } |
| 51 return *controller; | 51 return *controller; |
| 52 } | 52 } |
| 53 | 53 |
| 54 void DeviceOrientationController::didAddEventListener(LocalDOMWindow* window, co
nst AtomicString& eventType) | 54 void DeviceOrientationController::didAddEventListener(LocalDOMWindow* window, co
nst AtomicString& eventType) |
| 55 { | 55 { |
| 56 if (eventType != eventTypeName()) | 56 if (eventType != eventTypeName()) |
| 57 return; | 57 return; |
| 58 | 58 |
| 59 if (document().frame()) { | 59 if (document().frame()) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 87 void DeviceOrientationController::registerWithDispatcher() | 87 void DeviceOrientationController::registerWithDispatcher() |
| 88 { | 88 { |
| 89 dispatcherInstance().addController(this); | 89 dispatcherInstance().addController(this); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void DeviceOrientationController::unregisterWithDispatcher() | 92 void DeviceOrientationController::unregisterWithDispatcher() |
| 93 { | 93 { |
| 94 dispatcherInstance().removeController(this); | 94 dispatcherInstance().removeController(this); |
| 95 } | 95 } |
| 96 | 96 |
| 97 PassRefPtrWillBeRawPtr<Event> DeviceOrientationController::lastEvent() const | 97 RawPtr<Event> DeviceOrientationController::lastEvent() const |
| 98 { | 98 { |
| 99 return DeviceOrientationEvent::create(eventTypeName(), lastData()); | 99 return DeviceOrientationEvent::create(eventTypeName(), lastData()); |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool DeviceOrientationController::isNullEvent(Event* event) const | 102 bool DeviceOrientationController::isNullEvent(Event* event) const |
| 103 { | 103 { |
| 104 DeviceOrientationEvent* orientationEvent = toDeviceOrientationEvent(event); | 104 DeviceOrientationEvent* orientationEvent = toDeviceOrientationEvent(event); |
| 105 return !orientationEvent->orientation()->canProvideEventData(); | 105 return !orientationEvent->orientation()->canProvideEventData(); |
| 106 } | 106 } |
| 107 | 107 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 128 | 128 |
| 129 DeviceOrientationDispatcher& DeviceOrientationController::dispatcherInstance() c
onst | 129 DeviceOrientationDispatcher& DeviceOrientationController::dispatcherInstance() c
onst |
| 130 { | 130 { |
| 131 return DeviceOrientationDispatcher::instance(false); | 131 return DeviceOrientationDispatcher::instance(false); |
| 132 } | 132 } |
| 133 | 133 |
| 134 DEFINE_TRACE(DeviceOrientationController) | 134 DEFINE_TRACE(DeviceOrientationController) |
| 135 { | 135 { |
| 136 visitor->trace(m_overrideOrientationData); | 136 visitor->trace(m_overrideOrientationData); |
| 137 DeviceSingleWindowEventController::trace(visitor); | 137 DeviceSingleWindowEventController::trace(visitor); |
| 138 WillBeHeapSupplement<Document>::trace(visitor); | 138 HeapSupplement<Document>::trace(visitor); |
| 139 } | 139 } |
| 140 | 140 |
| 141 } // namespace blink | 141 } // namespace blink |
| OLD | NEW |