OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * |
| 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions |
| 6 * are met: |
| 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright |
| 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. |
| 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ |
| 25 |
| 26 #include "config.h" |
| 27 #include <public/WebDeviceMotionData.h> |
| 28 #include <modules/device_orientation/DeviceMotionData.h> |
| 29 #include <wtf/PassRefPtr.h> |
| 30 |
| 31 namespace WebKit { |
| 32 |
| 33 WebDeviceMotionData::WebDeviceMotionData() |
| 34 : m_interval(0) |
| 35 , m_hasAccelerationX(false) |
| 36 , m_hasAccelerationY(false) |
| 37 , m_hasAccelerationZ(false) |
| 38 , m_hasAccelerationIncludingGravityX(false) |
| 39 , m_hasAccelerationIncludingGravityY(false) |
| 40 , m_hasAccelerationIncludingGravityZ(false) |
| 41 , m_hasRotationRateAlpha(false) |
| 42 , m_hasRotationRateBeta(false) |
| 43 , m_hasRotationRateGamma(false) |
| 44 { |
| 45 } |
| 46 |
| 47 void WebDeviceMotionData::setAccelerationX(double acceleration) |
| 48 { |
| 49 m_hasAccelerationX = true; |
| 50 m_accelerationX = acceleration; |
| 51 } |
| 52 |
| 53 void WebDeviceMotionData::setAccelerationY(double acceleration) |
| 54 { |
| 55 m_hasAccelerationY = true; |
| 56 m_accelerationY = acceleration; |
| 57 } |
| 58 |
| 59 void WebDeviceMotionData::setAccelerationZ(double acceleration) |
| 60 { |
| 61 m_hasAccelerationZ = true; |
| 62 m_accelerationZ = acceleration; |
| 63 } |
| 64 |
| 65 void WebDeviceMotionData::setAccelerationIncludingGravityX(double acceleration) |
| 66 { |
| 67 m_hasAccelerationIncludingGravityX = true; |
| 68 m_accelerationIncludingGravityX = acceleration; |
| 69 } |
| 70 |
| 71 void WebDeviceMotionData::setAccelerationIncludingGravityY(double acceleration) |
| 72 { |
| 73 m_hasAccelerationIncludingGravityY = true; |
| 74 m_accelerationIncludingGravityY = acceleration; |
| 75 } |
| 76 |
| 77 void WebDeviceMotionData::setAccelerationIncludingGravityZ(double acceleration) |
| 78 { |
| 79 m_hasAccelerationIncludingGravityZ = true; |
| 80 m_accelerationIncludingGravityZ = acceleration; |
| 81 } |
| 82 |
| 83 void WebDeviceMotionData::setRotationRateAlpha(double rate) |
| 84 { |
| 85 m_hasRotationRateAlpha = true; |
| 86 m_rotationRateAlpha = rate; |
| 87 } |
| 88 |
| 89 void WebDeviceMotionData::setRotationRateBeta(double rate) |
| 90 { |
| 91 m_hasRotationRateBeta = true; |
| 92 m_rotationRateBeta = rate; |
| 93 } |
| 94 |
| 95 void WebDeviceMotionData::setRotationRateGamma(double rate) |
| 96 { |
| 97 m_hasRotationRateGamma = true; |
| 98 m_rotationRateGamma = rate; |
| 99 } |
| 100 |
| 101 void WebDeviceMotionData::setInterval(double interval) |
| 102 { |
| 103 m_interval = interval; |
| 104 } |
| 105 |
| 106 WebDeviceMotionData::operator PassRefPtr<WebCore::DeviceMotionData>() const |
| 107 { |
| 108 return WebCore::DeviceMotionData::create( |
| 109 WebCore::DeviceMotionData::Acceleration::create( |
| 110 hasAccelerationX(), accelerationX(), |
| 111 hasAccelerationY(), accelerationY(), |
| 112 hasAccelerationZ(), accelerationZ()), |
| 113 WebCore::DeviceMotionData::Acceleration::create( |
| 114 hasAccelerationIncludingGravityX(), accelerationIncludingGravityX(), |
| 115 hasAccelerationIncludingGravityY(), accelerationIncludingGravityY(), |
| 116 hasAccelerationIncludingGravityZ(), accelerationIncludingGravityZ())
, |
| 117 WebCore::DeviceMotionData::RotationRate::create( |
| 118 hasRotationRateAlpha(), rotationRateAlpha(), |
| 119 hasRotationRateBeta(), rotationRateBeta(), |
| 120 hasRotationRateGamma(), rotationRateGamma()), |
| 121 true, interval()); |
| 122 } |
| 123 |
| 124 } // namespace WebKit |
OLD | NEW |