michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set ts=8 sts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "CallEvent.h" michael@0: #include "mozilla/dom/CallEventBinding.h" michael@0: michael@0: #include "TelephonyCall.h" michael@0: michael@0: using namespace mozilla::dom; michael@0: using mozilla::ErrorResult; michael@0: michael@0: /* static */ michael@0: already_AddRefed michael@0: CallEvent::Create(EventTarget* aOwner, const nsAString& aType, michael@0: TelephonyCall* aCall, bool aCanBubble, michael@0: bool aCancelable) michael@0: { michael@0: nsRefPtr event = new CallEvent(aOwner, nullptr, nullptr); michael@0: event->mCall = aCall; michael@0: event->InitEvent(aType, aCanBubble, aCancelable); michael@0: return event.forget(); michael@0: } michael@0: michael@0: JSObject* michael@0: CallEvent::WrapObject(JSContext* aCx) michael@0: { michael@0: return CallEventBinding::Wrap(aCx, this); michael@0: } michael@0: michael@0: NS_IMPL_CYCLE_COLLECTION_CLASS(CallEvent) michael@0: michael@0: NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(CallEvent, Event) michael@0: NS_IMPL_CYCLE_COLLECTION_UNLINK(mCall) michael@0: NS_IMPL_CYCLE_COLLECTION_UNLINK_END michael@0: michael@0: NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(CallEvent, Event) michael@0: NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCall) michael@0: NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END michael@0: michael@0: NS_IMPL_ADDREF_INHERITED(CallEvent, Event) michael@0: NS_IMPL_RELEASE_INHERITED(CallEvent, Event) michael@0: michael@0: NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(CallEvent) michael@0: NS_INTERFACE_MAP_END_INHERITING(Event) michael@0: michael@0: // WebIDL michael@0: michael@0: /* static */ michael@0: already_AddRefed michael@0: CallEvent::Constructor(const GlobalObject& aGlobal, const nsAString& aType, michael@0: const CallEventInit& aOptions, ErrorResult& aRv) michael@0: { michael@0: nsCOMPtr target = do_QueryInterface(aGlobal.GetAsSupports()); michael@0: michael@0: if (!target) { michael@0: aRv.Throw(NS_ERROR_UNEXPECTED); michael@0: return nullptr; michael@0: } michael@0: michael@0: nsRefPtr event = Create(target, aType, aOptions.mCall, false, false); michael@0: michael@0: return event.forget(); michael@0: } michael@0: michael@0: already_AddRefed michael@0: CallEvent::GetCall() const michael@0: { michael@0: nsRefPtr call = mCall; michael@0: return call.forget(); michael@0: }