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
--- a/dom/base/DOMQuad.cpp
+++ b/dom/base/DOMQuad.cpp
@@ -10,17 +10,17 @@
#include "mozilla/dom/DOMPoint.h"
#include "mozilla/dom/DOMRect.h"
#include <algorithm>
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)
NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(DOMQuad, Release)
DOMQuad::DOMQuad(nsISupports* aParent, CSSPoint aPoints[4])
: mParent(aParent)
{
@@ -97,21 +97,39 @@ DOMQuad::GetVerticalMinMax(double* aY1,
double y = Point(i)->Y();
y1 = std::min(y1, y);
y2 = std::max(y2, y);
}
*aY1 = y1;
*aY2 = y2;
}
+DOMRectReadOnly*
+DOMQuad::Bounds()
+{
+ if (!mBounds) {
+ mBounds = GetBounds();
+ }
+ return mBounds;
+}
+
already_AddRefed<DOMRectReadOnly>
DOMQuad::GetBounds() const
{
double x1, x2;
double y1, y2;
GetHorizontalMinMax(&x1, &x2);
GetVerticalMinMax(&y1, &y2);
RefPtr<DOMRectReadOnly> rval = new DOMRectReadOnly(GetParentObject(),
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());
+}
--- a/dom/base/DOMQuad.h
+++ b/dom/base/DOMQuad.h
@@ -16,16 +16,17 @@
#include "mozilla/ErrorResult.h"
#include "Units.h"
namespace mozilla {
namespace dom {
class DOMRectReadOnly;
class DOMPoint;
+struct DOMQuadJSON;
struct DOMPointInit;
class DOMQuad final : public nsWrapperCache
{
~DOMQuad();
public:
DOMQuad(nsISupports* aParent, CSSPoint aPoints[4]);
@@ -43,28 +44,32 @@ public:
const DOMPointInit& aP2,
const DOMPointInit& aP3,
const DOMPointInit& aP4,
ErrorResult& aRV);
static already_AddRefed<DOMQuad>
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]; }
DOMPoint* P3() const { return mPoints[2]; }
DOMPoint* P4() const { return mPoints[3]; }
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
} // namespace mozilla
#endif /*MOZILLA_DOMRECT_H_*/
--- a/dom/base/nsDeprecatedOperationList.h
+++ b/dom/base/nsDeprecatedOperationList.h
@@ -43,8 +43,9 @@ DEPRECATED_OPERATION(RegisterProtocolHan
DEPRECATED_OPERATION(MixedDisplayObjectSubrequest)
DEPRECATED_OPERATION(MotionEvent)
DEPRECATED_OPERATION(OrientationEvent)
DEPRECATED_OPERATION(ProximityEvent)
DEPRECATED_OPERATION(AmbientLightEvent)
DEPRECATED_OPERATION(IDBOpenDBOptions_StorageType)
DEPRECATED_OPERATION(DOMAttrModifiedEvent)
DEPRECATED_OPERATION(MozBoxOrInlineBoxDisplay)
+DEPRECATED_OPERATION(DOMQuadBoundsAttr)
--- a/dom/locales/en-US/chrome/dom/dom.properties
+++ b/dom/locales/en-US/chrome/dom/dom.properties
@@ -353,8 +353,9 @@ ReadableStreamReadingFailed=Failed to read data from the ReadableStream: “%S”.
RegisterProtocolHandlerInsecureWarning=Use of the registerProtocolHandler for insecure connections will be removed in version 62.
MixedDisplayObjectSubrequestWarning=Loading insecure content within a plugin embedded in a secure connection is going to be removed.
MotionEventWarning=Use of the motion sensor is deprecated.
OrientationEventWarning=Use of the orientation sensor is deprecated.
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()
--- a/dom/webidl/DOMQuad.webidl
+++ b/dom/webidl/DOMQuad.webidl
@@ -16,10 +16,26 @@
Constructor(DOMRectReadOnly rect)]
interface DOMQuad {
[SameObject] readonly attribute DOMPoint p1;
[SameObject] readonly attribute DOMPoint p2;
[SameObject] readonly attribute DOMPoint p3;
[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;
+};
--- a/testing/web-platform/meta/css/geometry/historical.html.ini
+++ b/testing/web-platform/meta/css/geometry/historical.html.ini
@@ -1,15 +1,18 @@
[historical.html]
[DOMMatrixReadOnly scaleNonUniform must be nuked]
expected: FAIL
[DOMMatrix scaleNonUniformSelf must be nuked]
expected: FAIL
+ [DOMQuad bounds must be nuked]
+ expected: FAIL
+
[DOMMatrixReadOnly scale number of required arguments]
expected: FAIL
[DOMMatrix scaleSelf number of required arguments]
expected: FAIL
[DOMMatrixReadOnly translate number of required arguments]
expected: FAIL