2 * Copyright (C) 2010 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef DeviceMotionData_h
27 #define DeviceMotionData_h
29 #include "platform/heap/Handle.h"
33 class WebDeviceMotionData;
35 class DeviceMotionData final : public GarbageCollected<DeviceMotionData> {
38 class Acceleration final : public GarbageCollected<DeviceMotionData::Acceleration> {
40 static Acceleration* create(bool canProvideX, double x, bool canProvideY, double y, bool canProvideZ, double z);
41 void trace(Visitor*) { }
43 bool canProvideX() const { return m_canProvideX; }
44 bool canProvideY() const { return m_canProvideY; }
45 bool canProvideZ() const { return m_canProvideZ; }
47 double x() const { return m_x; }
48 double y() const { return m_y; }
49 double z() const { return m_z; }
52 Acceleration(bool canProvideX, double x, bool canProvideY, double y, bool canProvideZ, double z);
63 class RotationRate final : public GarbageCollected<DeviceMotionData::RotationRate> {
65 static RotationRate* create(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma);
66 void trace(Visitor*) { }
68 bool canProvideAlpha() const { return m_canProvideAlpha; }
69 bool canProvideBeta() const { return m_canProvideBeta; }
70 bool canProvideGamma() const { return m_canProvideGamma; }
72 double alpha() const { return m_alpha; }
73 double beta() const { return m_beta; }
74 double gamma() const { return m_gamma; }
77 RotationRate(bool canProvideAlpha, double alpha, bool canProvideBeta, double beta, bool canProvideGamma, double gamma);
83 bool m_canProvideAlpha;
84 bool m_canProvideBeta;
85 bool m_canProvideGamma;
88 static DeviceMotionData* create();
89 static DeviceMotionData* create(
91 Acceleration* accelerationIncludingGravity,
93 bool canProvideInterval,
95 static DeviceMotionData* create(const WebDeviceMotionData&);
98 Acceleration* acceleration() const { return m_acceleration.get(); }
99 Acceleration* accelerationIncludingGravity() const { return m_accelerationIncludingGravity.get(); }
100 RotationRate* rotationRate() const { return m_rotationRate.get(); }
102 bool canProvideInterval() const { return m_canProvideInterval; }
103 double interval() const { return m_interval; }
105 bool canProvideEventData() const;
109 DeviceMotionData(Acceleration*, Acceleration* accelerationIncludingGravity, RotationRate*, bool canProvideInterval, double interval);
111 Member<Acceleration> m_acceleration;
112 Member<Acceleration> m_accelerationIncludingGravity;
113 Member<RotationRate> m_rotationRate;
114 bool m_canProvideInterval;
120 #endif // DeviceMotionData_h