XRInputSourceArray.h (1664B)
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_XRInputSourceArray_h_ 8 #define mozilla_dom_XRInputSourceArray_h_ 9 10 #include "gfxVR.h" 11 #include "mozilla/DOMEventTargetHelper.h" 12 #include "mozilla/dom/WebXRBinding.h" 13 14 namespace mozilla { 15 namespace gfx { 16 struct VRControllerState; 17 } 18 namespace dom { 19 class XRInputSource; 20 21 class XRInputSourceArray final : public nsISupports, public nsWrapperCache { 22 public: 23 NS_DECL_CYCLE_COLLECTING_ISUPPORTS 24 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(XRInputSourceArray) 25 26 explicit XRInputSourceArray(nsISupports* aParent); 27 28 // WebIDL Boilerplate 29 nsISupports* GetParentObject() const { return mParent; } 30 JSObject* WrapObject(JSContext* aCx, 31 JS::Handle<JSObject*> aGivenProto) override; 32 33 // WebIDL Members 34 XRInputSource* IndexedGetter(uint32_t aIndex, bool& aFound); 35 uint32_t Length(); 36 void Setup(XRSession* aSession, RefPtr<gfx::VRDisplayClient> aDisplayClient); 37 void Update(XRSession* aSession); 38 void Clear(XRSession* aSession); 39 40 protected: 41 virtual ~XRInputSourceArray() = default; 42 43 private: 44 void DispatchInputSourceRemovedEvent( 45 const nsTArray<RefPtr<XRInputSource>>& aInputs, XRSession* aSession); 46 47 nsCOMPtr<nsISupports> mParent; 48 nsTArray<RefPtr<XRInputSource>> mInputSources; 49 }; 50 51 } // namespace dom 52 } // namespace mozilla 53 54 #endif // mozilla_dom_XRInputSourceArray_h_