Bug 1892041 - Part 1: Update test262 features. r=spidermonkey-reviewers,dminor
[gecko.git] / dom / base / DOMQuad.h
blobf6ca36f602ca9398f5501cdaa231e7cc7c7c711e
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef MOZILLA_DOMQUAD_H_
8 #define MOZILLA_DOMQUAD_H_
10 #include <cstdint>
11 #include "Units.h"
12 #include "js/TypeDecls.h"
13 #include "mozilla/AlreadyAddRefed.h"
14 #include "mozilla/Assertions.h"
15 #include "mozilla/RefPtr.h"
16 #include "nsCOMPtr.h"
17 #include "nsCycleCollectionParticipant.h"
18 #include "nsISupports.h"
19 #include "nsWrapperCache.h"
21 class JSObject;
22 class nsIGlobalObject;
23 struct JSContext;
24 struct JSStructuredCloneReader;
25 struct JSStructuredCloneWriter;
27 namespace mozilla::dom {
29 class DOMRectReadOnly;
30 class DOMPoint;
31 class GlobalObject;
32 struct DOMPointInit;
33 struct DOMQuadInit;
34 struct DOMRectInit;
36 class DOMQuad final : public nsWrapperCache {
37 ~DOMQuad();
39 public:
40 DOMQuad(nsISupports* aParent, CSSPoint aPoints[4]);
41 explicit DOMQuad(nsISupports* aParent);
43 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMQuad)
44 NS_DECL_CYCLE_COLLECTION_NATIVE_WRAPPERCACHE_CLASS(DOMQuad)
46 nsISupports* GetParentObject() const { return mParent; }
47 virtual JSObject* WrapObject(JSContext* aCx,
48 JS::Handle<JSObject*> aGivenProto) override;
50 static already_AddRefed<DOMQuad> FromRect(const GlobalObject& aGlobal,
51 const DOMRectInit& aInit);
53 static already_AddRefed<DOMQuad> FromQuad(const GlobalObject& aGlobal,
54 const DOMQuadInit& aInit);
56 static already_AddRefed<DOMQuad> Constructor(const GlobalObject& aGlobal,
57 const DOMPointInit& aP1,
58 const DOMPointInit& aP2,
59 const DOMPointInit& aP3,
60 const DOMPointInit& aP4);
61 static already_AddRefed<DOMQuad> Constructor(const GlobalObject& aGlobal,
62 const DOMRectReadOnly& aRect);
64 already_AddRefed<DOMRectReadOnly> GetBounds() const;
65 DOMPoint* P1() const { return mPoints[0]; }
66 DOMPoint* P2() const { return mPoints[1]; }
67 DOMPoint* P3() const { return mPoints[2]; }
68 DOMPoint* P4() const { return mPoints[3]; }
70 DOMPoint* Point(uint32_t aIndex) const { return mPoints[aIndex]; }
72 bool WriteStructuredClone(JSContext* aCx,
73 JSStructuredCloneWriter* aWriter) const;
75 static already_AddRefed<DOMQuad> ReadStructuredClone(
76 JSContext* aCx, nsIGlobalObject* aGlobal,
77 JSStructuredCloneReader* aReader);
79 protected:
80 void GetHorizontalMinMax(double* aX1, double* aX2) const;
81 void GetVerticalMinMax(double* aY1, double* aY2) const;
83 nsCOMPtr<nsISupports> mParent;
84 RefPtr<DOMPoint> mPoints[4];
87 } // namespace mozilla::dom
89 #endif /*MOZILLA_DOMRECT_H_*/