/src/mozilla-central/dom/vr/VRDisplayEvent.cpp
Line | Count | Source (jump to first uncovered line) |
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/RootingAPI.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 | | NS_IMPL_ADDREF_INHERITED(VRDisplayEvent, Event) |
20 | | 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(VRDisplayEvent) |
32 | 0 | NS_INTERFACE_MAP_END_INHERITING(Event) |
33 | | |
34 | | VRDisplayEvent::VRDisplayEvent(mozilla::dom::EventTarget* aOwner) |
35 | | : Event(aOwner, nullptr, nullptr) |
36 | 0 | { |
37 | 0 | } |
38 | | |
39 | | VRDisplay* |
40 | | VRDisplayEvent::Display() |
41 | 0 | { |
42 | 0 | return mDisplay; |
43 | 0 | } |
44 | | |
45 | | JSObject* |
46 | | VRDisplayEvent::WrapObjectInternal(JSContext* aCx, |
47 | | JS::Handle<JSObject*> aGivenProto) |
48 | 0 | { |
49 | 0 | return VRDisplayEvent_Binding::Wrap(aCx, this, aGivenProto); |
50 | 0 | } |
51 | | |
52 | | already_AddRefed<VRDisplayEvent> |
53 | | VRDisplayEvent::Constructor(mozilla::dom::EventTarget* aOwner, |
54 | | const nsAString& aType, |
55 | | const VRDisplayEventInit& aEventInitDict) |
56 | 0 | { |
57 | 0 | RefPtr<VRDisplayEvent> e = new VRDisplayEvent(aOwner); |
58 | 0 | bool trusted = e->Init(aOwner); |
59 | 0 | e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable); |
60 | 0 | if (aEventInitDict.mReason.WasPassed()) { |
61 | 0 | e->mReason = Some(aEventInitDict.mReason.Value()); |
62 | 0 | } |
63 | 0 | e->mDisplay = aEventInitDict.mDisplay; |
64 | 0 | e->SetTrusted(trusted); |
65 | 0 | e->SetComposed(aEventInitDict.mComposed); |
66 | 0 | return e.forget(); |
67 | 0 | } |
68 | | |
69 | | already_AddRefed<VRDisplayEvent> |
70 | | VRDisplayEvent::Constructor(const GlobalObject& aGlobal, const nsAString& aType, |
71 | | const VRDisplayEventInit& aEventInitDict, |
72 | | ErrorResult& aRv) |
73 | 0 | { |
74 | 0 | nsCOMPtr<mozilla::dom::EventTarget> owner = do_QueryInterface(aGlobal.GetAsSupports()); |
75 | 0 | return Constructor(owner, aType, aEventInitDict); |
76 | 0 | } |
77 | | |
78 | | Nullable<VRDisplayEventReason> |
79 | | VRDisplayEvent::GetReason() const |
80 | 0 | { |
81 | 0 | if (mReason.isSome()) { |
82 | 0 | return mReason.value(); |
83 | 0 | } |
84 | 0 | |
85 | 0 | return nullptr; |
86 | 0 | } |
87 | | |
88 | | |
89 | | } // namespace dom |
90 | | } // namespace mozilla |