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/DOMMatrixReadOnly.h" | 5 #include "core/geometry/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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 SetDictionaryMembers(other); | 85 SetDictionaryMembers(other); |
86 if (!other.hasIs2D()) { | 86 if (!other.hasIs2D()) { |
87 bool is2d = !(other.m31() || other.m32() || other.m13() || other.m23() || | 87 bool is2d = !(other.m31() || other.m32() || other.m13() || other.m23() || |
88 other.m43() || other.m14() || other.m24() || other.m34() || | 88 other.m43() || other.m14() || other.m24() || other.m34() || |
89 other.m33() != 1 || other.m44() != 1); | 89 other.m33() != 1 || other.m44() != 1); |
90 other.setIs2D(is2d); | 90 other.setIs2D(is2d); |
91 } | 91 } |
92 return true; | 92 return true; |
93 } | 93 } |
94 | 94 |
95 DOMMatrixReadOnly* DOMMatrixReadOnly::Create(ExceptionState& exception_state) { | 95 DOMMatrixReadOnly* DOMMatrixReadOnly::Create( |
| 96 ExecutionContext* execution_context, |
| 97 ExceptionState& exception_state) { |
96 return new DOMMatrixReadOnly(TransformationMatrix()); | 98 return new DOMMatrixReadOnly(TransformationMatrix()); |
97 } | 99 } |
98 | 100 |
99 DOMMatrixReadOnly* DOMMatrixReadOnly::Create( | 101 DOMMatrixReadOnly* DOMMatrixReadOnly::Create( |
| 102 ExecutionContext* execution_context, |
100 StringOrUnrestrictedDoubleSequence& init, | 103 StringOrUnrestrictedDoubleSequence& init, |
101 ExceptionState& exception_state) { | 104 ExceptionState& exception_state) { |
102 if (init.isString()) { | 105 if (init.isString()) { |
| 106 if (!execution_context->IsDocument()) { |
| 107 exception_state.ThrowTypeError( |
| 108 "DOMMatrix can't be constructed with strings on workers."); |
| 109 return nullptr; |
| 110 } |
| 111 |
103 DOMMatrixReadOnly* matrix = new DOMMatrixReadOnly(TransformationMatrix()); | 112 DOMMatrixReadOnly* matrix = new DOMMatrixReadOnly(TransformationMatrix()); |
104 matrix->SetMatrixValueFromString(init.getAsString(), exception_state); | 113 matrix->SetMatrixValueFromString(init.getAsString(), exception_state); |
105 return matrix; | 114 return matrix; |
106 } | 115 } |
107 | 116 |
108 if (init.isUnrestrictedDoubleSequence()) { | 117 if (init.isUnrestrictedDoubleSequence()) { |
109 const Vector<double>& sequence = init.getAsUnrestrictedDoubleSequence(); | 118 const Vector<double>& sequence = init.getAsUnrestrictedDoubleSequence(); |
110 if (sequence.size() != 6 && sequence.size() != 16) { | 119 if (sequence.size() != 6 && sequence.size() != 16) { |
111 exception_state.ThrowTypeError( | 120 exception_state.ThrowTypeError( |
112 "The sequence must contain 6 elements for a 2D matrix or 16 elements " | 121 "The sequence must contain 6 elements for a 2D matrix or 16 elements " |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 408 |
400 matrix_->MakeIdentity(); | 409 matrix_->MakeIdentity(); |
401 operations.Apply(FloatSize(0, 0), *matrix_); | 410 operations.Apply(FloatSize(0, 0), *matrix_); |
402 | 411 |
403 is2d_ = !operations.Has3DOperation(); | 412 is2d_ = !operations.Has3DOperation(); |
404 | 413 |
405 return; | 414 return; |
406 } | 415 } |
407 | 416 |
408 } // namespace blink | 417 } // namespace blink |
OLD | NEW |