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

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

Issue 2504543003: [GeometryInterface] Add Constructor() at DOMMatrixReadOnly. (Closed)
Patch Set: rebase Created 4 years, 1 month 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/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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 setDictionaryMembers(other); 78 setDictionaryMembers(other);
79 if (!other.hasIs2D()) { 79 if (!other.hasIs2D()) {
80 bool is2D = !(other.m31() || other.m32() || other.m13() || other.m23() || 80 bool is2D = !(other.m31() || other.m32() || other.m13() || other.m23() ||
81 other.m43() || other.m14() || other.m24() || other.m34() || 81 other.m43() || other.m14() || other.m24() || other.m34() ||
82 other.m33() != 1 || other.m44() != 1); 82 other.m33() != 1 || other.m44() != 1);
83 other.setIs2D(is2D); 83 other.setIs2D(is2D);
84 } 84 }
85 return true; 85 return true;
86 } 86 }
87 87
88 DOMMatrixReadOnly* DOMMatrixReadOnly::create(ExceptionState& exceptionState) {
89 return new DOMMatrixReadOnly(TransformationMatrix());
90 }
91
88 DOMMatrixReadOnly* DOMMatrixReadOnly::create(Vector<double> sequence, 92 DOMMatrixReadOnly* DOMMatrixReadOnly::create(Vector<double> sequence,
89 ExceptionState& exceptionState) { 93 ExceptionState& exceptionState) {
90 if (sequence.size() != 6 && sequence.size() != 16) { 94 if (sequence.size() != 6 && sequence.size() != 16) {
91 exceptionState.throwTypeError( 95 exceptionState.throwTypeError(
92 "The sequence must contain 6 elements for a 2D matrix or 16 elements " 96 "The sequence must contain 6 elements for a 2D matrix or 16 elements "
93 "for a 3D matrix."); 97 "for a 3D matrix.");
94 return nullptr; 98 return nullptr;
95 } 99 }
96 return new DOMMatrixReadOnly(sequence, sequence.size()); 100 return new DOMMatrixReadOnly(sequence, sequence.size());
97 } 101 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 point.w() * m41(); 246 point.w() * m41();
243 double y = point.x() * m12() + point.y() * m22() + point.z() * m32() + 247 double y = point.x() * m12() + point.y() * m22() + point.z() * m32() +
244 point.w() * m42(); 248 point.w() * m42();
245 double z = point.x() * m13() + point.y() * m23() + point.z() * m33() + 249 double z = point.x() * m13() + point.y() * m23() + point.z() * m33() +
246 point.w() * m43(); 250 point.w() * m43();
247 double w = point.x() * m14() + point.y() * m24() + point.z() * m34() + 251 double w = point.x() * m14() + point.y() * m24() + point.z() * m34() +
248 point.w() * m44(); 252 point.w() * m44();
249 return DOMPoint::create(x, y, z, w); 253 return DOMPoint::create(x, y, z, w);
250 } 254 }
251 255
256 DOMMatrixReadOnly::DOMMatrixReadOnly(const TransformationMatrix& matrix,
257 bool is2D) {
258 m_matrix = TransformationMatrix::create(matrix);
259 m_is2D = is2D;
260 }
261
252 DOMFloat32Array* DOMMatrixReadOnly::toFloat32Array() const { 262 DOMFloat32Array* DOMMatrixReadOnly::toFloat32Array() const {
253 float array[] = { 263 float array[] = {
254 static_cast<float>(m_matrix->m11()), static_cast<float>(m_matrix->m12()), 264 static_cast<float>(m_matrix->m11()), static_cast<float>(m_matrix->m12()),
255 static_cast<float>(m_matrix->m13()), static_cast<float>(m_matrix->m14()), 265 static_cast<float>(m_matrix->m13()), static_cast<float>(m_matrix->m14()),
256 static_cast<float>(m_matrix->m21()), static_cast<float>(m_matrix->m22()), 266 static_cast<float>(m_matrix->m21()), static_cast<float>(m_matrix->m22()),
257 static_cast<float>(m_matrix->m23()), static_cast<float>(m_matrix->m24()), 267 static_cast<float>(m_matrix->m23()), static_cast<float>(m_matrix->m24()),
258 static_cast<float>(m_matrix->m31()), static_cast<float>(m_matrix->m32()), 268 static_cast<float>(m_matrix->m31()), static_cast<float>(m_matrix->m32()),
259 static_cast<float>(m_matrix->m33()), static_cast<float>(m_matrix->m34()), 269 static_cast<float>(m_matrix->m33()), static_cast<float>(m_matrix->m34()),
260 static_cast<float>(m_matrix->m41()), static_cast<float>(m_matrix->m42()), 270 static_cast<float>(m_matrix->m41()), static_cast<float>(m_matrix->m42()),
261 static_cast<float>(m_matrix->m43()), static_cast<float>(m_matrix->m44())}; 271 static_cast<float>(m_matrix->m43()), static_cast<float>(m_matrix->m44())};
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 result.addNumber("m41", m41()); 324 result.addNumber("m41", m41());
315 result.addNumber("m42", m42()); 325 result.addNumber("m42", m42());
316 result.addNumber("m43", m43()); 326 result.addNumber("m43", m43());
317 result.addNumber("m44", m44()); 327 result.addNumber("m44", m44());
318 result.addBoolean("is2D", is2D()); 328 result.addBoolean("is2D", is2D());
319 result.addBoolean("isIdentity", isIdentity()); 329 result.addBoolean("isIdentity", isIdentity());
320 return result.scriptValue(); 330 return result.scriptValue();
321 } 331 }
322 332
323 } // namespace blink 333 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.h ('k') | third_party/WebKit/Source/core/dom/DOMMatrixReadOnly.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698