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/. */
6 
7 #ifndef MOZILLA_GEOMETRYUTILS_H_
8 #define MOZILLA_GEOMETRYUTILS_H_
9 
10 #include "mozilla/ErrorResult.h"
11 #include "nsTArray.h"
12 #include "nsCOMPtr.h"
13 
14 /**
15  * This file defines utility functions for converting between layout
16  * coordinate systems.
17  */
18 
19 class nsINode;
20 
21 namespace mozilla {
22 
23 namespace dom {
24 struct BoxQuadOptions;
25 struct ConvertCoordinateOptions;
26 class DOMQuad;
27 class DOMRectReadOnly;
28 class DOMPoint;
29 struct DOMPointInit;
30 class OwningTextOrElementOrDocument;
31 class TextOrElementOrDocument;
32 enum class CallerType : uint32_t;
33 }  // namespace dom
34 
35 typedef dom::TextOrElementOrDocument GeometryNode;
36 typedef dom::OwningTextOrElementOrDocument OwningGeometryNode;
37 
38 /**
39  * Computes quads for aNode using aOptions, according to
40  * GeometryUtils.getBoxQuads. May set an error in aRv.
41  */
42 void GetBoxQuads(nsINode* aNode, const dom::BoxQuadOptions& aOptions,
43                  nsTArray<RefPtr<dom::DOMQuad> >& aResult,
44                  dom::CallerType aCallerType, ErrorResult& aRv);
45 
46 already_AddRefed<dom::DOMQuad> ConvertQuadFromNode(
47     nsINode* aTo, dom::DOMQuad& aQuad, const GeometryNode& aFrom,
48     const dom::ConvertCoordinateOptions& aOptions, dom::CallerType aCallerType,
49     ErrorResult& aRv);
50 
51 already_AddRefed<dom::DOMQuad> ConvertRectFromNode(
52     nsINode* aTo, dom::DOMRectReadOnly& aRect, const GeometryNode& aFrom,
53     const dom::ConvertCoordinateOptions& aOptions, dom::CallerType aCallerType,
54     ErrorResult& aRv);
55 
56 already_AddRefed<dom::DOMPoint> ConvertPointFromNode(
57     nsINode* aTo, const dom::DOMPointInit& aPoint, const GeometryNode& aFrom,
58     const dom::ConvertCoordinateOptions& aOptions, dom::CallerType aCallerType,
59     ErrorResult& aRv);
60 
61 }  // namespace mozilla
62 
63 #endif /* MOZILLA_GEOMETRYUTILS_H_ */
64