1/*
2 * Copyright (C) 2010 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#ifndef WebDeviceMotionData_h
27#define WebDeviceMotionData_h
28
29#include "WebCommon.h"
30#include "WebPrivatePtr.h"
31
32namespace WebCore { class DeviceMotionData; }
33#if WEBKIT_IMPLEMENTATION
34namespace WTF { template <typename T> class PassRefPtr; }
35#endif
36
37namespace WebKit {
38
39class WebDeviceMotionData {
40public:
41 WebDeviceMotionData() { init(); }
42 WebDeviceMotionData(bool canProvideXAcceleration, double xAcceleration,
43 bool canProvideYAcceleration, double yAcceleration,
44 bool canProvideZAcceleration, double zAcceleration,
45 bool canProvideXAccelerationIncludingGravity, double xAccelerationIncludingGravity,
46 bool canProvideYAccelerationIncludingGravity, double yAccelerationIncludingGravity,
47 bool canProvideZAccelerationIncludingGravity, double zAccelerationIncludingGravity,
48 bool canProvideAlphaRotationRate, double alphaRotationRate,
49 bool canProvideBetaRotationRate, double betaRotationRate,
50 bool canProvideGammaRotationRate, double gammaRotationRate,
51 bool canProvideInterval, double interval)
52 {
53 init(canProvideXAcceleration, xAcceleration,
54 canProvideYAcceleration, yAcceleration,
55 canProvideZAcceleration, zAcceleration,
56 canProvideXAccelerationIncludingGravity, xAccelerationIncludingGravity,
57 canProvideYAccelerationIncludingGravity, yAccelerationIncludingGravity,
58 canProvideZAccelerationIncludingGravity, zAccelerationIncludingGravity,
59 canProvideAlphaRotationRate, alphaRotationRate,
60 canProvideBetaRotationRate, betaRotationRate,
61 canProvideGammaRotationRate, gammaRotationRate,
62 canProvideInterval, interval);
63 }
64
65 ~WebDeviceMotionData() { reset(); }
66
67#if WEBKIT_IMPLEMENTATION
68 WebDeviceMotionData(const WTF::PassRefPtr<WebCore::DeviceMotionData>&);
69 WebDeviceMotionData& operator=(const WTF::PassRefPtr<WebCore::DeviceMotionData>&);
70 operator WTF::PassRefPtr<WebCore::DeviceMotionData>() const;
71#endif
72
73private:
74 WEBKIT_API void init();
75 WEBKIT_API void init(bool canProvideXAcceleration, double xAcceleration,
76 bool canProvideYAcceleration, double yAcceleration,
77 bool canProvideZAcceleration, double zAcceleration,
78 bool canProvideXAccelerationIncludingGravity, double xAccelerationIncludingGravity,
79 bool canProvideYAccelerationIncludingGravity, double yAccelerationIncludingGravity,
80 bool canProvideZAccelerationIncludingGravity, double zAccelerationIncludingGravity,
81 bool canProvideAlphaRotationRate, double alphaRotationRate,
82 bool canProvideBetaRotationRate, double betaRotationRate,
83 bool canProvideGammaRotationRate, double gammaRotationRate,
84 bool canProvideInterval, double interval);
85 WEBKIT_API void reset();
86
87 WebPrivatePtr<WebCore::DeviceMotionData> m_deviceMotionData;
88};
89
90} // namespace WebKit
91
92#endif // WebDeviceMotionData_h