dom/base/DOMError.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set ts=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 file,
     5  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 #ifndef mozilla_dom_domerror_h__
     8 #define mozilla_dom_domerror_h__
    10 #include "mozilla/Attributes.h"
    11 #include "nsWrapperCache.h"
    12 #include "nsCOMPtr.h"
    13 #include "nsString.h"
    14 #include "nsPIDOMWindow.h"
    16 namespace mozilla {
    18 class ErrorResult;
    20 namespace dom {
    22 class GlobalObject;
    24 class DOMError : public nsISupports,
    25                  public nsWrapperCache
    26 {
    27   nsCOMPtr<nsPIDOMWindow> mWindow;
    28   nsString mName;
    29   nsString mMessage;
    31 public:
    32   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
    33   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(DOMError)
    35   // aWindow can be null if this DOMError is not associated with a particular
    36   // window.
    38   DOMError(nsPIDOMWindow* aWindow);
    40   DOMError(nsPIDOMWindow* aWindow, nsresult aValue);
    42   DOMError(nsPIDOMWindow* aWindow, const nsAString& aName);
    44   DOMError(nsPIDOMWindow* aWindow, const nsAString& aName,
    45            const nsAString& aMessage);
    47   virtual ~DOMError();
    49   nsPIDOMWindow* GetParentObject() const
    50   {
    51     return mWindow;
    52   }
    54   virtual JSObject*
    55   WrapObject(JSContext* aCx) MOZ_OVERRIDE;
    57   static already_AddRefed<DOMError>
    58   Constructor(const GlobalObject& global, const nsAString& name,
    59               const nsAString& message, ErrorResult& aRv);
    61   void GetName(nsString& aRetval) const
    62   {
    63     aRetval = mName;
    64   }
    66   void GetMessage(nsString& aRetval) const
    67   {
    68     aRetval = mMessage;
    69   }
    71   void Init(const nsAString& aName, const nsAString& aMessage)
    72   {
    73     mName = aName;
    74     mMessage = aMessage;
    75   }
    76 };
    78 } // namespace dom
    79 } // namespace mozilla
    81 #endif // mozilla_dom_domerror_h__

mercurial