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 #include "mozilla/dom/XRViewerPose.h"
8 #include "mozilla/dom/XRView.h"
9 
10 namespace mozilla {
11 namespace dom {
12 
13 NS_IMPL_CYCLE_COLLECTION_CLASS(XRViewerPose)
14 
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(XRViewerPose,XRPose)15 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(XRViewerPose, XRPose)
16   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mViews)
17 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
18 
19 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(XRViewerPose, XRPose)
20   NS_IMPL_CYCLE_COLLECTION_UNLINK(mViews)
21   // Don't need NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER because
22   // XRPose does it for us.
23 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
24 
25 NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED_0(XRViewerPose, XRPose)
26 
27 XRViewerPose::XRViewerPose(nsISupports* aParent, XRRigidTransform* aTransform,
28                            bool aEmulatedPosition,
29                            const nsTArray<RefPtr<XRView>>& aViews)
30     : XRPose(aParent, aTransform, aEmulatedPosition), mViews(aViews.Clone()) {}
31 
WrapObject(JSContext * aCx,JS::Handle<JSObject * > aGivenProto)32 JSObject* XRViewerPose::WrapObject(JSContext* aCx,
33                                    JS::Handle<JSObject*> aGivenProto) {
34   return XRViewerPose_Binding::Wrap(aCx, this, aGivenProto);
35 }
36 
GetEye(int32_t aIndex)37 RefPtr<XRView>& XRViewerPose::GetEye(int32_t aIndex) {
38   return mViews.ElementAt(aIndex);
39 }
40 
GetViews(nsTArray<RefPtr<XRView>> & aResult)41 void XRViewerPose::GetViews(nsTArray<RefPtr<XRView>>& aResult) {
42   aResult = mViews.Clone();
43 }
44 
45 }  // namespace dom
46 }  // namespace mozilla
47