Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: Source/core/platform/chromium/support/WebDeviceMotionData.cpp

Issue 14460010: Implement the Blink part of the Device Motion API. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: fixed similarity diff Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 "modules/device_orientation/DeviceMotionData.h"
jamesr 2013/04/29 17:44:48 you're making core/platform/ depend on the module?
timvolodine 2013/04/30 12:40:18 it was originally needed to perform conversion fro
30
31 namespace WebKit {
32
33 using WebCore::DeviceMotionData;
34
35 WebDeviceMotionData::WebDeviceMotionData() :
36 m_hasAccelerationX(0),
37 m_hasAccelerationY(0),
38 m_hasAccelerationZ(0),
39 m_hasAccelerationIncludingGravityX(0),
40 m_hasAccelerationIncludingGravityY(0),
41 m_hasAccelerationIncludingGravityZ(0),
42 m_hasRotationRateAlpha(0),
43 m_hasRotationRateBeta(0),
44 m_hasRotationRateGamma(0),
45 m_interval(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 void WebDeviceMotionData::setInterval(double interval)
104 {
105 m_interval = interval;
106 }
107
108 WebDeviceMotionData::operator PassRefPtr<WebCore::DeviceMotionData>() const
109 {
110 return DeviceMotionData::create(
111 DeviceMotionData::Acceleration::create(
112 m_hasAccelerationX, m_accelerationX,
113 m_hasAccelerationY, m_accelerationY,
114 m_hasAccelerationZ, m_accelerationZ),
115 DeviceMotionData::Acceleration::create(
116 m_hasAccelerationIncludingGravityX, m_accelerationIncludingGravityX,
117 m_hasAccelerationIncludingGravityY, m_accelerationIncludingGravityY,
118 m_hasAccelerationIncludingGravityZ, m_accelerationIncludingGravityZ) ,
119 DeviceMotionData::RotationRate::create(
120 m_hasRotationRateAlpha, m_rotationRateAlpha,
121 m_hasRotationRateBeta, m_rotationRateBeta,
122 m_hasRotationRateGamma, m_rotationRateGamma),
123 true, m_interval);
124 }
125
126 } // namespace WebKit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698