Bug 1186265 - Resurrect DOMQuad.bounds (deprecated) and count its uses. r=bz

I've made the returned object from .bounds not live. If that's not OK, I'll
resurrect DOMBounds (removed in a previous patch). This also forces
DOMQuad.toJSON() to only return the points.

MozReview-Commit-ID: 10TY5oJUmTN

--HG--
extra : rebase_source : ab209d584390c584aa0d0814b4dd2bbf48c6cca3
This commit is contained in:
Blake Kaplan 2018-05-23 16:56:22 -07:00
parent aec5df4e02
commit 934317efc9
6 changed files with 46 additions and 2 deletions

View File

@ -15,7 +15,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)
@ -102,6 +102,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
{
@ -115,3 +124,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());
}

View File

@ -21,6 +21,7 @@ namespace dom {
class DOMRectReadOnly;
class DOMPoint;
struct DOMQuadJSON;
struct DOMPointInit;
class DOMQuad final : public nsWrapperCache
@ -48,6 +49,7 @@ public:
Constructor(const GlobalObject& aGlobal, const DOMRectReadOnly& aRect,
ErrorResult& aRV);
DOMRectReadOnly* Bounds();
already_AddRefed<DOMRectReadOnly> GetBounds() const;
DOMPoint* P1() const { return mPoints[0]; }
DOMPoint* P2() const { return mPoints[1]; }
@ -56,12 +58,15 @@ public:
DOMPoint* Point(uint32_t aIndex) const { return mPoints[aIndex]; }
void ToJSON(DOMQuadJSON& aInit);
protected:
void GetHorizontalMinMax(double* aX1, double* aX2) const;
void GetVerticalMinMax(double* aY1, double* aY2) const;
nsCOMPtr<nsISupports> mParent;
RefPtr<DOMPoint> mPoints[4];
RefPtr<DOMRectReadOnly> mBounds;
};
} // namespace dom

View File

@ -47,3 +47,4 @@ DEPRECATED_OPERATION(ProximityEvent)
DEPRECATED_OPERATION(AmbientLightEvent)
DEPRECATED_OPERATION(IDBOpenDBOptions_StorageType)
DEPRECATED_OPERATION(DOMAttrModifiedEvent)
DEPRECATED_OPERATION(DOMQuadBoundsAttr)

View File

@ -358,3 +358,4 @@ ProximityEventWarning=Use of the proximity sensor is deprecated.
AmbientLightEventWarning=Use of the ambient light sensor is deprecated.
# LOCALIZATION NOTE: Do not translate "storage", "indexedDB.open" and "navigator.storage.persist()".
IDBOpenDBOptions_StorageTypeWarning=The storage attribute in options passed to indexedDB.open is deprecated and will soon be removed. To get persistent storage, please use navigator.storage.persist() instead.
DOMQuadBoundsAttrWarning=DOMQuad.bounds is deprecated in favor of DOMQuad.getBounds()

View File

@ -21,5 +21,21 @@ interface DOMQuad {
[SameObject] readonly attribute DOMPoint p4;
[NewObject] DOMRectReadOnly getBounds();
[Default] object toJSON();
[SameObject, Deprecated=DOMQuadBoundsAttr] readonly attribute DOMRectReadOnly bounds;
DOMQuadJSON toJSON();
};
dictionary DOMQuadJSON {
DOMPoint p1;
DOMPoint p2;
DOMPoint p3;
DOMPoint p4;
};
dictionary DOMQuadInit {
DOMPointInit p1;
DOMPointInit p2;
DOMPointInit p3;
DOMPointInit p4;
};

View File

@ -5,6 +5,9 @@
[DOMMatrix scaleNonUniformSelf must be nuked]
expected: FAIL
[DOMQuad bounds must be nuked]
expected: FAIL
[DOMMatrixReadOnly scale number of required arguments]
expected: FAIL