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

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

Issue 2707243006: [SharedArrayBuffer] Prevent SharedArrayBuffer being used in Web APIs (Closed)
Patch Set: update comment, add TODO Created 3 years, 8 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 if (sequence.size() != 6 && sequence.size() != 16) { 108 if (sequence.size() != 6 && sequence.size() != 16) {
109 exception_state.ThrowTypeError( 109 exception_state.ThrowTypeError(
110 "The sequence must contain 6 elements for a 2D matrix or 16 elements " 110 "The sequence must contain 6 elements for a 2D matrix or 16 elements "
111 "for a 3D matrix."); 111 "for a 3D matrix.");
112 return nullptr; 112 return nullptr;
113 } 113 }
114 return new DOMMatrixReadOnly(sequence, sequence.size()); 114 return new DOMMatrixReadOnly(sequence, sequence.size());
115 } 115 }
116 116
117 DOMMatrixReadOnly* DOMMatrixReadOnly::fromFloat32Array( 117 DOMMatrixReadOnly* DOMMatrixReadOnly::fromFloat32Array(
118 DOMFloat32Array* float32_array, 118 NotShared<DOMFloat32Array> float32_array,
119 ExceptionState& exception_state) { 119 ExceptionState& exception_state) {
120 if (float32_array->length() != 6 && float32_array->length() != 16) { 120 if (float32_array.View()->length() != 6 &&
121 float32_array.View()->length() != 16) {
121 exception_state.ThrowTypeError( 122 exception_state.ThrowTypeError(
122 "The sequence must contain 6 elements for a 2D matrix or 16 elements a " 123 "The sequence must contain 6 elements for a 2D matrix or 16 elements a "
123 "for 3D matrix."); 124 "for 3D matrix.");
124 return nullptr; 125 return nullptr;
125 } 126 }
126 return new DOMMatrixReadOnly(float32_array->Data(), float32_array->length()); 127 return new DOMMatrixReadOnly(float32_array.View()->Data(),
128 float32_array.View()->length());
127 } 129 }
128 130
129 DOMMatrixReadOnly* DOMMatrixReadOnly::fromFloat64Array( 131 DOMMatrixReadOnly* DOMMatrixReadOnly::fromFloat64Array(
130 DOMFloat64Array* float64_array, 132 NotShared<DOMFloat64Array> float64_array,
131 ExceptionState& exception_state) { 133 ExceptionState& exception_state) {
132 if (float64_array->length() != 6 && float64_array->length() != 16) { 134 if (float64_array.View()->length() != 6 &&
135 float64_array.View()->length() != 16) {
133 exception_state.ThrowTypeError( 136 exception_state.ThrowTypeError(
134 "The sequence must contain 6 elements for a 2D matrix or 16 elements " 137 "The sequence must contain 6 elements for a 2D matrix or 16 elements "
135 "for a 3D matrix."); 138 "for a 3D matrix.");
136 return nullptr; 139 return nullptr;
137 } 140 }
138 return new DOMMatrixReadOnly(float64_array->Data(), float64_array->length()); 141 return new DOMMatrixReadOnly(float64_array.View()->Data(),
142 float64_array.View()->length());
139 } 143 }
140 144
141 DOMMatrixReadOnly* DOMMatrixReadOnly::fromMatrix( 145 DOMMatrixReadOnly* DOMMatrixReadOnly::fromMatrix(
142 DOMMatrixInit& other, 146 DOMMatrixInit& other,
143 ExceptionState& exception_state) { 147 ExceptionState& exception_state) {
144 if (!ValidateAndFixup(other, exception_state)) { 148 if (!ValidateAndFixup(other, exception_state)) {
145 DCHECK(exception_state.HadException()); 149 DCHECK(exception_state.HadException());
146 return nullptr; 150 return nullptr;
147 } 151 }
148 152
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 point.w() * m44(); 272 point.w() * m44();
269 return DOMPoint::Create(x, y, z, w); 273 return DOMPoint::Create(x, y, z, w);
270 } 274 }
271 275
272 DOMMatrixReadOnly::DOMMatrixReadOnly(const TransformationMatrix& matrix, 276 DOMMatrixReadOnly::DOMMatrixReadOnly(const TransformationMatrix& matrix,
273 bool is2d) { 277 bool is2d) {
274 matrix_ = TransformationMatrix::Create(matrix); 278 matrix_ = TransformationMatrix::Create(matrix);
275 is2d_ = is2d; 279 is2d_ = is2d;
276 } 280 }
277 281
278 DOMFloat32Array* DOMMatrixReadOnly::toFloat32Array() const { 282 NotShared<DOMFloat32Array> DOMMatrixReadOnly::toFloat32Array() const {
279 float array[] = { 283 float array[] = {
280 static_cast<float>(matrix_->M11()), static_cast<float>(matrix_->M12()), 284 static_cast<float>(matrix_->M11()), static_cast<float>(matrix_->M12()),
281 static_cast<float>(matrix_->M13()), static_cast<float>(matrix_->M14()), 285 static_cast<float>(matrix_->M13()), static_cast<float>(matrix_->M14()),
282 static_cast<float>(matrix_->M21()), static_cast<float>(matrix_->M22()), 286 static_cast<float>(matrix_->M21()), static_cast<float>(matrix_->M22()),
283 static_cast<float>(matrix_->M23()), static_cast<float>(matrix_->M24()), 287 static_cast<float>(matrix_->M23()), static_cast<float>(matrix_->M24()),
284 static_cast<float>(matrix_->M31()), static_cast<float>(matrix_->M32()), 288 static_cast<float>(matrix_->M31()), static_cast<float>(matrix_->M32()),
285 static_cast<float>(matrix_->M33()), static_cast<float>(matrix_->M34()), 289 static_cast<float>(matrix_->M33()), static_cast<float>(matrix_->M34()),
286 static_cast<float>(matrix_->M41()), static_cast<float>(matrix_->M42()), 290 static_cast<float>(matrix_->M41()), static_cast<float>(matrix_->M42()),
287 static_cast<float>(matrix_->M43()), static_cast<float>(matrix_->M44())}; 291 static_cast<float>(matrix_->M43()), static_cast<float>(matrix_->M44())};
288 292
289 return DOMFloat32Array::Create(array, 16); 293 return NotShared<DOMFloat32Array>(DOMFloat32Array::Create(array, 16));
290 } 294 }
291 295
292 DOMFloat64Array* DOMMatrixReadOnly::toFloat64Array() const { 296 NotShared<DOMFloat64Array> DOMMatrixReadOnly::toFloat64Array() const {
293 double array[] = { 297 double array[] = {
294 matrix_->M11(), matrix_->M12(), matrix_->M13(), matrix_->M14(), 298 matrix_->M11(), matrix_->M12(), matrix_->M13(), matrix_->M14(),
295 matrix_->M21(), matrix_->M22(), matrix_->M23(), matrix_->M24(), 299 matrix_->M21(), matrix_->M22(), matrix_->M23(), matrix_->M24(),
296 matrix_->M31(), matrix_->M32(), matrix_->M33(), matrix_->M34(), 300 matrix_->M31(), matrix_->M32(), matrix_->M33(), matrix_->M34(),
297 matrix_->M41(), matrix_->M42(), matrix_->M43(), matrix_->M44()}; 301 matrix_->M41(), matrix_->M42(), matrix_->M43(), matrix_->M44()};
298 302
299 return DOMFloat64Array::Create(array, 16); 303 return NotShared<DOMFloat64Array>(DOMFloat64Array::Create(array, 16));
300 } 304 }
301 305
302 const String DOMMatrixReadOnly::toString() const { 306 const String DOMMatrixReadOnly::toString() const {
303 std::stringstream stream; 307 std::stringstream stream;
304 if (is2D()) { 308 if (is2D()) {
305 stream << "matrix(" << a() << ", " << b() << ", " << c() << ", " << d() 309 stream << "matrix(" << a() << ", " << b() << ", " << c() << ", " << d()
306 << ", " << e() << ", " << f(); 310 << ", " << e() << ", " << f();
307 } else { 311 } else {
308 stream << "matrix3d(" << m11() << ", " << m12() << ", " << m13() << ", " 312 stream << "matrix3d(" << m11() << ", " << m12() << ", " << m13() << ", "
309 << m14() << ", " << m21() << ", " << m22() << ", " << m23() << ", " 313 << m14() << ", " << m21() << ", " << m22() << ", " << m23() << ", "
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 393
390 matrix_->MakeIdentity(); 394 matrix_->MakeIdentity();
391 operations.Apply(FloatSize(0, 0), *matrix_); 395 operations.Apply(FloatSize(0, 0), *matrix_);
392 396
393 is2d_ = !operations.Has3DOperation(); 397 is2d_ = !operations.Has3DOperation();
394 398
395 return; 399 return;
396 } 400 }
397 401
398 } // namespace blink 402 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/geometry/DOMMatrixReadOnly.h ('k') | third_party/WebKit/Source/core/html/ImageData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698