| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 Apple Inc. All rights reserved. | 2 * Copyright 2010 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * * Redistributions of source code must retain the above copyright | 7 * * Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * * Redistributions in binary form must reproduce the above copyright | 9 * * Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 | 47 |
| 48 void DeviceMotionController::timerFired(Timer<DeviceMotionController>* timer) | 48 void DeviceMotionController::timerFired(Timer<DeviceMotionController>* timer) |
| 49 { | 49 { |
| 50 ASSERT_UNUSED(timer, timer == &m_timer); | 50 ASSERT_UNUSED(timer, timer == &m_timer); |
| 51 ASSERT(!m_client || m_client->currentDeviceMotion()); | 51 ASSERT(!m_client || m_client->currentDeviceMotion()); |
| 52 m_timer.stop(); | 52 m_timer.stop(); |
| 53 | 53 |
| 54 RefPtr<DeviceMotionData> deviceMotionData = m_client ? m_client->currentDevi
ceMotion() : DeviceMotionData::create(); | 54 RefPtr<DeviceMotionData> deviceMotionData = m_client ? m_client->currentDevi
ceMotion() : DeviceMotionData::create(); |
| 55 RefPtr<DeviceMotionEvent> event = DeviceMotionEvent::create(eventNames().dev
icemotionEvent, deviceMotionData.get()); | 55 RefPtr<DeviceMotionEvent> event = DeviceMotionEvent::create(eventNames().dev
icemotionEvent, deviceMotionData.get()); |
| 56 | 56 |
| 57 Vector<DOMWindow*> listenersVector; | 57 Vector<RefPtr<DOMWindow> > listenersVector; |
| 58 copyToVector(m_newListeners, listenersVector); | 58 copyToVector(m_newListeners, listenersVector); |
| 59 m_newListeners.clear(); | 59 m_newListeners.clear(); |
| 60 for (size_t i = 0; i < listenersVector.size(); ++i) | 60 for (size_t i = 0; i < listenersVector.size(); ++i) |
| 61 listenersVector[i]->dispatchEvent(event); | 61 listenersVector[i]->dispatchEvent(event); |
| 62 } | 62 } |
| 63 | 63 |
| 64 void DeviceMotionController::addListener(DOMWindow* window) | 64 void DeviceMotionController::addListener(DOMWindow* window) |
| 65 { | 65 { |
| 66 // If no client is present or the client already has motion data, | 66 // If no client is present or the client already has motion data, |
| 67 // immediately trigger an asynchronous response. | 67 // immediately trigger an asynchronous response. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 93 | 93 |
| 94 m_listeners.removeAll(window); | 94 m_listeners.removeAll(window); |
| 95 m_newListeners.remove(window); | 95 m_newListeners.remove(window); |
| 96 if (m_listeners.isEmpty() && m_client) | 96 if (m_listeners.isEmpty() && m_client) |
| 97 m_client->stopUpdating(); | 97 m_client->stopUpdating(); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void DeviceMotionController::didChangeDeviceMotion(DeviceMotionData* deviceMotio
nData) | 100 void DeviceMotionController::didChangeDeviceMotion(DeviceMotionData* deviceMotio
nData) |
| 101 { | 101 { |
| 102 RefPtr<DeviceMotionEvent> event = DeviceMotionEvent::create(eventNames().dev
icemotionEvent, deviceMotionData); | 102 RefPtr<DeviceMotionEvent> event = DeviceMotionEvent::create(eventNames().dev
icemotionEvent, deviceMotionData); |
| 103 Vector<DOMWindow*> listenersVector; | 103 Vector<RefPtr<DOMWindow> > listenersVector; |
| 104 copyToVector(m_listeners, listenersVector); | 104 copyToVector(m_listeners, listenersVector); |
| 105 for (size_t i = 0; i < listenersVector.size(); ++i) | 105 for (size_t i = 0; i < listenersVector.size(); ++i) |
| 106 listenersVector[i]->dispatchEvent(event); | 106 listenersVector[i]->dispatchEvent(event); |
| 107 } | 107 } |
| 108 | 108 |
| 109 } // namespace WebCore | 109 } // namespace WebCore |
| OLD | NEW |