Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Side by Side Diff: third_party/WebKit/Source/modules/sensor/OrientationSensor.cpp

Issue 2798923003: [Sensors] Update exceptions throwing from OrientationSensor.populateMatrix() (Closed)
Patch Set: Comments from Alex Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/sensor/absolute-orientation-sensor.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/sensor/absolute-orientation-sensor.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698