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:
Job Bautista 2023-05-12 13:45:39 +08:00 committed by roytam1
commit c3042a2f41
14 changed files with 404 additions and 16 deletions

View file

@ -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)