| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/sensor/Accelerometer.h" | 5 #include "modules/sensor/Accelerometer.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromise.h" | |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" | |
| 9 | |
| 10 using device::mojom::blink::SensorType; | 7 using device::mojom::blink::SensorType; |
| 11 | 8 |
| 12 namespace blink { | 9 namespace blink { |
| 13 | 10 |
| 14 Accelerometer* Accelerometer::create(ExecutionContext* executionContext, | 11 Accelerometer* Accelerometer::create(ExecutionContext* executionContext, |
| 15 const AccelerometerOptions& options, | 12 const SensorOptions& options, |
| 16 ExceptionState& exceptionState) { | 13 ExceptionState& exceptionState) { |
| 17 return new Accelerometer(executionContext, options, exceptionState); | 14 return new Accelerometer(executionContext, options, exceptionState); |
| 18 } | 15 } |
| 19 | 16 |
| 20 // static | 17 // static |
| 21 Accelerometer* Accelerometer::create(ExecutionContext* executionContext, | 18 Accelerometer* Accelerometer::create(ExecutionContext* executionContext, |
| 22 ExceptionState& exceptionState) { | 19 ExceptionState& exceptionState) { |
| 23 return create(executionContext, AccelerometerOptions(), exceptionState); | 20 return create(executionContext, SensorOptions(), exceptionState); |
| 24 } | 21 } |
| 25 | 22 |
| 26 Accelerometer::Accelerometer(ExecutionContext* executionContext, | 23 Accelerometer::Accelerometer(ExecutionContext* executionContext, |
| 27 const AccelerometerOptions& options, | 24 const SensorOptions& options, |
| 28 ExceptionState& exceptionState) | 25 ExceptionState& exceptionState) |
| 29 : Sensor(executionContext, | 26 : Sensor(executionContext, |
| 30 options, | 27 options, |
| 31 exceptionState, | 28 exceptionState, |
| 32 options.includeGravity() ? SensorType::ACCELEROMETER | 29 SensorType::ACCELEROMETER) {} |
| 33 : SensorType::LINEAR_ACCELERATION), | |
| 34 m_accelerometerOptions(options) {} | |
| 35 | 30 |
| 36 double Accelerometer::x(bool& isNull) const { | 31 double Accelerometer::x(bool& isNull) const { |
| 37 return readingValue(0, isNull); | 32 return readingValue(0, isNull); |
| 38 } | 33 } |
| 39 | 34 |
| 40 double Accelerometer::y(bool& isNull) const { | 35 double Accelerometer::y(bool& isNull) const { |
| 41 return readingValue(1, isNull); | 36 return readingValue(1, isNull); |
| 42 } | 37 } |
| 43 | 38 |
| 44 double Accelerometer::z(bool& isNull) const { | 39 double Accelerometer::z(bool& isNull) const { |
| 45 return readingValue(2, isNull); | 40 return readingValue(2, isNull); |
| 46 } | 41 } |
| 47 | 42 |
| 48 bool Accelerometer::includesGravity() const { | |
| 49 return m_accelerometerOptions.includeGravity(); | |
| 50 } | |
| 51 | |
| 52 DEFINE_TRACE(Accelerometer) { | 43 DEFINE_TRACE(Accelerometer) { |
| 53 Sensor::trace(visitor); | 44 Sensor::trace(visitor); |
| 54 } | 45 } |
| 55 | 46 |
| 56 } // namespace blink | 47 } // namespace blink |
| OLD | NEW |