Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: third_party/WebKit/Source/core/geometry/DOMMatrixReadOnly.cpp

Issue 2846523002: Update the stringifier behavior for DOMMatrixReadOnly (Closed)
Patch Set: Update the stringifier behavior for DOMMatrixReadOnly Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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()) ||
zino 2017/05/18 16:15:38 Shouldn't be && instead of || as follows: std::isf
fserb 2017/05/18 17:10:55 actually, shouldn't it be !std::isfinite(a()) || !
zino 2017/05/18 18:19:02 Yeah it's the same. :) (de morgan's law)
325 << ", " << e() << ", " << f(); 328 std::isfinite(d()) || std::isfinite(e()) || std::isfinite(f())) {
326 } else { 329 exception_state.ThrowDOMException(
327 stream << "matrix3d(" << m11() << ", " << m12() << ", " << m13() << ", " 330 kInvalidStateError,
328 << m14() << ", " << m21() << ", " << m22() << ", " << m23() << ", " 331 "DOMMatrix does not support NaN and Infinity values.");
fserb 2017/05/18 17:10:55 This is false. "DOMMatrix cannot be serialized wit
329 << m24() << ", " << m31() << ", " << m32() << ", " << m33() << ", " 332 return String();
330 << m34() << ", " << m41() << ", " << m42() << ", " << m43() << ", " 333 }
331 << m44(); 334
335 result.append("matrix(");
336 result.append(String::NumberToStringECMAScript(a()));
337 result.append(kComma);
338 result.append(String::NumberToStringECMAScript(b()));
339 result.append(kComma);
340 result.append(String::NumberToStringECMAScript(c()));
341 result.append(kComma);
342 result.append(String::NumberToStringECMAScript(d()));
343 result.append(kComma);
344 result.append(String::NumberToStringECMAScript(e()));
345 result.append(kComma);
346 result.append(String::NumberToStringECMAScript(f()));
347 result.append(")");
348 return result;
332 } 349 }
333 stream << ")";
334 350
335 return String(stream.str().c_str()); 351 if (std::isfinite(m11()) || std::isfinite(m12()) || std::isfinite(m13()) ||
fserb 2017/05/18 17:10:55 same as above.
352 std::isfinite(m14()) || std::isfinite(m21()) || std::isfinite(m22()) ||
353 std::isfinite(m23()) || std::isfinite(m24()) || std::isfinite(m31()) ||
354 std::isfinite(m32()) || std::isfinite(m33()) || std::isfinite(m34()) ||
355 std::isfinite(m41()) || std::isfinite(m42()) || std::isfinite(m43()) ||
356 std::isfinite(m44())) {
357 exception_state.ThrowDOMException(
358 kInvalidStateError,
359 "DOMMatrix does not support NaN and infinity values.");
fserb 2017/05/18 17:10:55 same as above.
360 return String();
361 }
362
363 result.append("matrix3d(");
364 result.append(String::NumberToStringECMAScript(m11()));
365 result.append(kComma);
366 result.append(String::NumberToStringECMAScript(m12()));
367 result.append(kComma);
368 result.append(String::NumberToStringECMAScript(m13()));
369 result.append(kComma);
370 result.append(String::NumberToStringECMAScript(m14()));
371 result.append(kComma);
372 result.append(String::NumberToStringECMAScript(m21()));
373 result.append(kComma);
374 result.append(String::NumberToStringECMAScript(m22()));
375 result.append(kComma);
376 result.append(String::NumberToStringECMAScript(m23()));
377 result.append(kComma);
378 result.append(String::NumberToStringECMAScript(m24()));
379 result.append(kComma);
380 result.append(String::NumberToStringECMAScript(m31()));
381 result.append(kComma);
382 result.append(String::NumberToStringECMAScript(m32()));
383 result.append(kComma);
384 result.append(String::NumberToStringECMAScript(m33()));
385 result.append(kComma);
386 result.append(String::NumberToStringECMAScript(m34()));
387 result.append(kComma);
388 result.append(String::NumberToStringECMAScript(m41()));
389 result.append(kComma);
390 result.append(String::NumberToStringECMAScript(m42()));
391 result.append(kComma);
392 result.append(String::NumberToStringECMAScript(m43()));
393 result.append(kComma);
394 result.append(String::NumberToStringECMAScript(m44()));
395 result.append(")");
396
397 return result;
336 } 398 }
337 399
338 ScriptValue DOMMatrixReadOnly::toJSONForBinding( 400 ScriptValue DOMMatrixReadOnly::toJSONForBinding(
339 ScriptState* script_state) const { 401 ScriptState* script_state) const {
340 V8ObjectBuilder result(script_state); 402 V8ObjectBuilder result(script_state);
341 result.AddNumber("a", a()); 403 result.AddNumber("a", a());
342 result.AddNumber("b", b()); 404 result.AddNumber("b", b());
343 result.AddNumber("c", c()); 405 result.AddNumber("c", c());
344 result.AddNumber("d", d()); 406 result.AddNumber("d", d());
345 result.AddNumber("e", e()); 407 result.AddNumber("e", e());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 470
409 matrix_->MakeIdentity(); 471 matrix_->MakeIdentity();
410 operations.Apply(FloatSize(0, 0), *matrix_); 472 operations.Apply(FloatSize(0, 0), *matrix_);
411 473
412 is2d_ = !operations.Has3DOperation(); 474 is2d_ = !operations.Has3DOperation();
413 475
414 return; 476 return;
415 } 477 }
416 478
417 } // namespace blink 479 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698