mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 00:38:39 +09:00
Issue #2241 - Part 5: Expose Geometry interfaces to web workers.
Exposes DOMMatrix, DOMPoint, DOMQuad, and DOMRect to workers. Backported from Mozilla bug 1420580.
This commit is contained in:
parent
69e45fd84e
commit
c3042a2f41
14 changed files with 404 additions and 16 deletions
|
|
@ -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()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -4,14 +4,15 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://dev.w3.org/fxtf/geometry/
|
||||
* https://drafts.fxtf.org/geometry/
|
||||
*
|
||||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
[Pref="layout.css.DOMMatrix.enabled",
|
||||
Constructor(optional (DOMString or sequence<unrestricted double>) init)]
|
||||
Constructor(optional (DOMString or sequence<unrestricted double>) init),
|
||||
Exposed=(Window,Worker)]
|
||||
interface DOMMatrixReadOnly {
|
||||
// These attributes are simple aliases for certain elements of the 4x4 matrix
|
||||
readonly attribute unrestricted double a;
|
||||
|
|
@ -77,7 +78,7 @@ interface DOMMatrixReadOnly {
|
|||
DOMPoint transformPoint(optional DOMPointInit point);
|
||||
[Throws] Float32Array toFloat32Array();
|
||||
[Throws] Float64Array toFloat64Array();
|
||||
stringifier;
|
||||
[Exposed=Window] stringifier;
|
||||
[Default] object toJSON();
|
||||
};
|
||||
|
||||
|
|
@ -87,7 +88,8 @@ interface DOMMatrixReadOnly {
|
|||
Constructor(DOMMatrixReadOnly other),
|
||||
Constructor(Float32Array array32),
|
||||
Constructor(Float64Array array64),
|
||||
Constructor(sequence<unrestricted double> numberSequence)]
|
||||
Constructor(sequence<unrestricted double> numberSequence),
|
||||
Exposed=(Window,Worker)]
|
||||
interface DOMMatrix : DOMMatrixReadOnly {
|
||||
// These attributes are simple aliases for certain elements of the 4x4 matrix
|
||||
inherit attribute unrestricted double a;
|
||||
|
|
@ -145,6 +147,6 @@ interface DOMMatrix : DOMMatrixReadOnly {
|
|||
DOMMatrix skewXSelf(unrestricted double sx);
|
||||
DOMMatrix skewYSelf(unrestricted double sy);
|
||||
DOMMatrix invertSelf();
|
||||
[Throws] DOMMatrix setMatrixValue(DOMString transformList);
|
||||
[Exposed=Window, Throws] DOMMatrix setMatrixValue(DOMString transformList);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://dev.w3.org/fxtf/geometry/
|
||||
* https://drafts.fxtf.org/geometry/
|
||||
*
|
||||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
|
|
@ -12,7 +12,8 @@
|
|||
|
||||
[Pref="layout.css.DOMPoint.enabled",
|
||||
Constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
|
||||
optional unrestricted double z = 0, optional unrestricted double w = 1)]
|
||||
optional unrestricted double z = 0, optional unrestricted double w = 1),
|
||||
Exposed=(Window,Worker)]
|
||||
interface DOMPointReadOnly {
|
||||
[NewObject] static DOMPointReadOnly fromPoint(optional DOMPointInit other);
|
||||
|
||||
|
|
@ -26,7 +27,8 @@ interface DOMPointReadOnly {
|
|||
|
||||
[Pref="layout.css.DOMPoint.enabled",
|
||||
Constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
|
||||
optional unrestricted double z = 0, optional unrestricted double w = 1)]
|
||||
optional unrestricted double z = 0, optional unrestricted double w = 1),
|
||||
Exposed=(Window,Worker)]
|
||||
interface DOMPoint : DOMPointReadOnly {
|
||||
[NewObject] static DOMPoint fromPoint(optional DOMPointInit other);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://dev.w3.org/fxtf/geometry/
|
||||
* https://drafts.fxtf.org/geometry/
|
||||
*
|
||||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
|
|
@ -13,7 +13,8 @@
|
|||
[Pref="layout.css.DOMQuad.enabled",
|
||||
Constructor(optional DOMPointInit p1, optional DOMPointInit p2,
|
||||
optional DOMPointInit p3, optional DOMPointInit p4),
|
||||
Constructor(DOMRectReadOnly rect)]
|
||||
Constructor(DOMRectReadOnly rect),
|
||||
Exposed=(Window,Worker)]
|
||||
interface DOMQuad {
|
||||
[SameObject] readonly attribute DOMPoint p1;
|
||||
[SameObject] readonly attribute DOMPoint p2;
|
||||
|
|
|
|||
|
|
@ -4,14 +4,15 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* http://dev.w3.org/fxtf/geometry/
|
||||
* https://drafts.fxtf.org/geometry/
|
||||
*
|
||||
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
|
||||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
[Constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
|
||||
optional unrestricted double width = 0, optional unrestricted double height = 0)]
|
||||
optional unrestricted double width = 0, optional unrestricted double height = 0),
|
||||
Exposed=(Window,Worker)]
|
||||
interface DOMRect : DOMRectReadOnly {
|
||||
inherit attribute unrestricted double x;
|
||||
inherit attribute unrestricted double y;
|
||||
|
|
@ -20,7 +21,8 @@ interface DOMRect : DOMRectReadOnly {
|
|||
};
|
||||
|
||||
[Constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
|
||||
optional unrestricted double width = 0, optional unrestricted double height = 0)]
|
||||
optional unrestricted double width = 0, optional unrestricted double height = 0),
|
||||
Exposed=(Window,Worker)]
|
||||
interface DOMRectReadOnly {
|
||||
readonly attribute unrestricted double x;
|
||||
readonly attribute unrestricted double y;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue