Title: [217764] trunk
Revision
217764
Author
cdu...@apple.com
Date
2017-06-03 18:54:14 -0700 (Sat, 03 Jun 2017)

Log Message

Implement DOMMatrix's fromFloat32Array / fromFloat64Array & toFloat32Array / toFloat64Array
https://bugs.webkit.org/show_bug.cgi?id=172898

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

Rebaseline web-platform-test now that more checks are passing.

* web-platform-tests/css/geometry-1/DOMMatrix-newobject-expected.txt:

Source/WebCore:

Implement DOMMatrix's fromFloat32Array / fromFloat64Array & toFloat32Array / toFloat64Array
as per:
- https://drafts.fxtf.org/geometry/#dommatrixreadonly

Test: http/wpt/geometry/DOMMatrix-from-to-typed-arrays.html

* css/DOMMatrix.cpp:
(WebCore::DOMMatrix::fromFloat32Array):
(WebCore::DOMMatrix::fromFloat64Array):
* css/DOMMatrix.h:
* css/DOMMatrix.idl:
* css/DOMMatrixReadOnly.cpp:
(WebCore::DOMMatrixReadOnly::fromFloat32Array):
(WebCore::DOMMatrixReadOnly::fromFloat64Array):
(WebCore::DOMMatrixReadOnly::toFloat32Array):
(WebCore::DOMMatrixReadOnly::toFloat64Array):
* css/DOMMatrixReadOnly.h:
* css/DOMMatrixReadOnly.idl:

LayoutTests:

Add layout test coverage.

* http/wpt/geometry/DOMMatrix-from-to-typed-arrays-expected.txt: Added.
* http/wpt/geometry/DOMMatrix-from-to-typed-arrays.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (217763 => 217764)


--- trunk/LayoutTests/ChangeLog	2017-06-03 21:09:00 UTC (rev 217763)
+++ trunk/LayoutTests/ChangeLog	2017-06-04 01:54:14 UTC (rev 217764)
@@ -1,3 +1,15 @@
+2017-06-03  Chris Dumez  <cdu...@apple.com>
+
+        Implement DOMMatrix's fromFloat32Array / fromFloat64Array & toFloat32Array / toFloat64Array
+        https://bugs.webkit.org/show_bug.cgi?id=172898
+
+        Reviewed by Sam Weinig.
+
+        Add layout test coverage.
+
+        * http/wpt/geometry/DOMMatrix-from-to-typed-arrays-expected.txt: Added.
+        * http/wpt/geometry/DOMMatrix-from-to-typed-arrays.html: Added.
+
 2017-06-03  Simon Fraser  <simon.fra...@apple.com>
 
         Implement DOMPointReadOnly.matrixTransform()

Added: trunk/LayoutTests/http/wpt/geometry/DOMMatrix-from-to-typed-arrays-expected.txt (0 => 217764)


--- trunk/LayoutTests/http/wpt/geometry/DOMMatrix-from-to-typed-arrays-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/geometry/DOMMatrix-from-to-typed-arrays-expected.txt	2017-06-04 01:54:14 UTC (rev 217764)
@@ -0,0 +1,12 @@
+
+PASS DOMMatrixReadOnly.fromFloat32Array (error cases) 
+PASS DOMMatrixReadOnly.fromFloat32Array 
+PASS DOMMatrixReadOnly.fromFloat64Array (error cases) 
+PASS DOMMatrixReadOnly.fromFloat64Array 
+PASS DOMMatrix.fromFloat32Array (error cases) 
+PASS DOMMatrix.fromFloat32Array 
+PASS DOMMatrix.fromFloat64Array (error cases) 
+PASS DOMMatrix.fromFloat64Array 
+PASS DOMMatrixReadonly.toFloat32Array 
+PASS DOMMatrixReadonly.toFloat64Array 
+

Added: trunk/LayoutTests/http/wpt/geometry/DOMMatrix-from-to-typed-arrays.html (0 => 217764)


--- trunk/LayoutTests/http/wpt/geometry/DOMMatrix-from-to-typed-arrays.html	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/geometry/DOMMatrix-from-to-typed-arrays.html	2017-06-04 01:54:14 UTC (rev 217764)
@@ -0,0 +1,85 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>Geometry Interfaces: DOMMatrix conversion to and from typed arrays</title>
+<link href="" rel="author" title="Chris Dumez">
+<link href="" rel="help">
+<script src=""
+<script src=""
+</head>
+<body>
+<script>
+for (let matrix of ["DOMMatrixReadOnly", "DOMMatrix"]) {
+
+    test(function() {
+        assert_throws(new TypeError, () => { window[matrix].fromFloat32Array() }, "No parameter");
+        assert_throws(new TypeError, () => { window[matrix].fromFloat32Array(null) }, "Passing null");
+        assert_throws(new TypeError, () => { window[matrix].fromFloat32Array(new Float64Array()) }, "Bad parameter");
+        assert_throws(new TypeError, () => { window[matrix].fromFloat32Array(new Float32Array()) }, "Empty Float32Array");
+        assert_throws(new TypeError, () => { window[matrix].fromFloat32Array(new Float32Array([1, 2])) }, "Float32Array with too few items");
+        assert_throws(new TypeError, () => { window[matrix].fromFloat32Array(new Float32Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17])) }, "Float32Array with too many items");
+    }, matrix + ".fromFloat32Array (error cases)");
+
+    test(function() {
+        let matrix2d = window[matrix].fromFloat32Array(new Float32Array([1.5, 2.5, 3.5, 4.5, 5.5, 6.5]));
+        assert_equals(matrix2d.__proto__, window[matrix].prototype);
+        assert_equals(matrix2d.toString(), "matrix(1.5, 2.5, 3.5, 4.5, 5.5, 6.5)");
+
+        let matrix3d = window[matrix].fromFloat32Array(new Float32Array([1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5]));
+        assert_equals(matrix3d.__proto__, window[matrix].prototype);
+        assert_equals(matrix3d.toString(), "matrix3d(1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5)");
+    }, matrix + ".fromFloat32Array");
+
+    test(function() {
+        assert_throws(new TypeError, () => { window[matrix].fromFloat64Array() }, "No parameter");
+        assert_throws(new TypeError, () => { window[matrix].fromFloat64Array(null) }, "Passing null");
+        assert_throws(new TypeError, () => { window[matrix].fromFloat64Array(new Float32Array()) }, "Bad parameter");
+        assert_throws(new TypeError, () => { window[matrix].fromFloat64Array(new Float64Array()) }, "Empty Float64Array");
+        assert_throws(new TypeError, () => { window[matrix].fromFloat64Array(new Float64Array([1, 2])) }, "Float64Array with too few items");
+        assert_throws(new TypeError, () => { window[matrix].fromFloat64Array(new Float64Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17])) }, "Float64Array with too many items");
+    }, matrix + ".fromFloat64Array (error cases)");
+
+    test(function() {
+        let matrix2d = window[matrix].fromFloat64Array(new Float64Array([1.5, 2.5, 3.5, 4.5, 5.5, 6.5]));
+        assert_equals(matrix2d.__proto__, window[matrix].prototype);
+        assert_equals(matrix2d.toString(), "matrix(1.5, 2.5, 3.5, 4.5, 5.5, 6.5)");
+
+        let matrix3d = window[matrix].fromFloat64Array(new Float64Array([1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5]));
+        assert_equals(matrix3d.__proto__, window[matrix].prototype);
+        assert_equals(matrix3d.toString(), "matrix3d(1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5)");
+}, matrix + ".fromFloat64Array");
+
+}
+
+test(function() {
+    let matrix2d = new DOMMatrixReadOnly([1.5, 2.5, 3.5, 4.5, 5.5, 6.5]);
+    let array32 = matrix2d.toFloat32Array();
+    assert_equals(array32.__proto__, Float32Array.prototype);
+    assert_equals(array32.length, 16);
+    assert_equals(array32.toString(), "1.5,2.5,0,0,3.5,4.5,0,0,0,0,1,0,5.5,6.5,0,1");
+
+    let matrix3d = new DOMMatrixReadOnly([1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5]);
+    array32 = matrix3d.toFloat32Array();
+    assert_equals(array32.__proto__, Float32Array.prototype);
+    assert_equals(array32.length, 16);
+    assert_equals(array32.toString(), "1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,11.5,12.5,13.5,14.5,15.5,16.5");
+    assert_equals(matrix3d.toString(), DOMMatrixReadOnly.fromFloat32Array(array32).toString());
+}, "DOMMatrixReadonly.toFloat32Array");
+
+test(function() {
+    let matrix2d = new DOMMatrixReadOnly([1.5, 2.5, 3.5, 4.5, 5.5, 6.5]);
+    let array64 = matrix2d.toFloat64Array();
+    assert_equals(array64.__proto__, Float64Array.prototype);
+    assert_equals(array64.length, 16);
+    assert_equals(array64.toString(), "1.5,2.5,0,0,3.5,4.5,0,0,0,0,1,0,5.5,6.5,0,1");
+
+    let matrix3d = new DOMMatrixReadOnly([1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5]);
+    array64 = matrix3d.toFloat64Array();
+    assert_equals(array64.__proto__, Float64Array.prototype);
+    assert_equals(array64.length, 16);
+    assert_equals(array64.toString(), "1.5,2.5,3.5,4.5,5.5,6.5,7.5,8.5,9.5,10.5,11.5,12.5,13.5,14.5,15.5,16.5");
+    assert_equals(matrix3d.toString(), DOMMatrixReadOnly.fromFloat64Array(array64).toString());
+}, "DOMMatrixReadonly.toFloat64Array");
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (217763 => 217764)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-06-03 21:09:00 UTC (rev 217763)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-06-04 01:54:14 UTC (rev 217764)
@@ -1,3 +1,14 @@
+2017-06-03  Chris Dumez  <cdu...@apple.com>
+
+        Implement DOMMatrix's fromFloat32Array / fromFloat64Array & toFloat32Array / toFloat64Array
+        https://bugs.webkit.org/show_bug.cgi?id=172898
+
+        Reviewed by Sam Weinig.
+
+        Rebaseline web-platform-test now that more checks are passing.
+
+        * web-platform-tests/css/geometry-1/DOMMatrix-newobject-expected.txt:
+
 2017-06-03  Simon Fraser  <simon.fra...@apple.com>
 
         Implement DOMPointReadOnly.matrixTransform()

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/geometry-1/DOMMatrix-newobject-expected.txt (217763 => 217764)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/geometry-1/DOMMatrix-newobject-expected.txt	2017-06-03 21:09:00 UTC (rev 217763)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/geometry-1/DOMMatrix-newobject-expected.txt	2017-06-04 01:54:14 UTC (rev 217764)
@@ -12,8 +12,8 @@
 PASS DOMMatrix flipY 
 PASS DOMMatrix inverse 
 FAIL DOMMatrix transformPoint matrix[method] is not a function. (In 'matrix[method]()', 'matrix[method]' is undefined)
-FAIL DOMMatrix toFloat32Array matrix[method] is not a function. (In 'matrix[method]()', 'matrix[method]' is undefined)
-FAIL DOMMatrix toFloat64Array matrix[method] is not a function. (In 'matrix[method]()', 'matrix[method]' is undefined)
+PASS DOMMatrix toFloat32Array 
+PASS DOMMatrix toFloat64Array 
 PASS DOMMatrixReadOnly translate 
 PASS DOMMatrixReadOnly scale 
 PASS DOMMatrixReadOnly scale3d 
@@ -27,6 +27,6 @@
 PASS DOMMatrixReadOnly flipY 
 PASS DOMMatrixReadOnly inverse 
 FAIL DOMMatrixReadOnly transformPoint matrix[method] is not a function. (In 'matrix[method]()', 'matrix[method]' is undefined)
-FAIL DOMMatrixReadOnly toFloat32Array matrix[method] is not a function. (In 'matrix[method]()', 'matrix[method]' is undefined)
-FAIL DOMMatrixReadOnly toFloat64Array matrix[method] is not a function. (In 'matrix[method]()', 'matrix[method]' is undefined)
+PASS DOMMatrixReadOnly toFloat32Array 
+PASS DOMMatrixReadOnly toFloat64Array 
 

Modified: trunk/Source/WebCore/ChangeLog (217763 => 217764)


--- trunk/Source/WebCore/ChangeLog	2017-06-03 21:09:00 UTC (rev 217763)
+++ trunk/Source/WebCore/ChangeLog	2017-06-04 01:54:14 UTC (rev 217764)
@@ -1,3 +1,29 @@
+2017-06-03  Chris Dumez  <cdu...@apple.com>
+
+        Implement DOMMatrix's fromFloat32Array / fromFloat64Array & toFloat32Array / toFloat64Array
+        https://bugs.webkit.org/show_bug.cgi?id=172898
+
+        Reviewed by Sam Weinig.
+
+        Implement DOMMatrix's fromFloat32Array / fromFloat64Array & toFloat32Array / toFloat64Array
+        as per:
+        - https://drafts.fxtf.org/geometry/#dommatrixreadonly
+
+        Test: http/wpt/geometry/DOMMatrix-from-to-typed-arrays.html
+
+        * css/DOMMatrix.cpp:
+        (WebCore::DOMMatrix::fromFloat32Array):
+        (WebCore::DOMMatrix::fromFloat64Array):
+        * css/DOMMatrix.h:
+        * css/DOMMatrix.idl:
+        * css/DOMMatrixReadOnly.cpp:
+        (WebCore::DOMMatrixReadOnly::fromFloat32Array):
+        (WebCore::DOMMatrixReadOnly::fromFloat64Array):
+        (WebCore::DOMMatrixReadOnly::toFloat32Array):
+        (WebCore::DOMMatrixReadOnly::toFloat64Array):
+        * css/DOMMatrixReadOnly.h:
+        * css/DOMMatrixReadOnly.idl:
+
 2017-06-03  Simon Fraser  <simon.fra...@apple.com>
 
         Implement DOMPointReadOnly.matrixTransform()

Modified: trunk/Source/WebCore/css/DOMMatrix.cpp (217763 => 217764)


--- trunk/Source/WebCore/css/DOMMatrix.cpp	2017-06-03 21:09:00 UTC (rev 217763)
+++ trunk/Source/WebCore/css/DOMMatrix.cpp	2017-06-04 01:54:14 UTC (rev 217764)
@@ -43,6 +43,40 @@
     return fromMatrixHelper<DOMMatrix>(WTFMove(init));
 }
 
+ExceptionOr<Ref<DOMMatrix>> DOMMatrix::fromFloat32Array(Ref<Float32Array>&& array32)
+{
+    if (array32->length() == 6)
+        return DOMMatrix::create(TransformationMatrix(array32->item(0), array32->item(1), array32->item(2), array32->item(3), array32->item(4), array32->item(5)), Is2D::Yes);
+
+    if (array32->length() == 16) {
+        return DOMMatrix::create(TransformationMatrix(
+            array32->item(0), array32->item(1), array32->item(2), array32->item(3),
+            array32->item(4), array32->item(5), array32->item(6), array32->item(7),
+            array32->item(8), array32->item(9), array32->item(10), array32->item(11),
+            array32->item(12), array32->item(13), array32->item(14), array32->item(15)
+        ), Is2D::No);
+    }
+
+    return Exception { TypeError };
+}
+
+ExceptionOr<Ref<DOMMatrix>> DOMMatrix::fromFloat64Array(Ref<Float64Array>&& array64)
+{
+    if (array64->length() == 6)
+        return DOMMatrix::create(TransformationMatrix(array64->item(0), array64->item(1), array64->item(2), array64->item(3), array64->item(4), array64->item(5)), Is2D::Yes);
+
+    if (array64->length() == 16) {
+        return DOMMatrix::create(TransformationMatrix(
+            array64->item(0), array64->item(1), array64->item(2), array64->item(3),
+            array64->item(4), array64->item(5), array64->item(6), array64->item(7),
+            array64->item(8), array64->item(9), array64->item(10), array64->item(11),
+            array64->item(12), array64->item(13), array64->item(14), array64->item(15)
+        ), Is2D::No);
+    }
+
+    return Exception { TypeError };
+}
+
 // https://drafts.fxtf.org/geometry/#dom-dommatrix-multiplyself
 ExceptionOr<Ref<DOMMatrix>> DOMMatrix::multiplySelf(DOMMatrixInit&& other)
 {

Modified: trunk/Source/WebCore/css/DOMMatrix.h (217763 => 217764)


--- trunk/Source/WebCore/css/DOMMatrix.h	2017-06-03 21:09:00 UTC (rev 217763)
+++ trunk/Source/WebCore/css/DOMMatrix.h	2017-06-04 01:54:14 UTC (rev 217764)
@@ -52,6 +52,9 @@
 
     static ExceptionOr<Ref<DOMMatrix>> fromMatrix(DOMMatrixInit&&);
 
+    static ExceptionOr<Ref<DOMMatrix>> fromFloat32Array(Ref<Float32Array>&&);
+    static ExceptionOr<Ref<DOMMatrix>> fromFloat64Array(Ref<Float64Array>&&);
+
     ExceptionOr<Ref<DOMMatrix>> multiplySelf(DOMMatrixInit&& other);
     ExceptionOr<Ref<DOMMatrix>> preMultiplySelf(DOMMatrixInit&& other);
     Ref<DOMMatrix> translateSelf(double tx = 0, double ty = 0, double tz = 0);

Modified: trunk/Source/WebCore/css/DOMMatrix.idl (217763 => 217764)


--- trunk/Source/WebCore/css/DOMMatrix.idl	2017-06-03 21:09:00 UTC (rev 217763)
+++ trunk/Source/WebCore/css/DOMMatrix.idl	2017-06-04 01:54:14 UTC (rev 217764)
@@ -32,8 +32,8 @@
     ImplementationLacksVTable
  ] interface DOMMatrix : DOMMatrixReadOnly {
     [MayThrowException, NewObject] static DOMMatrix fromMatrix(optional DOMMatrixInit other);
-    // [NewObject] static DOMMatrix fromFloat32Array(Float32Array array32); // FIXME: Implement this.
-    // [NewObject] static DOMMatrix fromFloat64Array(Float64Array array64);  // FIXME: Implement this.
+    [MayThrowException, NewObject] static DOMMatrix fromFloat32Array(Float32Array array32);
+    [MayThrowException, NewObject] static DOMMatrix fromFloat64Array(Float64Array array64);
 
     // These attributes are simple aliases for certain elements of the 4x4 matrix
     inherit attribute unrestricted double a; // Alias for m11.

Modified: trunk/Source/WebCore/css/DOMMatrixReadOnly.cpp (217763 => 217764)


--- trunk/Source/WebCore/css/DOMMatrixReadOnly.cpp	2017-06-03 21:09:00 UTC (rev 217763)
+++ trunk/Source/WebCore/css/DOMMatrixReadOnly.cpp	2017-06-04 01:54:14 UTC (rev 217764)
@@ -32,6 +32,9 @@
 #include "ExceptionCode.h"
 #include "StyleProperties.h"
 #include "TransformFunctions.h"
+#include <_javascript_Core/GenericTypedArrayViewInlines.h>
+#include <_javascript_Core/JSGenericTypedArrayViewInlines.h>
+#include <heap/HeapInlines.h>
 #include <wtf/text/StringBuilder.h>
 
 namespace WebCore {
@@ -114,6 +117,40 @@
     return fromMatrixHelper<DOMMatrixReadOnly>(WTFMove(init));
 }
 
+ExceptionOr<Ref<DOMMatrixReadOnly>> DOMMatrixReadOnly::fromFloat32Array(Ref<Float32Array>&& array32)
+{
+    if (array32->length() == 6)
+        return DOMMatrixReadOnly::create(TransformationMatrix(array32->item(0), array32->item(1), array32->item(2), array32->item(3), array32->item(4), array32->item(5)), Is2D::Yes);
+
+    if (array32->length() == 16) {
+        return DOMMatrixReadOnly::create(TransformationMatrix(
+            array32->item(0), array32->item(1), array32->item(2), array32->item(3),
+            array32->item(4), array32->item(5), array32->item(6), array32->item(7),
+            array32->item(8), array32->item(9), array32->item(10), array32->item(11),
+            array32->item(12), array32->item(13), array32->item(14), array32->item(15)
+        ), Is2D::No);
+    }
+
+    return Exception { TypeError };
+}
+
+ExceptionOr<Ref<DOMMatrixReadOnly>> DOMMatrixReadOnly::fromFloat64Array(Ref<Float64Array>&& array64)
+{
+    if (array64->length() == 6)
+        return DOMMatrixReadOnly::create(TransformationMatrix(array64->item(0), array64->item(1), array64->item(2), array64->item(3), array64->item(4), array64->item(5)), Is2D::Yes);
+
+    if (array64->length() == 16) {
+        return DOMMatrixReadOnly::create(TransformationMatrix(
+            array64->item(0), array64->item(1), array64->item(2), array64->item(3),
+            array64->item(4), array64->item(5), array64->item(6), array64->item(7),
+            array64->item(8), array64->item(9), array64->item(10), array64->item(11),
+            array64->item(12), array64->item(13), array64->item(14), array64->item(15)
+        ), Is2D::No);
+    }
+
+    return Exception { TypeError };
+}
+
 bool DOMMatrixReadOnly::isIdentity() const
 {
     return m_matrix.isIdentity();
@@ -248,6 +285,58 @@
     return matrix->invertSelf();
 }
 
+ExceptionOr<Ref<Float32Array>> DOMMatrixReadOnly::toFloat32Array() const
+{
+    auto array32 = Float32Array::createUninitialized(16);
+    if (!array32)
+        return Exception { UnknownError, ASCIILiteral("Out of memory") };
+
+    unsigned index = 0;
+    array32->set(index++, m_matrix.m11());
+    array32->set(index++, m_matrix.m12());
+    array32->set(index++, m_matrix.m13());
+    array32->set(index++, m_matrix.m14());
+    array32->set(index++, m_matrix.m21());
+    array32->set(index++, m_matrix.m22());
+    array32->set(index++, m_matrix.m23());
+    array32->set(index++, m_matrix.m24());
+    array32->set(index++, m_matrix.m31());
+    array32->set(index++, m_matrix.m32());
+    array32->set(index++, m_matrix.m33());
+    array32->set(index++, m_matrix.m34());
+    array32->set(index++, m_matrix.m41());
+    array32->set(index++, m_matrix.m42());
+    array32->set(index++, m_matrix.m43());
+    array32->set(index, m_matrix.m44());
+    return array32.releaseNonNull();
+}
+
+ExceptionOr<Ref<Float64Array>> DOMMatrixReadOnly::toFloat64Array() const
+{
+    auto array64 = Float64Array::createUninitialized(16);
+    if (!array64)
+        return Exception { UnknownError, ASCIILiteral("Out of memory") };
+
+    unsigned index = 0;
+    array64->set(index++, m_matrix.m11());
+    array64->set(index++, m_matrix.m12());
+    array64->set(index++, m_matrix.m13());
+    array64->set(index++, m_matrix.m14());
+    array64->set(index++, m_matrix.m21());
+    array64->set(index++, m_matrix.m22());
+    array64->set(index++, m_matrix.m23());
+    array64->set(index++, m_matrix.m24());
+    array64->set(index++, m_matrix.m31());
+    array64->set(index++, m_matrix.m32());
+    array64->set(index++, m_matrix.m33());
+    array64->set(index++, m_matrix.m34());
+    array64->set(index++, m_matrix.m41());
+    array64->set(index++, m_matrix.m42());
+    array64->set(index++, m_matrix.m43());
+    array64->set(index, m_matrix.m44());
+    return array64.releaseNonNull();
+}
+
 // https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-stringifier
 ExceptionOr<String> DOMMatrixReadOnly::toString() const
 {

Modified: trunk/Source/WebCore/css/DOMMatrixReadOnly.h (217763 => 217764)


--- trunk/Source/WebCore/css/DOMMatrixReadOnly.h	2017-06-03 21:09:00 UTC (rev 217763)
+++ trunk/Source/WebCore/css/DOMMatrixReadOnly.h	2017-06-04 01:54:14 UTC (rev 217764)
@@ -29,6 +29,8 @@
 #include "ExceptionOr.h"
 #include "ScriptWrappable.h"
 #include "TransformationMatrix.h"
+#include <runtime/Float32Array.h>
+#include <runtime/Float64Array.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Variant.h>
 #include <wtf/Vector.h>
@@ -63,6 +65,9 @@
 
     static ExceptionOr<Ref<DOMMatrixReadOnly>> fromMatrix(DOMMatrixInit&&);
 
+    static ExceptionOr<Ref<DOMMatrixReadOnly>> fromFloat32Array(Ref<Float32Array>&&);
+    static ExceptionOr<Ref<DOMMatrixReadOnly>> fromFloat64Array(Ref<Float64Array>&&);
+
     double a() const { return m_matrix.a(); }
     double b() const { return m_matrix.b(); }
     double c() const { return m_matrix.c(); }
@@ -106,6 +111,9 @@
     Ref<DOMMatrix> skewY(double sy = 0); // Angle is in degrees.
     Ref<DOMMatrix> inverse() const;
 
+    ExceptionOr<Ref<Float32Array>> toFloat32Array() const;
+    ExceptionOr<Ref<Float64Array>> toFloat64Array() const;
+
     ExceptionOr<String> toString() const;
 
     const TransformationMatrix& transformationMatrix() const { return m_matrix; }

Modified: trunk/Source/WebCore/css/DOMMatrixReadOnly.idl (217763 => 217764)


--- trunk/Source/WebCore/css/DOMMatrixReadOnly.idl	2017-06-03 21:09:00 UTC (rev 217763)
+++ trunk/Source/WebCore/css/DOMMatrixReadOnly.idl	2017-06-04 01:54:14 UTC (rev 217764)
@@ -31,8 +31,8 @@
     ImplementationLacksVTable
 ] interface DOMMatrixReadOnly {
     [MayThrowException, NewObject] static DOMMatrixReadOnly fromMatrix(optional DOMMatrixInit other);
-    // [NewObject] static DOMMatrixReadOnly fromFloat32Array(Float32Array array32); // FIXME: Implement this.
-    // [NewObject] static DOMMatrixReadOnly fromFloat64Array(Float64Array array64); // FIXME: Implement this.
+    [MayThrowException, NewObject] static DOMMatrixReadOnly fromFloat32Array(Float32Array array32);
+    [MayThrowException, NewObject] static DOMMatrixReadOnly fromFloat64Array(Float64Array array64);
 
     // These attributes are simple aliases for certain elements of the 4x4 matrix
     readonly attribute unrestricted double a; // Alias for m11.
@@ -93,8 +93,8 @@
     [NewObject] DOMMatrix inverse();
 
     // [NewObject] DOMPoint transformPoint(optional DOMPointInit point); // FIXME: Implement this.
-    // [NewObject] Float32Array toFloat32Array(); // FIXME: Implement this.
-    // [NewObject] Float64Array toFloat64Array(); // FIXME: Implement this.
+    [MayThrowException] Float32Array toFloat32Array();
+    [MayThrowException] Float64Array toFloat64Array();
 
     [MayThrowException] DOMString toString(); // FIXME: Should be stringifier; once it is supported.
     serializer = { attribute };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to