OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * * Redistributions of source code must retain the above copyright | 7 * * Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * * Redistributions in binary form must reproduce the above copyright | 9 * * Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "modules/device_orientation/DeviceOrientationData.h" | 26 #include "modules/device_orientation/DeviceOrientationData.h" |
27 #include "public/platform/modules/device_orientation/WebDeviceOrientationData.h" | 27 #include "public/platform/modules/device_orientation/WebDeviceOrientationData.h" |
28 | 28 |
29 namespace blink { | 29 namespace blink { |
30 | 30 |
31 DeviceOrientationData* DeviceOrientationData::create() | 31 DeviceOrientationData* DeviceOrientationData::create() |
32 { | 32 { |
33 return new DeviceOrientationData; | 33 return new DeviceOrientationData; |
34 } | 34 } |
35 | 35 |
36 DeviceOrientationData* DeviceOrientationData::create(const Nullable<double>& alp
ha, const Nullable<double>& beta, const Nullable<double>& gamma, const Nullable<
bool>& absolute) | 36 DeviceOrientationData* DeviceOrientationData::create(const Nullable<double>& alp
ha, const Nullable<double>& beta, const Nullable<double>& gamma, bool absolute) |
37 { | 37 { |
38 return new DeviceOrientationData(alpha, beta, gamma, absolute); | 38 return new DeviceOrientationData(alpha, beta, gamma, absolute); |
39 } | 39 } |
40 | 40 |
41 DeviceOrientationData* DeviceOrientationData::create(const WebDeviceOrientationD
ata& data) | 41 DeviceOrientationData* DeviceOrientationData::create(const WebDeviceOrientationD
ata& data) |
42 { | 42 { |
43 Nullable<double> alpha; | 43 Nullable<double> alpha; |
44 Nullable<double> beta; | 44 Nullable<double> beta; |
45 Nullable<double> gamma; | 45 Nullable<double> gamma; |
46 Nullable<bool> absolute; | |
47 if (data.hasAlpha) | 46 if (data.hasAlpha) |
48 alpha = data.alpha; | 47 alpha = data.alpha; |
49 if (data.hasBeta) | 48 if (data.hasBeta) |
50 beta = data.beta; | 49 beta = data.beta; |
51 if (data.hasGamma) | 50 if (data.hasGamma) |
52 gamma = data.gamma; | 51 gamma = data.gamma; |
53 if (data.hasAbsolute) | 52 return DeviceOrientationData::create(alpha, beta, gamma, data.absolute); |
54 absolute = data.absolute; | |
55 return DeviceOrientationData::create(alpha, beta, gamma, absolute); | |
56 } | 53 } |
57 | 54 |
58 DeviceOrientationData::DeviceOrientationData() | 55 DeviceOrientationData::DeviceOrientationData() |
59 { | 56 { |
60 } | 57 } |
61 | 58 |
62 DeviceOrientationData::DeviceOrientationData(const Nullable<double>& alpha, cons
t Nullable<double>& beta, const Nullable<double>& gamma, const Nullable<bool>& a
bsolute) | 59 DeviceOrientationData::DeviceOrientationData(const Nullable<double>& alpha, cons
t Nullable<double>& beta, const Nullable<double>& gamma, bool absolute) |
63 : m_alpha(alpha) | 60 : m_alpha(alpha) |
64 , m_beta(beta) | 61 , m_beta(beta) |
65 , m_gamma(gamma) | 62 , m_gamma(gamma) |
66 , m_absolute(absolute) | 63 , m_absolute(absolute) |
67 { | 64 { |
68 } | 65 } |
69 | 66 |
70 double DeviceOrientationData::alpha() const | 67 double DeviceOrientationData::alpha() const |
71 { | 68 { |
72 return m_alpha.get(); | 69 return m_alpha.get(); |
73 } | 70 } |
74 | 71 |
75 double DeviceOrientationData::beta() const | 72 double DeviceOrientationData::beta() const |
76 { | 73 { |
77 return m_beta.get(); | 74 return m_beta.get(); |
78 } | 75 } |
79 | 76 |
80 double DeviceOrientationData::gamma() const | 77 double DeviceOrientationData::gamma() const |
81 { | 78 { |
82 return m_gamma.get(); | 79 return m_gamma.get(); |
83 } | 80 } |
84 | 81 |
85 bool DeviceOrientationData::absolute() const | 82 bool DeviceOrientationData::absolute() const |
86 { | 83 { |
87 return m_absolute.get(); | 84 return m_absolute; |
88 } | 85 } |
89 | 86 |
90 bool DeviceOrientationData::canProvideAlpha() const | 87 bool DeviceOrientationData::canProvideAlpha() const |
91 { | 88 { |
92 return !m_alpha.isNull(); | 89 return !m_alpha.isNull(); |
93 } | 90 } |
94 | 91 |
95 bool DeviceOrientationData::canProvideBeta() const | 92 bool DeviceOrientationData::canProvideBeta() const |
96 { | 93 { |
97 return !m_beta.isNull(); | 94 return !m_beta.isNull(); |
98 } | 95 } |
99 | 96 |
100 bool DeviceOrientationData::canProvideGamma() const | 97 bool DeviceOrientationData::canProvideGamma() const |
101 { | 98 { |
102 return !m_gamma.isNull(); | 99 return !m_gamma.isNull(); |
103 } | 100 } |
104 | 101 |
105 bool DeviceOrientationData::canProvideAbsolute() const | |
106 { | |
107 return !m_absolute.isNull(); | |
108 } | |
109 | |
110 bool DeviceOrientationData::canProvideEventData() const | 102 bool DeviceOrientationData::canProvideEventData() const |
111 { | 103 { |
112 return canProvideAlpha() || canProvideBeta() || canProvideGamma(); | 104 return canProvideAlpha() || canProvideBeta() || canProvideGamma(); |
113 } | 105 } |
114 | 106 |
115 } // namespace blink | 107 } // namespace blink |
OLD | NEW |