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 nsDOMWindowUtils_h_
8 #define nsDOMWindowUtils_h_
10 #include "nsWeakReference.h"
12 #include "nsIDOMWindowUtils.h"
13 #include "mozilla/Attributes.h"
14 #include "mozilla/BasicEvents.h"
15 #include "mozilla/Result.h"
17 class nsGlobalWindowOuter
;
31 class LayerTransactionChild
;
32 class WebRenderBridgeChild
;
34 } // namespace mozilla
36 class nsTranslationNodeList final
: public nsITranslationNodeList
{
38 nsTranslationNodeList() {
39 mNodes
.SetCapacity(1000);
40 mNodeIsRoot
.SetCapacity(1000);
45 NS_DECL_NSITRANSLATIONNODELIST
47 void AppendElement(nsINode
* aElement
, bool aIsRoot
) {
48 mNodes
.AppendElement(aElement
);
49 mNodeIsRoot
.AppendElement(aIsRoot
);
54 ~nsTranslationNodeList() = default;
56 nsTArray
<nsCOMPtr
<nsINode
> > mNodes
;
57 nsTArray
<bool> mNodeIsRoot
;
61 class nsDOMWindowUtils final
: public nsIDOMWindowUtils
,
62 public nsSupportsWeakReference
{
63 using TextEventDispatcher
= mozilla::widget::TextEventDispatcher
;
66 explicit nsDOMWindowUtils(nsGlobalWindowOuter
* aWindow
);
68 NS_DECL_NSIDOMWINDOWUTILS
75 // If aOffset is non-null, it gets filled in with the offset of the root
76 // frame of our window to the nearest widget in the app units of our window.
77 // Add this offset to any event offset we're given to make it relative to the
78 // widget returned by GetWidget.
79 nsIWidget
* GetWidget(nsPoint
* aOffset
= nullptr);
80 nsIWidget
* GetWidgetForElement(mozilla::dom::Element
* aElement
);
82 nsIDocShell
* GetDocShell();
83 mozilla::PresShell
* GetPresShell();
84 nsPresContext
* GetPresContext();
85 mozilla::dom::Document
* GetDocument();
86 mozilla::layers::WebRenderBridgeChild
* GetWebRenderBridge();
87 mozilla::layers::CompositorBridgeChild
* GetCompositorBridge();
89 // Until callers are annotated.
91 NS_IMETHOD
SendMouseEventCommon(
92 const nsAString
& aType
, float aX
, float aY
, int32_t aButton
,
93 int32_t aClickCount
, int32_t aModifiers
, bool aIgnoreRootScrollFrame
,
94 float aPressure
, unsigned short aInputSourceArg
, uint32_t aIdentifier
,
95 bool aToWindow
, bool* aPreventDefault
, bool aIsDOMEventSynthesized
,
96 bool aIsWidgetEventSynthesized
, int32_t aButtons
);
99 nsresult
SendTouchEventCommon(
100 const nsAString
& aType
, const nsTArray
<uint32_t>& aIdentifiers
,
101 const nsTArray
<int32_t>& aXs
, const nsTArray
<int32_t>& aYs
,
102 const nsTArray
<uint32_t>& aRxs
, const nsTArray
<uint32_t>& aRys
,
103 const nsTArray
<float>& aRotationAngles
, const nsTArray
<float>& aForces
,
104 const nsTArray
<int32_t>& aTiltXs
, const nsTArray
<int32_t>& aTiltYs
,
105 const nsTArray
<int32_t>& aTwists
, int32_t aModifiers
,
106 bool aIgnoreRootScrollFrame
, bool aIsPen
, bool aToWindow
,
107 bool* aPreventDefault
);
109 void ReportErrorMessageForWindow(const nsAString
& aErrorMessage
,
110 const char* aClassification
,
114 enum class CoordsType
{
118 mozilla::Result
<mozilla::LayoutDeviceRect
, nsresult
> ConvertTo(
119 float aX
, float aY
, float aWidth
, float aHeight
, CoordsType
);