SpeechRecognitionError.h (1817B)
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 #ifndef SpeechRecognitionError_h__ 8 #define SpeechRecognitionError_h__ 9 10 #include "mozilla/dom/Event.h" 11 #include "mozilla/dom/SpeechRecognitionErrorBinding.h" 12 13 namespace mozilla::dom { 14 15 class SpeechRecognitionError : public Event { 16 public: 17 SpeechRecognitionError(mozilla::dom::EventTarget* aOwner, 18 nsPresContext* aPresContext, WidgetEvent* aEvent); 19 virtual ~SpeechRecognitionError(); 20 21 static already_AddRefed<SpeechRecognitionError> Constructor( 22 const GlobalObject& aGlobal, const nsAString& aType, 23 const SpeechRecognitionErrorInit& aParam); 24 25 virtual JSObject* WrapObjectInternal( 26 JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override { 27 return mozilla::dom::SpeechRecognitionError_Binding::Wrap(aCx, this, 28 aGivenProto); 29 } 30 31 void GetMessage(nsAString& aString); 32 33 SpeechRecognitionErrorCode Error() { return mError; } 34 // aMessage should be valid UTF-8, but invalid UTF-8 byte sequences are 35 // replaced with the REPLACEMENT CHARACTER on conversion to UTF-16. 36 void InitSpeechRecognitionError(const nsAString& aType, bool aCanBubble, 37 bool aCancelable, 38 SpeechRecognitionErrorCode aError, 39 const nsACString& aMessage); 40 41 protected: 42 SpeechRecognitionErrorCode mError; 43 nsCString mMessage; 44 }; 45 46 } // namespace mozilla::dom 47 48 #endif // SpeechRecognitionError_h__