diff options
author | Job Bautista <jobbautista9@aol.com> | 2023-05-12 13:45:39 +0800 |
---|---|---|
committer | Job Bautista <jobbautista9@aol.com> | 2023-05-12 16:26:05 +0800 |
commit | 709c34a4484a45c19c5a7c52a7a0052d5fca9678 (patch) | |
tree | a2b1e45852a855887220463ba087e442c31b4fc3 /dom/base | |
parent | 0adb8cc71fba46afe05a85ac89d92a3586346ea1 (diff) | |
download | uxp-709c34a4484a45c19c5a7c52a7a0052d5fca9678.tar.gz |
Issue #2241 - Part 5: Expose Geometry interfaces to web workers.
Exposes DOMMatrix, DOMPoint, DOMQuad, and DOMRect to workers.
Backported from Mozilla bug 1420580.
Diffstat (limited to 'dom/base')
-rw-r--r-- | dom/base/DOMMatrix.cpp | 105 | ||||
-rw-r--r-- | dom/base/DOMMatrix.h | 24 | ||||
-rw-r--r-- | dom/base/DOMPoint.cpp | 36 | ||||
-rw-r--r-- | dom/base/DOMPoint.h | 9 | ||||
-rw-r--r-- | dom/base/DOMQuad.cpp | 24 | ||||
-rw-r--r-- | dom/base/DOMQuad.h | 5 | ||||
-rw-r--r-- | dom/base/DOMRect.cpp | 36 | ||||
-rw-r--r-- | dom/base/DOMRect.h | 5 | ||||
-rw-r--r-- | dom/base/StructuredCloneHolder.cpp | 134 | ||||
-rw-r--r-- | dom/base/StructuredCloneTags.h | 9 |
10 files changed, 384 insertions, 3 deletions
diff --git a/dom/base/DOMMatrix.cpp b/dom/base/DOMMatrix.cpp index 1631f2cdcf..0045e17d84 100644 --- a/dom/base/DOMMatrix.cpp +++ b/dom/base/DOMMatrix.cpp @@ -64,6 +64,24 @@ DOMMatrixReadOnly::Constructor( return rval.forget(); } +already_AddRefed<DOMMatrixReadOnly> +DOMMatrixReadOnly::ReadStructuredClone(nsISupports* aParent, JSStructuredCloneReader* aReader) +{ + uint8_t is2D; + + if (!JS_ReadBytes(aReader, &is2D, 1)) { + return nullptr; + } + + RefPtr<DOMMatrixReadOnly> rval = new DOMMatrixReadOnly(aParent, is2D); + + if (!ReadStructuredCloneElements(aReader, rval)) { + return nullptr; + }; + + return rval.forget(); +} + already_AddRefed<DOMMatrix> DOMMatrixReadOnly::Translate(double aTx, double aTy, @@ -344,6 +362,70 @@ DOMMatrixReadOnly::Stringify(nsAString& aResult) aResult = matrixStr; } +// https://drafts.fxtf.org/geometry/#structured-serialization +bool +DOMMatrixReadOnly::WriteStructuredClone(JSStructuredCloneWriter* aWriter) const +{ +#define WriteFloatPair(f1, f2) \ + JS_WriteUint32Pair(aWriter, BitwiseCast<uint32_t>(f1), \ + BitwiseCast<uint32_t>(f2)) + + const uint8_t is2D = Is2D(); + + if (!JS_WriteBytes(aWriter, &is2D, 1)) { + return false; + } + + if (is2D == 1) { + return WriteFloatPair(mMatrix2D->_11, mMatrix2D->_12) && + WriteFloatPair(mMatrix2D->_21, mMatrix2D->_22) && + WriteFloatPair(mMatrix2D->_31, mMatrix2D->_32); + } + + return WriteFloatPair(mMatrix3D->_11, mMatrix3D->_12) && + WriteFloatPair(mMatrix3D->_13, mMatrix3D->_14) && + WriteFloatPair(mMatrix3D->_21, mMatrix3D->_22) && + WriteFloatPair(mMatrix3D->_23, mMatrix3D->_24) && + WriteFloatPair(mMatrix3D->_31, mMatrix3D->_32) && + WriteFloatPair(mMatrix3D->_33, mMatrix3D->_34) && + WriteFloatPair(mMatrix3D->_41, mMatrix3D->_42) && + WriteFloatPair(mMatrix3D->_43, mMatrix3D->_44); +#undef WriteFloatPair +} + +bool +DOMMatrixReadOnly::ReadStructuredCloneElements(JSStructuredCloneReader* aReader, DOMMatrixReadOnly* matrix) +{ + uint32_t high; + uint32_t low; + +#define ReadFloatPair(f1, f2) \ + if (!JS_ReadUint32Pair(aReader, &high, &low)) { \ + return false; \ + } \ + (*(f1) = BitwiseCast<float>(high)); \ + (*(f2) = BitwiseCast<float>(low)); + + if (matrix->Is2D() == 1) { + ReadFloatPair(&(matrix->mMatrix2D->_11), &(matrix->mMatrix2D->_12)); + ReadFloatPair(&(matrix->mMatrix2D->_21), &(matrix->mMatrix2D->_22)); + ReadFloatPair(&(matrix->mMatrix2D->_31), &(matrix->mMatrix2D->_32)); + } else { + ReadFloatPair(&(matrix->mMatrix3D->_11), &(matrix->mMatrix3D->_12)); + ReadFloatPair(&(matrix->mMatrix3D->_13), &(matrix->mMatrix3D->_14)); + ReadFloatPair(&(matrix->mMatrix3D->_21), &(matrix->mMatrix3D->_22)); + ReadFloatPair(&(matrix->mMatrix3D->_23), &(matrix->mMatrix3D->_24)); + ReadFloatPair(&(matrix->mMatrix3D->_31), &(matrix->mMatrix3D->_32)); + ReadFloatPair(&(matrix->mMatrix3D->_33), &(matrix->mMatrix3D->_34)); + ReadFloatPair(&(matrix->mMatrix3D->_41), &(matrix->mMatrix3D->_42)); + ReadFloatPair(&(matrix->mMatrix3D->_43), &(matrix->mMatrix3D->_44)); + } + + return true; + +#undef ReadFloatPair +} + already_AddRefed<DOMMatrix> DOMMatrix::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv) { @@ -354,6 +436,11 @@ DOMMatrix::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv) already_AddRefed<DOMMatrix> DOMMatrix::Constructor(const GlobalObject& aGlobal, const nsAString& aTransformList, ErrorResult& aRv) { + nsCOMPtr<nsPIDOMWindowInner> win = do_QueryInterface(aGlobal.GetAsSupports()); + if (!win) { + aRv.ThrowTypeError<MSG_ILLEGAL_CONSTRUCTOR>(); + return nullptr; + } RefPtr<DOMMatrix> obj = new DOMMatrix(aGlobal.GetAsSupports()); obj = obj->SetMatrixValue(aTransformList, aRv); @@ -431,6 +518,24 @@ DOMMatrix::Constructor(const GlobalObject& aGlobal, const Sequence<double>& aNum return obj.forget(); } +already_AddRefed<DOMMatrix> +DOMMatrix::ReadStructuredClone(nsISupports* aParent, JSStructuredCloneReader* aReader) +{ + uint8_t is2D; + + if (!JS_ReadBytes(aReader, &is2D, 1)) { + return nullptr; + } + + RefPtr<DOMMatrix> rval = new DOMMatrix(aParent, is2D); + + if (!ReadStructuredCloneElements(aReader, rval)) { + return nullptr; + }; + + return rval.forget(); +} + void DOMMatrixReadOnly::Ensure3DMatrix() { diff --git a/dom/base/DOMMatrix.h b/dom/base/DOMMatrix.h index e956878c20..fe1325c594 100644 --- a/dom/base/DOMMatrix.h +++ b/dom/base/DOMMatrix.h @@ -6,6 +6,7 @@ #ifndef MOZILLA_DOM_DOMMATRIX_H_ #define MOZILLA_DOM_DOMMATRIX_H_ +#include "js/StructuredClone.h" #include "nsWrapperCache.h" #include "nsISupports.h" #include "nsCycleCollectionParticipant.h" @@ -58,6 +59,12 @@ public: static already_AddRefed<DOMMatrixReadOnly> Constructor(const GlobalObject& aGlobal, const Optional<StringOrUnrestrictedDoubleSequence>& aArg, ErrorResult& aRv); + static already_AddRefed<DOMMatrixReadOnly> + ReadStructuredClone(nsISupports* aParent, JSStructuredCloneReader* aReader); + + static bool + ReadStructuredCloneElements(JSStructuredCloneReader* aReader, DOMMatrixReadOnly* matrix); + #define GetMatrixMember(entry2D, entry3D, default) \ { \ if (mMatrix3D) { \ @@ -188,6 +195,8 @@ public: JS::MutableHandle<JSObject*> aResult, ErrorResult& aRv) const; void Stringify(nsAString& aResult); + bool WriteStructuredClone(JSStructuredCloneWriter* aWriter) const; + protected: nsCOMPtr<nsISupports> mParent; nsAutoPtr<gfx::Matrix> mMatrix2D; @@ -198,6 +207,14 @@ protected: DOMMatrixReadOnly* SetMatrixValue(const nsAString& aTransformList, ErrorResult& aRv); void Ensure3DMatrix(); + DOMMatrixReadOnly(nsISupports* aParent, bool is2D) : mParent(aParent) { + if (is2D) { + mMatrix2D = new gfx::Matrix(); + } else { + mMatrix3D = new gfx::Matrix4x4(); + } + } + private: DOMMatrixReadOnly() = delete; DOMMatrixReadOnly(const DOMMatrixReadOnly&) = delete; @@ -232,6 +249,9 @@ public: static already_AddRefed<DOMMatrix> Constructor(const GlobalObject& aGlobal, const Sequence<double>& aNumberSequence, ErrorResult& aRv); + static already_AddRefed<DOMMatrix> + ReadStructuredClone(nsISupports* aParent, JSStructuredCloneReader* aReader); + virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; DOMMatrix* MultiplySelf(const DOMMatrix& aOther); @@ -267,6 +287,10 @@ public: DOMMatrix* SetMatrixValue(const nsAString& aTransformList, ErrorResult& aRv); virtual ~DOMMatrix() {} + + private: + DOMMatrix(nsISupports* aParent, bool is2D) + : DOMMatrixReadOnly(aParent, is2D) {} }; } // namespace dom diff --git a/dom/base/DOMPoint.cpp b/dom/base/DOMPoint.cpp index 508bfab1e2..7174a0cb1b 100644 --- a/dom/base/DOMPoint.cpp +++ b/dom/base/DOMPoint.cpp @@ -40,6 +40,42 @@ DOMPointReadOnly::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) return DOMPointReadOnlyBinding::Wrap(aCx, this, aGivenProto); } +// https://drafts.fxtf.org/geometry/#structured-serialization +bool +DOMPointReadOnly::WriteStructuredClone(JSStructuredCloneWriter* aWriter) const +{ +#define WriteDouble(d) \ + JS_WriteUint32Pair(aWriter, (BitwiseCast<uint64_t>(d) >> 32) & 0xffffffff, \ + BitwiseCast<uint64_t>(d) & 0xffffffff) + + return WriteDouble(mX) && WriteDouble(mY) && WriteDouble(mZ) && + WriteDouble(mW); + +#undef WriteDouble +} + +bool +DOMPointReadOnly::ReadStructuredClone(JSStructuredCloneReader* aReader) +{ + uint32_t high; + uint32_t low; + +#define ReadDouble(d) \ + if (!JS_ReadUint32Pair(aReader, &high, &low)) { \ + return false; \ + } \ + (*(d) = BitwiseCast<double>(static_cast<uint64_t>(high) << 32 | low)) + + ReadDouble(&mX); + ReadDouble(&mY); + ReadDouble(&mZ); + ReadDouble(&mW); + + return true; + +#undef ReadDouble +} + already_AddRefed<DOMPoint> DOMPoint::FromPoint(const GlobalObject& aGlobal, const DOMPointInit& aParams) { diff --git a/dom/base/DOMPoint.h b/dom/base/DOMPoint.h index 79937f83a3..f460ea725c 100644 --- a/dom/base/DOMPoint.h +++ b/dom/base/DOMPoint.h @@ -6,6 +6,7 @@ #ifndef MOZILLA_DOMPOINT_H_ #define MOZILLA_DOMPOINT_H_ +#include "js/StructuredClone.h" #include "nsWrapperCache.h" #include "nsISupports.h" #include "nsCycleCollectionParticipant.h" @@ -23,8 +24,8 @@ struct DOMPointInit; class DOMPointReadOnly : public nsWrapperCache { public: - DOMPointReadOnly(nsISupports* aParent, double aX, double aY, - double aZ, double aW) + explicit DOMPointReadOnly(nsISupports* aParent, double aX = 0.0, + double aY = 0.0, double aZ = 0.0, double aW = 1.0) : mParent(aParent) , mX(aX) , mY(aY) @@ -50,6 +51,10 @@ public: nsISupports* GetParentObject() const { return mParent; } virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; + bool WriteStructuredClone(JSStructuredCloneWriter* aWriter) const; + + bool ReadStructuredClone(JSStructuredCloneReader* aReader); + protected: virtual ~DOMPointReadOnly() {} diff --git a/dom/base/DOMQuad.cpp b/dom/base/DOMQuad.cpp index a64c883982..8457d9ddaa 100644 --- a/dom/base/DOMQuad.cpp +++ b/dom/base/DOMQuad.cpp @@ -132,3 +132,27 @@ DOMQuad::ToJSON(DOMQuadJSON& aInit) aInit.mP3.Construct(RefPtr<DOMPoint>(P3()).forget()); aInit.mP4.Construct(RefPtr<DOMPoint>(P4()).forget()); } + +// https://drafts.fxtf.org/geometry/#structured-serialization +bool +DOMQuad::WriteStructuredClone(JSStructuredCloneWriter* aWriter) const +{ + for (const auto& point : mPoints) { + if (!point->WriteStructuredClone(aWriter)) { + return false; + } + } + return true; +} + +bool +DOMQuad::ReadStructuredClone(JSStructuredCloneReader* aReader) +{ + for (auto& point : mPoints) { + point = new DOMPoint(mParent); + if (!point->ReadStructuredClone(aReader)) { + return false; + } + } + return true; +} diff --git a/dom/base/DOMQuad.h b/dom/base/DOMQuad.h index db38e5d236..9d740e0b5e 100644 --- a/dom/base/DOMQuad.h +++ b/dom/base/DOMQuad.h @@ -6,6 +6,7 @@ #ifndef MOZILLA_DOMQUAD_H_ #define MOZILLA_DOMQUAD_H_ +#include "js/StructuredClone.h" #include "nsWrapperCache.h" #include "nsISupports.h" #include "nsCycleCollectionParticipant.h" @@ -59,6 +60,10 @@ public: void ToJSON(DOMQuadJSON& aInit); + bool WriteStructuredClone(JSStructuredCloneWriter* aWriter) const; + + bool ReadStructuredClone(JSStructuredCloneReader* aReader); + protected: void GetHorizontalMinMax(double* aX1, double* aX2) const; void GetVerticalMinMax(double* aY1, double* aY2) const; diff --git a/dom/base/DOMRect.cpp b/dom/base/DOMRect.cpp index ecd56f10a7..46f395a083 100644 --- a/dom/base/DOMRect.cpp +++ b/dom/base/DOMRect.cpp @@ -36,6 +36,42 @@ DOMRectReadOnly::Constructor(const GlobalObject& aGlobal, double aX, double aY, return obj.forget(); } +// https://drafts.fxtf.org/geometry/#structured-serialization +bool +DOMRectReadOnly::WriteStructuredClone(JSStructuredCloneWriter* aWriter) const +{ +#define WriteDouble(d) \ + JS_WriteUint32Pair(aWriter, (BitwiseCast<uint64_t>(d) >> 32) & 0xffffffff, \ + BitwiseCast<uint64_t>(d) & 0xffffffff) + + return WriteDouble(mX) && WriteDouble(mY) && WriteDouble(mWidth) && + WriteDouble(mHeight); + +#undef WriteDouble +} + +bool +DOMRectReadOnly::ReadStructuredClone(JSStructuredCloneReader* aReader) +{ + uint32_t high; + uint32_t low; + +#define ReadDouble(d) \ + if (!JS_ReadUint32Pair(aReader, &high, &low)) { \ + return false; \ + } \ + (*(d) = BitwiseCast<double>(static_cast<uint64_t>(high) << 32 | low)) + + ReadDouble(&mX); + ReadDouble(&mY); + ReadDouble(&mWidth); + ReadDouble(&mHeight); + + return true; + +#undef ReadDouble +} + // ----------------------------------------------------------------------------- NS_IMPL_ISUPPORTS_INHERITED(DOMRect, DOMRectReadOnly, nsIDOMClientRect) diff --git a/dom/base/DOMRect.h b/dom/base/DOMRect.h index baf3268b20..56478f284c 100644 --- a/dom/base/DOMRect.h +++ b/dom/base/DOMRect.h @@ -6,6 +6,7 @@ #ifndef MOZILLA_DOMRECT_H_ #define MOZILLA_DOMRECT_H_ +#include "js/StructuredClone.h" #include "nsIDOMClientRect.h" #include "nsIDOMClientRectList.h" #include "nsTArray.h" @@ -91,6 +92,10 @@ public: return std::max(y, y + h); } + bool WriteStructuredClone(JSStructuredCloneWriter* aWriter) const; + + bool ReadStructuredClone(JSStructuredCloneReader* aReader); + protected: nsCOMPtr<nsISupports> mParent; double mX, mY, mWidth, mHeight; diff --git a/dom/base/StructuredCloneHolder.cpp b/dom/base/StructuredCloneHolder.cpp index 5ad8ebb688..71eab63138 100644 --- a/dom/base/StructuredCloneHolder.cpp +++ b/dom/base/StructuredCloneHolder.cpp @@ -11,6 +11,14 @@ #include "mozilla/dom/CryptoKey.h" #include "mozilla/dom/Directory.h" #include "mozilla/dom/DirectoryBinding.h" +#include "mozilla/dom/DOMMatrix.h" +#include "mozilla/dom/DOMMatrixBinding.h" +#include "mozilla/dom/DOMPoint.h" +#include "mozilla/dom/DOMPointBinding.h" +#include "mozilla/dom/DOMQuad.h" +#include "mozilla/dom/DOMQuadBinding.h" +#include "mozilla/dom/DOMRect.h" +#include "mozilla/dom/DOMRectBinding.h" #include "mozilla/dom/File.h" #include "mozilla/dom/FileList.h" #include "mozilla/dom/FileListBinding.h" @@ -355,7 +363,11 @@ StructuredCloneHolder::ReadFullySerializableObjects(JSContext* aCx, return ReadStructuredCloneImageData(aCx, aReader); } - if (aTag == SCTAG_DOM_WEBCRYPTO_KEY || aTag == SCTAG_DOM_URLSEARCHPARAMS) { + if (aTag == SCTAG_DOM_WEBCRYPTO_KEY || aTag == SCTAG_DOM_URLSEARCHPARAMS || + aTag == SCTAG_DOM_DOMPOINT || aTag == SCTAG_DOM_DOMPOINT_READONLY || + aTag == SCTAG_DOM_DOMRECT || aTag == SCTAG_DOM_DOMRECT_READONLY || + aTag == SCTAG_DOM_DOMQUAD || aTag == SCTAG_DOM_DOMMATRIX || + aTag == SCTAG_DOM_DOMMATRIX_READONLY) { nsIGlobalObject *global = xpc::NativeGlobal(JS::CurrentGlobalOrNull(aCx)); if (!global) { return nullptr; @@ -378,6 +390,57 @@ StructuredCloneHolder::ReadFullySerializableObjects(JSContext* aCx, } else { result = usp->WrapObject(aCx, nullptr); } + } else if (aTag == SCTAG_DOM_DOMPOINT) { + RefPtr<DOMPoint> domPoint = new DOMPoint(global); + if (!domPoint->ReadStructuredClone(aReader)) { + result = nullptr; + } else { + result = domPoint->WrapObject(aCx, nullptr); + } + } else if (aTag == SCTAG_DOM_DOMPOINT_READONLY) { + RefPtr<DOMPointReadOnly> domPoint = new DOMPointReadOnly(global); + if (!domPoint->ReadStructuredClone(aReader)) { + result = nullptr; + } else { + result = domPoint->WrapObject(aCx, nullptr); + } + } else if (aTag == SCTAG_DOM_DOMRECT) { + RefPtr<DOMRect> domRect = new DOMRect(global); + if (!domRect->ReadStructuredClone(aReader)) { + result = nullptr; + } else { + result = domRect->WrapObject(aCx, nullptr); + } + } else if (aTag == SCTAG_DOM_DOMRECT_READONLY) { + RefPtr<DOMRectReadOnly> domRect = new DOMRectReadOnly(global); + if (!domRect->ReadStructuredClone(aReader)) { + result = nullptr; + } else { + result = domRect->WrapObject(aCx, nullptr); + } + } else if (aTag == SCTAG_DOM_DOMQUAD) { + RefPtr<DOMQuad> domQuad = new DOMQuad(global); + if (!domQuad->ReadStructuredClone(aReader)) { + result = nullptr; + } else { + result = domQuad->WrapObject(aCx, nullptr); + } + } else if (aTag == SCTAG_DOM_DOMMATRIX) { + RefPtr<DOMMatrix> domMatrix = + DOMMatrix::ReadStructuredClone(global, aReader); + if (!domMatrix) { + result = nullptr; + } else { + result = domMatrix->WrapObject(aCx, nullptr); + } + } else if (aTag == SCTAG_DOM_DOMMATRIX_READONLY) { + RefPtr<DOMMatrixReadOnly> domMatrix = + DOMMatrixReadOnly::ReadStructuredClone(global, aReader); + if (!domMatrix) { + result = nullptr; + } else { + result = domMatrix->WrapObject(aCx, nullptr); + } } } return result; @@ -483,6 +546,75 @@ StructuredCloneHolder::WriteFullySerializableObjects(JSContext* aCx, } #endif + // Handle DOMPoint cloning + // Should be done before DOMPointeReadOnly check + // because every DOMPoint is also a DOMPointReadOnly + { + DOMPoint* domPoint = nullptr; + if (NS_SUCCEEDED(UNWRAP_OBJECT(DOMPoint, &obj, domPoint))) { + return JS_WriteUint32Pair(aWriter, SCTAG_DOM_DOMPOINT, 0) && + domPoint->WriteStructuredClone(aWriter); + } + } + + // Handle DOMPointReadOnly cloning + { + DOMPointReadOnly* domPoint = nullptr; + if (NS_SUCCEEDED(UNWRAP_OBJECT(DOMPointReadOnly, &obj, domPoint))) { + return JS_WriteUint32Pair(aWriter, SCTAG_DOM_DOMPOINT_READONLY, 0) && + domPoint->WriteStructuredClone(aWriter); + } + } + + // Handle DOMRect cloning + // Should be done before DOMRecteReadOnly check + // because every DOMRect is also a DOMRectReadOnly + { + DOMRect* domRect = nullptr; + if (NS_SUCCEEDED(UNWRAP_OBJECT(DOMRect, &obj, domRect))) { + return JS_WriteUint32Pair(aWriter, SCTAG_DOM_DOMRECT, 0) && + domRect->WriteStructuredClone(aWriter); + } + } + + // Handle DOMRectReadOnly cloning + { + DOMRectReadOnly* domRect = nullptr; + if (NS_SUCCEEDED(UNWRAP_OBJECT(DOMRectReadOnly, &obj, domRect))) { + return JS_WriteUint32Pair(aWriter, SCTAG_DOM_DOMRECT_READONLY, 0) && + domRect->WriteStructuredClone(aWriter); + } + } + + // Handle DOMQuad cloning + { + DOMQuad* domQuad = nullptr; + if (NS_SUCCEEDED(UNWRAP_OBJECT(DOMQuad, &obj, domQuad))) { + return JS_WriteUint32Pair(aWriter, SCTAG_DOM_DOMQUAD, 0) && + domQuad->WriteStructuredClone(aWriter); + } + } + + // Handle DOMMatrix cloning + // Should be done before DOMMatrixeReadOnly check + // because every DOMMatrix is also a DOMMatrixReadOnly + { + DOMMatrix* domMatrix = nullptr; + if (NS_SUCCEEDED(UNWRAP_OBJECT(DOMMatrix, &obj, domMatrix))) { + return JS_WriteUint32Pair(aWriter, SCTAG_DOM_DOMMATRIX, 0) && + domMatrix->WriteStructuredClone(aWriter); + } + } + + // Handle DOMMatrixReadOnly cloning + { + DOMMatrixReadOnly* domMatrix = nullptr; + if (NS_SUCCEEDED(UNWRAP_OBJECT(DOMMatrixReadOnly, &obj, domMatrix))) { + return JS_WriteUint32Pair(aWriter, SCTAG_DOM_DOMMATRIX_READONLY, 0) && + domMatrix->WriteStructuredClone(aWriter); + } + } + if (NS_IsMainThread() && xpc::IsReflector(obj)) { nsCOMPtr<nsISupports> base = xpc::UnwrapReflectorToISupports(obj); nsCOMPtr<nsIPrincipal> principal = do_QueryInterface(base); diff --git a/dom/base/StructuredCloneTags.h b/dom/base/StructuredCloneTags.h index 8766d8e4ad..09b91f7afb 100644 --- a/dom/base/StructuredCloneTags.h +++ b/dom/base/StructuredCloneTags.h @@ -30,6 +30,15 @@ enum StructuredCloneTags { // New IDB tags go here! + // Tags for Geometry interfaces. + SCTAG_DOM_DOMPOINT, + SCTAG_DOM_DOMPOINT_READONLY, + SCTAG_DOM_DOMQUAD, + SCTAG_DOM_DOMRECT, + SCTAG_DOM_DOMRECT_READONLY, + SCTAG_DOM_DOMMATRIX, + SCTAG_DOM_DOMMATRIX_READONLY, + // These tags are used for both main thread and workers. SCTAG_DOM_IMAGEDATA, SCTAG_DOM_MAP_MESSAGEPORT, |