haikuwebkit/Source/WebCore/css/DOMMatrix.cpp

255 lines
9.8 KiB
C++
Raw Permalink Normal View History

Implement DOMMatrix / DOMMatrixReadOnly https://bugs.webkit.org/show_bug.cgi?id=110001 Reviewed by Sam Weinig and Simon Fraser. LayoutTests/imported/w3c: Rebaseline web-platform-tests now that more checks are passing. * web-platform-tests/css/geometry-1/DOMMatrix-001-expected.txt: Most checks are now passing. The few remaining failures seem to be due to our parsing of the input CSS string now matching the specification. This behavior is not new to this patch as I re-used exactly the same logic as for WebKitCSSMatrix's parsing of the input string. * web-platform-tests/css/geometry-1/DOMMatrix-002-expected.txt: * web-platform-tests/css/geometry-1/DOMMatrix-003-expected.txt: * web-platform-tests/css/geometry-1/DOMMatrix-a-f-alias-expected.txt: All checks are now passing. * web-platform-tests/css/geometry-1/DOMMatrix-newobject-expected.txt: Most checks are now passing. The remaining failures are due to DOMMatrixReadOnly's transformPoint() / toFloat32Array() / toFloat64Array() not being implemented in this patch. I think we can take care of those in a follow-up. * web-platform-tests/css/geometry-1/DOMPoint-002-expected.txt: Fails differently now that we support DOMMatrix. The test goes further but still fails because DOMPoint.matrixTransform() is not implemented. * web-platform-tests/css/geometry-1/WebKitCSSMatrix-expected.txt: One more check is passing now that we implement DOMMatrix. The remaining failure is due to WebKitCSSMatrix not being an alias to DOMMatrix yet. I'd rather do this in a follow-up. * web-platform-tests/css/geometry-1/historical-expected.txt: A lot of new passes. * web-platform-tests/css/geometry-1/structured-serialization-expected.txt: The test fails differently now that we support DOMMatrix. The test still fails because we do not support yet the structured serialization of DOMMatrix objects. It appears we do not support this for other types in this spec either (e.g. DOMPoint). I filed: https://bugs.webkit.org/show_bug.cgi?id=172191 * web-platform-tests/css/geometry-1/DOMMatrix-stringifier-expected.txt: Added. * web-platform-tests/css/geometry-1/DOMMatrix-stringifier.html: Added. Import new test from upstream. The WebKitCSSMatrix failures are due to our WebKitCSSMatrix implementation not complying with the standard. As per the standard, WebKitCSSMatrix is supposed to become an alias to DOMMatrix. If we do this aliasing (in a follow-up), then those tests will start passing. * web-platform-tests/css/geometry-1/support/dommatrix-test-util.js: Added. Add missing script that was missed by the importer when I initially imported the test suite from upstream. Source/WebCore: Implement DOMMatrix / DOMMatrixReadOnly as per: - https://drafts.fxtf.org/geometry/#DOMMatrix For now, these new types co-exist with WebKitCSSMatrix / SVGMatrix. However, in the future, WebKitCSSMatrix / SVGMatrix are supposed to become aliases to DOMMatrix. Most of it has been implemented. What remaining to be implemented is: - Make WebKitCSSMatrix / SVGMatrix aliases to DOMMatrix - DOMMatrix.fromFloat32Array() / fromFloat64Array() - DOMMatrixReadOnly.fromFloat32Array() / fromFloat64Array() / toFloat32Array() / toFloat64Array() - DOMMatrixReadOnly.transformPoint(). Tests: imported/w3c/web-platform-tests/css/geometry-1/* * CMakeLists.txt: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: * bindings/scripts/test/JS/JSTestObj.cpp: Fix a bug in the bindings generator causing the generator code for "Constructor(optional (DOMString or sequence<unrestricted double>) init)" to be wrong and not build. * css/DOMMatrix.cpp: Added. (WebCore::DOMMatrix::DOMMatrix): (WebCore::DOMMatrix::fromMatrix): (WebCore::DOMMatrix::multiplySelf): (WebCore::DOMMatrix::preMultiplySelf): (WebCore::DOMMatrix::translateSelf): (WebCore::DOMMatrix::scaleSelf): (WebCore::DOMMatrix::scale3dSelf): (WebCore::DOMMatrix::rotateSelf): (WebCore::DOMMatrix::rotateFromVectorSelf): (WebCore::DOMMatrix::rotateAxisAngleSelf): (WebCore::DOMMatrix::skewXSelf): (WebCore::DOMMatrix::skewYSelf): (WebCore::DOMMatrix::invertSelf): (WebCore::DOMMatrix::setMatrixValueForBindings): * css/DOMMatrix.h: Added. (WebCore::DOMMatrix::create): (WebCore::DOMMatrix::setA): (WebCore::DOMMatrix::setB): (WebCore::DOMMatrix::setC): (WebCore::DOMMatrix::setD): (WebCore::DOMMatrix::setE): (WebCore::DOMMatrix::setF): (WebCore::DOMMatrix::setM11): (WebCore::DOMMatrix::setM12): (WebCore::DOMMatrix::setM13): (WebCore::DOMMatrix::setM14): (WebCore::DOMMatrix::setM21): (WebCore::DOMMatrix::setM22): (WebCore::DOMMatrix::setM23): (WebCore::DOMMatrix::setM24): (WebCore::DOMMatrix::setM31): (WebCore::DOMMatrix::setM32): (WebCore::DOMMatrix::setM33): (WebCore::DOMMatrix::setM34): (WebCore::DOMMatrix::setM41): (WebCore::DOMMatrix::setM42): (WebCore::DOMMatrix::setM43): (WebCore::DOMMatrix::setM44): * css/DOMMatrix.idl: Added. * css/DOMMatrixInit.h: Added. * css/DOMMatrixInit.idl: Added. * css/DOMMatrixReadOnly.cpp: Added. (WebCore::DOMMatrixReadOnly::DOMMatrixReadOnly): (WebCore::DOMMatrixReadOnly::validateAndFixup): (WebCore::DOMMatrixReadOnly::fromMatrix): (WebCore::DOMMatrixReadOnly::isIdentity): (WebCore::DOMMatrixReadOnly::setMatrixValue): (WebCore::DOMMatrixReadOnly::translate): (WebCore::DOMMatrixReadOnly::flipX): (WebCore::DOMMatrixReadOnly::flipY): (WebCore::DOMMatrixReadOnly::multiply): (WebCore::DOMMatrixReadOnly::scale): (WebCore::DOMMatrixReadOnly::scale3d): (WebCore::DOMMatrixReadOnly::rotate): (WebCore::DOMMatrixReadOnly::rotateFromVector): (WebCore::DOMMatrixReadOnly::rotateAxisAngle): (WebCore::DOMMatrixReadOnly::skewX): (WebCore::DOMMatrixReadOnly::skewY): (WebCore::DOMMatrixReadOnly::inverse): (WebCore::DOMMatrixReadOnly::toString): * css/DOMMatrixReadOnly.h: Added. (WebCore::DOMMatrixReadOnly::create): (WebCore::DOMMatrixReadOnly::a): (WebCore::DOMMatrixReadOnly::b): (WebCore::DOMMatrixReadOnly::c): (WebCore::DOMMatrixReadOnly::d): (WebCore::DOMMatrixReadOnly::e): (WebCore::DOMMatrixReadOnly::f): (WebCore::DOMMatrixReadOnly::m11): (WebCore::DOMMatrixReadOnly::m12): (WebCore::DOMMatrixReadOnly::m13): (WebCore::DOMMatrixReadOnly::m14): (WebCore::DOMMatrixReadOnly::m21): (WebCore::DOMMatrixReadOnly::m22): (WebCore::DOMMatrixReadOnly::m23): (WebCore::DOMMatrixReadOnly::m24): (WebCore::DOMMatrixReadOnly::m31): (WebCore::DOMMatrixReadOnly::m32): (WebCore::DOMMatrixReadOnly::m33): (WebCore::DOMMatrixReadOnly::m34): (WebCore::DOMMatrixReadOnly::m41): (WebCore::DOMMatrixReadOnly::m42): (WebCore::DOMMatrixReadOnly::m43): (WebCore::DOMMatrixReadOnly::m44): (WebCore::DOMMatrixReadOnly::is2D): (WebCore::DOMMatrixReadOnly::fromMatrixHelper): * css/DOMMatrixReadOnly.idl: Added. * css/WebKitCSSMatrix.h: * css/WebKitCSSMatrix.idl: * svg/SVGMatrix.h: * svg/SVGMatrix.idl: LayoutTests: Drop test I previously added now that a better version landed in web-platform-tests and was re-imported in this patch. * fast/css/matrix-stringifier-expected.txt: Removed. * fast/css/matrix-stringifier.html: Removed. Canonical link: https://commits.webkit.org/189124@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-16 23:45:13 +00:00
/*
* 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 APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 "DOMMatrix.h"
DOMMatrix and DOMMatrixReadOnly should be available in workers https://bugs.webkit.org/show_bug.cgi?id=176255 Reviewed by Simon Fraser. LayoutTests/imported/w3c: * web-platform-tests/css/geometry-1/DOMMatrix-css-string.worker-expected.txt: * web-platform-tests/css/geometry-1/interfaces.worker-expected.txt: Update test results. Source/WebCore: * WebCore.xcodeproj/project.pbxproj: Add GlobalPerformance.idl to the project. It was missing. * bindings/scripts/CodeGeneratorJS.pm: (IsAlwaysExposedOnInterface): (NeedsRuntimeCheck): (GenerateRuntimeEnableConditionalStringForExposed): (GenerateRuntimeEnableConditionalString): Adds support for [Exposed] extended attributes on operations, attributes and constants. This allows an interface that is exposed to both windows and workers (with [Exposed=(Window,Worker)]), to indicate that a specific property should only be be exposed somewhere, e.g only the window. This is need by DOMMatrixReadOnly's stringifier, which is only exposed in the window environment. * bindings/scripts/IDLParser.pm: (parseExtendedAttributeRest2): Fix bug where array extended attributes, like those found in Exposed expressions where being converter to scalars. * bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp: * bindings/scripts/test/JS/JSTestGlobalObject.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/TestObj.idl: Add tests and update results. Some results are just improved includes. * css/DOMMatrix.cpp: * css/DOMMatrix.h: * css/DOMMatrix.idl: * css/DOMMatrixReadOnly.cpp: * css/DOMMatrixReadOnly.h: * css/DOMMatrixReadOnly.idl: Expose DOMMatrix and DOMMatrixReadOnly to workers and update the constructors to match the current spec, throwing if the argument is a string, and the context is not the window / document context. Also did some refactoring to avoid allocating the DOMMatrix or DOMMatrixReadOnly until after all the exceptional cases were handled. LayoutTests: * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: * platform/mac-wk1/js/dom/global-constructors-attributes-dedicated-worker-expected.txt * platform/wpe/js/dom/global-constructors-attributes-dedicated-worker-expected.txt Canonical link: https://commits.webkit.org/192912@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221512 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-09-02 01:38:07 +00:00
#include "ScriptExecutionContext.h"
Implement DOMMatrix / DOMMatrixReadOnly https://bugs.webkit.org/show_bug.cgi?id=110001 Reviewed by Sam Weinig and Simon Fraser. LayoutTests/imported/w3c: Rebaseline web-platform-tests now that more checks are passing. * web-platform-tests/css/geometry-1/DOMMatrix-001-expected.txt: Most checks are now passing. The few remaining failures seem to be due to our parsing of the input CSS string now matching the specification. This behavior is not new to this patch as I re-used exactly the same logic as for WebKitCSSMatrix's parsing of the input string. * web-platform-tests/css/geometry-1/DOMMatrix-002-expected.txt: * web-platform-tests/css/geometry-1/DOMMatrix-003-expected.txt: * web-platform-tests/css/geometry-1/DOMMatrix-a-f-alias-expected.txt: All checks are now passing. * web-platform-tests/css/geometry-1/DOMMatrix-newobject-expected.txt: Most checks are now passing. The remaining failures are due to DOMMatrixReadOnly's transformPoint() / toFloat32Array() / toFloat64Array() not being implemented in this patch. I think we can take care of those in a follow-up. * web-platform-tests/css/geometry-1/DOMPoint-002-expected.txt: Fails differently now that we support DOMMatrix. The test goes further but still fails because DOMPoint.matrixTransform() is not implemented. * web-platform-tests/css/geometry-1/WebKitCSSMatrix-expected.txt: One more check is passing now that we implement DOMMatrix. The remaining failure is due to WebKitCSSMatrix not being an alias to DOMMatrix yet. I'd rather do this in a follow-up. * web-platform-tests/css/geometry-1/historical-expected.txt: A lot of new passes. * web-platform-tests/css/geometry-1/structured-serialization-expected.txt: The test fails differently now that we support DOMMatrix. The test still fails because we do not support yet the structured serialization of DOMMatrix objects. It appears we do not support this for other types in this spec either (e.g. DOMPoint). I filed: https://bugs.webkit.org/show_bug.cgi?id=172191 * web-platform-tests/css/geometry-1/DOMMatrix-stringifier-expected.txt: Added. * web-platform-tests/css/geometry-1/DOMMatrix-stringifier.html: Added. Import new test from upstream. The WebKitCSSMatrix failures are due to our WebKitCSSMatrix implementation not complying with the standard. As per the standard, WebKitCSSMatrix is supposed to become an alias to DOMMatrix. If we do this aliasing (in a follow-up), then those tests will start passing. * web-platform-tests/css/geometry-1/support/dommatrix-test-util.js: Added. Add missing script that was missed by the importer when I initially imported the test suite from upstream. Source/WebCore: Implement DOMMatrix / DOMMatrixReadOnly as per: - https://drafts.fxtf.org/geometry/#DOMMatrix For now, these new types co-exist with WebKitCSSMatrix / SVGMatrix. However, in the future, WebKitCSSMatrix / SVGMatrix are supposed to become aliases to DOMMatrix. Most of it has been implemented. What remaining to be implemented is: - Make WebKitCSSMatrix / SVGMatrix aliases to DOMMatrix - DOMMatrix.fromFloat32Array() / fromFloat64Array() - DOMMatrixReadOnly.fromFloat32Array() / fromFloat64Array() / toFloat32Array() / toFloat64Array() - DOMMatrixReadOnly.transformPoint(). Tests: imported/w3c/web-platform-tests/css/geometry-1/* * CMakeLists.txt: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: * bindings/scripts/test/JS/JSTestObj.cpp: Fix a bug in the bindings generator causing the generator code for "Constructor(optional (DOMString or sequence<unrestricted double>) init)" to be wrong and not build. * css/DOMMatrix.cpp: Added. (WebCore::DOMMatrix::DOMMatrix): (WebCore::DOMMatrix::fromMatrix): (WebCore::DOMMatrix::multiplySelf): (WebCore::DOMMatrix::preMultiplySelf): (WebCore::DOMMatrix::translateSelf): (WebCore::DOMMatrix::scaleSelf): (WebCore::DOMMatrix::scale3dSelf): (WebCore::DOMMatrix::rotateSelf): (WebCore::DOMMatrix::rotateFromVectorSelf): (WebCore::DOMMatrix::rotateAxisAngleSelf): (WebCore::DOMMatrix::skewXSelf): (WebCore::DOMMatrix::skewYSelf): (WebCore::DOMMatrix::invertSelf): (WebCore::DOMMatrix::setMatrixValueForBindings): * css/DOMMatrix.h: Added. (WebCore::DOMMatrix::create): (WebCore::DOMMatrix::setA): (WebCore::DOMMatrix::setB): (WebCore::DOMMatrix::setC): (WebCore::DOMMatrix::setD): (WebCore::DOMMatrix::setE): (WebCore::DOMMatrix::setF): (WebCore::DOMMatrix::setM11): (WebCore::DOMMatrix::setM12): (WebCore::DOMMatrix::setM13): (WebCore::DOMMatrix::setM14): (WebCore::DOMMatrix::setM21): (WebCore::DOMMatrix::setM22): (WebCore::DOMMatrix::setM23): (WebCore::DOMMatrix::setM24): (WebCore::DOMMatrix::setM31): (WebCore::DOMMatrix::setM32): (WebCore::DOMMatrix::setM33): (WebCore::DOMMatrix::setM34): (WebCore::DOMMatrix::setM41): (WebCore::DOMMatrix::setM42): (WebCore::DOMMatrix::setM43): (WebCore::DOMMatrix::setM44): * css/DOMMatrix.idl: Added. * css/DOMMatrixInit.h: Added. * css/DOMMatrixInit.idl: Added. * css/DOMMatrixReadOnly.cpp: Added. (WebCore::DOMMatrixReadOnly::DOMMatrixReadOnly): (WebCore::DOMMatrixReadOnly::validateAndFixup): (WebCore::DOMMatrixReadOnly::fromMatrix): (WebCore::DOMMatrixReadOnly::isIdentity): (WebCore::DOMMatrixReadOnly::setMatrixValue): (WebCore::DOMMatrixReadOnly::translate): (WebCore::DOMMatrixReadOnly::flipX): (WebCore::DOMMatrixReadOnly::flipY): (WebCore::DOMMatrixReadOnly::multiply): (WebCore::DOMMatrixReadOnly::scale): (WebCore::DOMMatrixReadOnly::scale3d): (WebCore::DOMMatrixReadOnly::rotate): (WebCore::DOMMatrixReadOnly::rotateFromVector): (WebCore::DOMMatrixReadOnly::rotateAxisAngle): (WebCore::DOMMatrixReadOnly::skewX): (WebCore::DOMMatrixReadOnly::skewY): (WebCore::DOMMatrixReadOnly::inverse): (WebCore::DOMMatrixReadOnly::toString): * css/DOMMatrixReadOnly.h: Added. (WebCore::DOMMatrixReadOnly::create): (WebCore::DOMMatrixReadOnly::a): (WebCore::DOMMatrixReadOnly::b): (WebCore::DOMMatrixReadOnly::c): (WebCore::DOMMatrixReadOnly::d): (WebCore::DOMMatrixReadOnly::e): (WebCore::DOMMatrixReadOnly::f): (WebCore::DOMMatrixReadOnly::m11): (WebCore::DOMMatrixReadOnly::m12): (WebCore::DOMMatrixReadOnly::m13): (WebCore::DOMMatrixReadOnly::m14): (WebCore::DOMMatrixReadOnly::m21): (WebCore::DOMMatrixReadOnly::m22): (WebCore::DOMMatrixReadOnly::m23): (WebCore::DOMMatrixReadOnly::m24): (WebCore::DOMMatrixReadOnly::m31): (WebCore::DOMMatrixReadOnly::m32): (WebCore::DOMMatrixReadOnly::m33): (WebCore::DOMMatrixReadOnly::m34): (WebCore::DOMMatrixReadOnly::m41): (WebCore::DOMMatrixReadOnly::m42): (WebCore::DOMMatrixReadOnly::m43): (WebCore::DOMMatrixReadOnly::m44): (WebCore::DOMMatrixReadOnly::is2D): (WebCore::DOMMatrixReadOnly::fromMatrixHelper): * css/DOMMatrixReadOnly.idl: Added. * css/WebKitCSSMatrix.h: * css/WebKitCSSMatrix.idl: * svg/SVGMatrix.h: * svg/SVGMatrix.idl: LayoutTests: Drop test I previously added now that a better version landed in web-platform-tests and was re-imported in this patch. * fast/css/matrix-stringifier-expected.txt: Removed. * fast/css/matrix-stringifier.html: Removed. Canonical link: https://commits.webkit.org/189124@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-16 23:45:13 +00:00
#include <cmath>
#include <limits>
namespace WebCore {
DOMMatrix and DOMMatrixReadOnly should be available in workers https://bugs.webkit.org/show_bug.cgi?id=176255 Reviewed by Simon Fraser. LayoutTests/imported/w3c: * web-platform-tests/css/geometry-1/DOMMatrix-css-string.worker-expected.txt: * web-platform-tests/css/geometry-1/interfaces.worker-expected.txt: Update test results. Source/WebCore: * WebCore.xcodeproj/project.pbxproj: Add GlobalPerformance.idl to the project. It was missing. * bindings/scripts/CodeGeneratorJS.pm: (IsAlwaysExposedOnInterface): (NeedsRuntimeCheck): (GenerateRuntimeEnableConditionalStringForExposed): (GenerateRuntimeEnableConditionalString): Adds support for [Exposed] extended attributes on operations, attributes and constants. This allows an interface that is exposed to both windows and workers (with [Exposed=(Window,Worker)]), to indicate that a specific property should only be be exposed somewhere, e.g only the window. This is need by DOMMatrixReadOnly's stringifier, which is only exposed in the window environment. * bindings/scripts/IDLParser.pm: (parseExtendedAttributeRest2): Fix bug where array extended attributes, like those found in Exposed expressions where being converter to scalars. * bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp: * bindings/scripts/test/JS/JSTestGlobalObject.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/TestObj.idl: Add tests and update results. Some results are just improved includes. * css/DOMMatrix.cpp: * css/DOMMatrix.h: * css/DOMMatrix.idl: * css/DOMMatrixReadOnly.cpp: * css/DOMMatrixReadOnly.h: * css/DOMMatrixReadOnly.idl: Expose DOMMatrix and DOMMatrixReadOnly to workers and update the constructors to match the current spec, throwing if the argument is a string, and the context is not the window / document context. Also did some refactoring to avoid allocating the DOMMatrix or DOMMatrixReadOnly until after all the exceptional cases were handled. LayoutTests: * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: * platform/mac-wk1/js/dom/global-constructors-attributes-dedicated-worker-expected.txt * platform/wpe/js/dom/global-constructors-attributes-dedicated-worker-expected.txt Canonical link: https://commits.webkit.org/192912@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221512 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-09-02 01:38:07 +00:00
// https://drafts.fxtf.org/geometry/#dom-dommatrixreadonly-dommatrixreadonly
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
ExceptionOr<Ref<DOMMatrix>> DOMMatrix::create(ScriptExecutionContext& scriptExecutionContext, std::optional<Variant<String, Vector<double>>>&& init)
DOMMatrix and DOMMatrixReadOnly should be available in workers https://bugs.webkit.org/show_bug.cgi?id=176255 Reviewed by Simon Fraser. LayoutTests/imported/w3c: * web-platform-tests/css/geometry-1/DOMMatrix-css-string.worker-expected.txt: * web-platform-tests/css/geometry-1/interfaces.worker-expected.txt: Update test results. Source/WebCore: * WebCore.xcodeproj/project.pbxproj: Add GlobalPerformance.idl to the project. It was missing. * bindings/scripts/CodeGeneratorJS.pm: (IsAlwaysExposedOnInterface): (NeedsRuntimeCheck): (GenerateRuntimeEnableConditionalStringForExposed): (GenerateRuntimeEnableConditionalString): Adds support for [Exposed] extended attributes on operations, attributes and constants. This allows an interface that is exposed to both windows and workers (with [Exposed=(Window,Worker)]), to indicate that a specific property should only be be exposed somewhere, e.g only the window. This is need by DOMMatrixReadOnly's stringifier, which is only exposed in the window environment. * bindings/scripts/IDLParser.pm: (parseExtendedAttributeRest2): Fix bug where array extended attributes, like those found in Exposed expressions where being converter to scalars. * bindings/scripts/test/JS/JSTestGenerateIsReachable.cpp: * bindings/scripts/test/JS/JSTestGlobalObject.cpp: * bindings/scripts/test/JS/JSTestObj.cpp: * bindings/scripts/test/TestObj.idl: Add tests and update results. Some results are just improved includes. * css/DOMMatrix.cpp: * css/DOMMatrix.h: * css/DOMMatrix.idl: * css/DOMMatrixReadOnly.cpp: * css/DOMMatrixReadOnly.h: * css/DOMMatrixReadOnly.idl: Expose DOMMatrix and DOMMatrixReadOnly to workers and update the constructors to match the current spec, throwing if the argument is a string, and the context is not the window / document context. Also did some refactoring to avoid allocating the DOMMatrix or DOMMatrixReadOnly until after all the exceptional cases were handled. LayoutTests: * js/dom/global-constructors-attributes-dedicated-worker-expected.txt: * platform/mac-wk1/js/dom/global-constructors-attributes-dedicated-worker-expected.txt * platform/wpe/js/dom/global-constructors-attributes-dedicated-worker-expected.txt Canonical link: https://commits.webkit.org/192912@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@221512 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-09-02 01:38:07 +00:00
{
if (!init)
return adoptRef(*new DOMMatrix);
return WTF::switchOn(init.value(),
[&scriptExecutionContext](const String& init) -> ExceptionOr<Ref<DOMMatrix>> {
if (!scriptExecutionContext.isDocument())
return Exception { TypeError };
auto parseResult = parseStringIntoAbstractMatrix(init);
if (parseResult.hasException())
return parseResult.releaseException();
return adoptRef(*new DOMMatrix(parseResult.returnValue().matrix, parseResult.returnValue().is2D ? Is2D::Yes : Is2D::No));
},
[](const Vector<double>& init) -> ExceptionOr<Ref<DOMMatrix>> {
if (init.size() == 6) {
return adoptRef(*new DOMMatrix(TransformationMatrix {
init[0], init[1], init[2], init[3], init[4], init[5]
}, Is2D::Yes));
}
if (init.size() == 16) {
return adoptRef(*new DOMMatrix(TransformationMatrix {
init[0], init[1], init[2], init[3],
init[4], init[5], init[6], init[7],
init[8], init[9], init[10], init[11],
init[12], init[13], init[14], init[15]
}, Is2D::No));
}
return Exception { TypeError };
}
);
}
Implement DOMMatrix / DOMMatrixReadOnly https://bugs.webkit.org/show_bug.cgi?id=110001 Reviewed by Sam Weinig and Simon Fraser. LayoutTests/imported/w3c: Rebaseline web-platform-tests now that more checks are passing. * web-platform-tests/css/geometry-1/DOMMatrix-001-expected.txt: Most checks are now passing. The few remaining failures seem to be due to our parsing of the input CSS string now matching the specification. This behavior is not new to this patch as I re-used exactly the same logic as for WebKitCSSMatrix's parsing of the input string. * web-platform-tests/css/geometry-1/DOMMatrix-002-expected.txt: * web-platform-tests/css/geometry-1/DOMMatrix-003-expected.txt: * web-platform-tests/css/geometry-1/DOMMatrix-a-f-alias-expected.txt: All checks are now passing. * web-platform-tests/css/geometry-1/DOMMatrix-newobject-expected.txt: Most checks are now passing. The remaining failures are due to DOMMatrixReadOnly's transformPoint() / toFloat32Array() / toFloat64Array() not being implemented in this patch. I think we can take care of those in a follow-up. * web-platform-tests/css/geometry-1/DOMPoint-002-expected.txt: Fails differently now that we support DOMMatrix. The test goes further but still fails because DOMPoint.matrixTransform() is not implemented. * web-platform-tests/css/geometry-1/WebKitCSSMatrix-expected.txt: One more check is passing now that we implement DOMMatrix. The remaining failure is due to WebKitCSSMatrix not being an alias to DOMMatrix yet. I'd rather do this in a follow-up. * web-platform-tests/css/geometry-1/historical-expected.txt: A lot of new passes. * web-platform-tests/css/geometry-1/structured-serialization-expected.txt: The test fails differently now that we support DOMMatrix. The test still fails because we do not support yet the structured serialization of DOMMatrix objects. It appears we do not support this for other types in this spec either (e.g. DOMPoint). I filed: https://bugs.webkit.org/show_bug.cgi?id=172191 * web-platform-tests/css/geometry-1/DOMMatrix-stringifier-expected.txt: Added. * web-platform-tests/css/geometry-1/DOMMatrix-stringifier.html: Added. Import new test from upstream. The WebKitCSSMatrix failures are due to our WebKitCSSMatrix implementation not complying with the standard. As per the standard, WebKitCSSMatrix is supposed to become an alias to DOMMatrix. If we do this aliasing (in a follow-up), then those tests will start passing. * web-platform-tests/css/geometry-1/support/dommatrix-test-util.js: Added. Add missing script that was missed by the importer when I initially imported the test suite from upstream. Source/WebCore: Implement DOMMatrix / DOMMatrixReadOnly as per: - https://drafts.fxtf.org/geometry/#DOMMatrix For now, these new types co-exist with WebKitCSSMatrix / SVGMatrix. However, in the future, WebKitCSSMatrix / SVGMatrix are supposed to become aliases to DOMMatrix. Most of it has been implemented. What remaining to be implemented is: - Make WebKitCSSMatrix / SVGMatrix aliases to DOMMatrix - DOMMatrix.fromFloat32Array() / fromFloat64Array() - DOMMatrixReadOnly.fromFloat32Array() / fromFloat64Array() / toFloat32Array() / toFloat64Array() - DOMMatrixReadOnly.transformPoint(). Tests: imported/w3c/web-platform-tests/css/geometry-1/* * CMakeLists.txt: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: * bindings/scripts/test/JS/JSTestObj.cpp: Fix a bug in the bindings generator causing the generator code for "Constructor(optional (DOMString or sequence<unrestricted double>) init)" to be wrong and not build. * css/DOMMatrix.cpp: Added. (WebCore::DOMMatrix::DOMMatrix): (WebCore::DOMMatrix::fromMatrix): (WebCore::DOMMatrix::multiplySelf): (WebCore::DOMMatrix::preMultiplySelf): (WebCore::DOMMatrix::translateSelf): (WebCore::DOMMatrix::scaleSelf): (WebCore::DOMMatrix::scale3dSelf): (WebCore::DOMMatrix::rotateSelf): (WebCore::DOMMatrix::rotateFromVectorSelf): (WebCore::DOMMatrix::rotateAxisAngleSelf): (WebCore::DOMMatrix::skewXSelf): (WebCore::DOMMatrix::skewYSelf): (WebCore::DOMMatrix::invertSelf): (WebCore::DOMMatrix::setMatrixValueForBindings): * css/DOMMatrix.h: Added. (WebCore::DOMMatrix::create): (WebCore::DOMMatrix::setA): (WebCore::DOMMatrix::setB): (WebCore::DOMMatrix::setC): (WebCore::DOMMatrix::setD): (WebCore::DOMMatrix::setE): (WebCore::DOMMatrix::setF): (WebCore::DOMMatrix::setM11): (WebCore::DOMMatrix::setM12): (WebCore::DOMMatrix::setM13): (WebCore::DOMMatrix::setM14): (WebCore::DOMMatrix::setM21): (WebCore::DOMMatrix::setM22): (WebCore::DOMMatrix::setM23): (WebCore::DOMMatrix::setM24): (WebCore::DOMMatrix::setM31): (WebCore::DOMMatrix::setM32): (WebCore::DOMMatrix::setM33): (WebCore::DOMMatrix::setM34): (WebCore::DOMMatrix::setM41): (WebCore::DOMMatrix::setM42): (WebCore::DOMMatrix::setM43): (WebCore::DOMMatrix::setM44): * css/DOMMatrix.idl: Added. * css/DOMMatrixInit.h: Added. * css/DOMMatrixInit.idl: Added. * css/DOMMatrixReadOnly.cpp: Added. (WebCore::DOMMatrixReadOnly::DOMMatrixReadOnly): (WebCore::DOMMatrixReadOnly::validateAndFixup): (WebCore::DOMMatrixReadOnly::fromMatrix): (WebCore::DOMMatrixReadOnly::isIdentity): (WebCore::DOMMatrixReadOnly::setMatrixValue): (WebCore::DOMMatrixReadOnly::translate): (WebCore::DOMMatrixReadOnly::flipX): (WebCore::DOMMatrixReadOnly::flipY): (WebCore::DOMMatrixReadOnly::multiply): (WebCore::DOMMatrixReadOnly::scale): (WebCore::DOMMatrixReadOnly::scale3d): (WebCore::DOMMatrixReadOnly::rotate): (WebCore::DOMMatrixReadOnly::rotateFromVector): (WebCore::DOMMatrixReadOnly::rotateAxisAngle): (WebCore::DOMMatrixReadOnly::skewX): (WebCore::DOMMatrixReadOnly::skewY): (WebCore::DOMMatrixReadOnly::inverse): (WebCore::DOMMatrixReadOnly::toString): * css/DOMMatrixReadOnly.h: Added. (WebCore::DOMMatrixReadOnly::create): (WebCore::DOMMatrixReadOnly::a): (WebCore::DOMMatrixReadOnly::b): (WebCore::DOMMatrixReadOnly::c): (WebCore::DOMMatrixReadOnly::d): (WebCore::DOMMatrixReadOnly::e): (WebCore::DOMMatrixReadOnly::f): (WebCore::DOMMatrixReadOnly::m11): (WebCore::DOMMatrixReadOnly::m12): (WebCore::DOMMatrixReadOnly::m13): (WebCore::DOMMatrixReadOnly::m14): (WebCore::DOMMatrixReadOnly::m21): (WebCore::DOMMatrixReadOnly::m22): (WebCore::DOMMatrixReadOnly::m23): (WebCore::DOMMatrixReadOnly::m24): (WebCore::DOMMatrixReadOnly::m31): (WebCore::DOMMatrixReadOnly::m32): (WebCore::DOMMatrixReadOnly::m33): (WebCore::DOMMatrixReadOnly::m34): (WebCore::DOMMatrixReadOnly::m41): (WebCore::DOMMatrixReadOnly::m42): (WebCore::DOMMatrixReadOnly::m43): (WebCore::DOMMatrixReadOnly::m44): (WebCore::DOMMatrixReadOnly::is2D): (WebCore::DOMMatrixReadOnly::fromMatrixHelper): * css/DOMMatrixReadOnly.idl: Added. * css/WebKitCSSMatrix.h: * css/WebKitCSSMatrix.idl: * svg/SVGMatrix.h: * svg/SVGMatrix.idl: LayoutTests: Drop test I previously added now that a better version landed in web-platform-tests and was re-imported in this patch. * fast/css/matrix-stringifier-expected.txt: Removed. * fast/css/matrix-stringifier.html: Removed. Canonical link: https://commits.webkit.org/189124@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-16 23:45:13 +00:00
DOMMatrix::DOMMatrix(const TransformationMatrix& matrix, Is2D is2D)
: DOMMatrixReadOnly(matrix, is2D)
{
}
Add support for structured serialization of CSS Geometry types https://bugs.webkit.org/show_bug.cgi?id=173631 Patch by Sam Weinig <sam@webkit.org> 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. Canonical link: https://commits.webkit.org/190540@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218644 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-06-21 20:05:59 +00:00
DOMMatrix::DOMMatrix(TransformationMatrix&& matrix, Is2D is2D)
: DOMMatrixReadOnly(WTFMove(matrix), is2D)
{
}
Implement DOMMatrix / DOMMatrixReadOnly https://bugs.webkit.org/show_bug.cgi?id=110001 Reviewed by Sam Weinig and Simon Fraser. LayoutTests/imported/w3c: Rebaseline web-platform-tests now that more checks are passing. * web-platform-tests/css/geometry-1/DOMMatrix-001-expected.txt: Most checks are now passing. The few remaining failures seem to be due to our parsing of the input CSS string now matching the specification. This behavior is not new to this patch as I re-used exactly the same logic as for WebKitCSSMatrix's parsing of the input string. * web-platform-tests/css/geometry-1/DOMMatrix-002-expected.txt: * web-platform-tests/css/geometry-1/DOMMatrix-003-expected.txt: * web-platform-tests/css/geometry-1/DOMMatrix-a-f-alias-expected.txt: All checks are now passing. * web-platform-tests/css/geometry-1/DOMMatrix-newobject-expected.txt: Most checks are now passing. The remaining failures are due to DOMMatrixReadOnly's transformPoint() / toFloat32Array() / toFloat64Array() not being implemented in this patch. I think we can take care of those in a follow-up. * web-platform-tests/css/geometry-1/DOMPoint-002-expected.txt: Fails differently now that we support DOMMatrix. The test goes further but still fails because DOMPoint.matrixTransform() is not implemented. * web-platform-tests/css/geometry-1/WebKitCSSMatrix-expected.txt: One more check is passing now that we implement DOMMatrix. The remaining failure is due to WebKitCSSMatrix not being an alias to DOMMatrix yet. I'd rather do this in a follow-up. * web-platform-tests/css/geometry-1/historical-expected.txt: A lot of new passes. * web-platform-tests/css/geometry-1/structured-serialization-expected.txt: The test fails differently now that we support DOMMatrix. The test still fails because we do not support yet the structured serialization of DOMMatrix objects. It appears we do not support this for other types in this spec either (e.g. DOMPoint). I filed: https://bugs.webkit.org/show_bug.cgi?id=172191 * web-platform-tests/css/geometry-1/DOMMatrix-stringifier-expected.txt: Added. * web-platform-tests/css/geometry-1/DOMMatrix-stringifier.html: Added. Import new test from upstream. The WebKitCSSMatrix failures are due to our WebKitCSSMatrix implementation not complying with the standard. As per the standard, WebKitCSSMatrix is supposed to become an alias to DOMMatrix. If we do this aliasing (in a follow-up), then those tests will start passing. * web-platform-tests/css/geometry-1/support/dommatrix-test-util.js: Added. Add missing script that was missed by the importer when I initially imported the test suite from upstream. Source/WebCore: Implement DOMMatrix / DOMMatrixReadOnly as per: - https://drafts.fxtf.org/geometry/#DOMMatrix For now, these new types co-exist with WebKitCSSMatrix / SVGMatrix. However, in the future, WebKitCSSMatrix / SVGMatrix are supposed to become aliases to DOMMatrix. Most of it has been implemented. What remaining to be implemented is: - Make WebKitCSSMatrix / SVGMatrix aliases to DOMMatrix - DOMMatrix.fromFloat32Array() / fromFloat64Array() - DOMMatrixReadOnly.fromFloat32Array() / fromFloat64Array() / toFloat32Array() / toFloat64Array() - DOMMatrixReadOnly.transformPoint(). Tests: imported/w3c/web-platform-tests/css/geometry-1/* * CMakeLists.txt: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: * bindings/scripts/test/JS/JSTestObj.cpp: Fix a bug in the bindings generator causing the generator code for "Constructor(optional (DOMString or sequence<unrestricted double>) init)" to be wrong and not build. * css/DOMMatrix.cpp: Added. (WebCore::DOMMatrix::DOMMatrix): (WebCore::DOMMatrix::fromMatrix): (WebCore::DOMMatrix::multiplySelf): (WebCore::DOMMatrix::preMultiplySelf): (WebCore::DOMMatrix::translateSelf): (WebCore::DOMMatrix::scaleSelf): (WebCore::DOMMatrix::scale3dSelf): (WebCore::DOMMatrix::rotateSelf): (WebCore::DOMMatrix::rotateFromVectorSelf): (WebCore::DOMMatrix::rotateAxisAngleSelf): (WebCore::DOMMatrix::skewXSelf): (WebCore::DOMMatrix::skewYSelf): (WebCore::DOMMatrix::invertSelf): (WebCore::DOMMatrix::setMatrixValueForBindings): * css/DOMMatrix.h: Added. (WebCore::DOMMatrix::create): (WebCore::DOMMatrix::setA): (WebCore::DOMMatrix::setB): (WebCore::DOMMatrix::setC): (WebCore::DOMMatrix::setD): (WebCore::DOMMatrix::setE): (WebCore::DOMMatrix::setF): (WebCore::DOMMatrix::setM11): (WebCore::DOMMatrix::setM12): (WebCore::DOMMatrix::setM13): (WebCore::DOMMatrix::setM14): (WebCore::DOMMatrix::setM21): (WebCore::DOMMatrix::setM22): (WebCore::DOMMatrix::setM23): (WebCore::DOMMatrix::setM24): (WebCore::DOMMatrix::setM31): (WebCore::DOMMatrix::setM32): (WebCore::DOMMatrix::setM33): (WebCore::DOMMatrix::setM34): (WebCore::DOMMatrix::setM41): (WebCore::DOMMatrix::setM42): (WebCore::DOMMatrix::setM43): (WebCore::DOMMatrix::setM44): * css/DOMMatrix.idl: Added. * css/DOMMatrixInit.h: Added. * css/DOMMatrixInit.idl: Added. * css/DOMMatrixReadOnly.cpp: Added. (WebCore::DOMMatrixReadOnly::DOMMatrixReadOnly): (WebCore::DOMMatrixReadOnly::validateAndFixup): (WebCore::DOMMatrixReadOnly::fromMatrix): (WebCore::DOMMatrixReadOnly::isIdentity): (WebCore::DOMMatrixReadOnly::setMatrixValue): (WebCore::DOMMatrixReadOnly::translate): (WebCore::DOMMatrixReadOnly::flipX): (WebCore::DOMMatrixReadOnly::flipY): (WebCore::DOMMatrixReadOnly::multiply): (WebCore::DOMMatrixReadOnly::scale): (WebCore::DOMMatrixReadOnly::scale3d): (WebCore::DOMMatrixReadOnly::rotate): (WebCore::DOMMatrixReadOnly::rotateFromVector): (WebCore::DOMMatrixReadOnly::rotateAxisAngle): (WebCore::DOMMatrixReadOnly::skewX): (WebCore::DOMMatrixReadOnly::skewY): (WebCore::DOMMatrixReadOnly::inverse): (WebCore::DOMMatrixReadOnly::toString): * css/DOMMatrixReadOnly.h: Added. (WebCore::DOMMatrixReadOnly::create): (WebCore::DOMMatrixReadOnly::a): (WebCore::DOMMatrixReadOnly::b): (WebCore::DOMMatrixReadOnly::c): (WebCore::DOMMatrixReadOnly::d): (WebCore::DOMMatrixReadOnly::e): (WebCore::DOMMatrixReadOnly::f): (WebCore::DOMMatrixReadOnly::m11): (WebCore::DOMMatrixReadOnly::m12): (WebCore::DOMMatrixReadOnly::m13): (WebCore::DOMMatrixReadOnly::m14): (WebCore::DOMMatrixReadOnly::m21): (WebCore::DOMMatrixReadOnly::m22): (WebCore::DOMMatrixReadOnly::m23): (WebCore::DOMMatrixReadOnly::m24): (WebCore::DOMMatrixReadOnly::m31): (WebCore::DOMMatrixReadOnly::m32): (WebCore::DOMMatrixReadOnly::m33): (WebCore::DOMMatrixReadOnly::m34): (WebCore::DOMMatrixReadOnly::m41): (WebCore::DOMMatrixReadOnly::m42): (WebCore::DOMMatrixReadOnly::m43): (WebCore::DOMMatrixReadOnly::m44): (WebCore::DOMMatrixReadOnly::is2D): (WebCore::DOMMatrixReadOnly::fromMatrixHelper): * css/DOMMatrixReadOnly.idl: Added. * css/WebKitCSSMatrix.h: * css/WebKitCSSMatrix.idl: * svg/SVGMatrix.h: * svg/SVGMatrix.idl: LayoutTests: Drop test I previously added now that a better version landed in web-platform-tests and was re-imported in this patch. * fast/css/matrix-stringifier-expected.txt: Removed. * fast/css/matrix-stringifier.html: Removed. Canonical link: https://commits.webkit.org/189124@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-16 23:45:13 +00:00
// https://drafts.fxtf.org/geometry/#create-a-dommatrix-from-the-dictionary
ExceptionOr<Ref<DOMMatrix>> DOMMatrix::fromMatrix(DOMMatrixInit&& init)
{
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 };
}
Implement DOMMatrix / DOMMatrixReadOnly https://bugs.webkit.org/show_bug.cgi?id=110001 Reviewed by Sam Weinig and Simon Fraser. LayoutTests/imported/w3c: Rebaseline web-platform-tests now that more checks are passing. * web-platform-tests/css/geometry-1/DOMMatrix-001-expected.txt: Most checks are now passing. The few remaining failures seem to be due to our parsing of the input CSS string now matching the specification. This behavior is not new to this patch as I re-used exactly the same logic as for WebKitCSSMatrix's parsing of the input string. * web-platform-tests/css/geometry-1/DOMMatrix-002-expected.txt: * web-platform-tests/css/geometry-1/DOMMatrix-003-expected.txt: * web-platform-tests/css/geometry-1/DOMMatrix-a-f-alias-expected.txt: All checks are now passing. * web-platform-tests/css/geometry-1/DOMMatrix-newobject-expected.txt: Most checks are now passing. The remaining failures are due to DOMMatrixReadOnly's transformPoint() / toFloat32Array() / toFloat64Array() not being implemented in this patch. I think we can take care of those in a follow-up. * web-platform-tests/css/geometry-1/DOMPoint-002-expected.txt: Fails differently now that we support DOMMatrix. The test goes further but still fails because DOMPoint.matrixTransform() is not implemented. * web-platform-tests/css/geometry-1/WebKitCSSMatrix-expected.txt: One more check is passing now that we implement DOMMatrix. The remaining failure is due to WebKitCSSMatrix not being an alias to DOMMatrix yet. I'd rather do this in a follow-up. * web-platform-tests/css/geometry-1/historical-expected.txt: A lot of new passes. * web-platform-tests/css/geometry-1/structured-serialization-expected.txt: The test fails differently now that we support DOMMatrix. The test still fails because we do not support yet the structured serialization of DOMMatrix objects. It appears we do not support this for other types in this spec either (e.g. DOMPoint). I filed: https://bugs.webkit.org/show_bug.cgi?id=172191 * web-platform-tests/css/geometry-1/DOMMatrix-stringifier-expected.txt: Added. * web-platform-tests/css/geometry-1/DOMMatrix-stringifier.html: Added. Import new test from upstream. The WebKitCSSMatrix failures are due to our WebKitCSSMatrix implementation not complying with the standard. As per the standard, WebKitCSSMatrix is supposed to become an alias to DOMMatrix. If we do this aliasing (in a follow-up), then those tests will start passing. * web-platform-tests/css/geometry-1/support/dommatrix-test-util.js: Added. Add missing script that was missed by the importer when I initially imported the test suite from upstream. Source/WebCore: Implement DOMMatrix / DOMMatrixReadOnly as per: - https://drafts.fxtf.org/geometry/#DOMMatrix For now, these new types co-exist with WebKitCSSMatrix / SVGMatrix. However, in the future, WebKitCSSMatrix / SVGMatrix are supposed to become aliases to DOMMatrix. Most of it has been implemented. What remaining to be implemented is: - Make WebKitCSSMatrix / SVGMatrix aliases to DOMMatrix - DOMMatrix.fromFloat32Array() / fromFloat64Array() - DOMMatrixReadOnly.fromFloat32Array() / fromFloat64Array() / toFloat32Array() / toFloat64Array() - DOMMatrixReadOnly.transformPoint(). Tests: imported/w3c/web-platform-tests/css/geometry-1/* * CMakeLists.txt: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: * bindings/scripts/test/JS/JSTestObj.cpp: Fix a bug in the bindings generator causing the generator code for "Constructor(optional (DOMString or sequence<unrestricted double>) init)" to be wrong and not build. * css/DOMMatrix.cpp: Added. (WebCore::DOMMatrix::DOMMatrix): (WebCore::DOMMatrix::fromMatrix): (WebCore::DOMMatrix::multiplySelf): (WebCore::DOMMatrix::preMultiplySelf): (WebCore::DOMMatrix::translateSelf): (WebCore::DOMMatrix::scaleSelf): (WebCore::DOMMatrix::scale3dSelf): (WebCore::DOMMatrix::rotateSelf): (WebCore::DOMMatrix::rotateFromVectorSelf): (WebCore::DOMMatrix::rotateAxisAngleSelf): (WebCore::DOMMatrix::skewXSelf): (WebCore::DOMMatrix::skewYSelf): (WebCore::DOMMatrix::invertSelf): (WebCore::DOMMatrix::setMatrixValueForBindings): * css/DOMMatrix.h: Added. (WebCore::DOMMatrix::create): (WebCore::DOMMatrix::setA): (WebCore::DOMMatrix::setB): (WebCore::DOMMatrix::setC): (WebCore::DOMMatrix::setD): (WebCore::DOMMatrix::setE): (WebCore::DOMMatrix::setF): (WebCore::DOMMatrix::setM11): (WebCore::DOMMatrix::setM12): (WebCore::DOMMatrix::setM13): (WebCore::DOMMatrix::setM14): (WebCore::DOMMatrix::setM21): (WebCore::DOMMatrix::setM22): (WebCore::DOMMatrix::setM23): (WebCore::DOMMatrix::setM24): (WebCore::DOMMatrix::setM31): (WebCore::DOMMatrix::setM32): (WebCore::DOMMatrix::setM33): (WebCore::DOMMatrix::setM34): (WebCore::DOMMatrix::setM41): (WebCore::DOMMatrix::setM42): (WebCore::DOMMatrix::setM43): (WebCore::DOMMatrix::setM44): * css/DOMMatrix.idl: Added. * css/DOMMatrixInit.h: Added. * css/DOMMatrixInit.idl: Added. * css/DOMMatrixReadOnly.cpp: Added. (WebCore::DOMMatrixReadOnly::DOMMatrixReadOnly): (WebCore::DOMMatrixReadOnly::validateAndFixup): (WebCore::DOMMatrixReadOnly::fromMatrix): (WebCore::DOMMatrixReadOnly::isIdentity): (WebCore::DOMMatrixReadOnly::setMatrixValue): (WebCore::DOMMatrixReadOnly::translate): (WebCore::DOMMatrixReadOnly::flipX): (WebCore::DOMMatrixReadOnly::flipY): (WebCore::DOMMatrixReadOnly::multiply): (WebCore::DOMMatrixReadOnly::scale): (WebCore::DOMMatrixReadOnly::scale3d): (WebCore::DOMMatrixReadOnly::rotate): (WebCore::DOMMatrixReadOnly::rotateFromVector): (WebCore::DOMMatrixReadOnly::rotateAxisAngle): (WebCore::DOMMatrixReadOnly::skewX): (WebCore::DOMMatrixReadOnly::skewY): (WebCore::DOMMatrixReadOnly::inverse): (WebCore::DOMMatrixReadOnly::toString): * css/DOMMatrixReadOnly.h: Added. (WebCore::DOMMatrixReadOnly::create): (WebCore::DOMMatrixReadOnly::a): (WebCore::DOMMatrixReadOnly::b): (WebCore::DOMMatrixReadOnly::c): (WebCore::DOMMatrixReadOnly::d): (WebCore::DOMMatrixReadOnly::e): (WebCore::DOMMatrixReadOnly::f): (WebCore::DOMMatrixReadOnly::m11): (WebCore::DOMMatrixReadOnly::m12): (WebCore::DOMMatrixReadOnly::m13): (WebCore::DOMMatrixReadOnly::m14): (WebCore::DOMMatrixReadOnly::m21): (WebCore::DOMMatrixReadOnly::m22): (WebCore::DOMMatrixReadOnly::m23): (WebCore::DOMMatrixReadOnly::m24): (WebCore::DOMMatrixReadOnly::m31): (WebCore::DOMMatrixReadOnly::m32): (WebCore::DOMMatrixReadOnly::m33): (WebCore::DOMMatrixReadOnly::m34): (WebCore::DOMMatrixReadOnly::m41): (WebCore::DOMMatrixReadOnly::m42): (WebCore::DOMMatrixReadOnly::m43): (WebCore::DOMMatrixReadOnly::m44): (WebCore::DOMMatrixReadOnly::is2D): (WebCore::DOMMatrixReadOnly::fromMatrixHelper): * css/DOMMatrixReadOnly.idl: Added. * css/WebKitCSSMatrix.h: * css/WebKitCSSMatrix.idl: * svg/SVGMatrix.h: * svg/SVGMatrix.idl: LayoutTests: Drop test I previously added now that a better version landed in web-platform-tests and was re-imported in this patch. * fast/css/matrix-stringifier-expected.txt: Removed. * fast/css/matrix-stringifier.html: Removed. Canonical link: https://commits.webkit.org/189124@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-16 23:45:13 +00:00
// https://drafts.fxtf.org/geometry/#dom-dommatrix-multiplyself
ExceptionOr<Ref<DOMMatrix>> DOMMatrix::multiplySelf(DOMMatrixInit&& other)
{
auto fromMatrixResult = DOMMatrix::fromMatrix(WTFMove(other));
if (fromMatrixResult.hasException())
return fromMatrixResult.releaseException();
auto otherObject = fromMatrixResult.releaseReturnValue();
m_matrix.multiply(otherObject->m_matrix);
if (!otherObject->is2D())
m_is2D = false;
return Ref<DOMMatrix> { *this };
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-premultiplyself
ExceptionOr<Ref<DOMMatrix>> DOMMatrix::preMultiplySelf(DOMMatrixInit&& other)
{
auto fromMatrixResult = DOMMatrix::fromMatrix(WTFMove(other));
if (fromMatrixResult.hasException())
return fromMatrixResult.releaseException();
auto otherObject = fromMatrixResult.releaseReturnValue();
m_matrix = otherObject->m_matrix * m_matrix;
if (!otherObject->is2D())
m_is2D = false;
return Ref<DOMMatrix> { *this };
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-translateself
Ref<DOMMatrix> DOMMatrix::translateSelf(double tx, double ty, double tz)
{
m_matrix.translate3d(tx, ty, tz);
if (tz)
m_is2D = false;
return *this;
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-scaleself
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
Ref<DOMMatrix> DOMMatrix::scaleSelf(double scaleX, std::optional<double> scaleY, double scaleZ, double originX, double originY, double originZ)
Implement DOMMatrix / DOMMatrixReadOnly https://bugs.webkit.org/show_bug.cgi?id=110001 Reviewed by Sam Weinig and Simon Fraser. LayoutTests/imported/w3c: Rebaseline web-platform-tests now that more checks are passing. * web-platform-tests/css/geometry-1/DOMMatrix-001-expected.txt: Most checks are now passing. The few remaining failures seem to be due to our parsing of the input CSS string now matching the specification. This behavior is not new to this patch as I re-used exactly the same logic as for WebKitCSSMatrix's parsing of the input string. * web-platform-tests/css/geometry-1/DOMMatrix-002-expected.txt: * web-platform-tests/css/geometry-1/DOMMatrix-003-expected.txt: * web-platform-tests/css/geometry-1/DOMMatrix-a-f-alias-expected.txt: All checks are now passing. * web-platform-tests/css/geometry-1/DOMMatrix-newobject-expected.txt: Most checks are now passing. The remaining failures are due to DOMMatrixReadOnly's transformPoint() / toFloat32Array() / toFloat64Array() not being implemented in this patch. I think we can take care of those in a follow-up. * web-platform-tests/css/geometry-1/DOMPoint-002-expected.txt: Fails differently now that we support DOMMatrix. The test goes further but still fails because DOMPoint.matrixTransform() is not implemented. * web-platform-tests/css/geometry-1/WebKitCSSMatrix-expected.txt: One more check is passing now that we implement DOMMatrix. The remaining failure is due to WebKitCSSMatrix not being an alias to DOMMatrix yet. I'd rather do this in a follow-up. * web-platform-tests/css/geometry-1/historical-expected.txt: A lot of new passes. * web-platform-tests/css/geometry-1/structured-serialization-expected.txt: The test fails differently now that we support DOMMatrix. The test still fails because we do not support yet the structured serialization of DOMMatrix objects. It appears we do not support this for other types in this spec either (e.g. DOMPoint). I filed: https://bugs.webkit.org/show_bug.cgi?id=172191 * web-platform-tests/css/geometry-1/DOMMatrix-stringifier-expected.txt: Added. * web-platform-tests/css/geometry-1/DOMMatrix-stringifier.html: Added. Import new test from upstream. The WebKitCSSMatrix failures are due to our WebKitCSSMatrix implementation not complying with the standard. As per the standard, WebKitCSSMatrix is supposed to become an alias to DOMMatrix. If we do this aliasing (in a follow-up), then those tests will start passing. * web-platform-tests/css/geometry-1/support/dommatrix-test-util.js: Added. Add missing script that was missed by the importer when I initially imported the test suite from upstream. Source/WebCore: Implement DOMMatrix / DOMMatrixReadOnly as per: - https://drafts.fxtf.org/geometry/#DOMMatrix For now, these new types co-exist with WebKitCSSMatrix / SVGMatrix. However, in the future, WebKitCSSMatrix / SVGMatrix are supposed to become aliases to DOMMatrix. Most of it has been implemented. What remaining to be implemented is: - Make WebKitCSSMatrix / SVGMatrix aliases to DOMMatrix - DOMMatrix.fromFloat32Array() / fromFloat64Array() - DOMMatrixReadOnly.fromFloat32Array() / fromFloat64Array() / toFloat32Array() / toFloat64Array() - DOMMatrixReadOnly.transformPoint(). Tests: imported/w3c/web-platform-tests/css/geometry-1/* * CMakeLists.txt: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: * bindings/scripts/test/JS/JSTestObj.cpp: Fix a bug in the bindings generator causing the generator code for "Constructor(optional (DOMString or sequence<unrestricted double>) init)" to be wrong and not build. * css/DOMMatrix.cpp: Added. (WebCore::DOMMatrix::DOMMatrix): (WebCore::DOMMatrix::fromMatrix): (WebCore::DOMMatrix::multiplySelf): (WebCore::DOMMatrix::preMultiplySelf): (WebCore::DOMMatrix::translateSelf): (WebCore::DOMMatrix::scaleSelf): (WebCore::DOMMatrix::scale3dSelf): (WebCore::DOMMatrix::rotateSelf): (WebCore::DOMMatrix::rotateFromVectorSelf): (WebCore::DOMMatrix::rotateAxisAngleSelf): (WebCore::DOMMatrix::skewXSelf): (WebCore::DOMMatrix::skewYSelf): (WebCore::DOMMatrix::invertSelf): (WebCore::DOMMatrix::setMatrixValueForBindings): * css/DOMMatrix.h: Added. (WebCore::DOMMatrix::create): (WebCore::DOMMatrix::setA): (WebCore::DOMMatrix::setB): (WebCore::DOMMatrix::setC): (WebCore::DOMMatrix::setD): (WebCore::DOMMatrix::setE): (WebCore::DOMMatrix::setF): (WebCore::DOMMatrix::setM11): (WebCore::DOMMatrix::setM12): (WebCore::DOMMatrix::setM13): (WebCore::DOMMatrix::setM14): (WebCore::DOMMatrix::setM21): (WebCore::DOMMatrix::setM22): (WebCore::DOMMatrix::setM23): (WebCore::DOMMatrix::setM24): (WebCore::DOMMatrix::setM31): (WebCore::DOMMatrix::setM32): (WebCore::DOMMatrix::setM33): (WebCore::DOMMatrix::setM34): (WebCore::DOMMatrix::setM41): (WebCore::DOMMatrix::setM42): (WebCore::DOMMatrix::setM43): (WebCore::DOMMatrix::setM44): * css/DOMMatrix.idl: Added. * css/DOMMatrixInit.h: Added. * css/DOMMatrixInit.idl: Added. * css/DOMMatrixReadOnly.cpp: Added. (WebCore::DOMMatrixReadOnly::DOMMatrixReadOnly): (WebCore::DOMMatrixReadOnly::validateAndFixup): (WebCore::DOMMatrixReadOnly::fromMatrix): (WebCore::DOMMatrixReadOnly::isIdentity): (WebCore::DOMMatrixReadOnly::setMatrixValue): (WebCore::DOMMatrixReadOnly::translate): (WebCore::DOMMatrixReadOnly::flipX): (WebCore::DOMMatrixReadOnly::flipY): (WebCore::DOMMatrixReadOnly::multiply): (WebCore::DOMMatrixReadOnly::scale): (WebCore::DOMMatrixReadOnly::scale3d): (WebCore::DOMMatrixReadOnly::rotate): (WebCore::DOMMatrixReadOnly::rotateFromVector): (WebCore::DOMMatrixReadOnly::rotateAxisAngle): (WebCore::DOMMatrixReadOnly::skewX): (WebCore::DOMMatrixReadOnly::skewY): (WebCore::DOMMatrixReadOnly::inverse): (WebCore::DOMMatrixReadOnly::toString): * css/DOMMatrixReadOnly.h: Added. (WebCore::DOMMatrixReadOnly::create): (WebCore::DOMMatrixReadOnly::a): (WebCore::DOMMatrixReadOnly::b): (WebCore::DOMMatrixReadOnly::c): (WebCore::DOMMatrixReadOnly::d): (WebCore::DOMMatrixReadOnly::e): (WebCore::DOMMatrixReadOnly::f): (WebCore::DOMMatrixReadOnly::m11): (WebCore::DOMMatrixReadOnly::m12): (WebCore::DOMMatrixReadOnly::m13): (WebCore::DOMMatrixReadOnly::m14): (WebCore::DOMMatrixReadOnly::m21): (WebCore::DOMMatrixReadOnly::m22): (WebCore::DOMMatrixReadOnly::m23): (WebCore::DOMMatrixReadOnly::m24): (WebCore::DOMMatrixReadOnly::m31): (WebCore::DOMMatrixReadOnly::m32): (WebCore::DOMMatrixReadOnly::m33): (WebCore::DOMMatrixReadOnly::m34): (WebCore::DOMMatrixReadOnly::m41): (WebCore::DOMMatrixReadOnly::m42): (WebCore::DOMMatrixReadOnly::m43): (WebCore::DOMMatrixReadOnly::m44): (WebCore::DOMMatrixReadOnly::is2D): (WebCore::DOMMatrixReadOnly::fromMatrixHelper): * css/DOMMatrixReadOnly.idl: Added. * css/WebKitCSSMatrix.h: * css/WebKitCSSMatrix.idl: * svg/SVGMatrix.h: * svg/SVGMatrix.idl: LayoutTests: Drop test I previously added now that a better version landed in web-platform-tests and was re-imported in this patch. * fast/css/matrix-stringifier-expected.txt: Removed. * fast/css/matrix-stringifier.html: Removed. Canonical link: https://commits.webkit.org/189124@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-16 23:45:13 +00:00
{
if (!scaleY)
scaleY = scaleX;
translateSelf(originX, originY, originZ);
// Post-multiply a non-uniform scale transformation on the current matrix.
// The 3D scale matrix is described in CSS Transforms with sx = scaleX, sy = scaleY and sz = scaleZ.
m_matrix.scale3d(scaleX, scaleY.value(), scaleZ);
translateSelf(-originX, -originY, -originZ);
if (scaleZ != 1 || originZ)
m_is2D = false;
return *this;
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-scale3dself
Ref<DOMMatrix> DOMMatrix::scale3dSelf(double scale, double originX, double originY, double originZ)
{
translateSelf(originX, originY, originZ);
// Post-multiply a uniform 3D scale transformation (m11 = m22 = m33 = scale) on the current matrix.
// The 3D scale matrix is described in CSS Transforms with sx = sy = sz = scale. [CSS3-TRANSFORMS]
m_matrix.scale3d(scale, scale, scale);
translateSelf(-originX, -originY, -originZ);
if (scale != 1)
m_is2D = false;
return *this;
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-rotateself
Remove WTF::Optional synonym for std::optional, using that class template directly instead https://bugs.webkit.org/show_bug.cgi?id=226433 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * inspector/scripts/codegen/generate_objc_protocol_types_implementation.py: (ObjCProtocolTypesImplementationGenerator._generate_init_method_for_payload): Use auto instead of Optional<>. Also use * instead of value() and nest the definition of the local inside an if statement in the case where it's an optional. * inspector/scripts/tests/expected/*: Regenerated these results. Source/WebCore: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebCore/PAL: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebDriver: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKit: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * Scripts/webkit/tests: Regenerated expected results, by running the command "python Scripts/webkit/messages_unittest.py -r". (How am I supposed to know to do that?) Source/WebKitLegacy/ios: * WebCoreSupport/WebChromeClientIOS.h: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/mac: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WebKitLegacy/win: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Source/WTF: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. * wtf/Optional.h: Remove WTF::Optional. Tools: * <many files>: Let the do-webcore-rename script rename Optional<> to std::optional<>. Canonical link: https://commits.webkit.org/238290@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278253 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-30 16:11:40 +00:00
Ref<DOMMatrix> DOMMatrix::rotateSelf(double rotX, std::optional<double> rotY, std::optional<double> rotZ)
Implement DOMMatrix / DOMMatrixReadOnly https://bugs.webkit.org/show_bug.cgi?id=110001 Reviewed by Sam Weinig and Simon Fraser. LayoutTests/imported/w3c: Rebaseline web-platform-tests now that more checks are passing. * web-platform-tests/css/geometry-1/DOMMatrix-001-expected.txt: Most checks are now passing. The few remaining failures seem to be due to our parsing of the input CSS string now matching the specification. This behavior is not new to this patch as I re-used exactly the same logic as for WebKitCSSMatrix's parsing of the input string. * web-platform-tests/css/geometry-1/DOMMatrix-002-expected.txt: * web-platform-tests/css/geometry-1/DOMMatrix-003-expected.txt: * web-platform-tests/css/geometry-1/DOMMatrix-a-f-alias-expected.txt: All checks are now passing. * web-platform-tests/css/geometry-1/DOMMatrix-newobject-expected.txt: Most checks are now passing. The remaining failures are due to DOMMatrixReadOnly's transformPoint() / toFloat32Array() / toFloat64Array() not being implemented in this patch. I think we can take care of those in a follow-up. * web-platform-tests/css/geometry-1/DOMPoint-002-expected.txt: Fails differently now that we support DOMMatrix. The test goes further but still fails because DOMPoint.matrixTransform() is not implemented. * web-platform-tests/css/geometry-1/WebKitCSSMatrix-expected.txt: One more check is passing now that we implement DOMMatrix. The remaining failure is due to WebKitCSSMatrix not being an alias to DOMMatrix yet. I'd rather do this in a follow-up. * web-platform-tests/css/geometry-1/historical-expected.txt: A lot of new passes. * web-platform-tests/css/geometry-1/structured-serialization-expected.txt: The test fails differently now that we support DOMMatrix. The test still fails because we do not support yet the structured serialization of DOMMatrix objects. It appears we do not support this for other types in this spec either (e.g. DOMPoint). I filed: https://bugs.webkit.org/show_bug.cgi?id=172191 * web-platform-tests/css/geometry-1/DOMMatrix-stringifier-expected.txt: Added. * web-platform-tests/css/geometry-1/DOMMatrix-stringifier.html: Added. Import new test from upstream. The WebKitCSSMatrix failures are due to our WebKitCSSMatrix implementation not complying with the standard. As per the standard, WebKitCSSMatrix is supposed to become an alias to DOMMatrix. If we do this aliasing (in a follow-up), then those tests will start passing. * web-platform-tests/css/geometry-1/support/dommatrix-test-util.js: Added. Add missing script that was missed by the importer when I initially imported the test suite from upstream. Source/WebCore: Implement DOMMatrix / DOMMatrixReadOnly as per: - https://drafts.fxtf.org/geometry/#DOMMatrix For now, these new types co-exist with WebKitCSSMatrix / SVGMatrix. However, in the future, WebKitCSSMatrix / SVGMatrix are supposed to become aliases to DOMMatrix. Most of it has been implemented. What remaining to be implemented is: - Make WebKitCSSMatrix / SVGMatrix aliases to DOMMatrix - DOMMatrix.fromFloat32Array() / fromFloat64Array() - DOMMatrixReadOnly.fromFloat32Array() / fromFloat64Array() / toFloat32Array() / toFloat64Array() - DOMMatrixReadOnly.transformPoint(). Tests: imported/w3c/web-platform-tests/css/geometry-1/* * CMakeLists.txt: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: * bindings/scripts/test/JS/JSTestObj.cpp: Fix a bug in the bindings generator causing the generator code for "Constructor(optional (DOMString or sequence<unrestricted double>) init)" to be wrong and not build. * css/DOMMatrix.cpp: Added. (WebCore::DOMMatrix::DOMMatrix): (WebCore::DOMMatrix::fromMatrix): (WebCore::DOMMatrix::multiplySelf): (WebCore::DOMMatrix::preMultiplySelf): (WebCore::DOMMatrix::translateSelf): (WebCore::DOMMatrix::scaleSelf): (WebCore::DOMMatrix::scale3dSelf): (WebCore::DOMMatrix::rotateSelf): (WebCore::DOMMatrix::rotateFromVectorSelf): (WebCore::DOMMatrix::rotateAxisAngleSelf): (WebCore::DOMMatrix::skewXSelf): (WebCore::DOMMatrix::skewYSelf): (WebCore::DOMMatrix::invertSelf): (WebCore::DOMMatrix::setMatrixValueForBindings): * css/DOMMatrix.h: Added. (WebCore::DOMMatrix::create): (WebCore::DOMMatrix::setA): (WebCore::DOMMatrix::setB): (WebCore::DOMMatrix::setC): (WebCore::DOMMatrix::setD): (WebCore::DOMMatrix::setE): (WebCore::DOMMatrix::setF): (WebCore::DOMMatrix::setM11): (WebCore::DOMMatrix::setM12): (WebCore::DOMMatrix::setM13): (WebCore::DOMMatrix::setM14): (WebCore::DOMMatrix::setM21): (WebCore::DOMMatrix::setM22): (WebCore::DOMMatrix::setM23): (WebCore::DOMMatrix::setM24): (WebCore::DOMMatrix::setM31): (WebCore::DOMMatrix::setM32): (WebCore::DOMMatrix::setM33): (WebCore::DOMMatrix::setM34): (WebCore::DOMMatrix::setM41): (WebCore::DOMMatrix::setM42): (WebCore::DOMMatrix::setM43): (WebCore::DOMMatrix::setM44): * css/DOMMatrix.idl: Added. * css/DOMMatrixInit.h: Added. * css/DOMMatrixInit.idl: Added. * css/DOMMatrixReadOnly.cpp: Added. (WebCore::DOMMatrixReadOnly::DOMMatrixReadOnly): (WebCore::DOMMatrixReadOnly::validateAndFixup): (WebCore::DOMMatrixReadOnly::fromMatrix): (WebCore::DOMMatrixReadOnly::isIdentity): (WebCore::DOMMatrixReadOnly::setMatrixValue): (WebCore::DOMMatrixReadOnly::translate): (WebCore::DOMMatrixReadOnly::flipX): (WebCore::DOMMatrixReadOnly::flipY): (WebCore::DOMMatrixReadOnly::multiply): (WebCore::DOMMatrixReadOnly::scale): (WebCore::DOMMatrixReadOnly::scale3d): (WebCore::DOMMatrixReadOnly::rotate): (WebCore::DOMMatrixReadOnly::rotateFromVector): (WebCore::DOMMatrixReadOnly::rotateAxisAngle): (WebCore::DOMMatrixReadOnly::skewX): (WebCore::DOMMatrixReadOnly::skewY): (WebCore::DOMMatrixReadOnly::inverse): (WebCore::DOMMatrixReadOnly::toString): * css/DOMMatrixReadOnly.h: Added. (WebCore::DOMMatrixReadOnly::create): (WebCore::DOMMatrixReadOnly::a): (WebCore::DOMMatrixReadOnly::b): (WebCore::DOMMatrixReadOnly::c): (WebCore::DOMMatrixReadOnly::d): (WebCore::DOMMatrixReadOnly::e): (WebCore::DOMMatrixReadOnly::f): (WebCore::DOMMatrixReadOnly::m11): (WebCore::DOMMatrixReadOnly::m12): (WebCore::DOMMatrixReadOnly::m13): (WebCore::DOMMatrixReadOnly::m14): (WebCore::DOMMatrixReadOnly::m21): (WebCore::DOMMatrixReadOnly::m22): (WebCore::DOMMatrixReadOnly::m23): (WebCore::DOMMatrixReadOnly::m24): (WebCore::DOMMatrixReadOnly::m31): (WebCore::DOMMatrixReadOnly::m32): (WebCore::DOMMatrixReadOnly::m33): (WebCore::DOMMatrixReadOnly::m34): (WebCore::DOMMatrixReadOnly::m41): (WebCore::DOMMatrixReadOnly::m42): (WebCore::DOMMatrixReadOnly::m43): (WebCore::DOMMatrixReadOnly::m44): (WebCore::DOMMatrixReadOnly::is2D): (WebCore::DOMMatrixReadOnly::fromMatrixHelper): * css/DOMMatrixReadOnly.idl: Added. * css/WebKitCSSMatrix.h: * css/WebKitCSSMatrix.idl: * svg/SVGMatrix.h: * svg/SVGMatrix.idl: LayoutTests: Drop test I previously added now that a better version landed in web-platform-tests and was re-imported in this patch. * fast/css/matrix-stringifier-expected.txt: Removed. * fast/css/matrix-stringifier.html: Removed. Canonical link: https://commits.webkit.org/189124@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-16 23:45:13 +00:00
{
if (!rotY && !rotZ) {
rotZ = rotX;
rotX = 0;
rotY = 0;
}
Next step toward using std::optional directly instead of through WTF::Optional typedef https://bugs.webkit.org/show_bug.cgi?id=226280 Reviewed by Chris Dumez. Source/JavaScriptCore: * <many files>: Accept the renaming done by do-webcore-rename. * yarr/YarrSyntaxChecker.cpp: Since the style checker complained about this file, tweaked style to make it happy after the renaming done by do-webcore-rename, and also hand-updated Optional to std::optional as long as we were touching it. Source/WebCore: * <many files>: Accept the renaming done by do-webcore-rename. * Modules/webauthn/fido/DeviceRequestConverter.h: Since style checker complained about the names of some arguments, fixed them, and also hand-updated Optional to std::optional as long as we were touching it. * loader/EmptyClients.cpp: Since style checker complained about the mix of WEBCORE_EXPORT and inlined functions, moved them out of line, and also hand-updated Optional to std::optional as long as we were touching it. Also removed is<EmptyFrameLoaderClient>(). * loader/EmptyFrameLoaderClient.h: Ditto. Source/WebCore/PAL: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebDriver: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKit: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy: * Storage/StorageTracker.cpp: (WebKit::StorageTracker::diskUsageForOrigin): Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/mac: * <many files>: Accept the renaming done by do-webcore-rename. Source/WebKitLegacy/win: * <many files>: Accept the renaming done by do-webcore-rename. Source/WTF: * <many files>: Accept the renaming done by do-webcore-rename. * wtf/Optional.h: Remove WTF::nullopt_t and WTF::makeOptional. * wtf/URLHelpers.cpp: (WTF::URLHelpers::mapHostName): Convert from nullopt to std::nullopt. Tools: * Scripts/do-webcore-rename: Use script to rename valueOr, WTF::nullopt, WTF::nullopt_t, WTF::Optional, WTF::makeOptional, and makeOptional. Other renamings can't necessarily be done by the script and so will be done in later passes. * <many files>: Accept the renaming done by do-webcore-rename. Canonical link: https://commits.webkit.org/238228@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@278185 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2021-05-28 01:26:23 +00:00
m_matrix.rotate3d(rotX, rotY.value_or(0), rotZ.value_or(0));
if (rotX || rotY.value_or(0))
Implement DOMMatrix / DOMMatrixReadOnly https://bugs.webkit.org/show_bug.cgi?id=110001 Reviewed by Sam Weinig and Simon Fraser. LayoutTests/imported/w3c: Rebaseline web-platform-tests now that more checks are passing. * web-platform-tests/css/geometry-1/DOMMatrix-001-expected.txt: Most checks are now passing. The few remaining failures seem to be due to our parsing of the input CSS string now matching the specification. This behavior is not new to this patch as I re-used exactly the same logic as for WebKitCSSMatrix's parsing of the input string. * web-platform-tests/css/geometry-1/DOMMatrix-002-expected.txt: * web-platform-tests/css/geometry-1/DOMMatrix-003-expected.txt: * web-platform-tests/css/geometry-1/DOMMatrix-a-f-alias-expected.txt: All checks are now passing. * web-platform-tests/css/geometry-1/DOMMatrix-newobject-expected.txt: Most checks are now passing. The remaining failures are due to DOMMatrixReadOnly's transformPoint() / toFloat32Array() / toFloat64Array() not being implemented in this patch. I think we can take care of those in a follow-up. * web-platform-tests/css/geometry-1/DOMPoint-002-expected.txt: Fails differently now that we support DOMMatrix. The test goes further but still fails because DOMPoint.matrixTransform() is not implemented. * web-platform-tests/css/geometry-1/WebKitCSSMatrix-expected.txt: One more check is passing now that we implement DOMMatrix. The remaining failure is due to WebKitCSSMatrix not being an alias to DOMMatrix yet. I'd rather do this in a follow-up. * web-platform-tests/css/geometry-1/historical-expected.txt: A lot of new passes. * web-platform-tests/css/geometry-1/structured-serialization-expected.txt: The test fails differently now that we support DOMMatrix. The test still fails because we do not support yet the structured serialization of DOMMatrix objects. It appears we do not support this for other types in this spec either (e.g. DOMPoint). I filed: https://bugs.webkit.org/show_bug.cgi?id=172191 * web-platform-tests/css/geometry-1/DOMMatrix-stringifier-expected.txt: Added. * web-platform-tests/css/geometry-1/DOMMatrix-stringifier.html: Added. Import new test from upstream. The WebKitCSSMatrix failures are due to our WebKitCSSMatrix implementation not complying with the standard. As per the standard, WebKitCSSMatrix is supposed to become an alias to DOMMatrix. If we do this aliasing (in a follow-up), then those tests will start passing. * web-platform-tests/css/geometry-1/support/dommatrix-test-util.js: Added. Add missing script that was missed by the importer when I initially imported the test suite from upstream. Source/WebCore: Implement DOMMatrix / DOMMatrixReadOnly as per: - https://drafts.fxtf.org/geometry/#DOMMatrix For now, these new types co-exist with WebKitCSSMatrix / SVGMatrix. However, in the future, WebKitCSSMatrix / SVGMatrix are supposed to become aliases to DOMMatrix. Most of it has been implemented. What remaining to be implemented is: - Make WebKitCSSMatrix / SVGMatrix aliases to DOMMatrix - DOMMatrix.fromFloat32Array() / fromFloat64Array() - DOMMatrixReadOnly.fromFloat32Array() / fromFloat64Array() / toFloat32Array() / toFloat64Array() - DOMMatrixReadOnly.transformPoint(). Tests: imported/w3c/web-platform-tests/css/geometry-1/* * CMakeLists.txt: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: * bindings/scripts/test/JS/JSTestObj.cpp: Fix a bug in the bindings generator causing the generator code for "Constructor(optional (DOMString or sequence<unrestricted double>) init)" to be wrong and not build. * css/DOMMatrix.cpp: Added. (WebCore::DOMMatrix::DOMMatrix): (WebCore::DOMMatrix::fromMatrix): (WebCore::DOMMatrix::multiplySelf): (WebCore::DOMMatrix::preMultiplySelf): (WebCore::DOMMatrix::translateSelf): (WebCore::DOMMatrix::scaleSelf): (WebCore::DOMMatrix::scale3dSelf): (WebCore::DOMMatrix::rotateSelf): (WebCore::DOMMatrix::rotateFromVectorSelf): (WebCore::DOMMatrix::rotateAxisAngleSelf): (WebCore::DOMMatrix::skewXSelf): (WebCore::DOMMatrix::skewYSelf): (WebCore::DOMMatrix::invertSelf): (WebCore::DOMMatrix::setMatrixValueForBindings): * css/DOMMatrix.h: Added. (WebCore::DOMMatrix::create): (WebCore::DOMMatrix::setA): (WebCore::DOMMatrix::setB): (WebCore::DOMMatrix::setC): (WebCore::DOMMatrix::setD): (WebCore::DOMMatrix::setE): (WebCore::DOMMatrix::setF): (WebCore::DOMMatrix::setM11): (WebCore::DOMMatrix::setM12): (WebCore::DOMMatrix::setM13): (WebCore::DOMMatrix::setM14): (WebCore::DOMMatrix::setM21): (WebCore::DOMMatrix::setM22): (WebCore::DOMMatrix::setM23): (WebCore::DOMMatrix::setM24): (WebCore::DOMMatrix::setM31): (WebCore::DOMMatrix::setM32): (WebCore::DOMMatrix::setM33): (WebCore::DOMMatrix::setM34): (WebCore::DOMMatrix::setM41): (WebCore::DOMMatrix::setM42): (WebCore::DOMMatrix::setM43): (WebCore::DOMMatrix::setM44): * css/DOMMatrix.idl: Added. * css/DOMMatrixInit.h: Added. * css/DOMMatrixInit.idl: Added. * css/DOMMatrixReadOnly.cpp: Added. (WebCore::DOMMatrixReadOnly::DOMMatrixReadOnly): (WebCore::DOMMatrixReadOnly::validateAndFixup): (WebCore::DOMMatrixReadOnly::fromMatrix): (WebCore::DOMMatrixReadOnly::isIdentity): (WebCore::DOMMatrixReadOnly::setMatrixValue): (WebCore::DOMMatrixReadOnly::translate): (WebCore::DOMMatrixReadOnly::flipX): (WebCore::DOMMatrixReadOnly::flipY): (WebCore::DOMMatrixReadOnly::multiply): (WebCore::DOMMatrixReadOnly::scale): (WebCore::DOMMatrixReadOnly::scale3d): (WebCore::DOMMatrixReadOnly::rotate): (WebCore::DOMMatrixReadOnly::rotateFromVector): (WebCore::DOMMatrixReadOnly::rotateAxisAngle): (WebCore::DOMMatrixReadOnly::skewX): (WebCore::DOMMatrixReadOnly::skewY): (WebCore::DOMMatrixReadOnly::inverse): (WebCore::DOMMatrixReadOnly::toString): * css/DOMMatrixReadOnly.h: Added. (WebCore::DOMMatrixReadOnly::create): (WebCore::DOMMatrixReadOnly::a): (WebCore::DOMMatrixReadOnly::b): (WebCore::DOMMatrixReadOnly::c): (WebCore::DOMMatrixReadOnly::d): (WebCore::DOMMatrixReadOnly::e): (WebCore::DOMMatrixReadOnly::f): (WebCore::DOMMatrixReadOnly::m11): (WebCore::DOMMatrixReadOnly::m12): (WebCore::DOMMatrixReadOnly::m13): (WebCore::DOMMatrixReadOnly::m14): (WebCore::DOMMatrixReadOnly::m21): (WebCore::DOMMatrixReadOnly::m22): (WebCore::DOMMatrixReadOnly::m23): (WebCore::DOMMatrixReadOnly::m24): (WebCore::DOMMatrixReadOnly::m31): (WebCore::DOMMatrixReadOnly::m32): (WebCore::DOMMatrixReadOnly::m33): (WebCore::DOMMatrixReadOnly::m34): (WebCore::DOMMatrixReadOnly::m41): (WebCore::DOMMatrixReadOnly::m42): (WebCore::DOMMatrixReadOnly::m43): (WebCore::DOMMatrixReadOnly::m44): (WebCore::DOMMatrixReadOnly::is2D): (WebCore::DOMMatrixReadOnly::fromMatrixHelper): * css/DOMMatrixReadOnly.idl: Added. * css/WebKitCSSMatrix.h: * css/WebKitCSSMatrix.idl: * svg/SVGMatrix.h: * svg/SVGMatrix.idl: LayoutTests: Drop test I previously added now that a better version landed in web-platform-tests and was re-imported in this patch. * fast/css/matrix-stringifier-expected.txt: Removed. * fast/css/matrix-stringifier.html: Removed. Canonical link: https://commits.webkit.org/189124@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-16 23:45:13 +00:00
m_is2D = false;
return *this;
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-rotatefromvectorself
Ref<DOMMatrix> DOMMatrix::rotateFromVectorSelf(double x, double y)
{
m_matrix.rotateFromVector(x, y);
return *this;
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-rotateaxisangleself
Ref<DOMMatrix> DOMMatrix::rotateAxisAngleSelf(double x, double y, double z, double angle)
{
m_matrix.rotate3d(x, y, z, angle);
if (x || y)
m_is2D = false;
return *this;
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-skewxself
Ref<DOMMatrix> DOMMatrix::skewXSelf(double sx)
{
m_matrix.skewX(sx);
return *this;
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-skewyself
Ref<DOMMatrix> DOMMatrix::skewYSelf(double sy)
{
m_matrix.skewY(sy);
return *this;
}
// https://drafts.fxtf.org/geometry/#dom-dommatrix-invertself
Ref<DOMMatrix> DOMMatrix::invertSelf()
{
auto inverse = m_matrix.inverse();
if (inverse)
m_matrix = *inverse;
else {
Implement DOMMatrix / DOMMatrixReadOnly https://bugs.webkit.org/show_bug.cgi?id=110001 Reviewed by Sam Weinig and Simon Fraser. LayoutTests/imported/w3c: Rebaseline web-platform-tests now that more checks are passing. * web-platform-tests/css/geometry-1/DOMMatrix-001-expected.txt: Most checks are now passing. The few remaining failures seem to be due to our parsing of the input CSS string now matching the specification. This behavior is not new to this patch as I re-used exactly the same logic as for WebKitCSSMatrix's parsing of the input string. * web-platform-tests/css/geometry-1/DOMMatrix-002-expected.txt: * web-platform-tests/css/geometry-1/DOMMatrix-003-expected.txt: * web-platform-tests/css/geometry-1/DOMMatrix-a-f-alias-expected.txt: All checks are now passing. * web-platform-tests/css/geometry-1/DOMMatrix-newobject-expected.txt: Most checks are now passing. The remaining failures are due to DOMMatrixReadOnly's transformPoint() / toFloat32Array() / toFloat64Array() not being implemented in this patch. I think we can take care of those in a follow-up. * web-platform-tests/css/geometry-1/DOMPoint-002-expected.txt: Fails differently now that we support DOMMatrix. The test goes further but still fails because DOMPoint.matrixTransform() is not implemented. * web-platform-tests/css/geometry-1/WebKitCSSMatrix-expected.txt: One more check is passing now that we implement DOMMatrix. The remaining failure is due to WebKitCSSMatrix not being an alias to DOMMatrix yet. I'd rather do this in a follow-up. * web-platform-tests/css/geometry-1/historical-expected.txt: A lot of new passes. * web-platform-tests/css/geometry-1/structured-serialization-expected.txt: The test fails differently now that we support DOMMatrix. The test still fails because we do not support yet the structured serialization of DOMMatrix objects. It appears we do not support this for other types in this spec either (e.g. DOMPoint). I filed: https://bugs.webkit.org/show_bug.cgi?id=172191 * web-platform-tests/css/geometry-1/DOMMatrix-stringifier-expected.txt: Added. * web-platform-tests/css/geometry-1/DOMMatrix-stringifier.html: Added. Import new test from upstream. The WebKitCSSMatrix failures are due to our WebKitCSSMatrix implementation not complying with the standard. As per the standard, WebKitCSSMatrix is supposed to become an alias to DOMMatrix. If we do this aliasing (in a follow-up), then those tests will start passing. * web-platform-tests/css/geometry-1/support/dommatrix-test-util.js: Added. Add missing script that was missed by the importer when I initially imported the test suite from upstream. Source/WebCore: Implement DOMMatrix / DOMMatrixReadOnly as per: - https://drafts.fxtf.org/geometry/#DOMMatrix For now, these new types co-exist with WebKitCSSMatrix / SVGMatrix. However, in the future, WebKitCSSMatrix / SVGMatrix are supposed to become aliases to DOMMatrix. Most of it has been implemented. What remaining to be implemented is: - Make WebKitCSSMatrix / SVGMatrix aliases to DOMMatrix - DOMMatrix.fromFloat32Array() / fromFloat64Array() - DOMMatrixReadOnly.fromFloat32Array() / fromFloat64Array() / toFloat32Array() / toFloat64Array() - DOMMatrixReadOnly.transformPoint(). Tests: imported/w3c/web-platform-tests/css/geometry-1/* * CMakeLists.txt: * DerivedSources.make: * WebCore.xcodeproj/project.pbxproj: * bindings/scripts/CodeGeneratorJS.pm: * bindings/scripts/test/JS/JSTestObj.cpp: Fix a bug in the bindings generator causing the generator code for "Constructor(optional (DOMString or sequence<unrestricted double>) init)" to be wrong and not build. * css/DOMMatrix.cpp: Added. (WebCore::DOMMatrix::DOMMatrix): (WebCore::DOMMatrix::fromMatrix): (WebCore::DOMMatrix::multiplySelf): (WebCore::DOMMatrix::preMultiplySelf): (WebCore::DOMMatrix::translateSelf): (WebCore::DOMMatrix::scaleSelf): (WebCore::DOMMatrix::scale3dSelf): (WebCore::DOMMatrix::rotateSelf): (WebCore::DOMMatrix::rotateFromVectorSelf): (WebCore::DOMMatrix::rotateAxisAngleSelf): (WebCore::DOMMatrix::skewXSelf): (WebCore::DOMMatrix::skewYSelf): (WebCore::DOMMatrix::invertSelf): (WebCore::DOMMatrix::setMatrixValueForBindings): * css/DOMMatrix.h: Added. (WebCore::DOMMatrix::create): (WebCore::DOMMatrix::setA): (WebCore::DOMMatrix::setB): (WebCore::DOMMatrix::setC): (WebCore::DOMMatrix::setD): (WebCore::DOMMatrix::setE): (WebCore::DOMMatrix::setF): (WebCore::DOMMatrix::setM11): (WebCore::DOMMatrix::setM12): (WebCore::DOMMatrix::setM13): (WebCore::DOMMatrix::setM14): (WebCore::DOMMatrix::setM21): (WebCore::DOMMatrix::setM22): (WebCore::DOMMatrix::setM23): (WebCore::DOMMatrix::setM24): (WebCore::DOMMatrix::setM31): (WebCore::DOMMatrix::setM32): (WebCore::DOMMatrix::setM33): (WebCore::DOMMatrix::setM34): (WebCore::DOMMatrix::setM41): (WebCore::DOMMatrix::setM42): (WebCore::DOMMatrix::setM43): (WebCore::DOMMatrix::setM44): * css/DOMMatrix.idl: Added. * css/DOMMatrixInit.h: Added. * css/DOMMatrixInit.idl: Added. * css/DOMMatrixReadOnly.cpp: Added. (WebCore::DOMMatrixReadOnly::DOMMatrixReadOnly): (WebCore::DOMMatrixReadOnly::validateAndFixup): (WebCore::DOMMatrixReadOnly::fromMatrix): (WebCore::DOMMatrixReadOnly::isIdentity): (WebCore::DOMMatrixReadOnly::setMatrixValue): (WebCore::DOMMatrixReadOnly::translate): (WebCore::DOMMatrixReadOnly::flipX): (WebCore::DOMMatrixReadOnly::flipY): (WebCore::DOMMatrixReadOnly::multiply): (WebCore::DOMMatrixReadOnly::scale): (WebCore::DOMMatrixReadOnly::scale3d): (WebCore::DOMMatrixReadOnly::rotate): (WebCore::DOMMatrixReadOnly::rotateFromVector): (WebCore::DOMMatrixReadOnly::rotateAxisAngle): (WebCore::DOMMatrixReadOnly::skewX): (WebCore::DOMMatrixReadOnly::skewY): (WebCore::DOMMatrixReadOnly::inverse): (WebCore::DOMMatrixReadOnly::toString): * css/DOMMatrixReadOnly.h: Added. (WebCore::DOMMatrixReadOnly::create): (WebCore::DOMMatrixReadOnly::a): (WebCore::DOMMatrixReadOnly::b): (WebCore::DOMMatrixReadOnly::c): (WebCore::DOMMatrixReadOnly::d): (WebCore::DOMMatrixReadOnly::e): (WebCore::DOMMatrixReadOnly::f): (WebCore::DOMMatrixReadOnly::m11): (WebCore::DOMMatrixReadOnly::m12): (WebCore::DOMMatrixReadOnly::m13): (WebCore::DOMMatrixReadOnly::m14): (WebCore::DOMMatrixReadOnly::m21): (WebCore::DOMMatrixReadOnly::m22): (WebCore::DOMMatrixReadOnly::m23): (WebCore::DOMMatrixReadOnly::m24): (WebCore::DOMMatrixReadOnly::m31): (WebCore::DOMMatrixReadOnly::m32): (WebCore::DOMMatrixReadOnly::m33): (WebCore::DOMMatrixReadOnly::m34): (WebCore::DOMMatrixReadOnly::m41): (WebCore::DOMMatrixReadOnly::m42): (WebCore::DOMMatrixReadOnly::m43): (WebCore::DOMMatrixReadOnly::m44): (WebCore::DOMMatrixReadOnly::is2D): (WebCore::DOMMatrixReadOnly::fromMatrixHelper): * css/DOMMatrixReadOnly.idl: Added. * css/WebKitCSSMatrix.h: * css/WebKitCSSMatrix.idl: * svg/SVGMatrix.h: * svg/SVGMatrix.idl: LayoutTests: Drop test I previously added now that a better version landed in web-platform-tests and was re-imported in this patch. * fast/css/matrix-stringifier-expected.txt: Removed. * fast/css/matrix-stringifier.html: Removed. Canonical link: https://commits.webkit.org/189124@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@216959 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-05-16 23:45:13 +00:00
m_matrix.setMatrix(
std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN()
);
m_is2D = false;
}
return Ref<DOMMatrix> { *this };
}
ExceptionOr<Ref<DOMMatrix>> DOMMatrix::setMatrixValueForBindings(const String& string)
{
auto result = setMatrixValue(string);
if (result.hasException())
return result.releaseException();
return Ref<DOMMatrix> { *this };
}
} // namespace WebCore