Diff
Modified: trunk/LayoutTests/ChangeLog (217762 => 217763)
--- trunk/LayoutTests/ChangeLog 2017-06-03 18:07:17 UTC (rev 217762)
+++ trunk/LayoutTests/ChangeLog 2017-06-03 21:09:00 UTC (rev 217763)
@@ -1,3 +1,15 @@
+2017-06-03 Simon Fraser <simon.fra...@apple.com>
+
+ Implement DOMPointReadOnly.matrixTransform()
+ https://bugs.webkit.org/show_bug.cgi?id=172896
+
+ Reviewed by Chris Dumez.
+
+ DOMPoint-003.html should be upstreamed at some point.
+
+ * http/wpt/geometry/DOMPoint-003-expected.txt: Added.
+ * http/wpt/geometry/DOMPoint-003.html: Added.
+
2017-06-03 Jonathan Bedard <jbed...@apple.com>
Unreviewed test gardening
Added: trunk/LayoutTests/http/wpt/geometry/DOMPoint-003-expected.txt (0 => 217763)
--- trunk/LayoutTests/http/wpt/geometry/DOMPoint-003-expected.txt (rev 0)
+++ trunk/LayoutTests/http/wpt/geometry/DOMPoint-003-expected.txt 2017-06-03 21:09:00 UTC (rev 217763)
@@ -0,0 +1,6 @@
+Test DOMPoint and DOMPointReadOnly interfaces
+
+
+PASS test DOMPoint matrixTransform with 3d matrix
+PASS test DOMPoint matrixTransform with perspective point
+
Added: trunk/LayoutTests/http/wpt/geometry/DOMPoint-003.html (0 => 217763)
--- trunk/LayoutTests/http/wpt/geometry/DOMPoint-003.html (rev 0)
+++ trunk/LayoutTests/http/wpt/geometry/DOMPoint-003.html 2017-06-03 21:09:00 UTC (rev 217763)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html><head>
+ <title>Geometry Interfaces: DOMPointReadOnly.matrixTransform</title>
+ <link href="" rel="author" title="Simon Fraser">
+ <link href="" rel="help">
+ <script src=""
+ <script src=""
+</head>
+<body>
+ <p>Test DOMPoint and DOMPointReadOnly interfaces</p>
+ <div id="log"></div>
+ <script>
+ function getMatrixTransform(matrix, point) {
+ var x = point.x * matrix.m11 + point.y * matrix.m21 + point.z * matrix.m31 + point.w * matrix.m41;
+ var y = point.x * matrix.m12 + point.y * matrix.m22 + point.z * matrix.m32 + point.w * matrix.m42;
+ var z = point.x * matrix.m13 + point.y * matrix.m23 + point.z * matrix.m33 + point.w * matrix.m43;
+ var w = point.x * matrix.m14 + point.y * matrix.m24 + point.z * matrix.m34 + point.w * matrix.m44;
+ return new DOMPoint(x, y, z, w)
+ }
+ test(function() {
+ var point = new DOMPoint(5, 4);
+ var matrix = new DOMMatrix();
+ matrix.setMatrixValue('perspective(400px) translate3d(123px, 456px, 120px)');
+ var result = point.matrixTransform(matrix);
+ var expected = getMatrixTransform(matrix, point);
+ checkDOMPoint(result, expected);
+ },'test DOMPoint matrixTransform with 3d matrix');
+
+ test(function() {
+ var point = DOMPointReadOnly.fromPoint({x:1, y:2, z:3, w:0.00234});
+ var matrix = new DOMMatrix();
+ matrix.setMatrixValue('perspective(400px) translate3d(123px, 456px, 120px)');
+ var result = point.matrixTransform(matrix);
+ var expected = getMatrixTransform(matrix, point);
+ checkDOMPoint(result, expected);
+ },'test DOMPoint matrixTransform with perspective point');
+
+ function checkDOMPoint(p, exp) {
+ assert_equals(p.x, exp.x, "x is not matched");
+ assert_equals(p.y, exp.y, "y is not matched");
+ assert_equals(p.z, exp.z, "z is not matched");
+ assert_equals(p.w, exp.w, "w is not matched");
+ }
+ </script>
+</body></html>
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (217762 => 217763)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2017-06-03 18:07:17 UTC (rev 217762)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2017-06-03 21:09:00 UTC (rev 217763)
@@ -1,3 +1,15 @@
+2017-06-03 Simon Fraser <simon.fra...@apple.com>
+
+ Implement DOMPointReadOnly.matrixTransform()
+ https://bugs.webkit.org/show_bug.cgi?id=172896
+
+ Reviewed by Chris Dumez.
+
+ New baselines.
+
+ * web-platform-tests/css/geometry-1/DOMPoint-002-expected.txt:
+ * web-platform-tests/css/geometry-1/historical-expected.txt:
+
2017-06-03 Yusuke Suzuki <utatane....@gmail.com>
Script modules should be able to import data urls
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/geometry-1/DOMPoint-002-expected.txt (217762 => 217763)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/geometry-1/DOMPoint-002-expected.txt 2017-06-03 18:07:17 UTC (rev 217762)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/geometry-1/DOMPoint-002-expected.txt 2017-06-03 21:09:00 UTC (rev 217763)
@@ -18,7 +18,7 @@
PASS test DOMPoint fromPoint with x, y, z, w, v
PASS test DOMPoint fromPoint with x, z
PASS test DOMPoint fromPoint with undefined value
-FAIL test DOMPoint matrixTransform point.matrixTransform is not a function. (In 'point.matrixTransform(matrix)', 'point.matrixTransform' is undefined)
+PASS test DOMPoint matrixTransform
PASS test DOMPoint Attributes undefined
PASS test DOMPoint Attributes NaN Infinity
PASS test DOMPointReadOnly Constructor no args
@@ -38,6 +38,6 @@
PASS test DOMPointReadOnly fromPoint with x, y, z, w, v
PASS test DOMPointReadOnly fromPoint with x, z
PASS test DOMPointReadOnly fromPoint with undefined value
-FAIL test DOMPointReadOnly matrixTransform point.matrixTransform is not a function. (In 'point.matrixTransform(matrix)', 'point.matrixTransform' is undefined)
+PASS test DOMPointReadOnly matrixTransform
PASS test DOMPointReadOnly Attributes undefined
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/geometry-1/historical-expected.txt (217762 => 217763)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/geometry-1/historical-expected.txt 2017-06-03 18:07:17 UTC (rev 217762)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/geometry-1/historical-expected.txt 2017-06-03 21:09:00 UTC (rev 217763)
@@ -28,7 +28,7 @@
PASS DOMMatrix rotateAxisAngleSelf number of required arguments
PASS DOMMatrix skewXSelf number of required arguments
PASS DOMMatrix skewYSelf number of required arguments
-FAIL DOMPointReadOnly matrixTransform number of required arguments undefined is not an object (evaluating 'self[interf].prototype[member].length')
+PASS DOMPointReadOnly matrixTransform number of required arguments
PASS DOMMatrixReadOnly multiply number of required arguments
PASS DOMMatrix multiplySelf number of required arguments
PASS DOMMatrix preMultiplySelf number of required arguments
Modified: trunk/Source/WebCore/CMakeLists.txt (217762 => 217763)
--- trunk/Source/WebCore/CMakeLists.txt 2017-06-03 18:07:17 UTC (rev 217762)
+++ trunk/Source/WebCore/CMakeLists.txt 2017-06-03 21:09:00 UTC (rev 217763)
@@ -1458,6 +1458,7 @@
dom/DOMError.cpp
dom/DOMImplementation.cpp
dom/DOMNamedFlowCollection.cpp
+ dom/DOMPointReadOnly.cpp
dom/DOMRectList.cpp
dom/DOMStringList.cpp
dom/DataTransfer.cpp
Modified: trunk/Source/WebCore/ChangeLog (217762 => 217763)
--- trunk/Source/WebCore/ChangeLog 2017-06-03 18:07:17 UTC (rev 217762)
+++ trunk/Source/WebCore/ChangeLog 2017-06-03 21:09:00 UTC (rev 217763)
@@ -1,3 +1,27 @@
+2017-06-03 Simon Fraser <simon.fra...@apple.com>
+
+ Implement DOMPointReadOnly.matrixTransform()
+ https://bugs.webkit.org/show_bug.cgi?id=172896
+
+ Reviewed by Chris Dumez.
+
+ DOMPointReadOnly.matrixTransform() creates the matrix or throws, then uses
+ a new function in TransformationMatrix to map x,y,z,w through the matrix.
+
+ Test: http/wpt/geometry/DOMPoint-003.html
+
+ * CMakeLists.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * css/DOMMatrixReadOnly.h:
+ (WebCore::DOMMatrixReadOnly::transformationMatrix):
+ * dom/DOMPointReadOnly.cpp: Copied from Source/WebCore/dom/DOMPointReadOnly.idl.
+ (WebCore::DOMPointReadOnly::matrixTransform):
+ * dom/DOMPointReadOnly.h:
+ * dom/DOMPointReadOnly.idl:
+ * platform/graphics/transforms/TransformationMatrix.cpp:
+ (WebCore::TransformationMatrix::map4ComponentPoint):
+ * platform/graphics/transforms/TransformationMatrix.h:
+
2017-06-03 Myles C. Maxfield <mmaxfi...@apple.com>
Cleanup arguments to preparePlatformFont() and fontWithFamily() in FontCacheCoreText.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (217762 => 217763)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-06-03 18:07:17 UTC (rev 217762)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-06-03 21:09:00 UTC (rev 217763)
@@ -562,6 +562,7 @@
0FF5026A102BA9430066F39A /* JSStyleMedia.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FF50268102BA9430066F39A /* JSStyleMedia.h */; };
0FF50271102BA96A0066F39A /* StyleMedia.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FF5026E102BA9660066F39A /* StyleMedia.cpp */; };
0FF50272102BA96A0066F39A /* StyleMedia.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FF5026F102BA96A0066F39A /* StyleMedia.h */; };
+ 0FF835B81EE3274F008B4CC7 /* DOMPointReadOnly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FF835B71EE3274F008B4CC7 /* DOMPointReadOnly.cpp */; };
0FFD4D6018651FA300512F6E /* AsyncScrollingCoordinator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FFD4D5E18651FA300512F6E /* AsyncScrollingCoordinator.cpp */; };
0FFD4D6118651FA300512F6E /* AsyncScrollingCoordinator.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FFD4D5F18651FA300512F6E /* AsyncScrollingCoordinator.h */; settings = {ATTRIBUTES = (Private, ); }; };
10FB084B14E15C7E00A3DB98 /* PublicURLManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 10FB084A14E15C7E00A3DB98 /* PublicURLManager.h */; };
@@ -7999,6 +8000,7 @@
0FF5026E102BA9660066F39A /* StyleMedia.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleMedia.cpp; sourceTree = "<group>"; };
0FF5026F102BA96A0066F39A /* StyleMedia.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleMedia.h; sourceTree = "<group>"; };
0FF50270102BA96A0066F39A /* StyleMedia.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = StyleMedia.idl; sourceTree = "<group>"; };
+ 0FF835B71EE3274F008B4CC7 /* DOMPointReadOnly.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DOMPointReadOnly.cpp; sourceTree = "<group>"; };
0FFD4D5E18651FA300512F6E /* AsyncScrollingCoordinator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AsyncScrollingCoordinator.cpp; sourceTree = "<group>"; };
0FFD4D5F18651FA300512F6E /* AsyncScrollingCoordinator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncScrollingCoordinator.h; sourceTree = "<group>"; };
10FB084A14E15C7E00A3DB98 /* PublicURLManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PublicURLManager.h; sourceTree = "<group>"; };
@@ -25716,6 +25718,7 @@
0F49669A1DB408C100A274BB /* DOMPoint.idl */,
0F4966A21DB4091000A274BB /* DOMPointInit.h */,
0F4966A11DB4090100A274BB /* DOMPointInit.idl */,
+ 0FF835B71EE3274F008B4CC7 /* DOMPointReadOnly.cpp */,
0F49669B1DB408C100A274BB /* DOMPointReadOnly.h */,
0F49669C1DB408C100A274BB /* DOMPointReadOnly.idl */,
0F4710A91DB56AFC002DCEC3 /* DOMRect.h */,
@@ -31209,6 +31212,7 @@
2D5002F81B56D7810020AAF7 /* DOMPath.cpp in Sources */,
A9C6E4EB0D745E2B006442E9 /* DOMPlugin.cpp in Sources */,
A9C6E4EF0D745E38006442E9 /* DOMPluginArray.cpp in Sources */,
+ 0FF835B81EE3274F008B4CC7 /* DOMPointReadOnly.cpp in Sources */,
468344DF1EDDFAAA00B7795B /* DOMRectList.cpp in Sources */,
BC5A86840C33676000EEA649 /* DOMSelection.cpp in Sources */,
C55610F111A704EB00B82D27 /* DOMStringList.cpp in Sources */,
Modified: trunk/Source/WebCore/css/DOMMatrixReadOnly.h (217762 => 217763)
--- trunk/Source/WebCore/css/DOMMatrixReadOnly.h 2017-06-03 18:07:17 UTC (rev 217762)
+++ trunk/Source/WebCore/css/DOMMatrixReadOnly.h 2017-06-03 21:09:00 UTC (rev 217763)
@@ -108,6 +108,8 @@
ExceptionOr<String> toString() const;
+ const TransformationMatrix& transformationMatrix() const { return m_matrix; }
+
protected:
DOMMatrixReadOnly() = default;
DOMMatrixReadOnly(const TransformationMatrix&, Is2D);
Copied: trunk/Source/WebCore/dom/DOMPointReadOnly.cpp (from rev 217762, trunk/Source/WebCore/dom/DOMPointReadOnly.idl) (0 => 217763)
--- trunk/Source/WebCore/dom/DOMPointReadOnly.cpp (rev 0)
+++ trunk/Source/WebCore/dom/DOMPointReadOnly.cpp 2017-06-03 21:09:00 UTC (rev 217763)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DOMPointReadOnly.h"
+
+#include "DOMMatrixReadOnly.h"
+#include "DOMPoint.h"
+
+namespace WebCore {
+
+ExceptionOr<Ref<DOMPoint>> DOMPointReadOnly::matrixTransform(DOMMatrixInit&& matrixInit) const
+{
+ auto matrixOrException = DOMMatrixReadOnly::fromMatrix(WTFMove(matrixInit));
+ if (matrixOrException.hasException())
+ return matrixOrException.releaseException();
+
+ auto matrix = matrixOrException.releaseReturnValue();
+
+ double x = this->x();
+ double y = this->y();
+ double z = this->z();
+ double w = this->w();
+ matrix->transformationMatrix().map4ComponentPoint(x, y, z, w);
+
+ return { DOMPoint::create(x, y, z, w) };
+}
+
+} // namespace WebCore
+
Modified: trunk/Source/WebCore/dom/DOMPointReadOnly.h (217762 => 217763)
--- trunk/Source/WebCore/dom/DOMPointReadOnly.h 2017-06-03 18:07:17 UTC (rev 217762)
+++ trunk/Source/WebCore/dom/DOMPointReadOnly.h 2017-06-03 21:09:00 UTC (rev 217763)
@@ -31,11 +31,15 @@
#pragma once
#include "DOMPointInit.h"
+#include "ExceptionOr.h"
#include "ScriptWrappable.h"
#include <wtf/RefCounted.h>
namespace WebCore {
+struct DOMMatrixInit;
+class DOMPoint;
+
class DOMPointReadOnly : public ScriptWrappable, public RefCounted<DOMPointReadOnly> {
WTF_MAKE_FAST_ALLOCATED;
public:
@@ -48,6 +52,8 @@
double z() const { return m_z; }
double w() const { return m_w; }
+ ExceptionOr<Ref<DOMPoint>> matrixTransform(DOMMatrixInit&&) const;
+
protected:
DOMPointReadOnly(double x, double y, double z, double w)
: m_x(x)
Modified: trunk/Source/WebCore/dom/DOMPointReadOnly.idl (217762 => 217763)
--- trunk/Source/WebCore/dom/DOMPointReadOnly.idl 2017-06-03 18:07:17 UTC (rev 217762)
+++ trunk/Source/WebCore/dom/DOMPointReadOnly.idl 2017-06-03 21:09:00 UTC (rev 217763)
@@ -44,8 +44,7 @@
readonly attribute unrestricted double z;
readonly attribute unrestricted double w;
- // FIXME: No support for DOMMatrix yet (webkit.org/b/110001)
- // DOMPoint matrixTransform(optional DOMMatrixInit matrix);
+ [MayThrowException] DOMPoint matrixTransform(optional DOMMatrixInit matrix);
serializer = { attribute };
};
Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp (217762 => 217763)
--- trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp 2017-06-03 18:07:17 UTC (rev 217762)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.cpp 2017-06-03 21:09:00 UTC (rev 217763)
@@ -44,13 +44,6 @@
namespace WebCore {
//
-// Supporting Math Functions
-//
-// This is a set of function from various places (attributed inline) to do things like
-// inversion and decomposition of a 4x4 matrix. They are used throughout the code
-//
-
-//
// Adapted from Matrix Inversion by Richard Carling, Graphics Gems <http://tog.acm.org/GraphicsGems/index.html>.
// EULA: The Graphics Gems code is copyright-protected. In other words, you cannot claim the text of the code
@@ -706,6 +699,25 @@
return LayoutRect(LayoutUnit::clamp(left), LayoutUnit::clamp(top), LayoutUnit::clamp(right - left), LayoutUnit::clamp(bottom - top));
}
+void TransformationMatrix::map4ComponentPoint(double& x, double& y, double& z, double& w) const
+{
+ if (isIdentityOrTranslation()) {
+ x += m_matrix[3][0];
+ y += m_matrix[3][1];
+ z += m_matrix[3][2];
+ return;
+ }
+
+ Vector4 input = { x, y, z, w };
+ Vector4 result;
+ v4MulPointByMatrix(input, m_matrix, result);
+
+ x = result[0];
+ y = result[1];
+ z = result[2];
+ w = result[3];
+}
+
FloatPoint TransformationMatrix::mapPoint(const FloatPoint& p) const
{
if (isIdentityOrTranslation())
Modified: trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h (217762 => 217763)
--- trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h 2017-06-03 18:07:17 UTC (rev 217762)
+++ trunk/Source/WebCore/platform/graphics/transforms/TransformationMatrix.h 2017-06-03 21:09:00 UTC (rev 217763)
@@ -23,8 +23,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef TransformationMatrix_h
-#define TransformationMatrix_h
+#pragma once
#include "FloatPoint.h"
#include "FloatPoint3D.h"
@@ -135,6 +134,7 @@
// This form preserves the double math from input to output.
void map(double x, double y, double& x2, double& y2) const { multVecMatrix(x, y, x2, y2); }
+ void map4ComponentPoint(double& x, double& y, double& z, double& w) const;
// Maps a 3D point through the transform, returning a 3D point.
FloatPoint3D mapPoint(const FloatPoint3D&) const;
@@ -427,5 +427,3 @@
WEBCORE_EXPORT TextStream& operator<<(TextStream&, const TransformationMatrix&);
} // namespace WebCore
-
-#endif // TransformationMatrix_h