michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsDOMWindowUtils_h_ michael@0: #define nsDOMWindowUtils_h_ michael@0: michael@0: #include "nsWeakReference.h" michael@0: michael@0: #include "nsIDOMWindowUtils.h" michael@0: #include "mozilla/Attributes.h" michael@0: #include "mozilla/BasicEvents.h" michael@0: michael@0: class nsGlobalWindow; michael@0: class nsIPresShell; michael@0: class nsIWidget; michael@0: class nsPresContext; michael@0: class nsPoint; michael@0: class nsIDocument; michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: class LayerTransactionChild; michael@0: } michael@0: } michael@0: michael@0: class nsTranslationNodeList MOZ_FINAL : public nsITranslationNodeList michael@0: { michael@0: public: michael@0: nsTranslationNodeList() michael@0: { michael@0: mNodes.SetCapacity(1000); michael@0: mNodeIsRoot.SetCapacity(1000); michael@0: mLength = 0; michael@0: } michael@0: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSITRANSLATIONNODELIST michael@0: michael@0: void AppendElement(nsIDOMNode* aElement, bool aIsRoot) michael@0: { michael@0: mNodes.AppendElement(aElement); michael@0: mNodeIsRoot.AppendElement(aIsRoot); michael@0: mLength++; michael@0: } michael@0: michael@0: private: michael@0: nsTArray > mNodes; michael@0: nsTArray mNodeIsRoot; michael@0: uint32_t mLength; michael@0: }; michael@0: michael@0: class nsDOMWindowUtils MOZ_FINAL : public nsIDOMWindowUtils, michael@0: public nsSupportsWeakReference michael@0: { michael@0: public: michael@0: nsDOMWindowUtils(nsGlobalWindow *aWindow); michael@0: ~nsDOMWindowUtils(); michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSIDOMWINDOWUTILS michael@0: michael@0: protected: michael@0: nsWeakPtr mWindow; michael@0: michael@0: // If aOffset is non-null, it gets filled in with the offset of the root michael@0: // frame of our window to the nearest widget in the app units of our window. michael@0: // Add this offset to any event offset we're given to make it relative to the michael@0: // widget returned by GetWidget. michael@0: nsIWidget* GetWidget(nsPoint* aOffset = nullptr); michael@0: nsIWidget* GetWidgetForElement(nsIDOMElement* aElement); michael@0: michael@0: nsIPresShell* GetPresShell(); michael@0: nsPresContext* GetPresContext(); michael@0: nsIDocument* GetDocument(); michael@0: mozilla::layers::LayerTransactionChild* GetLayerTransaction(); michael@0: michael@0: NS_IMETHOD SendMouseEventCommon(const nsAString& aType, michael@0: float aX, michael@0: float aY, michael@0: int32_t aButton, michael@0: int32_t aClickCount, michael@0: int32_t aModifiers, michael@0: bool aIgnoreRootScrollFrame, michael@0: float aPressure, michael@0: unsigned short aInputSourceArg, michael@0: bool aToWindow, michael@0: bool *aPreventDefault, michael@0: bool aIsSynthesized); michael@0: michael@0: NS_IMETHOD SendTouchEventCommon(const nsAString& aType, michael@0: uint32_t* aIdentifiers, michael@0: int32_t* aXs, michael@0: int32_t* aYs, michael@0: uint32_t* aRxs, michael@0: uint32_t* aRys, michael@0: float* aRotationAngles, michael@0: float* aForces, michael@0: uint32_t aCount, michael@0: int32_t aModifiers, michael@0: bool aIgnoreRootScrollFrame, michael@0: bool aToWindow, michael@0: bool* aPreventDefault); michael@0: michael@0: michael@0: static mozilla::Modifiers GetWidgetModifiers(int32_t aModifiers); michael@0: }; michael@0: michael@0: #endif