diff options
Diffstat (limited to 'dom/base/DOMQuad.h')
-rw-r--r-- | dom/base/DOMQuad.h | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/dom/base/DOMQuad.h b/dom/base/DOMQuad.h index 89d258a106..e32aea26f8 100644 --- a/dom/base/DOMQuad.h +++ b/dom/base/DOMQuad.h @@ -6,6 +6,7 @@ #ifndef MOZILLA_DOMQUAD_H_ #define MOZILLA_DOMQUAD_H_ +#include "js/StructuredClone.h" #include "nsWrapperCache.h" #include "nsISupports.h" #include "nsCycleCollectionParticipant.h" @@ -20,7 +21,10 @@ namespace dom { class DOMRectReadOnly; class DOMPoint; +struct DOMQuadJSON; struct DOMPointInit; +struct DOMQuadInit; +struct DOMRectInit; class DOMQuad final : public nsWrapperCache { @@ -37,6 +41,12 @@ public: virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override; static already_AddRefed<DOMQuad> + FromRect(const GlobalObject& aGlobal, const DOMRectInit& aInit); + + static already_AddRefed<DOMQuad> + FromQuad(const GlobalObject& aGlobal, const DOMQuadInit& aInit); + + static already_AddRefed<DOMQuad> Constructor(const GlobalObject& aGlobal, const DOMPointInit& aP1, const DOMPointInit& aP2, @@ -47,20 +57,28 @@ public: Constructor(const GlobalObject& aGlobal, const DOMRectReadOnly& aRect, ErrorResult& aRV); - DOMRectReadOnly* Bounds() const; + 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) { return mPoints[aIndex]; } + DOMPoint* Point(uint32_t aIndex) const { return mPoints[aIndex]; } + + void ToJSON(DOMQuadJSON& aInit); + + bool WriteStructuredClone(JSStructuredCloneWriter* aWriter) const; + + bool ReadStructuredClone(JSStructuredCloneReader* aReader); protected: - class QuadBounds; + void GetHorizontalMinMax(double* aX1, double* aX2) const; + void GetVerticalMinMax(double* aY1, double* aY2) const; nsCOMPtr<nsISupports> mParent; RefPtr<DOMPoint> mPoints[4]; - mutable RefPtr<QuadBounds> mBounds; // allocated lazily + RefPtr<DOMRectReadOnly> mBounds; }; } // namespace dom |