Chromium Code Reviews| Index: third_party/WebKit/Source/core/geometry/DOMMatrixReadOnly.cpp |
| diff --git a/third_party/WebKit/Source/core/geometry/DOMMatrixReadOnly.cpp b/third_party/WebKit/Source/core/geometry/DOMMatrixReadOnly.cpp |
| index b7e45a254475d8ac7e1c99b4eff15ad2e6ec1129..aad06a1403734b72dbfbafa6e3e7d6ba30d6afc8 100644 |
| --- a/third_party/WebKit/Source/core/geometry/DOMMatrixReadOnly.cpp |
| +++ b/third_party/WebKit/Source/core/geometry/DOMMatrixReadOnly.cpp |
| @@ -318,21 +318,79 @@ NotShared<DOMFloat64Array> DOMMatrixReadOnly::toFloat64Array() const { |
| return NotShared<DOMFloat64Array>(DOMFloat64Array::Create(array, 16)); |
| } |
| -const String DOMMatrixReadOnly::toString() const { |
| - std::stringstream stream; |
| +const String DOMMatrixReadOnly::toString( |
| + ExceptionState& exception_state) const { |
| + const char* kComma = ", "; |
| + String result; |
| + |
| if (is2D()) { |
| - stream << "matrix(" << a() << ", " << b() << ", " << c() << ", " << d() |
| - << ", " << e() << ", " << f(); |
| - } else { |
| - stream << "matrix3d(" << m11() << ", " << m12() << ", " << m13() << ", " |
| - << m14() << ", " << m21() << ", " << m22() << ", " << m23() << ", " |
| - << m24() << ", " << m31() << ", " << m32() << ", " << m33() << ", " |
| - << m34() << ", " << m41() << ", " << m42() << ", " << m43() << ", " |
| - << m44(); |
| + if (std::isfinite(a()) || std::isfinite(b()) || std::isfinite(c()) || |
| + std::isfinite(d()) || std::isfinite(e()) || std::isfinite(f())) { |
| + exception_state.ThrowDOMException(kInvalidStateError, "Wrong values."); |
|
zino
2017/05/16 22:25:37
nit: Please update this exception message in more
Byoungkwon Ko
2017/05/18 13:52:14
Done.
|
| + return String(); |
| + } |
| + |
| + result.append("matrix("); |
| + result.append(String::NumberToStringECMAScript(a())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(b())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(c())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(d())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(e())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(f())); |
| + result.append(")"); |
| + return result; |
| + } |
| + |
| + if (std::isfinite(m11()) || std::isfinite(m12()) || std::isfinite(m13()) || |
| + std::isfinite(m14()) || std::isfinite(m21()) || std::isfinite(m22()) || |
| + std::isfinite(m23()) || std::isfinite(m24()) || std::isfinite(m31()) || |
| + std::isfinite(m32()) || std::isfinite(m33()) || std::isfinite(m34()) || |
| + std::isfinite(m41()) || std::isfinite(m42()) || std::isfinite(m43()) || |
| + std::isfinite(m44())) { |
| + exception_state.ThrowDOMException(kInvalidStateError, "Wrong values."); |
| + return String(); |
| } |
| - stream << ")"; |
| - return String(stream.str().c_str()); |
| + result.append("matrix3d("); |
| + result.append(String::NumberToStringECMAScript(m11())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(m12())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(m13())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(m14())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(m21())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(m22())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(m23())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(m24())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(m31())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(m32())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(m33())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(m34())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(m41())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(m42())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(m43())); |
| + result.append(kComma); |
| + result.append(String::NumberToStringECMAScript(m44())); |
| + result.append(")"); |
| + |
| + return result; |
| } |
| ScriptValue DOMMatrixReadOnly::toJSONForBinding( |