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

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