From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- dom/base/DOMQuad.h | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 dom/base/DOMQuad.h (limited to 'dom/base/DOMQuad.h') diff --git a/dom/base/DOMQuad.h b/dom/base/DOMQuad.h new file mode 100644 index 0000000000..f6ca36f602 --- /dev/null +++ b/dom/base/DOMQuad.h @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef MOZILLA_DOMQUAD_H_ +#define MOZILLA_DOMQUAD_H_ + +#include +#include "Units.h" +#include "js/TypeDecls.h" +#include "mozilla/AlreadyAddRefed.h" +#include "mozilla/Assertions.h" +#include "mozilla/RefPtr.h" +#include "nsCOMPtr.h" +#include "nsCycleCollectionParticipant.h" +#include "nsISupports.h" +#include "nsWrapperCache.h" + +class JSObject; +class nsIGlobalObject; +struct JSContext; +struct JSStructuredCloneReader; +struct JSStructuredCloneWriter; + +namespace mozilla::dom { + +class DOMRectReadOnly; +class DOMPoint; +class GlobalObject; +struct DOMPointInit; +struct DOMQuadInit; +struct DOMRectInit; + +class DOMQuad final : public nsWrapperCache { + ~DOMQuad(); + + public: + DOMQuad(nsISupports* aParent, CSSPoint aPoints[4]); + explicit DOMQuad(nsISupports* aParent); + + NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(DOMQuad) + NS_DECL_CYCLE_COLLECTION_NATIVE_WRAPPERCACHE_CLASS(DOMQuad) + + nsISupports* GetParentObject() const { return mParent; } + virtual JSObject* WrapObject(JSContext* aCx, + JS::Handle aGivenProto) override; + + static already_AddRefed FromRect(const GlobalObject& aGlobal, + const DOMRectInit& aInit); + + static already_AddRefed FromQuad(const GlobalObject& aGlobal, + const DOMQuadInit& aInit); + + static already_AddRefed Constructor(const GlobalObject& aGlobal, + const DOMPointInit& aP1, + const DOMPointInit& aP2, + const DOMPointInit& aP3, + const DOMPointInit& aP4); + static already_AddRefed Constructor(const GlobalObject& aGlobal, + const DOMRectReadOnly& aRect); + + already_AddRefed 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]; } + + bool WriteStructuredClone(JSContext* aCx, + JSStructuredCloneWriter* aWriter) const; + + static already_AddRefed ReadStructuredClone( + JSContext* aCx, nsIGlobalObject* aGlobal, + JSStructuredCloneReader* aReader); + + protected: + void GetHorizontalMinMax(double* aX1, double* aX2) const; + void GetVerticalMinMax(double* aY1, double* aY2) const; + + nsCOMPtr mParent; + RefPtr mPoints[4]; +}; + +} // namespace mozilla::dom + +#endif /*MOZILLA_DOMRECT_H_*/ -- cgit v1.2.3