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

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

Powered by Google App Engine
This is Rietveld 408576698