OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/OrientationSensor.h" | 5 #include "modules/sensor/OrientationSensor.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "core/geometry/DOMMatrix.h" | 8 #include "core/geometry/DOMMatrix.h" |
9 | 9 |
10 using device::mojom::blink::SensorType; | 10 using device::mojom::blink::SensorType; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 77 } |
78 | 78 |
79 template <typename Matrix> | 79 template <typename Matrix> |
80 void OrientationSensor::populateMatrixInternal(Matrix* targetMatrix, | 80 void OrientationSensor::populateMatrixInternal(Matrix* targetMatrix, |
81 ExceptionState& exceptionState) { | 81 ExceptionState& exceptionState) { |
82 if (!checkBufferLength(targetMatrix)) { | 82 if (!checkBufferLength(targetMatrix)) { |
83 exceptionState.throwTypeError( | 83 exceptionState.throwTypeError( |
84 "Target buffer must have at least 16 elements."); | 84 "Target buffer must have at least 16 elements."); |
85 return; | 85 return; |
86 } | 86 } |
87 if (!isActivated()) { | 87 if (!canReturnReadings()) { |
88 exceptionState.throwDOMException( | 88 exceptionState.throwDOMException(NotReadableError, |
89 InvalidStateError, "The sensor must be in 'connected' state."); | 89 "Sensor data is not available."); |
90 return; | 90 return; |
91 } | 91 } |
92 if (!canReturnReadings()) | |
93 return; | |
94 | 92 |
95 double x = readingValueUnchecked(0); | 93 double x = readingValueUnchecked(0); |
96 double y = readingValueUnchecked(1); | 94 double y = readingValueUnchecked(1); |
97 double z = readingValueUnchecked(2); | 95 double z = readingValueUnchecked(2); |
98 double w = readingValueUnchecked(3); | 96 double w = readingValueUnchecked(3); |
99 | 97 |
100 doPopulateMatrix(targetMatrix, x, y, z, w); | 98 doPopulateMatrix(targetMatrix, x, y, z, w); |
101 } | 99 } |
102 | 100 |
103 void OrientationSensor::populateMatrix( | 101 void OrientationSensor::populateMatrix( |
(...skipping 22 matching lines...) Expand all Loading... |
126 | 124 |
127 void OrientationSensor::onSensorReadingChanged() { | 125 void OrientationSensor::onSensorReadingChanged() { |
128 m_readingDirty = true; | 126 m_readingDirty = true; |
129 } | 127 } |
130 | 128 |
131 DEFINE_TRACE(OrientationSensor) { | 129 DEFINE_TRACE(OrientationSensor) { |
132 Sensor::trace(visitor); | 130 Sensor::trace(visitor); |
133 } | 131 } |
134 | 132 |
135 } // namespace blink | 133 } // namespace blink |
OLD | NEW |