| 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/DOMMatrix.h" | 5 #include "core/dom/DOMMatrix.h" |
| 6 | 6 |
| 7 namespace blink { | 7 namespace blink { |
| 8 | 8 |
| 9 DOMMatrixReadOnly* DOMMatrixReadOnly::create(Vector<double> sequence, ExceptionS
tate& exceptionState) |
| 10 { |
| 11 if (sequence.size() != 6 && sequence.size() != 16) { |
| 12 exceptionState.throwTypeError("An invalid number sequence is specified.
The sequence must contain 6 elements for 2D matrix and 16 elements for 3D matrix
."); |
| 13 return nullptr; |
| 14 } |
| 15 return new DOMMatrixReadOnly(sequence); |
| 16 } |
| 17 |
| 18 DOMMatrixReadOnly::DOMMatrixReadOnly(Vector<double> sequence) |
| 19 { |
| 20 if (sequence.size() == 6) { |
| 21 m_matrix = TransformationMatrix::create( |
| 22 sequence[0], sequence[1], sequence[2], sequence[3], |
| 23 sequence[4], sequence[5]); |
| 24 m_is2D = true; |
| 25 } else if (sequence.size() == 16) { |
| 26 m_matrix = TransformationMatrix::create( |
| 27 sequence[0], sequence[1], sequence[2], sequence[3], |
| 28 sequence[4], sequence[5], sequence[6], sequence[7], |
| 29 sequence[8], sequence[9], sequence[10], sequence[11], |
| 30 sequence[12], sequence[13], sequence[14], sequence[15]); |
| 31 m_is2D = false; |
| 32 } else { |
| 33 NOTREACHED(); |
| 34 } |
| 35 } |
| 36 |
| 9 DOMMatrixReadOnly::~DOMMatrixReadOnly() | 37 DOMMatrixReadOnly::~DOMMatrixReadOnly() |
| 10 { | 38 { |
| 11 } | 39 } |
| 12 | 40 |
| 13 bool DOMMatrixReadOnly::is2D() const | 41 bool DOMMatrixReadOnly::is2D() const |
| 14 { | 42 { |
| 15 return m_is2D; | 43 return m_is2D; |
| 16 } | 44 } |
| 17 | 45 |
| 18 bool DOMMatrixReadOnly::isIdentity() const | 46 bool DOMMatrixReadOnly::isIdentity() const |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 m_matrix->m11(), m_matrix->m12(), m_matrix->m13(), m_matrix->m14(), | 92 m_matrix->m11(), m_matrix->m12(), m_matrix->m13(), m_matrix->m14(), |
| 65 m_matrix->m21(), m_matrix->m22(), m_matrix->m23(), m_matrix->m24(), | 93 m_matrix->m21(), m_matrix->m22(), m_matrix->m23(), m_matrix->m24(), |
| 66 m_matrix->m31(), m_matrix->m32(), m_matrix->m33(), m_matrix->m34(), | 94 m_matrix->m31(), m_matrix->m32(), m_matrix->m33(), m_matrix->m34(), |
| 67 m_matrix->m41(), m_matrix->m42(), m_matrix->m43(), m_matrix->m44() | 95 m_matrix->m41(), m_matrix->m42(), m_matrix->m43(), m_matrix->m44() |
| 68 }; | 96 }; |
| 69 | 97 |
| 70 return DOMFloat64Array::create(array, 16); | 98 return DOMFloat64Array::create(array, 16); |
| 71 } | 99 } |
| 72 | 100 |
| 73 } // namespace blink | 101 } // namespace blink |
| OLD | NEW |