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/. */
7 #include "SpeechRecognitionError.h"
9 namespace mozilla::dom
{
11 SpeechRecognitionError::SpeechRecognitionError(
12 mozilla::dom::EventTarget
* aOwner
, nsPresContext
* aPresContext
,
14 : Event(aOwner
, aPresContext
, aEvent
), mError() {}
16 SpeechRecognitionError::~SpeechRecognitionError() = default;
18 already_AddRefed
<SpeechRecognitionError
> SpeechRecognitionError::Constructor(
19 const GlobalObject
& aGlobal
, const nsAString
& aType
,
20 const SpeechRecognitionErrorInit
& aParam
) {
21 nsCOMPtr
<mozilla::dom::EventTarget
> t
=
22 do_QueryInterface(aGlobal
.GetAsSupports());
23 RefPtr
<SpeechRecognitionError
> e
=
24 new SpeechRecognitionError(t
, nullptr, nullptr);
25 bool trusted
= e
->Init(t
);
26 e
->InitSpeechRecognitionError(aType
, aParam
.mBubbles
, aParam
.mCancelable
,
28 NS_ConvertUTF16toUTF8(aParam
.mMessage
));
29 e
->SetTrusted(trusted
);
30 e
->SetComposed(aParam
.mComposed
);
34 void SpeechRecognitionError::GetMessage(nsAString
& aString
) {
35 CopyUTF8toUTF16(mMessage
, aString
);
38 void SpeechRecognitionError::InitSpeechRecognitionError(
39 const nsAString
& aType
, bool aCanBubble
, bool aCancelable
,
40 SpeechRecognitionErrorCode aError
, const nsACString
& aMessage
) {
41 Event::InitEvent(aType
, aCanBubble
, aCancelable
);
46 } // namespace mozilla::dom