Line data Source code
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 "VRDisplayEvent.h"
8 : #include "js/GCAPI.h"
9 : #include "mozilla/dom/Nullable.h"
10 : #include "mozilla/dom/PrimitiveConversions.h"
11 :
12 : using namespace mozilla::gfx;
13 :
14 : namespace mozilla {
15 : namespace dom {
16 :
17 : NS_IMPL_CYCLE_COLLECTION_CLASS(VRDisplayEvent)
18 :
19 0 : NS_IMPL_ADDREF_INHERITED(VRDisplayEvent, Event)
20 0 : NS_IMPL_RELEASE_INHERITED(VRDisplayEvent, Event)
21 :
22 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(VRDisplayEvent, Event)
23 0 : NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
24 :
25 0 : NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(VRDisplayEvent, Event)
26 0 : NS_IMPL_CYCLE_COLLECTION_TRACE_END
27 :
28 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(VRDisplayEvent, Event)
29 0 : NS_IMPL_CYCLE_COLLECTION_UNLINK_END
30 :
31 0 : NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(VRDisplayEvent)
32 0 : NS_INTERFACE_MAP_END_INHERITING(Event)
33 :
34 0 : VRDisplayEvent::VRDisplayEvent(mozilla::dom::EventTarget* aOwner)
35 0 : : Event(aOwner, nullptr, nullptr)
36 : {
37 0 : }
38 :
39 0 : VRDisplayEvent::~VRDisplayEvent()
40 : {
41 0 : }
42 :
43 : VRDisplay*
44 0 : VRDisplayEvent::Display()
45 : {
46 0 : return mDisplay;
47 : }
48 :
49 : JSObject*
50 0 : VRDisplayEvent::WrapObjectInternal(JSContext* aCx,
51 : JS::Handle<JSObject*> aGivenProto)
52 : {
53 0 : return VRDisplayEventBinding::Wrap(aCx, this, aGivenProto);
54 : }
55 :
56 : already_AddRefed<VRDisplayEvent>
57 0 : VRDisplayEvent::Constructor(mozilla::dom::EventTarget* aOwner,
58 : const nsAString& aType,
59 : const VRDisplayEventInit& aEventInitDict)
60 : {
61 0 : RefPtr<VRDisplayEvent> e = new VRDisplayEvent(aOwner);
62 0 : bool trusted = e->Init(aOwner);
63 0 : e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
64 0 : if (aEventInitDict.mReason.WasPassed()) {
65 0 : e->mReason = Some(aEventInitDict.mReason.Value());
66 : }
67 0 : e->mDisplay = aEventInitDict.mDisplay;
68 0 : e->SetTrusted(trusted);
69 0 : e->SetComposed(aEventInitDict.mComposed);
70 0 : return e.forget();
71 : }
72 :
73 : already_AddRefed<VRDisplayEvent>
74 0 : VRDisplayEvent::Constructor(const GlobalObject& aGlobal, const nsAString& aType,
75 : const VRDisplayEventInit& aEventInitDict,
76 : ErrorResult& aRv)
77 : {
78 0 : nsCOMPtr<mozilla::dom::EventTarget> owner = do_QueryInterface(aGlobal.GetAsSupports());
79 0 : return Constructor(owner, aType, aEventInitDict);
80 : }
81 :
82 : Nullable<VRDisplayEventReason>
83 0 : VRDisplayEvent::GetReason() const
84 : {
85 0 : if (mReason.isSome()) {
86 0 : return mReason.value();
87 : } else {
88 0 : return nullptr;
89 : }
90 :
91 : }
92 :
93 :
94 : } // namespace dom
95 : } // namespace mozilla
|