GamepadTouch.h (1728B)
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 file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_gamepad_GamepadTouch_h 8 #define mozilla_dom_gamepad_GamepadTouch_h 9 10 #include "mozilla/dom/GamepadTouchBinding.h" 11 #include "mozilla/dom/GamepadTouchState.h" 12 #include "nsWrapperCache.h" 13 14 namespace mozilla::dom { 15 16 class GamepadTouch final : public nsWrapperCache { 17 public: 18 explicit GamepadTouch(nsISupports* aParent); 19 20 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(GamepadTouch) 21 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(GamepadTouch) 22 23 nsISupports* GetParentObject() const { return mParent; } 24 virtual JSObject* WrapObject(JSContext* aCx, 25 JS::Handle<JSObject*> aGivenProto) override; 26 uint32_t TouchId() const { return mTouchState.touchId; } 27 uint32_t SurfaceId() const { return mTouchState.surfaceId; } 28 void GetPosition(JSContext* aCx, JS::MutableHandle<JSObject*> aRetval, 29 ErrorResult& aRv); 30 void GetSurfaceDimensions(JSContext* aCx, 31 JS::MutableHandle<JSObject*> aRetval, 32 ErrorResult& aRv); 33 void SetTouchState(const GamepadTouchState& aTouch); 34 void Set(const GamepadTouch* aOther); 35 36 private: 37 virtual ~GamepadTouch(); 38 39 nsCOMPtr<nsISupports> mParent; 40 JS::Heap<JSObject*> mPosition; 41 JS::Heap<JSObject*> mSurfaceDimensions; 42 GamepadTouchState mTouchState; 43 }; 44 45 } // namespace mozilla::dom 46 47 #endif // mozilla_dom_gamepad_GamepadTouch_h