Title: [218644] trunk
Revision
218644
Author
[email protected]
Date
2017-06-21 13:05:59 -0700 (Wed, 21 Jun 2017)

Log Message

Add support for structured serialization of CSS Geometry types
https://bugs.webkit.org/show_bug.cgi?id=173631

Patch by Sam Weinig <[email protected]> on 2017-06-21
Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

* web-platform-tests/css/geometry-1/structured-serialization-expected.txt:
Update test results now that they pass.

Source/WebCore:

Tests: imported/w3c/web-platform-tests/css/geometry-1/structured-serialization.html

Adds support for serializing the new geometry types as specified by:
https://drafts.fxtf.org/geometry-1/#structured-serialization

* WebCore.xcodeproj/project.pbxproj:
Move a few custom bindings into the "GC / Wrapping Only" since they have no more custom operations or attributes.

* bindings/js/SerializedScriptValue.cpp:
(WebCore::CloneSerializer::dumpDOMPoint):
(WebCore::CloneSerializer::dumpDOMRect):
(WebCore::CloneSerializer::dumpDOMMatrix):
(WebCore::CloneSerializer::dumpDOMQuad):
(WebCore::CloneSerializer::dumpIfTerminal):
(WebCore::CloneDeserializer::getJSValue):
(WebCore::CloneDeserializer::readDOMPoint):
(WebCore::CloneDeserializer::readDOMMatrix):
(WebCore::CloneDeserializer::readDOMRect):
(WebCore::CloneDeserializer::readDOMPointInit):
(WebCore::CloneDeserializer::readDOMQuad):
(WebCore::CloneDeserializer::readTerminal):
Add serialization/deserialization of the geometry types.

* css/DOMMatrix.cpp:
(WebCore::DOMMatrix::DOMMatrix):
* css/DOMMatrix.h:
(WebCore::DOMMatrix::create):
* css/DOMMatrixReadOnly.cpp:
(WebCore::DOMMatrixReadOnly::DOMMatrixReadOnly):
* css/DOMMatrixReadOnly.h:
(WebCore::DOMMatrixReadOnly::create):
Add create functions and constructors that take a TransformationMatrix by r-value reference
so they can be moved into the DOM type.

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (218643 => 218644)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-06-21 19:49:11 UTC (rev 218643)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-06-21 20:05:59 UTC (rev 218644)
@@ -1,3 +1,13 @@
+2017-06-21  Sam Weinig  <[email protected]>
+
+        Add support for structured serialization of CSS Geometry types
+        https://bugs.webkit.org/show_bug.cgi?id=173631
+
+        Reviewed by Simon Fraser.
+
+        * web-platform-tests/css/geometry-1/structured-serialization-expected.txt:
+        Update test results now that they pass.
+
 2017-06-21  Frederic Wang  <[email protected]>
 
         Import W3C tests regarding navigation inside sandboxed iframes

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/geometry-1/structured-serialization-expected.txt (218643 => 218644)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/geometry-1/structured-serialization-expected.txt	2017-06-21 19:49:11 UTC (rev 218643)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/geometry-1/structured-serialization-expected.txt	2017-06-21 20:05:59 UTC (rev 218644)
@@ -1,32 +1,32 @@
 
-FAIL DOMPointReadOnly clone: basic promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMPointReadOnly clone: custom property promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMPointReadOnly clone: throwing getters promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMPointReadOnly clone: non-initial values promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMPoint clone: basic promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMPoint clone: custom property promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMPoint clone: throwing getters promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMPoint clone: non-initial values promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMRectReadOnly clone: basic promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMRectReadOnly clone: custom property promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMRectReadOnly clone: throwing getters promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMRectReadOnly clone: non-initial values promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMRect clone: basic promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMRect clone: custom property promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMRect clone: throwing getters promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMRect clone: non-initial values promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMQuad clone: basic promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMQuad clone: custom property promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMQuad clone: throwing getters promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMQuad clone: non-initial values promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMMatrixReadOnly clone: basic promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMMatrixReadOnly clone: custom property promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMMatrixReadOnly clone: throwing getters promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMMatrixReadOnly clone: non-initial values (2d) promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMMatrixReadOnly clone: non-initial values (3d) promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMMatrix clone: basic promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMMatrix clone: custom property promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMMatrix clone: throwing getters promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMMatrix clone: non-initial values (2d) promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
-FAIL DOMMatrix clone: non-initial values (3d) promise_test: Unhandled rejection with value: object "DataCloneError (DOM Exception 25): The object can not be cloned."
+PASS DOMPointReadOnly clone: basic 
+PASS DOMPointReadOnly clone: custom property 
+PASS DOMPointReadOnly clone: throwing getters 
+PASS DOMPointReadOnly clone: non-initial values 
+PASS DOMPoint clone: basic 
+PASS DOMPoint clone: custom property 
+PASS DOMPoint clone: throwing getters 
+PASS DOMPoint clone: non-initial values 
+PASS DOMRectReadOnly clone: basic 
+PASS DOMRectReadOnly clone: custom property 
+PASS DOMRectReadOnly clone: throwing getters 
+PASS DOMRectReadOnly clone: non-initial values 
+PASS DOMRect clone: basic 
+PASS DOMRect clone: custom property 
+PASS DOMRect clone: throwing getters 
+PASS DOMRect clone: non-initial values 
+PASS DOMQuad clone: basic 
+PASS DOMQuad clone: custom property 
+PASS DOMQuad clone: throwing getters 
+PASS DOMQuad clone: non-initial values 
+PASS DOMMatrixReadOnly clone: basic 
+PASS DOMMatrixReadOnly clone: custom property 
+PASS DOMMatrixReadOnly clone: throwing getters 
+PASS DOMMatrixReadOnly clone: non-initial values (2d) 
+PASS DOMMatrixReadOnly clone: non-initial values (3d) 
+PASS DOMMatrix clone: basic 
+PASS DOMMatrix clone: custom property 
+PASS DOMMatrix clone: throwing getters 
+PASS DOMMatrix clone: non-initial values (2d) 
+PASS DOMMatrix clone: non-initial values (3d) 
 

Modified: trunk/Source/WebCore/ChangeLog (218643 => 218644)


--- trunk/Source/WebCore/ChangeLog	2017-06-21 19:49:11 UTC (rev 218643)
+++ trunk/Source/WebCore/ChangeLog	2017-06-21 20:05:59 UTC (rev 218644)
@@ -1,3 +1,44 @@
+2017-06-21  Sam Weinig  <[email protected]>
+
+        Add support for structured serialization of CSS Geometry types
+        https://bugs.webkit.org/show_bug.cgi?id=173631
+
+        Reviewed by Simon Fraser.
+
+        Tests: imported/w3c/web-platform-tests/css/geometry-1/structured-serialization.html
+
+        Adds support for serializing the new geometry types as specified by:
+        https://drafts.fxtf.org/geometry-1/#structured-serialization
+
+        * WebCore.xcodeproj/project.pbxproj:
+        Move a few custom bindings into the "GC / Wrapping Only" since they have no more custom operations or attributes.
+
+        * bindings/js/SerializedScriptValue.cpp:
+        (WebCore::CloneSerializer::dumpDOMPoint):
+        (WebCore::CloneSerializer::dumpDOMRect):
+        (WebCore::CloneSerializer::dumpDOMMatrix):
+        (WebCore::CloneSerializer::dumpDOMQuad):
+        (WebCore::CloneSerializer::dumpIfTerminal):
+        (WebCore::CloneDeserializer::getJSValue):
+        (WebCore::CloneDeserializer::readDOMPoint):
+        (WebCore::CloneDeserializer::readDOMMatrix):
+        (WebCore::CloneDeserializer::readDOMRect):
+        (WebCore::CloneDeserializer::readDOMPointInit):
+        (WebCore::CloneDeserializer::readDOMQuad):
+        (WebCore::CloneDeserializer::readTerminal):
+        Add serialization/deserialization of the geometry types.
+
+        * css/DOMMatrix.cpp:
+        (WebCore::DOMMatrix::DOMMatrix):
+        * css/DOMMatrix.h:
+        (WebCore::DOMMatrix::create):
+        * css/DOMMatrixReadOnly.cpp:
+        (WebCore::DOMMatrixReadOnly::DOMMatrixReadOnly):
+        * css/DOMMatrixReadOnly.h:
+        (WebCore::DOMMatrixReadOnly::create):
+        Add create functions and constructors that take a TransformationMatrix by r-value reference
+        so they can be moved into the DOM type.
+
 2017-06-21  Andreas Kling  <[email protected]>
 
         [iOS] Ensure that GraphicsServices is initialized before calling GSFontPurgeFontCache().

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (218643 => 218644)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-06-21 19:49:11 UTC (rev 218643)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-06-21 20:05:59 UTC (rev 218644)
@@ -19748,11 +19748,16 @@
 				AD726FE916D9F40A003A4E6D /* JSCSSRuleCustom.h */,
 				9392262E10321084006E7D5D /* JSCSSRuleListCustom.cpp */,
 				BC20FB7E0C0E8E6C00D1447F /* JSCSSValueCustom.cpp */,
+				49C7BA8C1042F5B10009D447 /* JSDocumentCustom.cpp */,
+				ADDA94BF19686F8000453029 /* JSDocumentCustom.h */,
 				7C33F3601B4A050400502CAF /* JSDocumentFragmentCustom.cpp */,
+				0F94A3951EF1B10500FBAFFB /* JSDOMQuadCustom.cpp */,
 				BC2ED5540C6B9BD300920BFF /* JSElementCustom.cpp */,
 				ADEC78F718EE5308001315C2 /* JSElementCustom.h */,
 				BCEFAF4D0C317E6900FA81F6 /* JSEventCustom.cpp */,
 				E34EE49F1DC2D57500EAA9D3 /* JSEventCustom.h */,
+				BC60901E0E91B8EC000C68B5 /* JSEventTargetCustom.cpp */,
+				46B63F6B1C6E8CDF002E914B /* JSEventTargetCustom.h */,
 				BCCBAD3A0C18BFF800CE890F /* JSHTMLCollectionCustom.cpp */,
 				512BDB4C1C46B0FF006494DF /* JSIDBCursorCustom.cpp */,
 				5141298D1C5FD7E90059E714 /* JSIDBCursorWithValueCustom.cpp */,
@@ -23626,8 +23631,6 @@
 				7C45C9CB1E3E8E4900AAB558 /* JSDOMWrapperCache.cpp */,
 				7C45C9C81E3E8B5100AAB558 /* JSDOMWrapperCache.h */,
 				E3A5872E1DC3F52600F607A6 /* JSDynamicDowncast.h */,
-				BC60901E0E91B8EC000C68B5 /* JSEventTargetCustom.cpp */,
-				46B63F6B1C6E8CDF002E914B /* JSEventTargetCustom.h */,
 				3314ACE910892086000F0E56 /* JSExceptionBase.cpp */,
 				3314ACEA10892086000F0E56 /* JSExceptionBase.h */,
 				8F934D841189F1EE00508D5D /* JSMainThreadExecState.cpp */,
@@ -23683,9 +23686,6 @@
 				AD726FEA16D9F40B003A4E6D /* JSCSSStyleDeclarationCustom.h */,
 				9BC5F9DF1D5AAF6A002B749D /* JSCustomElementRegistryCustom.cpp */,
 				DEC2975D1B4DEB2A005F5945 /* JSCustomEventCustom.cpp */,
-				49C7BA8C1042F5B10009D447 /* JSDocumentCustom.cpp */,
-				ADDA94BF19686F8000453029 /* JSDocumentCustom.h */,
-				0F94A3951EF1B10500FBAFFB /* JSDOMQuadCustom.cpp */,
 				BCD9C25E0C17AA67005C90A2 /* JSDOMWindowCustom.cpp */,
 				652FBBBB0DE27CB60001D386 /* JSDOMWindowCustom.h */,
 				C28083411C6DC96A001451B6 /* JSFontFaceCustom.cpp */,

Modified: trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp (218643 => 218644)


--- trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp	2017-06-21 19:49:11 UTC (rev 218643)
+++ trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp	2017-06-21 20:05:59 UTC (rev 218644)
@@ -45,6 +45,10 @@
 #include "JSDOMBinding.h"
 #include "JSDOMConvertBufferSource.h"
 #include "JSDOMGlobalObject.h"
+#include "JSDOMMatrix.h"
+#include "JSDOMPoint.h"
+#include "JSDOMQuad.h"
+#include "JSDOMRect.h"
 #include "JSFile.h"
 #include "JSFileList.h"
 #include "JSImageData.h"
@@ -152,6 +156,13 @@
 #if ENABLE(WEBASSEMBLY)
     WasmModuleTag = 35,
 #endif
+    DOMPointReadOnlyTag = 36,
+    DOMPointTag = 37,
+    DOMRectReadOnlyTag = 38,
+    DOMRectTag = 39,
+    DOMMatrixReadOnlyTag = 40,
+    DOMMatrixTag = 41,
+    DOMQuadTag = 42,
     ErrorTag = 255
 };
 
@@ -327,6 +338,10 @@
  *    | ArrayBufferViewTag ArrayBufferViewSubtag <byteOffset:uint32_t> <byteLength:uint32_t> (ArrayBuffer | ObjectReference)
  *    | ArrayBufferTransferTag <value:uint32_t>
  *    | CryptoKeyTag <wrappedKeyLength:uint32_t> <factor:byte{wrappedKeyLength}>
+ *    | DOMPoint
+ *    | DOMRect
+ *    | DOMMatrix
+ *    | DOMQuad
  *
  * Inside wrapped crypto key, data is serialized in this format:
  *
@@ -395,6 +410,35 @@
  *
  * CryptoKeyRaw :-
  *    CryptoAlgorithmIdentifierTag <keySize:uint32_t> <keyData:byte{keySize}>
+ *
+ * DOMPoint :-
+ *        DOMPointReadOnlyTag DOMPointData
+ *      | DOMPointTag DOMPointData
+ *
+ * DOMPointData :-
+ *      <x:double> <y:double> <z:double> <w:double>
+ *
+ * DOMRect :-
+ *        DOMRectReadOnlyTag DOMRectData
+ *      | DOMRectTag DOMRectData
+ *
+ * DOMRectData :-
+ *      <x:double> <y:double> <width:double> <height:double>
+ *
+ * DOMMatrix :-
+ *        DOMMatrixReadOnlyTag DOMMatrixData
+ *      | DOMMatrixTag DOMMatrixData
+ *
+ * DOMMatrixData :-
+ *        <is2D:uint8_t:true> <m11:double> <m12:double> <m21:double> <m22:double> <m41:double> <m42:double>
+ *      | <is2D:uint8_t:false> <m11:double> <m12:double> <m13:double> <m14:double> <m21:double> <m22:double> <m23:double> <m24:double> <m31:double> <m32:double> <m33:double> <m34:double> <m41:double> <m42:double> <m43:double> <m44:double>
+ *
+ * DOMQuad :-
+ *      DOMQuadTag DOMQuadData
+ *
+ * DOMQuadData :-
+ *      <p1:DOMPointData> <p2:DOMPointData> <p3:DOMPointData> <p4:DOMPointData>
+ *
  */
 
 using DeserializationResult = std::pair<JSC::JSValue, SerializationReturnCode>;
@@ -772,6 +816,89 @@
         return dumpIfTerminal(bufferObj, code);
     }
 
+    void dumpDOMPoint(const DOMPointReadOnly& point)
+    {
+        write(point.x());
+        write(point.y());
+        write(point.z());
+        write(point.w());
+    }
+
+    void dumpDOMPoint(JSObject* obj)
+    {
+        VM& vm = m_exec->vm();
+        if (obj->inherits(vm, JSDOMPoint::info()))
+            write(DOMPointTag);
+        else
+            write(DOMPointReadOnlyTag);
+
+        dumpDOMPoint(jsCast<JSDOMPointReadOnly*>(obj)->wrapped());
+    }
+
+    void dumpDOMRect(JSObject* obj)
+    {
+        VM& vm = m_exec->vm();
+        if (obj->inherits(vm, JSDOMRect::info()))
+            write(DOMRectTag);
+        else
+            write(DOMRectReadOnlyTag);
+
+        auto& rect = jsCast<JSDOMRectReadOnly*>(obj)->wrapped();
+        write(rect.x());
+        write(rect.y());
+        write(rect.width());
+        write(rect.height());
+    }
+
+    void dumpDOMMatrix(JSObject* obj)
+    {
+        VM& vm = m_exec->vm();
+        if (obj->inherits(vm, JSDOMMatrix::info()))
+            write(DOMMatrixTag);
+        else
+            write(DOMMatrixReadOnlyTag);
+
+        auto& matrix = jsCast<JSDOMMatrixReadOnly*>(obj)->wrapped();
+        bool is2D = matrix.is2D();
+        write(static_cast<uint8_t>(is2D));
+        if (is2D) {
+            write(matrix.m11());
+            write(matrix.m12());
+            write(matrix.m21());
+            write(matrix.m22());
+            write(matrix.m41());
+            write(matrix.m42());
+        } else {
+            write(matrix.m11());
+            write(matrix.m12());
+            write(matrix.m13());
+            write(matrix.m14());
+            write(matrix.m21());
+            write(matrix.m22());
+            write(matrix.m23());
+            write(matrix.m24());
+            write(matrix.m31());
+            write(matrix.m32());
+            write(matrix.m33());
+            write(matrix.m34());
+            write(matrix.m41());
+            write(matrix.m42());
+            write(matrix.m43());
+            write(matrix.m44());
+        }
+    }
+
+    void dumpDOMQuad(JSObject* obj)
+    {
+        write(DOMQuadTag);
+
+        auto& quad = jsCast<JSDOMQuad*>(obj)->wrapped();
+        dumpDOMPoint(quad.p1());
+        dumpDOMPoint(quad.p2());
+        dumpDOMPoint(quad.p3());
+        dumpDOMPoint(quad.p4());
+    }
+
     bool dumpIfTerminal(JSValue value, SerializationReturnCode& code)
     {
         if (!value.isCell()) {
@@ -953,7 +1080,22 @@
                 return true;
             }
 #endif
-
+            if (obj->inherits(vm, JSDOMPointReadOnly::info())) {
+                dumpDOMPoint(obj);
+                return true;
+            }
+            if (obj->inherits(vm, JSDOMRectReadOnly::info())) {
+                dumpDOMRect(obj);
+                return true;
+            }
+            if (obj->inherits(vm, JSDOMMatrixReadOnly::info())) {
+                dumpDOMMatrix(obj);
+                return true;
+            }
+            if (obj->inherits(vm, JSDOMQuad::info())) {
+                dumpDOMQuad(obj);
+                return true;
+            }
             return false;
         }
         // Any other types are expected to serialize as null.
@@ -2330,9 +2472,164 @@
     template<class T>
     JSValue getJSValue(T& nativeObj)
     {
-        return getJSValue(&nativeObj);
+        return toJS(m_exec, jsCast<JSDOMGlobalObject*>(m_globalObject), nativeObj);
     }
 
+    template<class T>
+    JSValue readDOMPoint()
+    {
+        double x;
+        if (!read(x))
+            return { };
+        double y;
+        if (!read(y))
+            return { };
+        double z;
+        if (!read(z))
+            return { };
+        double w;
+        if (!read(w))
+            return { };
+
+        return toJSNewlyCreated(m_exec, jsCast<JSDOMGlobalObject*>(m_globalObject), T::create(x, y, z, w));
+    }
+
+    template<class T>
+    JSValue readDOMMatrix()
+    {
+        uint8_t is2D;
+        if (!read(is2D))
+            return { };
+
+        if (is2D) {
+            double m11;
+            if (!read(m11))
+                return { };
+            double m12;
+            if (!read(m12))
+                return { };
+            double m21;
+            if (!read(m21))
+                return { };
+            double m22;
+            if (!read(m22))
+                return { };
+            double m41;
+            if (!read(m41))
+                return { };
+            double m42;
+            if (!read(m42))
+                return { };
+
+            TransformationMatrix matrix(m11, m12, m21, m22, m41, m42);
+            return toJSNewlyCreated(m_exec, jsCast<JSDOMGlobalObject*>(m_globalObject), T::create(WTFMove(matrix), DOMMatrixReadOnly::Is2D::Yes));
+        } else {
+            double m11;
+            if (!read(m11))
+                return { };
+            double m12;
+            if (!read(m12))
+                return { };
+            double m13;
+            if (!read(m13))
+                return { };
+            double m14;
+            if (!read(m14))
+                return { };
+            double m21;
+            if (!read(m21))
+                return { };
+            double m22;
+            if (!read(m22))
+                return { };
+            double m23;
+            if (!read(m23))
+                return { };
+            double m24;
+            if (!read(m24))
+                return { };
+            double m31;
+            if (!read(m31))
+                return { };
+            double m32;
+            if (!read(m32))
+                return { };
+            double m33;
+            if (!read(m33))
+                return { };
+            double m34;
+            if (!read(m34))
+                return { };
+            double m41;
+            if (!read(m41))
+                return { };
+            double m42;
+            if (!read(m42))
+                return { };
+            double m43;
+            if (!read(m43))
+                return { };
+            double m44;
+            if (!read(m44))
+                return { };
+
+            TransformationMatrix matrix(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33, m34, m41, m42, m43, m44);
+            return toJSNewlyCreated(m_exec, jsCast<JSDOMGlobalObject*>(m_globalObject), T::create(WTFMove(matrix), DOMMatrixReadOnly::Is2D::No));
+        }
+    }
+
+    template<class T>
+    JSValue readDOMRect()
+    {
+        double x;
+        if (!read(x))
+            return { };
+        double y;
+        if (!read(y))
+            return { };
+        double width;
+        if (!read(width))
+            return { };
+        double height;
+        if (!read(height))
+            return { };
+
+        return toJSNewlyCreated(m_exec, jsCast<JSDOMGlobalObject*>(m_globalObject), T::create(x, y, width, height));
+    }
+
+    std::optional<DOMPointInit> readDOMPointInit()
+    {
+        DOMPointInit point;
+        if (!read(point.x))
+            return std::nullopt;
+        if (!read(point.y))
+            return std::nullopt;
+        if (!read(point.z))
+            return std::nullopt;
+        if (!read(point.w))
+            return std::nullopt;
+
+        return WTFMove(point);
+    }
+
+    JSValue readDOMQuad()
+    {
+        auto p1 = readDOMPointInit();
+        if (!p1)
+            return JSValue();
+        auto p2 = readDOMPointInit();
+        if (!p2)
+            return JSValue();
+        auto p3 = readDOMPointInit();
+        if (!p3)
+            return JSValue();
+        auto p4 = readDOMPointInit();
+        if (!p4)
+            return JSValue();
+
+        return toJSNewlyCreated(m_exec, jsCast<JSDOMGlobalObject*>(m_globalObject), DOMQuad::create(p1.value(), p2.value(), p3.value(), p4.value()));
+    }
+
     JSValue readTerminal()
     {
         SerializationTag tag = readTag();
@@ -2607,6 +2904,20 @@
             return cryptoKey;
         }
 #endif
+        case DOMPointReadOnlyTag:
+            return readDOMPoint<DOMPointReadOnly>();
+        case DOMPointTag:
+            return readDOMPoint<DOMPoint>();
+        case DOMRectReadOnlyTag:
+            return readDOMRect<DOMRectReadOnly>();
+        case DOMRectTag:
+            return readDOMRect<DOMRect>();
+        case DOMMatrixReadOnlyTag:
+            return readDOMMatrix<DOMMatrixReadOnly>();
+        case DOMMatrixTag:
+            return readDOMMatrix<DOMMatrix>();
+        case DOMQuadTag:
+            return readDOMQuad();
         default:
             m_ptr--; // Push the tag back
             return JSValue();

Modified: trunk/Source/WebCore/css/DOMMatrix.cpp (218643 => 218644)


--- trunk/Source/WebCore/css/DOMMatrix.cpp	2017-06-21 19:49:11 UTC (rev 218643)
+++ trunk/Source/WebCore/css/DOMMatrix.cpp	2017-06-21 20:05:59 UTC (rev 218644)
@@ -37,6 +37,11 @@
 {
 }
 
+DOMMatrix::DOMMatrix(TransformationMatrix&& matrix, Is2D is2D)
+    : DOMMatrixReadOnly(WTFMove(matrix), is2D)
+{
+}
+
 // https://drafts.fxtf.org/geometry/#create-a-dommatrix-from-the-dictionary
 ExceptionOr<Ref<DOMMatrix>> DOMMatrix::fromMatrix(DOMMatrixInit&& init)
 {

Modified: trunk/Source/WebCore/css/DOMMatrix.h (218643 => 218644)


--- trunk/Source/WebCore/css/DOMMatrix.h	2017-06-21 19:49:11 UTC (rev 218643)
+++ trunk/Source/WebCore/css/DOMMatrix.h	2017-06-21 20:05:59 UTC (rev 218644)
@@ -50,6 +50,11 @@
         return adoptRef(*new DOMMatrix(matrix, is2D));
     }
 
+    static Ref<DOMMatrix> create(TransformationMatrix&& matrix, Is2D is2D)
+    {
+        return adoptRef(*new DOMMatrix(WTFMove(matrix), is2D));
+    }
+
     static ExceptionOr<Ref<DOMMatrix>> fromMatrix(DOMMatrixInit&&);
 
     static ExceptionOr<Ref<DOMMatrix>> fromFloat32Array(Ref<Float32Array>&&);
@@ -95,6 +100,7 @@
 private:
     DOMMatrix() = default;
     DOMMatrix(const TransformationMatrix&, Is2D);
+    DOMMatrix(TransformationMatrix&&, Is2D);
 };
 
 inline void DOMMatrix::setM13(double f)

Modified: trunk/Source/WebCore/css/DOMMatrixReadOnly.cpp (218643 => 218644)


--- trunk/Source/WebCore/css/DOMMatrixReadOnly.cpp	2017-06-21 19:49:11 UTC (rev 218643)
+++ trunk/Source/WebCore/css/DOMMatrixReadOnly.cpp	2017-06-21 20:05:59 UTC (rev 218644)
@@ -47,6 +47,13 @@
     ASSERT(!m_is2D || m_matrix.isAffine());
 }
 
+DOMMatrixReadOnly::DOMMatrixReadOnly(TransformationMatrix&& matrix, Is2D is2D)
+    : m_matrix(WTFMove(matrix))
+    , m_is2D(is2D == Is2D::Yes)
+{
+    ASSERT(!m_is2D || m_matrix.isAffine());
+}
+
 inline Ref<DOMMatrix> DOMMatrixReadOnly::cloneAsDOMMatrix() const
 {
     return DOMMatrix::create(m_matrix, m_is2D ? Is2D::Yes : Is2D::No);

Modified: trunk/Source/WebCore/css/DOMMatrixReadOnly.h (218643 => 218644)


--- trunk/Source/WebCore/css/DOMMatrixReadOnly.h	2017-06-21 19:49:11 UTC (rev 218643)
+++ trunk/Source/WebCore/css/DOMMatrixReadOnly.h	2017-06-21 20:05:59 UTC (rev 218644)
@@ -65,6 +65,11 @@
         return adoptRef(*new DOMMatrixReadOnly(matrix, is2D));
     }
 
+    static Ref<DOMMatrixReadOnly> create(TransformationMatrix&& matrix, Is2D is2D)
+    {
+        return adoptRef(*new DOMMatrixReadOnly(WTFMove(matrix), is2D));
+    }
+
     static ExceptionOr<Ref<DOMMatrixReadOnly>> fromMatrix(DOMMatrixInit&&);
 
     static ExceptionOr<Ref<DOMMatrixReadOnly>> fromFloat32Array(Ref<Float32Array>&&);
@@ -125,6 +130,7 @@
 protected:
     DOMMatrixReadOnly() = default;
     DOMMatrixReadOnly(const TransformationMatrix&, Is2D);
+    DOMMatrixReadOnly(TransformationMatrix&&, Is2D);
 
     Ref<DOMMatrix> cloneAsDOMMatrix() const;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to