15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/* 25c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Copyright (C) 2010 Apple Inc. All rights reserved. 35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without 55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * modification, are permitted provided that the following conditions 65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * are met: 75c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 1. Redistributions of source code must retain the above copyright 85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * notice, this list of conditions and the following disclaimer. 95c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 2. Redistributions in binary form must reproduce the above copyright 105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * notice, this list of conditions and the following disclaimer in the 115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * documentation and/or other materials provided with the distribution. 125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * 135c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 165c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2353e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) */ 255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 265c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#ifndef DeviceMotionEvent_h 275c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#define DeviceMotionEvent_h 285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 29d6cdb82654e8f3343a693ca752d5c4cee0324e17Torne (Richard Coles)#include "modules/EventModules.h" 3010f88d5669dbd969c059d61ba09fa37dd72ac559Ben Murdoch#include "platform/heap/Handle.h" 315c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 32c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink { 335c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3453e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)class DeviceAcceleration; 355c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)class DeviceMotionData; 3653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)class DeviceRotationRate; 375c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 3809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)class DeviceMotionEvent FINAL : public Event { 397242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci DEFINE_WRAPPERTYPEINFO(); 405c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)public: 4109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual ~DeviceMotionEvent(); 4207a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch static PassRefPtrWillBeRawPtr<DeviceMotionEvent> create() 435c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) { 44a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch return adoptRefWillBeNoop(new DeviceMotionEvent); 455c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 4607a852d8c1953036774d8f3b65d18dcfea3bb4a2Ben Murdoch static PassRefPtrWillBeRawPtr<DeviceMotionEvent> create(const AtomicString& eventType, DeviceMotionData* deviceMotionData) 475c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) { 48a9984bf9ddc3cf73fdae3f29134a2bab379e7029Ben Murdoch return adoptRefWillBeNoop(new DeviceMotionEvent(eventType, deviceMotionData)); 495c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) } 505c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 515c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) void initDeviceMotionEvent(const AtomicString& type, bool bubbles, bool cancelable, DeviceMotionData*); 525c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 535c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) DeviceMotionData* deviceMotionData() const { return m_deviceMotionData.get(); } 545c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 5553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) DeviceAcceleration* acceleration(); 5653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) DeviceAcceleration* accelerationIncludingGravity(); 5753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) DeviceRotationRate* rotationRate(); 5853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) double interval(bool& isNull) const; 5953e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) 6009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual const AtomicString& interfaceName() const OVERRIDE; 615c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 62d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) virtual void trace(Visitor*) OVERRIDE; 63d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) 645c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)private: 655c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) DeviceMotionEvent(); 665c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) DeviceMotionEvent(const AtomicString& eventType, DeviceMotionData*); 675c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 687242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci PersistentWillBeMember<DeviceMotionData> m_deviceMotionData; 697242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci PersistentWillBeMember<DeviceAcceleration> m_acceleration; 707242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci PersistentWillBeMember<DeviceAcceleration> m_accelerationIncludingGravity; 717242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci PersistentWillBeMember<DeviceRotationRate> m_rotationRate; 725c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)}; 735c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 7409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)DEFINE_TYPE_CASTS(DeviceMotionEvent, Event, event, event->interfaceName() == EventNames::DeviceMotionEvent, event.interfaceName() == EventNames::DeviceMotionEvent); 751e202183a5dc46166763171984b285173f8585e5Torne (Richard Coles) 76c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink 775c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 785c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)#endif // DeviceMotionEvent_h 79