/src/mozilla-central/dom/base/nsDOMWindowUtils.h
Line | Count | Source (jump to first uncovered line) |
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 nsDOMWindowUtils_h_ |
8 | | #define nsDOMWindowUtils_h_ |
9 | | |
10 | | #include "nsWeakReference.h" |
11 | | |
12 | | #include "nsIDOMWindowUtils.h" |
13 | | #include "mozilla/Attributes.h" |
14 | | #include "mozilla/BasicEvents.h" |
15 | | |
16 | | class nsGlobalWindowOuter; |
17 | | class nsIPresShell; |
18 | | class nsIWidget; |
19 | | class nsPresContext; |
20 | | class nsIDocument; |
21 | | class nsView; |
22 | | struct nsPoint; |
23 | | |
24 | | namespace mozilla { |
25 | | namespace dom { |
26 | | class Element; |
27 | | } // namespace dom |
28 | | namespace layers { |
29 | | class LayerTransactionChild; |
30 | | class WebRenderBridgeChild; |
31 | | } // namespace layers |
32 | | } // namespace mozilla |
33 | | |
34 | | class nsTranslationNodeList final : public nsITranslationNodeList |
35 | | { |
36 | | public: |
37 | | nsTranslationNodeList() |
38 | 0 | { |
39 | 0 | mNodes.SetCapacity(1000); |
40 | 0 | mNodeIsRoot.SetCapacity(1000); |
41 | 0 | mLength = 0; |
42 | 0 | } |
43 | | |
44 | | NS_DECL_ISUPPORTS |
45 | | NS_DECL_NSITRANSLATIONNODELIST |
46 | | |
47 | | void AppendElement(nsINode* aElement, bool aIsRoot) |
48 | 0 | { |
49 | 0 | mNodes.AppendElement(aElement); |
50 | 0 | mNodeIsRoot.AppendElement(aIsRoot); |
51 | 0 | mLength++; |
52 | 0 | } |
53 | | |
54 | | private: |
55 | 0 | ~nsTranslationNodeList() {} |
56 | | |
57 | | nsTArray<nsCOMPtr<nsINode> > mNodes; |
58 | | nsTArray<bool> mNodeIsRoot; |
59 | | uint32_t mLength; |
60 | | }; |
61 | | |
62 | | class nsDOMWindowUtils final : public nsIDOMWindowUtils, |
63 | | public nsSupportsWeakReference |
64 | | { |
65 | | typedef mozilla::widget::TextEventDispatcher |
66 | | TextEventDispatcher; |
67 | | public: |
68 | | explicit nsDOMWindowUtils(nsGlobalWindowOuter *aWindow); |
69 | | NS_DECL_ISUPPORTS |
70 | | NS_DECL_NSIDOMWINDOWUTILS |
71 | | |
72 | | protected: |
73 | | ~nsDOMWindowUtils(); |
74 | | |
75 | | nsWeakPtr mWindow; |
76 | | |
77 | | // If aOffset is non-null, it gets filled in with the offset of the root |
78 | | // frame of our window to the nearest widget in the app units of our window. |
79 | | // Add this offset to any event offset we're given to make it relative to the |
80 | | // widget returned by GetWidget. |
81 | | nsIWidget* GetWidget(nsPoint* aOffset = nullptr); |
82 | | nsIWidget* GetWidgetForElement(mozilla::dom::Element* aElement); |
83 | | |
84 | | nsIPresShell* GetPresShell(); |
85 | | nsPresContext* GetPresContext(); |
86 | | nsIDocument* GetDocument(); |
87 | | mozilla::layers::LayerTransactionChild* GetLayerTransaction(); |
88 | | mozilla::layers::WebRenderBridgeChild* GetWebRenderBridge(); |
89 | | |
90 | | // Until callers are annotated. |
91 | | MOZ_CAN_RUN_SCRIPT_BOUNDARY |
92 | | NS_IMETHOD SendMouseEventCommon(const nsAString& aType, |
93 | | float aX, |
94 | | float aY, |
95 | | int32_t aButton, |
96 | | int32_t aClickCount, |
97 | | int32_t aModifiers, |
98 | | bool aIgnoreRootScrollFrame, |
99 | | float aPressure, |
100 | | unsigned short aInputSourceArg, |
101 | | uint32_t aIdentifier, |
102 | | bool aToWindow, |
103 | | bool *aPreventDefault, |
104 | | bool aIsDOMEventSynthesized, |
105 | | bool aIsWidgetEventSynthesized, |
106 | | int32_t aButtons); |
107 | | |
108 | | NS_IMETHOD SendTouchEventCommon(const nsAString& aType, |
109 | | uint32_t* aIdentifiers, |
110 | | int32_t* aXs, |
111 | | int32_t* aYs, |
112 | | uint32_t* aRxs, |
113 | | uint32_t* aRys, |
114 | | float* aRotationAngles, |
115 | | float* aForces, |
116 | | uint32_t aCount, |
117 | | int32_t aModifiers, |
118 | | bool aIgnoreRootScrollFrame, |
119 | | bool aToWindow, |
120 | | bool* aPreventDefault); |
121 | | }; |
122 | | |
123 | | #endif |