/src/mozilla-central/dom/payments/PaymentMethodChangeEvent.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 |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "mozilla/dom/PaymentMethodChangeEvent.h" |
8 | | #include "mozilla/dom/PaymentRequestUpdateEvent.h" |
9 | | #include "mozilla/HoldDropJSObjects.h" |
10 | | |
11 | | namespace mozilla { |
12 | | namespace dom { |
13 | | |
14 | | NS_IMPL_CYCLE_COLLECTION_CLASS(PaymentMethodChangeEvent) |
15 | 0 | NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(PaymentMethodChangeEvent, |
16 | 0 | PaymentRequestUpdateEvent) |
17 | 0 | tmp->mMethodDetails = nullptr; |
18 | 0 | mozilla::DropJSObjects(this); |
19 | 0 | NS_IMPL_CYCLE_COLLECTION_UNLINK_END |
20 | | |
21 | 0 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(PaymentMethodChangeEvent, |
22 | 0 | PaymentRequestUpdateEvent) |
23 | 0 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END |
24 | | |
25 | 0 | NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(PaymentMethodChangeEvent, |
26 | 0 | PaymentRequestUpdateEvent) |
27 | 0 | NS_IMPL_CYCLE_COLLECTION_TRACE_JS_MEMBER_CALLBACK(mMethodDetails) |
28 | 0 | NS_IMPL_CYCLE_COLLECTION_TRACE_END |
29 | | |
30 | | NS_IMPL_ADDREF_INHERITED(PaymentMethodChangeEvent, PaymentRequestUpdateEvent) |
31 | | NS_IMPL_RELEASE_INHERITED(PaymentMethodChangeEvent, PaymentRequestUpdateEvent) |
32 | | |
33 | 0 | NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(PaymentMethodChangeEvent) |
34 | 0 | NS_INTERFACE_MAP_END_INHERITING(PaymentRequestUpdateEvent) |
35 | | |
36 | | already_AddRefed<PaymentMethodChangeEvent> |
37 | | PaymentMethodChangeEvent::Constructor( |
38 | | mozilla::dom::EventTarget* aOwner, |
39 | | const nsAString& aType, |
40 | | const PaymentMethodChangeEventInit& aEventInitDict) |
41 | 0 | { |
42 | 0 | RefPtr<PaymentMethodChangeEvent> e = new PaymentMethodChangeEvent(aOwner); |
43 | 0 | bool trusted = e->Init(aOwner); |
44 | 0 | e->InitEvent(aType, aEventInitDict.mBubbles, aEventInitDict.mCancelable); |
45 | 0 | e->SetTrusted(trusted); |
46 | 0 | e->SetComposed(aEventInitDict.mComposed); |
47 | 0 | e->init(aEventInitDict); |
48 | 0 | return e.forget(); |
49 | 0 | } |
50 | | |
51 | | already_AddRefed<PaymentMethodChangeEvent> |
52 | | PaymentMethodChangeEvent::Constructor( |
53 | | const GlobalObject& aGlobal, |
54 | | const nsAString& aType, |
55 | | const PaymentMethodChangeEventInit& aEventInitDict, |
56 | | ErrorResult& aRv) |
57 | 0 | { |
58 | 0 | nsCOMPtr<mozilla::dom::EventTarget> owner = |
59 | 0 | do_QueryInterface(aGlobal.GetAsSupports()); |
60 | 0 | return Constructor(owner, aType, aEventInitDict); |
61 | 0 | } |
62 | | |
63 | | PaymentMethodChangeEvent::PaymentMethodChangeEvent(EventTarget* aOwner) |
64 | | : PaymentRequestUpdateEvent(aOwner) |
65 | 0 | { |
66 | 0 | MOZ_ASSERT(aOwner); |
67 | 0 | mozilla::HoldJSObjects(this); |
68 | 0 | } |
69 | | |
70 | | void |
71 | | PaymentMethodChangeEvent::init( |
72 | | const PaymentMethodChangeEventInit& aEventInitDict) |
73 | 0 | { |
74 | 0 | mMethodName.Assign(aEventInitDict.mMethodName); |
75 | 0 | mMethodDetails = aEventInitDict.mMethodDetails; |
76 | 0 | } |
77 | | |
78 | | void |
79 | | PaymentMethodChangeEvent::GetMethodName(nsAString& aMethodName) |
80 | 0 | { |
81 | 0 | aMethodName.Assign(mMethodName); |
82 | 0 | } |
83 | | |
84 | | void |
85 | | PaymentMethodChangeEvent::GetMethodDetails(JSContext* cx, |
86 | | JS::MutableHandle<JSObject*> retval) |
87 | 0 | { |
88 | 0 | retval.set(mMethodDetails.get()); |
89 | 0 | } |
90 | | |
91 | | PaymentMethodChangeEvent::~PaymentMethodChangeEvent() |
92 | 0 | { |
93 | 0 | mozilla::DropJSObjects(this); |
94 | 0 | } |
95 | | |
96 | | JSObject* |
97 | | PaymentMethodChangeEvent::WrapObjectInternal(JSContext* aCx, |
98 | | JS::Handle<JSObject*> aGivenProto) |
99 | 0 | { |
100 | 0 | return PaymentMethodChangeEvent_Binding::Wrap(aCx, this, aGivenProto); |
101 | 0 | } |
102 | | |
103 | | } // namespace dom |
104 | | } // namespace mozilla |