source: webkit/trunk/Source/WebCore/css/DOMMatrixReadOnly.h

Last change on this file was 284213, checked in by [email protected], 4 years ago

Remove Variant.h
https://bugs.webkit.org/show_bug.cgi?id=231744

Patch by Alex Christensen <[email protected]> on 2021-10-14
Reviewed by Darin Adler.

Source/JavaScriptCore:

  • jit/AssemblyHelpers.h:
  • jit/SnippetReg.h:
  • parser/Lexer.cpp:
  • parser/VariableEnvironment.h:
  • runtime/BytecodeCacheError.h:
  • runtime/CachePayload.h:
  • runtime/CacheUpdate.h:
  • runtime/TemporalObject.h:
  • runtime/TemporalTimeZone.h:
  • wasm/WasmLLIntGenerator.cpp:

Source/WebCore:

  • Modules/async-clipboard/ClipboardItemBindingsDataSource.h:
  • Modules/fetch/FetchBody.h:
  • Modules/fetch/FetchHeaders.h:
  • Modules/indexeddb/IDBCursor.h:
  • Modules/indexeddb/IDBGetAllResult.h:
  • Modules/indexeddb/IDBKey.h:
  • Modules/indexeddb/IDBKeyData.h:
  • Modules/indexeddb/IDBKeyPath.h:
  • Modules/indexeddb/IDBRequest.cpp:
  • Modules/mediacontrols/MediaControlsHost.cpp:
  • Modules/mediacontrols/MediaControlsHost.h:
  • Modules/mediastream/MediaTrackConstraints.h:
  • Modules/mediastream/RTCIceServer.h:
  • Modules/paymentrequest/PaymentMethodChangeEvent.h:
  • Modules/paymentrequest/PaymentRequest.h:
  • Modules/push-api/PushEventInit.h:
  • Modules/push-api/PushSubscription.h:
  • Modules/push-api/PushSubscriptionOptionsInit.h:
  • Modules/speech/SpeechRecognitionUpdate.h:
  • Modules/webaudio/AudioContextOptions.h:
  • Modules/webaudio/AudioNode.h:
  • Modules/webxr/WebXRWebGLLayer.h:
  • accessibility/AccessibilityObjectInterface.h:
  • accessibility/isolatedtree/AXIsolatedObject.h:
  • accessibility/mac/WebAccessibilityObjectWrapperBase.h:
  • animation/AnimationEffect.h:
  • animation/EffectTiming.h:
  • animation/OptionalEffectTiming.h:
  • bindings/IDLTypes.h:
  • bindings/js/BufferSource.h:
  • bindings/js/JSDOMConvertUnion.h:
  • bindings/js/JSValueInWrappedObject.h:
  • bindings/scripts/CodeGeneratorJS.pm:

(AddToIncludesForIDLType):

  • crypto/CryptoAlgorithm.h:
  • crypto/CryptoKey.h:
  • crypto/SubtleCrypto.h:
  • crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
  • crypto/algorithms/CryptoAlgorithmHMAC.cpp:
  • crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
  • crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
  • crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
  • crypto/algorithms/CryptoAlgorithmRSA_PSS.cpp:
  • crypto/parameters/CryptoAlgorithmEcdsaParams.h:
  • crypto/parameters/CryptoAlgorithmHmacKeyParams.h:
  • crypto/parameters/CryptoAlgorithmRsaHashedImportParams.h:
  • crypto/parameters/CryptoAlgorithmRsaHashedKeyGenParams.h:
  • css/CSSCustomPropertyValue.h:
  • css/CSSFontFaceSet.h:
  • css/CSSStyleDeclaration.cpp:
  • css/DOMMatrixReadOnly.h:
  • css/FontFace.h:
  • css/StyleRule.h:
  • css/parser/CSSPropertyParserHelpers.h:
  • css/typedom/CSSNumericValue.h:
  • css/typedom/CSSUnparsedValue.cpp:
  • css/typedom/CSSUnparsedValue.h:
  • dom/ContainerNode.cpp:
  • dom/DocumentMarker.h:
  • dom/EventTarget.h:
  • dom/MessageEvent.h:
  • dom/Node.cpp:
  • editing/AlternativeTextController.h:
  • fileapi/Blob.h:
  • fileapi/NetworkSendQueue.h:
  • html/DOMFormData.h:
  • html/HTMLAllCollection.cpp:
  • html/ImageBitmap.cpp:
  • html/URLSearchParams.h:
  • html/canvas/CanvasStyle.h:
  • inspector/InspectorCanvas.cpp:
  • inspector/InspectorCanvas.h:
  • inspector/InspectorCanvasCallTracer.cpp:
  • inspector/InspectorShaderProgram.cpp:
  • inspector/InspectorShaderProgram.h:
  • inspector/agents/InspectorCanvasAgent.cpp:
  • layout/integration/InlineIteratorBox.h:
  • layout/integration/InlineIteratorLine.h:
  • page/DOMWindow.cpp:
  • page/DiagnosticLoggingClient.h:
  • page/IntersectionObserver.h:
  • page/Performance.h:
  • page/PerformanceMeasureOptions.h:
  • page/scrolling/ScrollingCoordinator.h:
  • platform/PasteboardCustomData.h:
  • platform/SharedBuffer.h:
  • platform/audio/AudioStreamDescription.h:
  • platform/generic/KeyedDecoderGeneric.cpp:
  • platform/graphics/DecodingOptions.h:
  • platform/graphics/FontCascadeDescription.h:
  • platform/graphics/FontPalette.h:
  • platform/graphics/FontPaletteValues.h:
  • platform/graphics/Gradient.h:
  • platform/graphics/InlinePathData.h:
  • platform/graphics/cocoa/SourceBufferParser.h:
  • platform/graphics/cocoa/SourceBufferParserWebM.h:
  • platform/graphics/displaylists/DisplayListItems.h:
  • platform/graphics/texmap/TextureMapperPlatformLayerBuffer.h:
  • platform/network/DNS.h:
  • platform/network/FormData.h:
  • platform/network/curl/CurlSSLHandle.h:
  • platform/sql/SQLValue.h:
  • platform/sql/SQLiteStatement.cpp:
  • platform/xr/PlatformXR.h:
  • testing/TypeConversions.h:
  • workers/service/ExtendableMessageEvent.h:
  • workers/service/ServiceWorkerTypes.h:
  • xml/XMLHttpRequest.h:

Source/WebKit:

  • NetworkProcess/NetworkLoadChecker.h:
  • NetworkProcess/cache/NetworkCacheData.h:
  • Platform/IPC/ArgumentCoders.h:
  • Platform/IPC/Attachment.h:
  • Platform/IPC/MessageReceiveQueueMap.h:
  • Scripts/PreferencesTemplates/WebPreferencesStoreDefaultsMap.cpp.erb:
  • Shared/WebCompiledContentRuleListData.h:
  • Shared/mac/MediaFormatReader/MediaSampleCursor.cpp:
  • Shared/mac/MediaFormatReader/MediaSampleCursor.h:
  • UIProcess/API/APIWebAuthenticationPanel.h:
  • UIProcess/API/Cocoa/WKWebViewInternal.h:
  • UIProcess/API/wpe/TouchGestureController.h:
  • UIProcess/Automation/SimulatedInputDispatcher.cpp:
  • UIProcess/Automation/SimulatedInputDispatcher.h:
  • UIProcess/Cocoa/WKSafeBrowsingWarning.h:
  • UIProcess/PageClient.h:
  • UIProcess/ProcessThrottler.h:
  • UIProcess/WebAuthentication/WebAuthenticationRequestData.h:
  • WebProcess/GPU/graphics/ImageBufferBackendHandle.h:
  • WebProcess/WebCoreSupport/gtk/WebEditorClientGtk.cpp:

Source/WebKitLegacy/mac:

  • DOM/DOMHTMLOptionsCollection.mm:

Source/WTF:

  • WTF.xcodeproj/project.pbxproj:
  • wtf/CMakeLists.txt:
  • wtf/LikelyDenseUnsignedIntegerSet.h:
  • wtf/StdLibExtras.h:

(WTF::switchOn):

  • wtf/Variant.h: Removed.
  • wtf/text/TextBreakIterator.h:
File size: 6.5 KB
Line 
1/*
2 * Copyright (C) 2017 Apple Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26#pragma once
27
28#include "DOMMatrixInit.h"
29#include "ExceptionOr.h"
30#include "ScriptWrappable.h"
31#include "TransformationMatrix.h"
32#include <JavaScriptCore/Forward.h>
33#include <variant>
34#include <wtf/RefCounted.h>
35#include <wtf/Vector.h>
36#include <wtf/text/WTFString.h>
37
38namespace WebCore {
39
40class DOMMatrix;
41class DOMPoint;
42class ScriptExecutionContext;
43struct DOMPointInit;
44
45class DOMMatrixReadOnly : public ScriptWrappable, public RefCounted<DOMMatrixReadOnly> {
46 WTF_MAKE_ISO_ALLOCATED(DOMMatrixReadOnly);
47public:
48 static ExceptionOr<Ref<DOMMatrixReadOnly>> create(ScriptExecutionContext&, std::optional<std::variant<String, Vector<double>>>&&);
49
50 enum class Is2D { No, Yes };
51 static Ref<DOMMatrixReadOnly> create(const TransformationMatrix& matrix, Is2D is2D)
52 {
53 return adoptRef(*new DOMMatrixReadOnly(matrix, is2D));
54 }
55
56 static Ref<DOMMatrixReadOnly> create(TransformationMatrix&& matrix, Is2D is2D)
57 {
58 return adoptRef(*new DOMMatrixReadOnly(WTFMove(matrix), is2D));
59 }
60
61 static ExceptionOr<Ref<DOMMatrixReadOnly>> fromMatrix(DOMMatrixInit&&);
62
63 static ExceptionOr<Ref<DOMMatrixReadOnly>> fromFloat32Array(Ref<Float32Array>&&);
64 static ExceptionOr<Ref<DOMMatrixReadOnly>> fromFloat64Array(Ref<Float64Array>&&);
65
66 static ExceptionOr<void> validateAndFixup(DOMMatrix2DInit&);
67 static ExceptionOr<void> validateAndFixup(DOMMatrixInit&);
68
69 double a() const { return m_matrix.a(); }
70 double b() const { return m_matrix.b(); }
71 double c() const { return m_matrix.c(); }
72 double d() const { return m_matrix.d(); }
73 double e() const { return m_matrix.e(); }
74 double f() const { return m_matrix.f(); }
75
76 double m11() const { return m_matrix.m11(); }
77 double m12() const { return m_matrix.m12(); }
78 double m13() const { return m_matrix.m13(); }
79 double m14() const { return m_matrix.m14(); }
80 double m21() const { return m_matrix.m21(); }
81 double m22() const { return m_matrix.m22(); }
82 double m23() const { return m_matrix.m23(); }
83 double m24() const { return m_matrix.m24(); }
84 double m31() const { return m_matrix.m31(); }
85 double m32() const { return m_matrix.m32(); }
86 double m33() const { return m_matrix.m33(); }
87 double m34() const { return m_matrix.m34(); }
88 double m41() const { return m_matrix.m41(); }
89 double m42() const { return m_matrix.m42(); }
90 double m43() const { return m_matrix.m43(); }
91 double m44() const { return m_matrix.m44(); }
92
93 bool is2D() const { return m_is2D; }
94 bool isIdentity() const;
95
96 ExceptionOr<void> setMatrixValue(const String&);
97 ExceptionOr<void> setMatrixValue(const Vector<double>&);
98
99 Ref<DOMMatrix> translate(double tx = 0, double ty = 0, double tz = 0);
100 ExceptionOr<Ref<DOMMatrix>> multiply(DOMMatrixInit&& other) const;
101 Ref<DOMMatrix> flipX();
102 Ref<DOMMatrix> flipY();
103 Ref<DOMMatrix> scale(double scaleX = 1, std::optional<double> scaleY = std::nullopt, double scaleZ = 1, double originX = 0, double originY = 0, double originZ = 0);
104 Ref<DOMMatrix> scale3d(double scale = 1, double originX = 0, double originY = 0, double originZ = 0);
105 Ref<DOMMatrix> rotate(double rotX = 0, std::optional<double> rotY = std::nullopt, std::optional<double> rotZ = std::nullopt); // Angles are in degrees.
106 Ref<DOMMatrix> rotateFromVector(double x = 0, double y = 0);
107 Ref<DOMMatrix> rotateAxisAngle(double x = 0, double y = 0, double z = 0, double angle = 0); // Angle is in degrees.
108 Ref<DOMMatrix> skewX(double sx = 0); // Angle is in degrees.
109 Ref<DOMMatrix> skewY(double sy = 0); // Angle is in degrees.
110 Ref<DOMMatrix> inverse() const;
111
112 Ref<DOMPoint> transformPoint(DOMPointInit&&);
113
114 ExceptionOr<Ref<Float32Array>> toFloat32Array() const;
115 ExceptionOr<Ref<Float64Array>> toFloat64Array() const;
116
117 ExceptionOr<String> toString() const;
118
119 const TransformationMatrix& transformationMatrix() const { return m_matrix; }
120
121 Ref<DOMMatrix> cloneAsDOMMatrix() const;
122
123protected:
124 DOMMatrixReadOnly() = default;
125 DOMMatrixReadOnly(const TransformationMatrix&, Is2D);
126 DOMMatrixReadOnly(TransformationMatrix&&, Is2D);
127
128 struct AbstractMatrix {
129 TransformationMatrix matrix;
130 bool is2D { true };
131 };
132
133 static ExceptionOr<AbstractMatrix> parseStringIntoAbstractMatrix(const String&);
134
135 template <typename T>
136 static ExceptionOr<Ref<T>> fromMatrixHelper(DOMMatrixInit&&);
137
138 TransformationMatrix m_matrix;
139 bool m_is2D { true };
140};
141
142// https://drafts.fxtf.org/geometry/#create-a-dommatrix-from-the-dictionary
143template<typename T>
144inline ExceptionOr<Ref<T>> DOMMatrixReadOnly::fromMatrixHelper(DOMMatrixInit&& init)
145{
146 auto result = validateAndFixup(init);
147 if (result.hasException())
148 return result.releaseException();
149 if (init.is2D.value())
150 return T::create(TransformationMatrix { init.m11.value(), init.m12.value(), init.m21.value(), init.m22.value(), init.m41.value(), init.m42.value() }, Is2D::Yes);
151 return T::create(TransformationMatrix {
152 init.m11.value(), init.m12.value(), init.m13, init.m14,
153 init.m21.value(), init.m22.value(), init.m23, init.m24,
154 init.m31, init.m32, init.m33, init.m34,
155 init.m41.value(), init.m42.value(), init.m43, init.m44
156 }, Is2D::No);
157}
158
159} // namespace WebCore
Note: See TracBrowser for help on using the repository browser.