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

Side by Side Diff: Source/Platform/chromium/public/WebDeviceMotionData.h

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 Adam's comments 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 #ifndef WebDeviceMotionData_h
32 #define WebDeviceMotionData_h
33
34 #if WEBKIT_IMPLEMENTATION
35 namespace WTF { template <typename T> class PassRefPtr; }
36 namespace WebCore { class DeviceMotionData; }
37 #endif
38
39 namespace WebKit {
40
41 #pragma pack(push, 1)
42
43 class WebDeviceMotionData {
44 public:
45 WebDeviceMotionData();
46 ~WebDeviceMotionData() { }
47
48 void setAccelerationX(double);
49 void setAccelerationY(double);
50 void setAccelerationZ(double);
51
52 void setAccelerationIncludingGravityX(double);
53 void setAccelerationIncludingGravityY(double);
54 void setAccelerationIncludingGravityZ(double);
55
56 void setRotationRateAlpha(double);
57 void setRotationRateBeta(double);
58 void setRotationRateGamma(double);
59
60 void setInterval(double);
61
62 double accelerationX() const { return m_accelerationX; }
63 double accelerationY() const { return m_accelerationY; }
64 double accelerationZ() const { return m_accelerationZ; }
65
66 double accelerationIncludingGravityX() const { return m_accelerationIncludin gGravityX; }
67 double accelerationIncludingGravityY() const { return m_accelerationIncludin gGravityY; }
68 double accelerationIncludingGravityZ() const { return m_accelerationIncludin gGravityZ; }
69
70 double rotationRateAlpha() const { return m_rotationRateAlpha; }
71 double rotationRateBeta() const { return m_rotationRateBeta; }
72 double rotationRateGamma() const { return m_rotationRateGamma; }
73
74 double interval() const { return m_interval; }
75
76 double hasAccelerationX() const { return m_hasAccelerationX; }
77 double hasAccelerationY() const { return m_hasAccelerationY; }
78 double hasAccelerationZ() const { return m_hasAccelerationZ; }
79
80 double hasAccelerationIncludingGravityX() const { return m_hasAccelerationIn cludingGravityX; }
81 double hasAccelerationIncludingGravityY() const { return m_hasAccelerationIn cludingGravityY; }
82 double hasAccelerationIncludingGravityZ() const { return m_hasAccelerationIn cludingGravityZ; }
83
84 double hasRotationRateAlpha() const { return m_hasRotationRateAlpha; }
85 double hasRotationRateBeta() const { return m_hasRotationRateBeta; }
86 double hasRotationRateGamma() const { return m_hasRotationRateGamma; }
87
88 private:
89 double m_accelerationX;
90 double m_accelerationY;
91 double m_accelerationZ;
92
93 double m_accelerationIncludingGravityX;
94 double m_accelerationIncludingGravityY;
95 double m_accelerationIncludingGravityZ;
96
97 double m_rotationRateAlpha;
98 double m_rotationRateBeta;
99 double m_rotationRateGamma;
100
101 double m_interval;
102
103 char m_hasAccelerationX : 1;
104 char m_hasAccelerationY : 1;
105 char m_hasAccelerationZ : 1;
abarth-chromium 2013/05/07 16:43:47 Yes, but the ": 1" should give it the proper size
timvolodine 2013/05/07 19:02:30 my reasoning behind using a char instead of bool i
106
107 char m_hasAccelerationIncludingGravityX : 1;
108 char m_hasAccelerationIncludingGravityY : 1;
109 char m_hasAccelerationIncludingGravityZ : 1;
110
111 char m_hasRotationRateAlpha : 1;
112 char m_hasRotationRateBeta : 1;
113 char m_hasRotationRateGamma : 1;
114 };
115
116 #if WEBKIT_IMPLEMENTATION
117 COMPILE_ASSERT(sizeof(WebDeviceMotionData) == (10*8 + 2), WebDeviceMotionData_ha s_wrong_size);
118 #endif
119
120 #pragma pack(pop)
121
122 } // namespace WebKit
123
124 #endif // WebDeviceMotionData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698