Bug 1852740: add tests for the `fetchpriority` attribute in Link headers. r=necko...
[gecko.git] / dom / vr / VRDisplayEvent.cpp
blob4ef355dcb9000e31daa91082037fbb9afbbd843e
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/. */
7 #include "VRDisplayEvent.h"
8 #include "js/RootingAPI.h"
9 #include "mozilla/dom/Nullable.h"
10 #include "mozilla/dom/PrimitiveConversions.h"
12 using namespace mozilla::gfx;
14 namespace mozilla::dom {
16 NS_IMPL_CYCLE_COLLECTION_CLASS(VRDisplayEvent)
18 NS_IMPL_ADDREF_INHERITED(VRDisplayEvent, Event)
19 NS_IMPL_RELEASE_INHERITED(VRDisplayEvent, Event)
21 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(VRDisplayEvent, Event)
22 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
24 NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(VRDisplayEvent, Event)
25 NS_IMPL_CYCLE_COLLECTION_TRACE_END
27 NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(VRDisplayEvent, Event)
28 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
30 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(VRDisplayEvent)
31 NS_INTERFACE_MAP_END_INHERITING(Event)
33 VRDisplayEvent::VRDisplayEvent(mozilla::dom::EventTarget* aOwner)
34 : Event(aOwner, nullptr, nullptr) {}
36 VRDisplay* VRDisplayEvent::Display() { return mDisplay; }
38 JSObject* VRDisplayEvent::WrapObjectInternal(
39 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) {
40 return VRDisplayEvent_Binding::Wrap(aCx, this, aGivenProto);
43 already_AddRefed<VRDisplayEvent> VRDisplayEvent::Constructor(
44 mozilla::dom::EventTarget* aOwner, const nsAString& aType,
45 const VRDisplayEventInit& aEventInitDict) {
46 RefPtr<VRDisplayEvent> e = new VRDisplayEvent(aOwner);
47 bool trusted = e->Init(aOwner);
48 e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable);
49 if (aEventInitDict.mReason.WasPassed()) {
50 e->mReason = Some(aEventInitDict.mReason.Value());
52 e->mDisplay = aEventInitDict.mDisplay;
53 e->SetTrusted(trusted);
54 e->SetComposed(aEventInitDict.mComposed);
55 return e.forget();
58 already_AddRefed<VRDisplayEvent> VRDisplayEvent::Constructor(
59 const GlobalObject& aGlobal, const nsAString& aType,
60 const VRDisplayEventInit& aEventInitDict) {
61 nsCOMPtr<mozilla::dom::EventTarget> owner =
62 do_QueryInterface(aGlobal.GetAsSupports());
63 return Constructor(owner, aType, aEventInitDict);
66 Nullable<VRDisplayEventReason> VRDisplayEvent::GetReason() const {
67 if (mReason.isSome()) {
68 return mReason.value();
71 return nullptr;
74 } // namespace mozilla::dom