1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/events/SpeechRecognitionError.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,53 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "SpeechRecognitionError.h" 1.10 + 1.11 +namespace mozilla { 1.12 +namespace dom { 1.13 + 1.14 +SpeechRecognitionError::SpeechRecognitionError( 1.15 + mozilla::dom::EventTarget* aOwner, 1.16 + nsPresContext* aPresContext, 1.17 + WidgetEvent* aEvent) 1.18 + : Event(aOwner, aPresContext, aEvent) 1.19 + , mError() 1.20 +{ 1.21 +} 1.22 + 1.23 +SpeechRecognitionError::~SpeechRecognitionError() {} 1.24 + 1.25 +already_AddRefed<SpeechRecognitionError> 1.26 +SpeechRecognitionError::Constructor(const GlobalObject& aGlobal, 1.27 + const nsAString& aType, 1.28 + const SpeechRecognitionErrorInit& aParam, 1.29 + ErrorResult& aRv) 1.30 +{ 1.31 + nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports()); 1.32 + nsRefPtr<SpeechRecognitionError> e = new SpeechRecognitionError(t, nullptr, nullptr); 1.33 + bool trusted = e->Init(t); 1.34 + e->InitSpeechRecognitionError(aType, aParam.mBubbles, aParam.mCancelable, aParam.mError, aParam.mMessage, aRv); 1.35 + e->SetTrusted(trusted); 1.36 + return e.forget(); 1.37 +} 1.38 + 1.39 +void 1.40 +SpeechRecognitionError::InitSpeechRecognitionError(const nsAString& aType, 1.41 + bool aCanBubble, 1.42 + bool aCancelable, 1.43 + SpeechRecognitionErrorCode aError, 1.44 + const nsAString& aMessage, 1.45 + ErrorResult& aRv) 1.46 +{ 1.47 + aRv = Event::InitEvent(aType, aCanBubble, aCancelable); 1.48 + NS_ENSURE_SUCCESS_VOID(aRv.ErrorCode()); 1.49 + 1.50 + mError = aError; 1.51 + mMessage = aMessage; 1.52 + return; 1.53 +} 1.54 + 1.55 +} // namespace dom 1.56 +} // namespace mozilla