| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Apple Inc. All rights reserved. | 2 * Copyright 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2012 Samsung Electronics. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 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 copyright | 10 * * Redistributions in binary form must reproduce the above copyright |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "RuntimeEnabledFeatures.h" | 30 #include "RuntimeEnabledFeatures.h" |
| 31 #include "core/dom/Document.h" | 31 #include "core/dom/Document.h" |
| 32 #include "core/events/ThreadLocalEventNames.h" | 32 #include "core/events/ThreadLocalEventNames.h" |
| 33 #include "core/page/Page.h" | 33 #include "core/page/Page.h" |
| 34 #include "modules/device_orientation/DeviceMotionData.h" | 34 #include "modules/device_orientation/DeviceMotionData.h" |
| 35 #include "modules/device_orientation/DeviceMotionDispatcher.h" | 35 #include "modules/device_orientation/DeviceMotionDispatcher.h" |
| 36 #include "modules/device_orientation/DeviceMotionEvent.h" | 36 #include "modules/device_orientation/DeviceMotionEvent.h" |
| 37 | 37 |
| 38 namespace WebCore { | 38 namespace WebCore { |
| 39 | 39 |
| 40 DeviceMotionController::DeviceMotionController(Document* document) | 40 DeviceMotionController::DeviceMotionController(Document& document) |
| 41 : DeviceSensorEventController(document) | 41 : DeviceSensorEventController(document) |
| 42 , DOMWindowLifecycleObserver(document->domWindow()) | 42 , DOMWindowLifecycleObserver(document.domWindow()) |
| 43 { | 43 { |
| 44 } | 44 } |
| 45 | 45 |
| 46 DeviceMotionController::~DeviceMotionController() | 46 DeviceMotionController::~DeviceMotionController() |
| 47 { | 47 { |
| 48 stopUpdating(); | 48 stopUpdating(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void DeviceMotionController::didChangeDeviceMotion(DeviceMotionData* deviceMotio
nData) | 51 void DeviceMotionController::didChangeDeviceMotion(DeviceMotionData* deviceMotio
nData) |
| 52 { | 52 { |
| 53 dispatchDeviceEvent(DeviceMotionEvent::create(EventTypeNames::devicemotion,
deviceMotionData)); | 53 dispatchDeviceEvent(DeviceMotionEvent::create(EventTypeNames::devicemotion,
deviceMotionData)); |
| 54 } | 54 } |
| 55 | 55 |
| 56 const char* DeviceMotionController::supplementName() | 56 const char* DeviceMotionController::supplementName() |
| 57 { | 57 { |
| 58 return "DeviceMotionController"; | 58 return "DeviceMotionController"; |
| 59 } | 59 } |
| 60 | 60 |
| 61 DeviceMotionController* DeviceMotionController::from(Document* document) | 61 DeviceMotionController& DeviceMotionController::from(Document& document) |
| 62 { | 62 { |
| 63 DeviceMotionController* controller = static_cast<DeviceMotionController*>(Do
cumentSupplement::from(document, supplementName())); | 63 DeviceMotionController* controller = static_cast<DeviceMotionController*>(Do
cumentSupplement::from(document, supplementName())); |
| 64 if (!controller) { | 64 if (!controller) { |
| 65 controller = new DeviceMotionController(document); | 65 controller = new DeviceMotionController(document); |
| 66 DocumentSupplement::provideTo(document, supplementName(), adoptPtr(contr
oller)); | 66 DocumentSupplement::provideTo(document, supplementName(), adoptPtr(contr
oller)); |
| 67 } | 67 } |
| 68 return controller; | 68 return *controller; |
| 69 } | 69 } |
| 70 | 70 |
| 71 bool DeviceMotionController::hasLastData() | 71 bool DeviceMotionController::hasLastData() |
| 72 { | 72 { |
| 73 return DeviceMotionDispatcher::instance().latestDeviceMotionData(); | 73 return DeviceMotionDispatcher::instance().latestDeviceMotionData(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 PassRefPtr<Event> DeviceMotionController::getLastEvent() | 76 PassRefPtr<Event> DeviceMotionController::getLastEvent() |
| 77 { | 77 { |
| 78 return DeviceMotionEvent::create(EventTypeNames::devicemotion, DeviceMotionD
ispatcher::instance().latestDeviceMotionData()); | 78 return DeviceMotionEvent::create(EventTypeNames::devicemotion, DeviceMotionD
ispatcher::instance().latestDeviceMotionData()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 void DeviceMotionController::didRemoveAllEventListeners(DOMWindow*) | 114 void DeviceMotionController::didRemoveAllEventListeners(DOMWindow*) |
| 115 { | 115 { |
| 116 stopUpdating(); | 116 stopUpdating(); |
| 117 m_hasEventListener = false; | 117 m_hasEventListener = false; |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace WebCore | 120 } // namespace WebCore |
| OLD | NEW |