Skip to content

Commit

Permalink
Bug 1186265 - Resurrect DOMQuad.bounds (deprecated) and count its use…
Browse files Browse the repository at this point in the history
…s. 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
mrbkap committed May 23, 2018
1 parent aec5df4 commit 934317e
Showing 6 changed files with 46 additions and 2 deletions.
20 changes: 19 additions & 1 deletion dom/base/DOMQuad.cpp
Original file line number Diff line number Diff line change
@@ -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());
}
5 changes: 5 additions & 0 deletions dom/base/DOMQuad.h
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ namespace dom {

class DOMRectReadOnly;
class DOMPoint;
struct DOMQuadJSON;
struct DOMPointInit;

class DOMQuad final : public nsWrapperCache
@@ -48,6 +49,7 @@ class DOMQuad final : public nsWrapperCache
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 @@ class DOMQuad final : public nsWrapperCache

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
1 change: 1 addition & 0 deletions dom/base/nsDeprecatedOperationList.h
Original file line number Diff line number Diff line change
@@ -47,3 +47,4 @@ DEPRECATED_OPERATION(ProximityEvent)
DEPRECATED_OPERATION(AmbientLightEvent)
DEPRECATED_OPERATION(IDBOpenDBOptions_StorageType)
DEPRECATED_OPERATION(DOMAttrModifiedEvent)
DEPRECATED_OPERATION(DOMQuadBoundsAttr)
1 change: 1 addition & 0 deletions dom/locales/en-US/chrome/dom/dom.properties
Original file line number Diff line number Diff line change
@@ -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()
18 changes: 17 additions & 1 deletion dom/webidl/DOMQuad.webidl
Original file line number Diff line number Diff line change
@@ -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;
};
3 changes: 3 additions & 0 deletions testing/web-platform/meta/css/geometry/historical.html.ini
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 934317e

Please sign in to comment.