1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/base/DOMError.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,81 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozilla_dom_domerror_h__ 1.11 +#define mozilla_dom_domerror_h__ 1.12 + 1.13 +#include "mozilla/Attributes.h" 1.14 +#include "nsWrapperCache.h" 1.15 +#include "nsCOMPtr.h" 1.16 +#include "nsString.h" 1.17 +#include "nsPIDOMWindow.h" 1.18 + 1.19 +namespace mozilla { 1.20 + 1.21 +class ErrorResult; 1.22 + 1.23 +namespace dom { 1.24 + 1.25 +class GlobalObject; 1.26 + 1.27 +class DOMError : public nsISupports, 1.28 + public nsWrapperCache 1.29 +{ 1.30 + nsCOMPtr<nsPIDOMWindow> mWindow; 1.31 + nsString mName; 1.32 + nsString mMessage; 1.33 + 1.34 +public: 1.35 + NS_DECL_CYCLE_COLLECTING_ISUPPORTS 1.36 + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMError) 1.37 + 1.38 + // aWindow can be null if this DOMError is not associated with a particular 1.39 + // window. 1.40 + 1.41 + DOMError(nsPIDOMWindow* aWindow); 1.42 + 1.43 + DOMError(nsPIDOMWindow* aWindow, nsresult aValue); 1.44 + 1.45 + DOMError(nsPIDOMWindow* aWindow, const nsAString& aName); 1.46 + 1.47 + DOMError(nsPIDOMWindow* aWindow, const nsAString& aName, 1.48 + const nsAString& aMessage); 1.49 + 1.50 + virtual ~DOMError(); 1.51 + 1.52 + nsPIDOMWindow* GetParentObject() const 1.53 + { 1.54 + return mWindow; 1.55 + } 1.56 + 1.57 + virtual JSObject* 1.58 + WrapObject(JSContext* aCx) MOZ_OVERRIDE; 1.59 + 1.60 + static already_AddRefed<DOMError> 1.61 + Constructor(const GlobalObject& global, const nsAString& name, 1.62 + const nsAString& message, ErrorResult& aRv); 1.63 + 1.64 + void GetName(nsString& aRetval) const 1.65 + { 1.66 + aRetval = mName; 1.67 + } 1.68 + 1.69 + void GetMessage(nsString& aRetval) const 1.70 + { 1.71 + aRetval = mMessage; 1.72 + } 1.73 + 1.74 + void Init(const nsAString& aName, const nsAString& aMessage) 1.75 + { 1.76 + mName = aName; 1.77 + mMessage = aMessage; 1.78 + } 1.79 +}; 1.80 + 1.81 +} // namespace dom 1.82 +} // namespace mozilla 1.83 + 1.84 +#endif // mozilla_dom_domerror_h__