Bug 920377 part.8 Get rid of nsClipboardEvent r=roc
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 27 Sep 2013 15:20:55 +0900
changeset 148952 103d145e68c09368cf73bf58caedb97ad3eb176a
parent 148951 99e55a7040fad62d3a60e2c488cca941cddf60c8
child 148953 65a887bb7f110bacdeaf3c39c5092ac7f7066f39
push id25366
push userkwierso@gmail.com
push dateSat, 28 Sep 2013 02:13:38 +0000
treeherdermozilla-central@e1914e294152 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs920377
milestone27.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 920377 part.8 Get rid of nsClipboardEvent r=roc
content/base/src/nsCopySupport.cpp
content/events/src/nsDOMClipboardEvent.cpp
content/events/src/nsDOMClipboardEvent.h
content/events/src/nsDOMEvent.cpp
content/events/src/nsEventDispatcher.cpp
dom/interfaces/events/nsIDOMEvent.idl
widget/ContentEvents.h
widget/EventForwards.h
--- a/content/base/src/nsCopySupport.cpp
+++ b/content/base/src/nsCopySupport.cpp
@@ -644,17 +644,17 @@ nsCopySupport::FireClipboardEvent(int32_
   // next, fire the cut, copy or paste event
   // XXXndeakin Bug 844941 - why was a preference added here without a running-in-chrome check?
   bool doDefault = true;
   nsRefPtr<nsDOMDataTransfer> clipboardData;
   if (Preferences::GetBool("dom.event.clipboardevents.enabled", true)) {
     clipboardData = new nsDOMDataTransfer(aType, aType == NS_PASTE, aClipboardType);
 
     nsEventStatus status = nsEventStatus_eIgnore;
-    nsClipboardEvent evt(true, aType);
+    InternalClipboardEvent evt(true, aType);
     evt.clipboardData = clipboardData;
     nsEventDispatcher::Dispatch(content, presShell->GetPresContext(), &evt, nullptr,
                                 &status);
     // If the event was cancelled, don't do the clipboard operation
     doDefault = (status != nsEventStatus_eConsumeNoDefault);
   }
   
   // No need to do anything special during a paste. Either an event listener
--- a/content/events/src/nsDOMClipboardEvent.cpp
+++ b/content/events/src/nsDOMClipboardEvent.cpp
@@ -3,34 +3,36 @@
  * 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 "nsDOMClipboardEvent.h"
 #include "nsDOMDataTransfer.h"
 #include "nsIClipboard.h"
 #include "mozilla/ContentEvents.h"
 
+using namespace mozilla;
+
 nsDOMClipboardEvent::nsDOMClipboardEvent(mozilla::dom::EventTarget* aOwner,
                                          nsPresContext* aPresContext,
-                                         nsClipboardEvent* aEvent)
+                                         InternalClipboardEvent* aEvent)
   : nsDOMEvent(aOwner, aPresContext, aEvent ? aEvent :
-               new nsClipboardEvent(false, 0))
+               new InternalClipboardEvent(false, 0))
 {
   if (aEvent) {
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
     mEvent->time = PR_Now();
   }
 }
 
 nsDOMClipboardEvent::~nsDOMClipboardEvent()
 {
   if (mEventIsInternal && mEvent->eventStructType == NS_CLIPBOARD_EVENT) {
-    delete static_cast<nsClipboardEvent*>(mEvent);
+    delete static_cast<InternalClipboardEvent*>(mEvent);
     mEvent = nullptr;
   }
 }
 
 NS_INTERFACE_MAP_BEGIN(nsDOMClipboardEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMClipboardEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
 
@@ -39,17 +41,17 @@ NS_IMPL_RELEASE_INHERITED(nsDOMClipboard
 
 nsresult
 nsDOMClipboardEvent::InitClipboardEvent(const nsAString & aType, bool aCanBubble, bool aCancelable,
                                         nsIDOMDataTransfer* clipboardData)
 {
   nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  nsClipboardEvent* event = static_cast<nsClipboardEvent*>(mEvent);
+  InternalClipboardEvent* event = static_cast<InternalClipboardEvent*>(mEvent);
   event->clipboardData = clipboardData;
 
   return NS_OK;
 }
 
 already_AddRefed<nsDOMClipboardEvent>
 nsDOMClipboardEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
                                  const nsAString& aType,
@@ -58,17 +60,18 @@ nsDOMClipboardEvent::Constructor(const m
 {
   nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
   nsRefPtr<nsDOMClipboardEvent> e =
     new nsDOMClipboardEvent(t, nullptr, nullptr);
   bool trusted = e->Init(t);
 
   nsRefPtr<nsDOMDataTransfer> clipboardData;
   if (e->mEventIsInternal) {
-    nsClipboardEvent* event = static_cast<nsClipboardEvent*>(e->mEvent);
+    InternalClipboardEvent* event =
+      static_cast<InternalClipboardEvent*>(e->mEvent);
     if (event) {
       // Always create a clipboardData for the copy event. If this is changed to
       // support other types of events, make sure that read/write privileges are
       // checked properly within nsDOMDataTransfer.
       clipboardData = new nsDOMDataTransfer(NS_COPY, false, -1);
       clipboardData->SetData(aParam.mDataType, aParam.mData);
     }
   }
@@ -84,31 +87,31 @@ nsDOMClipboardEvent::GetClipboardData(ns
 {
   NS_IF_ADDREF(*aClipboardData = GetClipboardData());
   return NS_OK;
 }
 
 nsIDOMDataTransfer*
 nsDOMClipboardEvent::GetClipboardData()
 {
-  nsClipboardEvent* event = static_cast<nsClipboardEvent*>(mEvent);
+  InternalClipboardEvent* event = static_cast<InternalClipboardEvent*>(mEvent);
 
   if (!event->clipboardData) {
     if (mEventIsInternal) {
       event->clipboardData = new nsDOMDataTransfer(NS_COPY, false, -1);
     } else {
       event->clipboardData =
         new nsDOMDataTransfer(event->message, event->message == NS_PASTE, nsIClipboard::kGlobalClipboard);
     }
   }
 
   return event->clipboardData;
 }
 
 nsresult NS_NewDOMClipboardEvent(nsIDOMEvent** aInstancePtrResult,
                                  mozilla::dom::EventTarget* aOwner,
                                  nsPresContext* aPresContext,
-                                 nsClipboardEvent *aEvent)
+                                 InternalClipboardEvent* aEvent)
 {
   nsDOMClipboardEvent* it =
     new nsDOMClipboardEvent(aOwner, aPresContext, aEvent);
   return CallQueryInterface(it, aInstancePtrResult);
 }
--- a/content/events/src/nsDOMClipboardEvent.h
+++ b/content/events/src/nsDOMClipboardEvent.h
@@ -12,17 +12,17 @@
 #include "mozilla/dom/ClipboardEventBinding.h"
 
 class nsDOMClipboardEvent : public nsDOMEvent,
                             public nsIDOMClipboardEvent
 {
 public:
   nsDOMClipboardEvent(mozilla::dom::EventTarget* aOwner,
                       nsPresContext* aPresContext,
-                      nsClipboardEvent* aEvent);
+                      mozilla::InternalClipboardEvent* aEvent);
   virtual ~nsDOMClipboardEvent();
 
   NS_DECL_ISUPPORTS_INHERITED
 
   NS_DECL_NSIDOMCLIPBOARDEVENT
 
   // Forward to base class
   NS_FORWARD_TO_NSDOMEVENT
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -145,17 +145,18 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ns
       case NS_SIMPLE_GESTURE_EVENT:
         static_cast<nsMouseEvent_base*>(tmp->mEvent)->relatedTarget = nullptr;
         break;
       case NS_DRAG_EVENT:
         static_cast<nsDragEvent*>(tmp->mEvent)->dataTransfer = nullptr;
         static_cast<nsMouseEvent_base*>(tmp->mEvent)->relatedTarget = nullptr;
         break;
       case NS_CLIPBOARD_EVENT:
-        static_cast<nsClipboardEvent*>(tmp->mEvent)->clipboardData = nullptr;
+        static_cast<InternalClipboardEvent*>(tmp->mEvent)->clipboardData =
+          nullptr;
         break;
       case NS_MUTATION_EVENT:
         static_cast<InternalMutationEvent*>(tmp->mEvent)->mRelatedNode =
           nullptr;
         break;
       case NS_FOCUS_EVENT:
         static_cast<InternalFocusEvent*>(tmp->mEvent)->relatedTarget = nullptr;
         break;
@@ -189,17 +190,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(
           static_cast<nsDragEvent*>(tmp->mEvent)->dataTransfer);
         NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->relatedTarget");
         cb.NoteXPCOMChild(
           static_cast<nsMouseEvent_base*>(tmp->mEvent)->relatedTarget);
         break;
       case NS_CLIPBOARD_EVENT:
         NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->clipboardData");
         cb.NoteXPCOMChild(
-          static_cast<nsClipboardEvent*>(tmp->mEvent)->clipboardData);
+          static_cast<InternalClipboardEvent*>(tmp->mEvent)->clipboardData);
         break;
       case NS_MUTATION_EVENT:
         NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->mRelatedNode");
         cb.NoteXPCOMChild(
           static_cast<InternalMutationEvent*>(tmp->mEvent)->mRelatedNode);
         break;
       case NS_FOCUS_EVENT:
         NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->relatedTarget");
@@ -558,18 +559,20 @@ nsDOMEvent::DuplicatePrivateData()
       nsDragEvent* dragEvent =
         new nsDragEvent(false, msg, nullptr);
       dragEvent->AssignDragEventData(*oldDragEvent, true);
       newEvent = dragEvent;
       break;
     }
     case NS_CLIPBOARD_EVENT:
     {
-      nsClipboardEvent* oldClipboardEvent = static_cast<nsClipboardEvent*>(mEvent);
-      nsClipboardEvent* clipboardEvent = new nsClipboardEvent(false, msg);
+      InternalClipboardEvent* oldClipboardEvent =
+        static_cast<InternalClipboardEvent*>(mEvent);
+      InternalClipboardEvent* clipboardEvent =
+        new InternalClipboardEvent(false, msg);
       clipboardEvent->AssignClipboardEventData(*oldClipboardEvent, true);
       newEvent = clipboardEvent;
       break;
     }
     case NS_SCRIPT_ERROR_EVENT:
     {
       nsScriptErrorEvent* oldScriptErrorEvent =
         static_cast<nsScriptErrorEvent*>(mEvent);
--- a/content/events/src/nsEventDispatcher.cpp
+++ b/content/events/src/nsEventDispatcher.cpp
@@ -721,17 +721,17 @@ nsEventDispatcher::CreateEvent(mozilla::
     case NS_DRAG_EVENT:
       return NS_NewDOMDragEvent(aDOMEvent, aOwner, aPresContext,
                                  static_cast<nsDragEvent*>(aEvent));
     case NS_TEXT_EVENT:
       return NS_NewDOMTextEvent(aDOMEvent, aOwner, aPresContext,
                                 static_cast<nsTextEvent*>(aEvent));
     case NS_CLIPBOARD_EVENT:
       return NS_NewDOMClipboardEvent(aDOMEvent, aOwner, aPresContext,
-                                     static_cast<nsClipboardEvent*>(aEvent));
+               static_cast<InternalClipboardEvent*>(aEvent));
     case NS_SVGZOOM_EVENT:
       return NS_NewDOMSVGZoomEvent(aDOMEvent, aOwner, aPresContext,
                                    static_cast<nsGUIEvent*>(aEvent));
     case NS_SMIL_TIME_EVENT:
       return NS_NewDOMTimeEvent(aDOMEvent, aOwner, aPresContext, aEvent);
 
     case NS_COMMAND_EVENT:
       return NS_NewDOMCommandEvent(aDOMEvent, aOwner, aPresContext,
--- a/dom/interfaces/events/nsIDOMEvent.idl
+++ b/dom/interfaces/events/nsIDOMEvent.idl
@@ -262,17 +262,17 @@ nsresult
 NS_NewDOMDragEvent(nsIDOMEvent** aInstancePtrResult,
                    mozilla::dom::EventTarget* aOwner,
                    nsPresContext* aPresContext,
                    nsDragEvent* aEvent);
 nsresult
 NS_NewDOMClipboardEvent(nsIDOMEvent** aInstancePtrResult,
                         mozilla::dom::EventTarget* aOwner,
                         nsPresContext* aPresContext,
-                        nsClipboardEvent *aEvent);
+                        mozilla::InternalClipboardEvent* aEvent);
 
 nsresult
 NS_NewDOMKeyboardEvent(nsIDOMEvent** aInstancePtrResult,
                        mozilla::dom::EventTarget* aOwner,
                        nsPresContext* aPresContext,
                        nsKeyEvent* aEvent);
 nsresult
 NS_NewDOMCompositionEvent(nsIDOMEvent** aInstancePtrResult,
--- a/widget/ContentEvents.h
+++ b/widget/ContentEvents.h
@@ -247,11 +247,10 @@ public:
 
 } // namespace mozilla
 
 // TODO: Remove following typedefs
 typedef mozilla::InternalScriptErrorEvent nsScriptErrorEvent;
 typedef mozilla::InternalScrollPortEvent  nsScrollPortEvent;
 typedef mozilla::InternalScrollAreaEvent  nsScrollAreaEvent;
 typedef mozilla::InternalFormEvent        nsFormEvent;
-typedef mozilla::InternalClipboardEvent   nsClipboardEvent;
 
 #endif // mozilla_ContentEvents_h__
--- a/widget/EventForwards.h
+++ b/widget/EventForwards.h
@@ -127,11 +127,10 @@ typedef WidgetWheelEvent                
 
 typedef mozilla::WidgetGestureNotifyEvent  nsGestureNotifyEvent;
 typedef mozilla::WidgetSimpleGestureEvent  nsSimpleGestureEvent;
 typedef mozilla::WidgetTouchEvent          nsTouchEvent;
 typedef mozilla::InternalScriptErrorEvent  nsScriptErrorEvent;
 typedef mozilla::InternalScrollPortEvent   nsScrollPortEvent;
 typedef mozilla::InternalScrollAreaEvent   nsScrollAreaEvent;
 typedef mozilla::InternalFormEvent         nsFormEvent;
-typedef mozilla::InternalClipboardEvent    nsClipboardEvent;
 
 #endif // mozilla_EventForwards_h__