Bug 975688 part.12 Rename nsDOMMessageEvent to mozilla::dom::MessageEvent r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 27 Feb 2014 19:51:14 +0900
changeset 171274 c2cd59ab0a41a29188c6e009e8e02f996ca23f8a
parent 171273 449bb2ddc4f1be5a37ed49f133f366a9a60e4a6a
child 171275 47dd7fd956290ff01881f3539b0755617ee904d7
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewerssmaug
bugs975688
milestone30.0a1
Bug 975688 part.12 Rename nsDOMMessageEvent to mozilla::dom::MessageEvent r=smaug
content/base/src/EventSource.cpp
dom/bindings/Bindings.conf
dom/events/MessageEvent.cpp
dom/events/MessageEvent.h
dom/events/moz.build
dom/events/nsDOMMessageEvent.cpp
dom/events/nsDOMMessageEvent.h
dom/workers/WorkerPrivate.cpp
--- a/content/base/src/EventSource.cpp
+++ b/content/base/src/EventSource.cpp
@@ -3,21 +3,21 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/dom/EventSource.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/dom/EventSourceBinding.h"
+#include "mozilla/dom/MessageEvent.h"
 
 #include "js/OldDebugAPI.h"
 #include "nsNetUtil.h"
 #include "nsMimeTypes.h"
-#include "nsDOMMessageEvent.h"
 #include "nsIPromptFactory.h"
 #include "nsIWindowWatcher.h"
 #include "nsPresContext.h"
 #include "nsContentPolicyUtils.h"
 #include "nsIStringBundle.h"
 #include "nsIConsoleService.h"
 #include "nsIObserverService.h"
 #include "nsIScriptObjectPrincipal.h"
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -737,20 +737,16 @@ DOMInterfaces = {
     'concrete': False
 },
 
 'MediaRecorder': {
     'headerFile': 'MediaRecorder.h',
     'resultNotAddRefed': [ 'stream' ]
 },
 
-'MessageEvent': {
-    'nativeType': 'nsDOMMessageEvent',
-},
-
 'MessagePort': {
     'nativeType': 'mozilla::dom::MessagePortBase',
     'headerFile': 'mozilla/dom/MessagePort.h',
     'binaryNames': {
         'postMessage': 'postMessageMoz',
     },
 },
 
rename from dom/events/nsDOMMessageEvent.cpp
rename to dom/events/MessageEvent.cpp
--- a/dom/events/nsDOMMessageEvent.cpp
+++ b/dom/events/MessageEvent.cpp
@@ -1,131 +1,129 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#include "nsDOMMessageEvent.h"
+#include "mozilla/dom/MessageEvent.h"
 #include "mozilla/dom/MessageEventBinding.h"
 #include "mozilla/dom/MessagePort.h"
 #include "mozilla/dom/MessagePortBinding.h"
 #include "mozilla/dom/MessagePortList.h"
 #include "mozilla/dom/UnionTypes.h"
 
 #include "mozilla/HoldDropJSObjects.h"
 #include "jsapi.h"
 
-using namespace mozilla;
-using namespace mozilla::dom;
+namespace mozilla {
+namespace dom {
 
-NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMMessageEvent)
+NS_IMPL_CYCLE_COLLECTION_CLASS(MessageEvent)
 
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMMessageEvent, nsDOMEvent)
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(MessageEvent, nsDOMEvent)
   tmp->mData = JSVAL_VOID;
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindowSource)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mPortSource)
   NS_IMPL_CYCLE_COLLECTION_UNLINK(mPorts)
 NS_IMPL_CYCLE_COLLECTION_UNLINK_END
 
-NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsDOMMessageEvent, nsDOMEvent)
+NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MessageEvent, nsDOMEvent)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindowSource)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPortSource)
   NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPorts)
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
 
-NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(nsDOMMessageEvent, nsDOMEvent)
+NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(MessageEvent, nsDOMEvent)
   NS_IMPL_CYCLE_COLLECTION_TRACE_JSVAL_MEMBER_CALLBACK(mData)
 NS_IMPL_CYCLE_COLLECTION_TRACE_END
 
-NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(nsDOMMessageEvent)
+NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(MessageEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMMessageEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
 
-NS_IMPL_ADDREF_INHERITED(nsDOMMessageEvent, nsDOMEvent)
-NS_IMPL_RELEASE_INHERITED(nsDOMMessageEvent, nsDOMEvent)
+NS_IMPL_ADDREF_INHERITED(MessageEvent, nsDOMEvent)
+NS_IMPL_RELEASE_INHERITED(MessageEvent, nsDOMEvent)
 
-nsDOMMessageEvent::nsDOMMessageEvent(mozilla::dom::EventTarget* aOwner,
-                                     nsPresContext* aPresContext,
-                                     WidgetEvent* aEvent)
-  : nsDOMEvent(aOwner, aPresContext, aEvent),
-    mData(JSVAL_VOID)
+MessageEvent::MessageEvent(EventTarget* aOwner,
+                           nsPresContext* aPresContext,
+                           WidgetEvent* aEvent)
+  : nsDOMEvent(aOwner, aPresContext, aEvent)
+  , mData(JSVAL_VOID)
 {
 }
 
-nsDOMMessageEvent::~nsDOMMessageEvent()
+MessageEvent::~MessageEvent()
 {
   mData = JSVAL_VOID;
-  mozilla::DropJSObjects(this);
+  DropJSObjects(this);
 }
 
 JSObject*
-nsDOMMessageEvent::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
+MessageEvent::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
 {
   return mozilla::dom::MessageEventBinding::Wrap(aCx, aScope, this);
 }
 
 NS_IMETHODIMP
-nsDOMMessageEvent::GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData)
+MessageEvent::GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData)
 {
   ErrorResult rv;
   aData.set(GetData(aCx, rv));
   return rv.ErrorCode();
 }
 
 JS::Value
-nsDOMMessageEvent::GetData(JSContext* aCx, ErrorResult& aRv)
+MessageEvent::GetData(JSContext* aCx, ErrorResult& aRv)
 {
   JS::Rooted<JS::Value> data(aCx, mData);
   if (!JS_WrapValue(aCx, &data)) {
     aRv.Throw(NS_ERROR_FAILURE);
   }
   return data;
 }
 
 NS_IMETHODIMP
-nsDOMMessageEvent::GetOrigin(nsAString& aOrigin)
+MessageEvent::GetOrigin(nsAString& aOrigin)
 {
   aOrigin = mOrigin;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMessageEvent::GetLastEventId(nsAString& aLastEventId)
+MessageEvent::GetLastEventId(nsAString& aLastEventId)
 {
   aLastEventId = mLastEventId;
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsDOMMessageEvent::GetSource(nsIDOMWindow** aSource)
+MessageEvent::GetSource(nsIDOMWindow** aSource)
 {
   NS_IF_ADDREF(*aSource = mWindowSource);
   return NS_OK;
 }
 
 void
-nsDOMMessageEvent::GetSource(Nullable<mozilla::dom::OwningWindowProxyOrMessagePort>& aValue) const
+MessageEvent::GetSource(Nullable<OwningWindowProxyOrMessagePort>& aValue) const
 {
   if (mWindowSource) {
     aValue.SetValue().SetAsWindowProxy() = mWindowSource;
   } else if (mPortSource) {
     aValue.SetValue().SetAsMessagePort() = mPortSource;
   }
 }
 
-/* static */ already_AddRefed<nsDOMMessageEvent>
-nsDOMMessageEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
-                               JSContext* aCx, const nsAString& aType,
-                               const mozilla::dom::MessageEventInit& aParam,
-                               mozilla::ErrorResult& aRv)
+/* static */ already_AddRefed<MessageEvent>
+MessageEvent::Constructor(const GlobalObject& aGlobal,
+                          JSContext* aCx, const nsAString& aType,
+                          const MessageEventInit& aParam,
+                          ErrorResult& aRv)
 {
-  nsCOMPtr<mozilla::dom::EventTarget> t =
-    do_QueryInterface(aGlobal.GetAsSupports());
-  nsRefPtr<nsDOMMessageEvent> event =
-    new nsDOMMessageEvent(t, nullptr, nullptr);
+  nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
+  nsRefPtr<MessageEvent> event = new MessageEvent(t, nullptr, nullptr);
 
   aRv = event->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
   if (aRv.Failed()) {
     return nullptr;
   }
 
   bool trusted = event->Init(t);
   event->SetTrusted(trusted);
@@ -161,45 +159,50 @@ nsDOMMessageEvent::Constructor(const moz
     event->mPorts = new MessagePortList(static_cast<nsDOMEventBase*>(event),
                                         ports);
   }
 
   return event.forget();
 }
 
 NS_IMETHODIMP
-nsDOMMessageEvent::InitMessageEvent(const nsAString& aType,
-                                    bool aCanBubble,
-                                    bool aCancelable,
-                                    JS::Handle<JS::Value> aData,
-                                    const nsAString& aOrigin,
-                                    const nsAString& aLastEventId,
-                                    nsIDOMWindow* aSource)
+MessageEvent::InitMessageEvent(const nsAString& aType,
+                               bool aCanBubble,
+                               bool aCancelable,
+                               JS::Handle<JS::Value> aData,
+                               const nsAString& aOrigin,
+                               const nsAString& aLastEventId,
+                               nsIDOMWindow* aSource)
 {
   nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
   NS_ENSURE_SUCCESS(rv, rv);
 
   mData = aData;
   mozilla::HoldJSObjects(this);
   mOrigin = aOrigin;
   mLastEventId = aLastEventId;
   mWindowSource = aSource;
 
   return NS_OK;
 }
 
 void
-nsDOMMessageEvent::SetPorts(mozilla::dom::MessagePortList* aPorts)
+MessageEvent::SetPorts(MessagePortList* aPorts)
 {
   MOZ_ASSERT(!mPorts && aPorts);
   mPorts = aPorts;
 }
 
+} // namespace dom
+} // namespace mozilla
+
+using namespace mozilla;
+using namespace mozilla::dom;
+
 nsresult
 NS_NewDOMMessageEvent(nsIDOMEvent** aInstancePtrResult,
-                      mozilla::dom::EventTarget* aOwner,
+                      EventTarget* aOwner,
                       nsPresContext* aPresContext,
                       WidgetEvent* aEvent) 
 {
-  nsDOMMessageEvent* it = new nsDOMMessageEvent(aOwner, aPresContext, aEvent);
-
+  MessageEvent* it = new MessageEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
rename from dom/events/nsDOMMessageEvent.h
rename to dom/events/MessageEvent.h
--- a/dom/events/nsDOMMessageEvent.h
+++ b/dom/events/MessageEvent.h
@@ -1,77 +1,79 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-#ifndef nsDOMMessageEvent_h__
-#define nsDOMMessageEvent_h__
+#ifndef mozilla_dom_MessageEvent_h_
+#define mozilla_dom_MessageEvent_h_
 
 #include "nsIDOMMessageEvent.h"
 #include "nsDOMEvent.h"
 #include "nsCycleCollectionParticipant.h"
 
 namespace mozilla {
 namespace dom {
+
 class MessageEventInit;
 class MessagePort;
 class MessagePortBase;
 class MessagePortList;
 class OwningWindowProxyOrMessagePort;
-}
-}
 
 /**
  * Implements the MessageEvent event, used for cross-document messaging and
  * server-sent events.
  *
  * See http://www.whatwg.org/specs/web-apps/current-work/#messageevent for
  * further details.
  */
-class nsDOMMessageEvent : public nsDOMEvent,
-                          public nsIDOMMessageEvent
+class MessageEvent : public nsDOMEvent,
+                     public nsIDOMMessageEvent
 {
 public:
-  nsDOMMessageEvent(mozilla::dom::EventTarget* aOwner,
-                    nsPresContext* aPresContext,
-                    mozilla::WidgetEvent* aEvent);
-  ~nsDOMMessageEvent();
+  MessageEvent(EventTarget* aOwner,
+               nsPresContext* aPresContext,
+               WidgetEvent* aEvent);
+  ~MessageEvent();
 
   NS_DECL_ISUPPORTS_INHERITED
-  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(nsDOMMessageEvent,
+  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MessageEvent,
                                                          nsDOMEvent)
 
   NS_DECL_NSIDOMMESSAGEEVENT
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMEVENT
 
   virtual JSObject* WrapObject(JSContext* aCx,
                                JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
 
-  JS::Value GetData(JSContext* aCx, mozilla::ErrorResult& aRv);
+  JS::Value GetData(JSContext* aCx, ErrorResult& aRv);
 
-  void GetSource(Nullable<mozilla::dom::OwningWindowProxyOrMessagePort>& aValue) const;
+  void GetSource(Nullable<OwningWindowProxyOrMessagePort>& aValue) const;
 
-  mozilla::dom::MessagePortList* GetPorts()
+  MessagePortList* GetPorts()
   {
     return mPorts;
   }
 
-  void SetPorts(mozilla::dom::MessagePortList* aPorts);
+  void SetPorts(MessagePortList* aPorts);
 
-  static already_AddRefed<nsDOMMessageEvent>
-  Constructor(const mozilla::dom::GlobalObject& aGlobal, JSContext* aCx,
+  static already_AddRefed<MessageEvent>
+  Constructor(const GlobalObject& aGlobal, JSContext* aCx,
               const nsAString& aType,
-              const mozilla::dom::MessageEventInit& aEventInit,
-              mozilla::ErrorResult& aRv);
+              const MessageEventInit& aEventInit,
+              ErrorResult& aRv);
 
 private:
   JS::Heap<JS::Value> mData;
   nsString mOrigin;
   nsString mLastEventId;
   nsCOMPtr<nsIDOMWindow> mWindowSource;
-  nsRefPtr<mozilla::dom::MessagePortBase> mPortSource;
-  nsRefPtr<mozilla::dom::MessagePortList> mPorts;
+  nsRefPtr<MessagePortBase> mPortSource;
+  nsRefPtr<MessagePortList> mPorts;
 };
 
-#endif // nsDOMMessageEvent_h__
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_MessageEvent_h_
--- a/dom/events/moz.build
+++ b/dom/events/moz.build
@@ -43,16 +43,17 @@ EXPORTS.mozilla.dom += [
     'CompositionEvent.h',
     'DataContainerEvent.h',
     'DataTransfer.h',
     'DeviceMotionEvent.h',
     'DragEvent.h',
     'EventTarget.h',
     'FocusEvent.h',
     'KeyboardEvent.h',
+    'MessageEvent.h',
     'PointerEvent.h',
     'Touch.h',
     'WheelEvent.h',
 ]
 
 if CONFIG['MOZ_WEBSPEECH']:
     EXPORTS.mozilla.dom += ['SpeechRecognitionError.h']
 
@@ -64,20 +65,20 @@ UNIFIED_SOURCES += [
     'CompositionEvent.cpp',
     'DataContainerEvent.cpp',
     'DataTransfer.cpp',
     'DeviceMotionEvent.cpp',
     'DragEvent.cpp',
     'EventTarget.cpp',
     'FocusEvent.cpp',
     'KeyboardEvent.cpp',
+    'MessageEvent.cpp',
     'nsAsyncDOMEvent.cpp',
     'nsContentEventHandler.cpp',
     'nsDOMEventTargetHelper.cpp',
-    'nsDOMMessageEvent.cpp',
     'nsDOMMouseEvent.cpp',
     'nsDOMMouseScrollEvent.cpp',
     'nsDOMMutationEvent.cpp',
     'nsDOMNotifyAudioAvailableEvent.cpp',
     'nsDOMSimpleGestureEvent.cpp',
     'nsDOMTextEvent.cpp',
     'nsDOMTouchEvent.cpp',
     'nsDOMTransitionEvent.cpp',
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -38,26 +38,26 @@
 #include "mozilla/Likely.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/ErrorEvent.h"
 #include "mozilla/dom/ErrorEventBinding.h"
 #include "mozilla/dom/Exceptions.h"
 #include "mozilla/dom/FunctionBinding.h"
 #include "mozilla/dom/ImageData.h"
 #include "mozilla/dom/ImageDataBinding.h"
+#include "mozilla/dom/MessageEvent.h"
 #include "mozilla/dom/MessageEventBinding.h"
 #include "mozilla/dom/MessagePortList.h"
 #include "mozilla/dom/WorkerBinding.h"
 #include "mozilla/Preferences.h"
 #include "nsAlgorithm.h"
 #include "nsContentUtils.h"
 #include "nsCxPusher.h"
 #include "nsError.h"
 #include "nsEventDispatcher.h"
-#include "nsDOMMessageEvent.h"
 #include "nsDOMJSUtils.h"
 #include "nsHostObjectProtocolHandler.h"
 #include "nsJSEnvironment.h"
 #include "nsJSUtils.h"
 #include "nsNetUtil.h"
 #include "nsPrintfCString.h"
 #include "nsProxyRelease.h"
 #include "nsSandboxFlags.h"
@@ -976,18 +976,17 @@ public:
 
     JS::Rooted<JS::Value> messageData(aCx);
     if (!mBuffer.read(aCx, &messageData,
                       workers::WorkerStructuredCloneCallbacks(aIsMainThread))) {
       xpc::Throw(aCx, NS_ERROR_DOM_DATA_CLONE_ERR);
       return false;
     }
 
-    nsRefPtr<nsDOMMessageEvent> event =
-      new nsDOMMessageEvent(aTarget, nullptr, nullptr);
+    nsRefPtr<MessageEvent> event = new MessageEvent(aTarget, nullptr, nullptr);
     nsresult rv =
       event->InitMessageEvent(NS_LITERAL_STRING("message"),
                               false /* non-bubbling */,
                               true /* cancelable */,
                               messageData,
                               EmptyString(),
                               EmptyString(),
                               nullptr);
@@ -2788,19 +2787,17 @@ WorkerPrivateParent<Derived>::DispatchMe
 
   JS::Rooted<JS::Value> data(cx);
   if (!buffer.read(cx, &data, WorkerStructuredCloneCallbacks(true))) {
     return false;
   }
 
   buffer.clear();
 
-  nsRefPtr<nsDOMMessageEvent> event =
-    new nsDOMMessageEvent(port, nullptr, nullptr);
-
+  nsRefPtr<MessageEvent> event = new MessageEvent(port, nullptr, nullptr);
   nsresult rv =
     event->InitMessageEvent(NS_LITERAL_STRING("message"), false, false, data,
                             EmptyString(), EmptyString(), nullptr);
   if (NS_FAILED(rv)) {
     xpc::Throw(cx, rv);
     return false;
   }
 
@@ -5733,19 +5730,19 @@ WorkerPrivate::ConnectMessagePort(JSCont
 
   RootedDictionary<MessageEventInit> init(aCx);
   init.mBubbles = false;
   init.mCancelable = false;
   init.mSource.SetValue().SetAsMessagePort() = port;
 
   ErrorResult rv;
 
-  nsRefPtr<nsDOMMessageEvent> event =
-    nsDOMMessageEvent::Constructor(globalObject, aCx,
-                                   NS_LITERAL_STRING("connect"), init, rv);
+  nsRefPtr<MessageEvent> event =
+    MessageEvent::Constructor(globalObject, aCx,
+                              NS_LITERAL_STRING("connect"), init, rv);
 
   event->SetTrusted(true);
 
   nsTArray<nsRefPtr<MessagePortBase>> ports;
   ports.AppendElement(port);
 
   nsRefPtr<MessagePortList> portList =
     new MessagePortList(static_cast<nsIDOMEventTarget*>(globalScope), ports);