| 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/dom/DOMMatrix.h" | 8 #include "core/dom/DOMMatrix.h" |
| 9 #include "core/dom/DOMMatrixInit.h" | 9 #include "core/dom/DOMMatrixInit.h" |
| 10 #include "core/dom/DOMPoint.h" | 10 #include "core/dom/DOMPoint.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 other.setM22(other.hasD() ? other.d() : 1); | 27 other.setM22(other.hasD() ? other.d() : 1); |
| 28 | 28 |
| 29 if (!other.hasM41()) | 29 if (!other.hasM41()) |
| 30 other.setM41(other.hasE() ? other.e() : 0); | 30 other.setM41(other.hasE() ? other.e() : 0); |
| 31 | 31 |
| 32 if (!other.hasM42()) | 32 if (!other.hasM42()) |
| 33 other.setM42(other.hasF() ? other.f() : 0); | 33 other.setM42(other.hasF() ? other.f() : 0); |
| 34 } | 34 } |
| 35 | 35 |
| 36 String getErrorMessage(const char* a, const char* b) { | 36 String getErrorMessage(const char* a, const char* b) { |
| 37 return String::format("The '%s' property should eqaul the '%s' property.", a, | 37 return String::format("The '%s' property should equal the '%s' property.", a, |
| 38 b); | 38 b); |
| 39 } | 39 } |
| 40 | 40 |
| 41 } // namespace | 41 } // namespace |
| 42 | 42 |
| 43 bool DOMMatrixReadOnly::validateAndFixup(DOMMatrixInit& other, | 43 bool DOMMatrixReadOnly::validateAndFixup(DOMMatrixInit& other, |
| 44 ExceptionState& exceptionState) { | 44 ExceptionState& exceptionState) { |
| 45 if (other.hasA() && other.hasM11() && other.a() != other.m11()) { | 45 if (other.hasA() && other.hasM11() && other.a() != other.m11()) { |
| 46 exceptionState.throwTypeError(getErrorMessage("a", "m11")); | 46 exceptionState.throwTypeError(getErrorMessage("a", "m11")); |
| 47 return false; | 47 return false; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 "The sequence must contain 6 elements for a 2D matrix or 16 elements " | 120 "The sequence must contain 6 elements for a 2D matrix or 16 elements " |
| 121 "for a 3D matrix."); | 121 "for a 3D matrix."); |
| 122 return nullptr; | 122 return nullptr; |
| 123 } | 123 } |
| 124 return new DOMMatrixReadOnly(float64Array->data(), float64Array->length()); | 124 return new DOMMatrixReadOnly(float64Array->data(), float64Array->length()); |
| 125 } | 125 } |
| 126 | 126 |
| 127 DOMMatrixReadOnly* DOMMatrixReadOnly::fromMatrix( | 127 DOMMatrixReadOnly* DOMMatrixReadOnly::fromMatrix( |
| 128 DOMMatrixInit& other, | 128 DOMMatrixInit& other, |
| 129 ExceptionState& exceptionState) { | 129 ExceptionState& exceptionState) { |
| 130 if (!validateAndFixup(other, exceptionState)) | 130 if (!validateAndFixup(other, exceptionState)) { |
| 131 DCHECK(exceptionState.hadException()); |
| 131 return nullptr; | 132 return nullptr; |
| 133 } |
| 132 | 134 |
| 133 if (other.is2D()) { | 135 if (other.is2D()) { |
| 134 double args[] = {other.m11(), other.m12(), other.m21(), | 136 double args[] = {other.m11(), other.m12(), other.m21(), |
| 135 other.m22(), other.m41(), other.m42()}; | 137 other.m22(), other.m41(), other.m42()}; |
| 136 return new DOMMatrixReadOnly(args, 6); | 138 return new DOMMatrixReadOnly(args, 6); |
| 137 } | 139 } |
| 138 | 140 |
| 139 double args[] = {other.m11(), other.m12(), other.m13(), other.m14(), | 141 double args[] = {other.m11(), other.m12(), other.m13(), other.m14(), |
| 140 other.m21(), other.m22(), other.m23(), other.m24(), | 142 other.m21(), other.m22(), other.m23(), other.m24(), |
| 141 other.m31(), other.m32(), other.m33(), other.m34(), | 143 other.m31(), other.m32(), other.m33(), other.m34(), |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 result.addNumber("m41", m41()); | 326 result.addNumber("m41", m41()); |
| 325 result.addNumber("m42", m42()); | 327 result.addNumber("m42", m42()); |
| 326 result.addNumber("m43", m43()); | 328 result.addNumber("m43", m43()); |
| 327 result.addNumber("m44", m44()); | 329 result.addNumber("m44", m44()); |
| 328 result.addBoolean("is2D", is2D()); | 330 result.addBoolean("is2D", is2D()); |
| 329 result.addBoolean("isIdentity", isIdentity()); | 331 result.addBoolean("isIdentity", isIdentity()); |
| 330 return result.scriptValue(); | 332 return result.scriptValue(); |
| 331 } | 333 } |
| 332 | 334 |
| 333 } // namespace blink | 335 } // namespace blink |
| OLD | NEW |