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 "SpeechRecognitionError.h"
8
9 namespace mozilla {
10 namespace dom {
11
SpeechRecognitionError(mozilla::dom::EventTarget * aOwner,nsPresContext * aPresContext,WidgetEvent * aEvent)12 SpeechRecognitionError::SpeechRecognitionError(
13 mozilla::dom::EventTarget* aOwner, nsPresContext* aPresContext,
14 WidgetEvent* aEvent)
15 : Event(aOwner, aPresContext, aEvent), mError() {}
16
17 SpeechRecognitionError::~SpeechRecognitionError() = default;
18
Constructor(const GlobalObject & aGlobal,const nsAString & aType,const SpeechRecognitionErrorInit & aParam)19 already_AddRefed<SpeechRecognitionError> SpeechRecognitionError::Constructor(
20 const GlobalObject& aGlobal, const nsAString& aType,
21 const SpeechRecognitionErrorInit& aParam) {
22 nsCOMPtr<mozilla::dom::EventTarget> t =
23 do_QueryInterface(aGlobal.GetAsSupports());
24 RefPtr<SpeechRecognitionError> e =
25 new SpeechRecognitionError(t, nullptr, nullptr);
26 bool trusted = e->Init(t);
27 e->InitSpeechRecognitionError(aType, aParam.mBubbles, aParam.mCancelable,
28 aParam.mError, aParam.mMessage);
29 e->SetTrusted(trusted);
30 e->SetComposed(aParam.mComposed);
31 return e.forget();
32 }
33
InitSpeechRecognitionError(const nsAString & aType,bool aCanBubble,bool aCancelable,SpeechRecognitionErrorCode aError,const nsAString & aMessage)34 void SpeechRecognitionError::InitSpeechRecognitionError(
35 const nsAString& aType, bool aCanBubble, bool aCancelable,
36 SpeechRecognitionErrorCode aError, const nsAString& aMessage) {
37 Event::InitEvent(aType, aCanBubble, aCancelable);
38 mError = aError;
39 mMessage = aMessage;
40 }
41
42 } // namespace dom
43 } // namespace mozilla
44