OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "core/dom/DOMMatrixReadOnly.h" | 5 #include "core/dom/DOMMatrixReadOnly.h" |
6 | 6 |
7 #include "bindings/core/v8/V8ObjectBuilder.h" | 7 #include "bindings/core/v8/V8ObjectBuilder.h" |
8 #include "core/css/CSSIdentifierValue.h" | 8 #include "core/css/CSSIdentifierValue.h" |
9 #include "core/css/CSSToLengthConversionData.h" | 9 #include "core/css/CSSToLengthConversionData.h" |
10 #include "core/css/CSSValueList.h" | 10 #include "core/css/CSSValueList.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 if (sequence.size() != 6 && sequence.size() != 16) { | 108 if (sequence.size() != 6 && sequence.size() != 16) { |
109 exceptionState.throwTypeError( | 109 exceptionState.throwTypeError( |
110 "The sequence must contain 6 elements for a 2D matrix or 16 elements " | 110 "The sequence must contain 6 elements for a 2D matrix or 16 elements " |
111 "for a 3D matrix."); | 111 "for a 3D matrix."); |
112 return nullptr; | 112 return nullptr; |
113 } | 113 } |
114 return new DOMMatrixReadOnly(sequence, sequence.size()); | 114 return new DOMMatrixReadOnly(sequence, sequence.size()); |
115 } | 115 } |
116 | 116 |
117 DOMMatrixReadOnly* DOMMatrixReadOnly::fromFloat32Array( | 117 DOMMatrixReadOnly* DOMMatrixReadOnly::fromFloat32Array( |
118 DOMFloat32Array* float32Array, | 118 const MaybeShared<DOMFloat32Array>& maybeShared, |
119 ExceptionState& exceptionState) { | 119 ExceptionState& exceptionState) { |
| 120 if (maybeShared.isShared()) { |
| 121 exceptionState.throwTypeError( |
| 122 "The Float32Array must not be backed by a SharedArrayBuffer."); |
| 123 return nullptr; |
| 124 } |
| 125 DOMFloat32Array* float32Array = maybeShared.viewNotShared(); |
120 if (float32Array->length() != 6 && float32Array->length() != 16) { | 126 if (float32Array->length() != 6 && float32Array->length() != 16) { |
121 exceptionState.throwTypeError( | 127 exceptionState.throwTypeError( |
122 "The sequence must contain 6 elements for a 2D matrix or 16 elements a " | 128 "The sequence must contain 6 elements for a 2D matrix or 16 elements a " |
123 "for 3D matrix."); | 129 "for 3D matrix."); |
124 return nullptr; | 130 return nullptr; |
125 } | 131 } |
126 return new DOMMatrixReadOnly(float32Array->data(), float32Array->length()); | 132 return new DOMMatrixReadOnly(float32Array->data(), float32Array->length()); |
127 } | 133 } |
128 | 134 |
129 DOMMatrixReadOnly* DOMMatrixReadOnly::fromFloat64Array( | 135 DOMMatrixReadOnly* DOMMatrixReadOnly::fromFloat64Array( |
130 DOMFloat64Array* float64Array, | 136 const MaybeShared<DOMFloat64Array>& maybeShared, |
131 ExceptionState& exceptionState) { | 137 ExceptionState& exceptionState) { |
| 138 if (maybeShared.isShared()) { |
| 139 exceptionState.throwTypeError( |
| 140 "The Float64Array must not be backed by a SharedArrayBuffer."); |
| 141 return nullptr; |
| 142 } |
| 143 DOMFloat64Array* float64Array = maybeShared.viewNotShared(); |
132 if (float64Array->length() != 6 && float64Array->length() != 16) { | 144 if (float64Array->length() != 6 && float64Array->length() != 16) { |
133 exceptionState.throwTypeError( | 145 exceptionState.throwTypeError( |
134 "The sequence must contain 6 elements for a 2D matrix or 16 elements " | 146 "The sequence must contain 6 elements for a 2D matrix or 16 elements " |
135 "for a 3D matrix."); | 147 "for a 3D matrix."); |
136 return nullptr; | 148 return nullptr; |
137 } | 149 } |
138 return new DOMMatrixReadOnly(float64Array->data(), float64Array->length()); | 150 return new DOMMatrixReadOnly(float64Array->data(), float64Array->length()); |
139 } | 151 } |
140 | 152 |
141 DOMMatrixReadOnly* DOMMatrixReadOnly::fromMatrix( | 153 DOMMatrixReadOnly* DOMMatrixReadOnly::fromMatrix( |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 | 401 |
390 m_matrix->makeIdentity(); | 402 m_matrix->makeIdentity(); |
391 operations.apply(FloatSize(0, 0), *m_matrix); | 403 operations.apply(FloatSize(0, 0), *m_matrix); |
392 | 404 |
393 m_is2D = !operations.has3DOperation(); | 405 m_is2D = !operations.has3DOperation(); |
394 | 406 |
395 return; | 407 return; |
396 } | 408 } |
397 | 409 |
398 } // namespace blink | 410 } // namespace blink |
OLD | NEW |