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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 NotShared<DOMFloat64Array> DOMMatrixReadOnly::toFloat64Array() const { | 311 NotShared<DOMFloat64Array> DOMMatrixReadOnly::toFloat64Array() const { |
312 double array[] = { | 312 double array[] = { |
313 matrix_->M11(), matrix_->M12(), matrix_->M13(), matrix_->M14(), | 313 matrix_->M11(), matrix_->M12(), matrix_->M13(), matrix_->M14(), |
314 matrix_->M21(), matrix_->M22(), matrix_->M23(), matrix_->M24(), | 314 matrix_->M21(), matrix_->M22(), matrix_->M23(), matrix_->M24(), |
315 matrix_->M31(), matrix_->M32(), matrix_->M33(), matrix_->M34(), | 315 matrix_->M31(), matrix_->M32(), matrix_->M33(), matrix_->M34(), |
316 matrix_->M41(), matrix_->M42(), matrix_->M43(), matrix_->M44()}; | 316 matrix_->M41(), matrix_->M42(), matrix_->M43(), matrix_->M44()}; |
317 | 317 |
318 return NotShared<DOMFloat64Array>(DOMFloat64Array::Create(array, 16)); | 318 return NotShared<DOMFloat64Array>(DOMFloat64Array::Create(array, 16)); |
319 } | 319 } |
320 | 320 |
321 const String DOMMatrixReadOnly::toString() const { | 321 const String DOMMatrixReadOnly::toString( |
322 std::stringstream stream; | 322 ExceptionState& exception_state) const { |
323 const char* kComma = ", "; | |
324 String result; | |
325 | |
323 if (is2D()) { | 326 if (is2D()) { |
324 stream << "matrix(" << a() << ", " << b() << ", " << c() << ", " << d() | 327 if (std::isfinite(a()) || std::isfinite(b()) || std::isfinite(c()) || |
325 << ", " << e() << ", " << f(); | 328 std::isfinite(d()) || std::isfinite(e()) || std::isfinite(f())) { |
326 } else { | 329 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.
| |
327 stream << "matrix3d(" << m11() << ", " << m12() << ", " << m13() << ", " | 330 return String(); |
328 << m14() << ", " << m21() << ", " << m22() << ", " << m23() << ", " | 331 } |
329 << m24() << ", " << m31() << ", " << m32() << ", " << m33() << ", " | 332 |
330 << m34() << ", " << m41() << ", " << m42() << ", " << m43() << ", " | 333 result.append("matrix("); |
331 << m44(); | 334 result.append(String::NumberToStringECMAScript(a())); |
335 result.append(kComma); | |
336 result.append(String::NumberToStringECMAScript(b())); | |
337 result.append(kComma); | |
338 result.append(String::NumberToStringECMAScript(c())); | |
339 result.append(kComma); | |
340 result.append(String::NumberToStringECMAScript(d())); | |
341 result.append(kComma); | |
342 result.append(String::NumberToStringECMAScript(e())); | |
343 result.append(kComma); | |
344 result.append(String::NumberToStringECMAScript(f())); | |
345 result.append(")"); | |
346 return result; | |
332 } | 347 } |
333 stream << ")"; | |
334 | 348 |
335 return String(stream.str().c_str()); | 349 if (std::isfinite(m11()) || std::isfinite(m12()) || std::isfinite(m13()) || |
350 std::isfinite(m14()) || std::isfinite(m21()) || std::isfinite(m22()) || | |
351 std::isfinite(m23()) || std::isfinite(m24()) || std::isfinite(m31()) || | |
352 std::isfinite(m32()) || std::isfinite(m33()) || std::isfinite(m34()) || | |
353 std::isfinite(m41()) || std::isfinite(m42()) || std::isfinite(m43()) || | |
354 std::isfinite(m44())) { | |
355 exception_state.ThrowDOMException(kInvalidStateError, "Wrong values."); | |
356 return String(); | |
357 } | |
358 | |
359 result.append("matrix3d("); | |
360 result.append(String::NumberToStringECMAScript(m11())); | |
361 result.append(kComma); | |
362 result.append(String::NumberToStringECMAScript(m12())); | |
363 result.append(kComma); | |
364 result.append(String::NumberToStringECMAScript(m13())); | |
365 result.append(kComma); | |
366 result.append(String::NumberToStringECMAScript(m14())); | |
367 result.append(kComma); | |
368 result.append(String::NumberToStringECMAScript(m21())); | |
369 result.append(kComma); | |
370 result.append(String::NumberToStringECMAScript(m22())); | |
371 result.append(kComma); | |
372 result.append(String::NumberToStringECMAScript(m23())); | |
373 result.append(kComma); | |
374 result.append(String::NumberToStringECMAScript(m24())); | |
375 result.append(kComma); | |
376 result.append(String::NumberToStringECMAScript(m31())); | |
377 result.append(kComma); | |
378 result.append(String::NumberToStringECMAScript(m32())); | |
379 result.append(kComma); | |
380 result.append(String::NumberToStringECMAScript(m33())); | |
381 result.append(kComma); | |
382 result.append(String::NumberToStringECMAScript(m34())); | |
383 result.append(kComma); | |
384 result.append(String::NumberToStringECMAScript(m41())); | |
385 result.append(kComma); | |
386 result.append(String::NumberToStringECMAScript(m42())); | |
387 result.append(kComma); | |
388 result.append(String::NumberToStringECMAScript(m43())); | |
389 result.append(kComma); | |
390 result.append(String::NumberToStringECMAScript(m44())); | |
391 result.append(")"); | |
392 | |
393 return result; | |
336 } | 394 } |
337 | 395 |
338 ScriptValue DOMMatrixReadOnly::toJSONForBinding( | 396 ScriptValue DOMMatrixReadOnly::toJSONForBinding( |
339 ScriptState* script_state) const { | 397 ScriptState* script_state) const { |
340 V8ObjectBuilder result(script_state); | 398 V8ObjectBuilder result(script_state); |
341 result.AddNumber("a", a()); | 399 result.AddNumber("a", a()); |
342 result.AddNumber("b", b()); | 400 result.AddNumber("b", b()); |
343 result.AddNumber("c", c()); | 401 result.AddNumber("c", c()); |
344 result.AddNumber("d", d()); | 402 result.AddNumber("d", d()); |
345 result.AddNumber("e", e()); | 403 result.AddNumber("e", e()); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
408 | 466 |
409 matrix_->MakeIdentity(); | 467 matrix_->MakeIdentity(); |
410 operations.Apply(FloatSize(0, 0), *matrix_); | 468 operations.Apply(FloatSize(0, 0), *matrix_); |
411 | 469 |
412 is2d_ = !operations.Has3DOperation(); | 470 is2d_ = !operations.Has3DOperation(); |
413 | 471 |
414 return; | 472 return; |
415 } | 473 } |
416 | 474 |
417 } // namespace blink | 475 } // namespace blink |
OLD | NEW |