1ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com/* 2ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Copyright 2010, The Android Open Source Project 3ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * 4ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * Redistribution and use in source and binary forms, with or without 5ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * modification, are permitted provided that the following conditions 6ec3ed6a5ebf6f2c406d7bcf94b6bc34fcaeb976eepoger@google.com * are met: 7bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com * * Redistributions of source code must retain the above copyright 8b7061176c7f414616fe2e79e832b3e0abe326af6robertphillips@google.com * notice, this list of conditions and the following disclaimer. 9b7061176c7f414616fe2e79e832b3e0abe326af6robertphillips@google.com * * Redistributions in binary form must reproduce the above copyright 10b7061176c7f414616fe2e79e832b3e0abe326af6robertphillips@google.com * notice, this list of conditions and the following disclaimer in the 11a0f5d1546d499ef0cd7dbfba9a866ae5a27e1541reed@android.com * documentation and/or other materials provided with the distribution. 128f6884aab8aecd7657cf3f9cdbc682f0deca29c5tfarina@chromium.org * 13bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY 14aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 17aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18aca1c01f3b39a8159a0ca10ba740d9995027317bcommit-bot@chromium.org * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 198f6884aab8aecd7657cf3f9cdbc682f0deca29c5tfarina@chromium.org * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 20bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 21bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 23bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com */ 25bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com 26bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com#include "config.h" 27bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com#include "modules/device_orientation/DeviceOrientationEvent.h" 28bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com 29bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com#include "modules/device_orientation/DeviceOrientationData.h" 30bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com 31bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.comnamespace blink { 32bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com 33bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.comDeviceOrientationEvent::~DeviceOrientationEvent() 34bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com{ 35bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com} 36bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com 37bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.comDeviceOrientationEvent::DeviceOrientationEvent() 38bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com : m_orientation(DeviceOrientationData::create()) 39bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com{ 40bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com} 41bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com 42bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.comDeviceOrientationEvent::DeviceOrientationEvent(const AtomicString& eventType, DeviceOrientationData* orientation) 43bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com : Event(eventType, false, false) // Can't bubble, not cancelable 44bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com , m_orientation(orientation) 45bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com{ 46bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com} 47bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com 48bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.comvoid DeviceOrientationEvent::initDeviceOrientationEvent(const AtomicString& type, bool bubbles, bool cancelable, DeviceOrientationData* orientation) 49bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com{ 50bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com if (dispatched()) 51bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com return; 52bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com 53bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com initEvent(type, bubbles, cancelable); 54bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com m_orientation = orientation; 55bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com} 56bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com 57bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.comdouble DeviceOrientationEvent::alpha(bool& isNull) const 58bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com{ 59bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com if (m_orientation->canProvideAlpha()) 60bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com return m_orientation->alpha(); 61bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com 62e8807f49ed24be3933acf84c9ffa840a03fa43dccommit-bot@chromium.org isNull = true; 63e8807f49ed24be3933acf84c9ffa840a03fa43dccommit-bot@chromium.org return 0; 64e8807f49ed24be3933acf84c9ffa840a03fa43dccommit-bot@chromium.org} 65e8807f49ed24be3933acf84c9ffa840a03fa43dccommit-bot@chromium.org 66e8807f49ed24be3933acf84c9ffa840a03fa43dccommit-bot@chromium.orgdouble DeviceOrientationEvent::beta(bool& isNull) const 67bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com{ 68bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com if (m_orientation->canProvideBeta()) 69bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com return m_orientation->beta(); 70bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com 71bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com isNull = true; 72bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com return 0; 73bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com} 74bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com 75bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.comdouble DeviceOrientationEvent::gamma(bool& isNull) const 76bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com{ 77bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com if (m_orientation->canProvideGamma()) 78bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com return m_orientation->gamma(); 79bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com 80bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com isNull = true; 81e0e7cfe44bb9d66d76120a79e5275c294bacaa22commit-bot@chromium.org return 0; 82bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com} 83bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com 84bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.combool DeviceOrientationEvent::absolute(bool& isNull) const 85bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com{ 86bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com if (m_orientation->canProvideAbsolute()) 87bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com return m_orientation->absolute(); 88bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com 89bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com isNull = true; 90bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com return 0; 91bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com} 92bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com 9398a196770cc7b9914ad68367c5b06829a5e0b440skia.committer@gmail.comconst AtomicString& DeviceOrientationEvent::interfaceName() const 94bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com{ 95bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com return EventNames::DeviceOrientationEvent; 96bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com} 97bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com 9898a196770cc7b9914ad68367c5b06829a5e0b440skia.committer@gmail.comvoid DeviceOrientationEvent::trace(Visitor* visitor) 99bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com{ 10098a196770cc7b9914ad68367c5b06829a5e0b440skia.committer@gmail.com visitor->trace(m_orientation); 101bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com Event::trace(visitor); 102bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com} 103bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com 104bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com} // namespace blink 105bcb42aecf1bdb9ae80d766d203b4f636b954cf03reed@google.com