|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #ifndef nsDOMWindowUtils_h_ |
|
7 #define nsDOMWindowUtils_h_ |
|
8 |
|
9 #include "nsWeakReference.h" |
|
10 |
|
11 #include "nsIDOMWindowUtils.h" |
|
12 #include "mozilla/Attributes.h" |
|
13 #include "mozilla/BasicEvents.h" |
|
14 |
|
15 class nsGlobalWindow; |
|
16 class nsIPresShell; |
|
17 class nsIWidget; |
|
18 class nsPresContext; |
|
19 class nsPoint; |
|
20 class nsIDocument; |
|
21 |
|
22 namespace mozilla { |
|
23 namespace layers { |
|
24 class LayerTransactionChild; |
|
25 } |
|
26 } |
|
27 |
|
28 class nsTranslationNodeList MOZ_FINAL : public nsITranslationNodeList |
|
29 { |
|
30 public: |
|
31 nsTranslationNodeList() |
|
32 { |
|
33 mNodes.SetCapacity(1000); |
|
34 mNodeIsRoot.SetCapacity(1000); |
|
35 mLength = 0; |
|
36 } |
|
37 |
|
38 NS_DECL_ISUPPORTS |
|
39 NS_DECL_NSITRANSLATIONNODELIST |
|
40 |
|
41 void AppendElement(nsIDOMNode* aElement, bool aIsRoot) |
|
42 { |
|
43 mNodes.AppendElement(aElement); |
|
44 mNodeIsRoot.AppendElement(aIsRoot); |
|
45 mLength++; |
|
46 } |
|
47 |
|
48 private: |
|
49 nsTArray<nsCOMPtr<nsIDOMNode> > mNodes; |
|
50 nsTArray<bool> mNodeIsRoot; |
|
51 uint32_t mLength; |
|
52 }; |
|
53 |
|
54 class nsDOMWindowUtils MOZ_FINAL : public nsIDOMWindowUtils, |
|
55 public nsSupportsWeakReference |
|
56 { |
|
57 public: |
|
58 nsDOMWindowUtils(nsGlobalWindow *aWindow); |
|
59 ~nsDOMWindowUtils(); |
|
60 NS_DECL_ISUPPORTS |
|
61 NS_DECL_NSIDOMWINDOWUTILS |
|
62 |
|
63 protected: |
|
64 nsWeakPtr mWindow; |
|
65 |
|
66 // If aOffset is non-null, it gets filled in with the offset of the root |
|
67 // frame of our window to the nearest widget in the app units of our window. |
|
68 // Add this offset to any event offset we're given to make it relative to the |
|
69 // widget returned by GetWidget. |
|
70 nsIWidget* GetWidget(nsPoint* aOffset = nullptr); |
|
71 nsIWidget* GetWidgetForElement(nsIDOMElement* aElement); |
|
72 |
|
73 nsIPresShell* GetPresShell(); |
|
74 nsPresContext* GetPresContext(); |
|
75 nsIDocument* GetDocument(); |
|
76 mozilla::layers::LayerTransactionChild* GetLayerTransaction(); |
|
77 |
|
78 NS_IMETHOD SendMouseEventCommon(const nsAString& aType, |
|
79 float aX, |
|
80 float aY, |
|
81 int32_t aButton, |
|
82 int32_t aClickCount, |
|
83 int32_t aModifiers, |
|
84 bool aIgnoreRootScrollFrame, |
|
85 float aPressure, |
|
86 unsigned short aInputSourceArg, |
|
87 bool aToWindow, |
|
88 bool *aPreventDefault, |
|
89 bool aIsSynthesized); |
|
90 |
|
91 NS_IMETHOD SendTouchEventCommon(const nsAString& aType, |
|
92 uint32_t* aIdentifiers, |
|
93 int32_t* aXs, |
|
94 int32_t* aYs, |
|
95 uint32_t* aRxs, |
|
96 uint32_t* aRys, |
|
97 float* aRotationAngles, |
|
98 float* aForces, |
|
99 uint32_t aCount, |
|
100 int32_t aModifiers, |
|
101 bool aIgnoreRootScrollFrame, |
|
102 bool aToWindow, |
|
103 bool* aPreventDefault); |
|
104 |
|
105 |
|
106 static mozilla::Modifiers GetWidgetModifiers(int32_t aModifiers); |
|
107 }; |
|
108 |
|
109 #endif |