Issue #2241 - Part 4.2: Resurrect DOMQuad.bounds, but deprecated.

This also forces DOMQuad.toJSON() to only return the points.

Backported from Mozilla bug 1186265.
This commit is contained in:
Job Bautista 2023-05-12 11:42:59 +08:00 • committed by roytam1
commit 840658ab39
5 changed files with 43 additions and 2 deletions

View file

@ -14,7 +14,7 @@ using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::gfx;
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMQuad, mParent, mPoints[0],
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(DOMQuad, mParent, mBounds, mPoints[0],
mPoints[1], mPoints[2], mPoints[3])
NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(DOMQuad, AddRef)
@ -101,6 +101,15 @@ DOMQuad::GetVerticalMinMax(double* aY1, double* aY2) const
*aY2 = y2;
}
DOMRectReadOnly*
DOMQuad::Bounds()
{
if (!mBounds) {
mBounds = GetBounds();
}
return mBounds;
}
already_AddRefed<DOMRectReadOnly>
DOMQuad::GetBounds() const
{
@ -114,3 +123,12 @@ DOMQuad::GetBounds() const
x1, y1, x2 - x1, y2 - y1);
return rval.forget();
}
void
DOMQuad::ToJSON(DOMQuadJSON& aInit)
{
aInit.mP1.Construct(RefPtr<DOMPoint>(P1()).forget());
aInit.mP2.Construct(RefPtr<DOMPoint>(P2()).forget());
aInit.mP3.Construct(RefPtr<DOMPoint>(P3()).forget());
aInit.mP4.Construct(RefPtr<DOMPoint>(P4()).forget());
}