diff options
author | Job Bautista <jobbautista9@aol.com> | 2023-05-12 11:42:59 +0800 |
---|---|---|
committer | Job Bautista <jobbautista9@aol.com> | 2023-05-12 16:26:05 +0800 |
commit | 286e18e40ca01418725b978e4cd140f085b63079 (patch) | |
tree | 391d8a6cfe75ccc702b6be316be111b2cc746351 /dom | |
parent | 4c2a1920b821645f1766dec320d83f1ffb97ce35 (diff) | |
download | uxp-286e18e40ca01418725b978e4cd140f085b63079.tar.gz |
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.
Diffstat (limited to 'dom')
-rw-r--r-- | dom/base/DOMQuad.cpp | 20 | ||||
-rw-r--r-- | dom/base/DOMQuad.h | 5 | ||||
-rw-r--r-- | dom/base/nsDeprecatedOperationList.h | 1 | ||||
-rw-r--r-- | dom/locales/en-US/chrome/dom/dom.properties | 1 | ||||
-rw-r--r-- | dom/webidl/DOMQuad.webidl | 18 |
5 files changed, 43 insertions, 2 deletions
diff --git a/dom/base/DOMQuad.cpp b/dom/base/DOMQuad.cpp index 2cf55e1b8b..a64c883982 100644 --- a/dom/base/DOMQuad.cpp +++ b/dom/base/DOMQuad.cpp @@ -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()); +} diff --git a/dom/base/DOMQuad.h b/dom/base/DOMQuad.h index 25cf7dbd06..db38e5d236 100644 --- a/dom/base/DOMQuad.h +++ b/dom/base/DOMQuad.h @@ -20,6 +20,7 @@ namespace dom { class DOMRectReadOnly; class DOMPoint; +struct DOMQuadJSON; struct DOMPointInit; class DOMQuad final : public nsWrapperCache @@ -47,6 +48,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]; } @@ -55,12 +57,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 diff --git a/dom/base/nsDeprecatedOperationList.h b/dom/base/nsDeprecatedOperationList.h index 0bae2d6211..bb9d8fd3b1 100644 --- a/dom/base/nsDeprecatedOperationList.h +++ b/dom/base/nsDeprecatedOperationList.h @@ -47,3 +47,4 @@ DEPRECATED_OPERATION(PrefixedFullscreenAPI) DEPRECATED_OPERATION(LenientSetter) DEPRECATED_OPERATION(FileLastModifiedDate) DEPRECATED_OPERATION(ImageBitmapRenderingContext_TransferImageBitmap) +DEPRECATED_OPERATION(DOMQuadBoundsAttr) diff --git a/dom/locales/en-US/chrome/dom/dom.properties b/dom/locales/en-US/chrome/dom/dom.properties index 60104a63ad..27b4eebf12 100644 --- a/dom/locales/en-US/chrome/dom/dom.properties +++ b/dom/locales/en-US/chrome/dom/dom.properties @@ -320,3 +320,4 @@ LargeAllocationNonE10S=A Large-Allocation header was ignored due to the document PushStateFloodingPrevented=Call to pushState or replaceState ignored due to excessive calls within a short timeframe. # LOCALIZATION NOTE: Do not translate "Reload" ReloadFloodingPrevented=Call to Reload ignored due to excessive calls within a short timeframe. +DOMQuadBoundsAttrWarning=DOMQuad.bounds is deprecated in favor of DOMQuad.getBounds() diff --git a/dom/webidl/DOMQuad.webidl b/dom/webidl/DOMQuad.webidl index f3674e9ad7..7370330b29 100644 --- a/dom/webidl/DOMQuad.webidl +++ b/dom/webidl/DOMQuad.webidl @@ -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; }; |