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 "core/dom/Document.h" | 30 #include "core/dom/Document.h" |
31 #include "core/frame/DOMWindow.h" | 31 #include "core/frame/DOMWindow.h" |
32 #include "core/page/Page.h" | 32 #include "core/page/Page.h" |
33 #include "modules/device_orientation/DeviceMotionData.h" | 33 #include "modules/device_orientation/DeviceMotionData.h" |
34 #include "modules/device_orientation/DeviceMotionDispatcher.h" | 34 #include "modules/device_orientation/DeviceMotionDispatcher.h" |
35 #include "modules/device_orientation/DeviceMotionEvent.h" | 35 #include "modules/device_orientation/DeviceMotionEvent.h" |
36 | 36 |
37 namespace WebCore { | 37 namespace WebCore { |
38 | 38 |
39 DeviceMotionController::DeviceMotionController(Document& document) | 39 DeviceMotionController::DeviceMotionController(Document& document) |
40 : DeviceSensorEventController(document) | 40 : DeviceSensorEventController(document.page()) |
41 , DOMWindowLifecycleObserver(document.domWindow()) | 41 , DOMWindowLifecycleObserver(document.domWindow()) |
| 42 , m_document(document) |
42 { | 43 { |
43 } | 44 } |
44 | 45 |
45 DeviceMotionController::~DeviceMotionController() | 46 DeviceMotionController::~DeviceMotionController() |
46 { | 47 { |
47 stopUpdating(); | 48 stopUpdating(); |
48 } | 49 } |
49 | 50 |
50 void DeviceMotionController::didChangeDeviceMotion(DeviceMotionData* deviceMotio
nData) | 51 void DeviceMotionController::didChangeDeviceMotion(DeviceMotionData* deviceMotio
nData) |
51 { | 52 { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 { | 87 { |
87 DeviceMotionDispatcher::instance().removeDeviceMotionController(this); | 88 DeviceMotionDispatcher::instance().removeDeviceMotionController(this); |
88 } | 89 } |
89 | 90 |
90 bool DeviceMotionController::isNullEvent(Event* event) | 91 bool DeviceMotionController::isNullEvent(Event* event) |
91 { | 92 { |
92 DeviceMotionEvent* motionEvent = toDeviceMotionEvent(event); | 93 DeviceMotionEvent* motionEvent = toDeviceMotionEvent(event); |
93 return !motionEvent->deviceMotionData()->canProvideEventData(); | 94 return !motionEvent->deviceMotionData()->canProvideEventData(); |
94 } | 95 } |
95 | 96 |
| 97 Document* DeviceMotionController::document() |
| 98 { |
| 99 return &m_document; |
| 100 } |
| 101 |
96 void DeviceMotionController::didAddEventListener(DOMWindow* window, const Atomic
String& eventType) | 102 void DeviceMotionController::didAddEventListener(DOMWindow* window, const Atomic
String& eventType) |
97 { | 103 { |
98 if (eventType != EventTypeNames::devicemotion) | 104 if (eventType != EventTypeNames::devicemotion) |
99 return; | 105 return; |
100 | 106 |
101 if (page() && page()->visibilityState() == PageVisibilityStateVisible) | 107 if (page() && page()->visibilityState() == PageVisibilityStateVisible) |
102 startUpdating(); | 108 startUpdating(); |
103 | 109 |
104 m_hasEventListener = true; | 110 m_hasEventListener = true; |
105 } | 111 } |
106 | 112 |
107 void DeviceMotionController::didRemoveEventListener(DOMWindow* window, const Ato
micString& eventType) | 113 void DeviceMotionController::didRemoveEventListener(DOMWindow* window, const Ato
micString& eventType) |
108 { | 114 { |
109 if (eventType != EventTypeNames::devicemotion || window->hasEventListeners(E
ventTypeNames::devicemotion)) | 115 if (eventType != EventTypeNames::devicemotion || window->hasEventListeners(E
ventTypeNames::devicemotion)) |
110 return; | 116 return; |
111 | 117 |
112 stopUpdating(); | 118 stopUpdating(); |
113 m_hasEventListener = false; | 119 m_hasEventListener = false; |
114 } | 120 } |
115 | 121 |
116 void DeviceMotionController::didRemoveAllEventListeners(DOMWindow*) | 122 void DeviceMotionController::didRemoveAllEventListeners(DOMWindow*) |
117 { | 123 { |
118 stopUpdating(); | 124 stopUpdating(); |
119 m_hasEventListener = false; | 125 m_hasEventListener = false; |
120 } | 126 } |
121 | 127 |
122 } // namespace WebCore | 128 } // namespace WebCore |
OLD | NEW |