| 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 |
| 29 #include "DeviceMotionData.h" |
| 30 #include "WebDeviceMotionEventPump.h" |
| 31 |
| 32 namespace WebKit { |
| 33 |
| 34 using WebCore::DeviceMotionData; |
| 35 |
| 36 WebDeviceMotionData::WebDeviceMotionData() : |
| 37 m_hasAccelerationX(0), |
| 38 m_hasAccelerationY(0), |
| 39 m_hasAccelerationZ(0), |
| 40 m_hasAccelerationIncludingGravityX(0), |
| 41 m_hasAccelerationIncludingGravityY(0), |
| 42 m_hasAccelerationIncludingGravityZ(0), |
| 43 m_hasRotationRateAlpha(0), |
| 44 m_hasRotationRateBeta(0), |
| 45 m_hasRotationRateGamma(0) |
| 46 { |
| 47 } |
| 48 |
| 49 void WebDeviceMotionData::setAccelerationX(double acceleration) |
| 50 { |
| 51 m_hasAccelerationX = 1; |
| 52 m_accelerationX = acceleration; |
| 53 } |
| 54 |
| 55 void WebDeviceMotionData::setAccelerationY(double acceleration) |
| 56 { |
| 57 m_hasAccelerationY = 1; |
| 58 m_accelerationY = acceleration; |
| 59 } |
| 60 |
| 61 void WebDeviceMotionData::setAccelerationZ(double acceleration) |
| 62 { |
| 63 m_hasAccelerationZ = 1; |
| 64 m_accelerationZ = acceleration; |
| 65 } |
| 66 |
| 67 void WebDeviceMotionData::setAccelerationIncludingGravityX(double acceleration) |
| 68 { |
| 69 m_hasAccelerationIncludingGravityX = 1; |
| 70 m_accelerationIncludingGravityX = acceleration; |
| 71 } |
| 72 |
| 73 void WebDeviceMotionData::setAccelerationIncludingGravityY(double acceleration) |
| 74 { |
| 75 m_hasAccelerationIncludingGravityY = 1; |
| 76 m_accelerationIncludingGravityY = acceleration; |
| 77 } |
| 78 |
| 79 void WebDeviceMotionData::setAccelerationIncludingGravityZ(double acceleration) |
| 80 { |
| 81 m_hasAccelerationIncludingGravityZ = 1; |
| 82 m_accelerationIncludingGravityZ = acceleration; |
| 83 } |
| 84 |
| 85 void WebDeviceMotionData::setRotationRateAlpha(double rate) |
| 86 { |
| 87 m_hasRotationRateAlpha = 1; |
| 88 m_rotationRateAlpha = rate; |
| 89 } |
| 90 |
| 91 void WebDeviceMotionData::setRotationRateBeta(double rate) |
| 92 { |
| 93 m_hasRotationRateBeta = 1; |
| 94 m_rotationRateBeta = rate; |
| 95 } |
| 96 |
| 97 void WebDeviceMotionData::setRotationRateGamma(double rate) |
| 98 { |
| 99 m_hasRotationRateGamma = 1; |
| 100 m_rotationRateGamma = rate; |
| 101 } |
| 102 |
| 103 WebDeviceMotionData::operator PassRefPtr<WebCore::DeviceMotionData>() const |
| 104 { |
| 105 return DeviceMotionData::create( |
| 106 DeviceMotionData::Acceleration::create( |
| 107 m_hasAccelerationX, m_accelerationX, |
| 108 m_hasAccelerationY, m_accelerationY, |
| 109 m_hasAccelerationZ, m_accelerationZ), |
| 110 DeviceMotionData::Acceleration::create( |
| 111 m_hasAccelerationIncludingGravityX, m_accelerationIncludingGravityX, |
| 112 m_hasAccelerationIncludingGravityY, m_accelerationIncludingGravityY, |
| 113 m_hasAccelerationIncludingGravityZ, m_accelerationIncludingGravityZ)
, |
| 114 DeviceMotionData::RotationRate::create( |
| 115 m_hasRotationRateAlpha, m_rotationRateAlpha, |
| 116 m_hasRotationRateBeta, m_rotationRateBeta, |
| 117 m_hasRotationRateGamma, m_rotationRateGamma), |
| 118 true, WebDeviceMotionEventPump::kPumpDelayMilliseconds); |
| 119 } |
| 120 |
| 121 } // namespace WebKit |
| OLD | NEW |