|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "SpeechRecognitionError.h" |
|
7 |
|
8 namespace mozilla { |
|
9 namespace dom { |
|
10 |
|
11 SpeechRecognitionError::SpeechRecognitionError( |
|
12 mozilla::dom::EventTarget* aOwner, |
|
13 nsPresContext* aPresContext, |
|
14 WidgetEvent* aEvent) |
|
15 : Event(aOwner, aPresContext, aEvent) |
|
16 , mError() |
|
17 { |
|
18 } |
|
19 |
|
20 SpeechRecognitionError::~SpeechRecognitionError() {} |
|
21 |
|
22 already_AddRefed<SpeechRecognitionError> |
|
23 SpeechRecognitionError::Constructor(const GlobalObject& aGlobal, |
|
24 const nsAString& aType, |
|
25 const SpeechRecognitionErrorInit& aParam, |
|
26 ErrorResult& aRv) |
|
27 { |
|
28 nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports()); |
|
29 nsRefPtr<SpeechRecognitionError> e = new SpeechRecognitionError(t, nullptr, nullptr); |
|
30 bool trusted = e->Init(t); |
|
31 e->InitSpeechRecognitionError(aType, aParam.mBubbles, aParam.mCancelable, aParam.mError, aParam.mMessage, aRv); |
|
32 e->SetTrusted(trusted); |
|
33 return e.forget(); |
|
34 } |
|
35 |
|
36 void |
|
37 SpeechRecognitionError::InitSpeechRecognitionError(const nsAString& aType, |
|
38 bool aCanBubble, |
|
39 bool aCancelable, |
|
40 SpeechRecognitionErrorCode aError, |
|
41 const nsAString& aMessage, |
|
42 ErrorResult& aRv) |
|
43 { |
|
44 aRv = Event::InitEvent(aType, aCanBubble, aCancelable); |
|
45 NS_ENSURE_SUCCESS_VOID(aRv.ErrorCode()); |
|
46 |
|
47 mError = aError; |
|
48 mMessage = aMessage; |
|
49 return; |
|
50 } |
|
51 |
|
52 } // namespace dom |
|
53 } // namespace mozilla |