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/geometry/DOMMatrix.h" | 5 #include "core/geometry/DOMMatrix.h" |
6 | 6 |
7 namespace blink { | 7 namespace blink { |
8 | 8 |
9 DOMMatrix* DOMMatrix::Create(ExceptionState& exception_state) { | 9 DOMMatrix* DOMMatrix::Create(ExecutionContext* execution_context, |
| 10 ExceptionState& exception_state) { |
10 return new DOMMatrix(TransformationMatrix()); | 11 return new DOMMatrix(TransformationMatrix()); |
11 } | 12 } |
12 | 13 |
13 DOMMatrix* DOMMatrix::Create(StringOrUnrestrictedDoubleSequence& init, | 14 DOMMatrix* DOMMatrix::Create(ExecutionContext* execution_context, |
| 15 StringOrUnrestrictedDoubleSequence& init, |
14 ExceptionState& exception_state) { | 16 ExceptionState& exception_state) { |
15 if (init.isString()) { | 17 if (init.isString()) { |
| 18 if (!execution_context->IsDocument()) { |
| 19 exception_state.ThrowTypeError( |
| 20 "DOMMatrix can't be constructed with strings on workers."); |
| 21 return nullptr; |
| 22 } |
| 23 |
16 DOMMatrix* matrix = new DOMMatrix(TransformationMatrix()); | 24 DOMMatrix* matrix = new DOMMatrix(TransformationMatrix()); |
17 matrix->SetMatrixValueFromString(init.getAsString(), exception_state); | 25 matrix->SetMatrixValueFromString(init.getAsString(), exception_state); |
18 return matrix; | 26 return matrix; |
19 } | 27 } |
20 | 28 |
21 if (init.isUnrestrictedDoubleSequence()) { | 29 if (init.isUnrestrictedDoubleSequence()) { |
22 const Vector<double>& sequence = init.getAsUnrestrictedDoubleSequence(); | 30 const Vector<double>& sequence = init.getAsUnrestrictedDoubleSequence(); |
23 if (sequence.size() != 6 && sequence.size() != 16) { | 31 if (sequence.size() != 6 && sequence.size() != 16) { |
24 exception_state.ThrowTypeError( | 32 exception_state.ThrowTypeError( |
25 "The sequence must contain 6 elements for a 2D matrix or 16 elements " | 33 "The sequence must contain 6 elements for a 2D matrix or 16 elements " |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 return this; | 275 return this; |
268 } | 276 } |
269 | 277 |
270 DOMMatrix* DOMMatrix::setMatrixValue(const String& input_string, | 278 DOMMatrix* DOMMatrix::setMatrixValue(const String& input_string, |
271 ExceptionState& exception_state) { | 279 ExceptionState& exception_state) { |
272 SetMatrixValueFromString(input_string, exception_state); | 280 SetMatrixValueFromString(input_string, exception_state); |
273 return this; | 281 return this; |
274 } | 282 } |
275 | 283 |
276 } // namespace blink | 284 } // namespace blink |
OLD | NEW |