Bug 920425 part.8 Use mozilla::WidgetEvent::AsClipboardEvent() r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 18 Oct 2013 15:10:22 +0900
changeset 165119 45a99edd7297ca07227e7a8b6eab96bb6fb73ca9
parent 165118 72b0df413e3bc298d3213b8781e435197ee35825
child 165120 9080e47ab89d3dd3299ec38f314c51c1e1407cef
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs920425
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 920425 part.8 Use mozilla::WidgetEvent::AsClipboardEvent() r=smaug
content/events/src/nsDOMClipboardEvent.cpp
content/events/src/nsDOMEvent.cpp
content/events/src/nsEventDispatcher.cpp
--- a/content/events/src/nsDOMClipboardEvent.cpp
+++ b/content/events/src/nsDOMClipboardEvent.cpp
@@ -27,24 +27,25 @@ nsDOMClipboardEvent::nsDOMClipboardEvent
 NS_INTERFACE_MAP_BEGIN(nsDOMClipboardEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMClipboardEvent)
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
 
 NS_IMPL_ADDREF_INHERITED(nsDOMClipboardEvent, nsDOMEvent)
 NS_IMPL_RELEASE_INHERITED(nsDOMClipboardEvent, nsDOMEvent)
 
 nsresult
-nsDOMClipboardEvent::InitClipboardEvent(const nsAString & aType, bool aCanBubble, bool aCancelable,
-                                        nsIDOMDataTransfer* clipboardData)
+nsDOMClipboardEvent::InitClipboardEvent(const nsAString& aType,
+                                        bool aCanBubble,
+                                        bool aCancelable,
+                                        nsIDOMDataTransfer* aClipboardData)
 {
   nsresult rv = nsDOMEvent::InitEvent(aType, aCanBubble, aCancelable);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  InternalClipboardEvent* event = static_cast<InternalClipboardEvent*>(mEvent);
-  event->clipboardData = clipboardData;
+  mEvent->AsClipboardEvent()->clipboardData = aClipboardData;
 
   return NS_OK;
 }
 
 already_AddRefed<nsDOMClipboardEvent>
 nsDOMClipboardEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
                                  const nsAString& aType,
                                  const mozilla::dom::ClipboardEventInit& aParam,
@@ -52,18 +53,17 @@ 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) {
-    InternalClipboardEvent* event =
-      static_cast<InternalClipboardEvent*>(e->mEvent);
+    InternalClipboardEvent* event = e->mEvent->AsClipboardEvent();
     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);
     }
   }
@@ -79,17 +79,17 @@ nsDOMClipboardEvent::GetClipboardData(ns
 {
   NS_IF_ADDREF(*aClipboardData = GetClipboardData());
   return NS_OK;
 }
 
 nsIDOMDataTransfer*
 nsDOMClipboardEvent::GetClipboardData()
 {
-  InternalClipboardEvent* event = static_cast<InternalClipboardEvent*>(mEvent);
+  InternalClipboardEvent* event = mEvent->AsClipboardEvent();
 
   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);
     }
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -147,18 +147,17 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ns
           nullptr;
         break;
       case NS_DRAG_EVENT:
         static_cast<WidgetDragEvent*>(tmp->mEvent)->dataTransfer = nullptr;
         static_cast<WidgetMouseEventBase*>(tmp->mEvent)->relatedTarget =
           nullptr;
         break;
       case NS_CLIPBOARD_EVENT:
-        static_cast<InternalClipboardEvent*>(tmp->mEvent)->clipboardData =
-          nullptr;
+        tmp->mEvent->AsClipboardEvent()->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;
@@ -191,18 +190,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(
         cb.NoteXPCOMChild(
           static_cast<WidgetDragEvent*>(tmp->mEvent)->dataTransfer);
         NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->relatedTarget");
         cb.NoteXPCOMChild(
           static_cast<WidgetMouseEventBase*>(tmp->mEvent)->relatedTarget);
         break;
       case NS_CLIPBOARD_EVENT:
         NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->clipboardData");
-        cb.NoteXPCOMChild(
-          static_cast<InternalClipboardEvent*>(tmp->mEvent)->clipboardData);
+        cb.NoteXPCOMChild(tmp->mEvent->AsClipboardEvent()->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");
@@ -562,18 +560,17 @@ nsDOMEvent::DuplicatePrivateData()
       WidgetDragEvent* oldDragEvent = static_cast<WidgetDragEvent*>(mEvent);
       WidgetDragEvent* dragEvent = new WidgetDragEvent(false, msg, nullptr);
       dragEvent->AssignDragEventData(*oldDragEvent, true);
       newEvent = dragEvent;
       break;
     }
     case NS_CLIPBOARD_EVENT:
     {
-      InternalClipboardEvent* oldClipboardEvent =
-        static_cast<InternalClipboardEvent*>(mEvent);
+      InternalClipboardEvent* oldClipboardEvent = mEvent->AsClipboardEvent();
       InternalClipboardEvent* clipboardEvent =
         new InternalClipboardEvent(false, msg);
       clipboardEvent->AssignClipboardEventData(*oldClipboardEvent, true);
       newEvent = clipboardEvent;
       break;
     }
     case NS_SCRIPT_ERROR_EVENT:
     {
--- a/content/events/src/nsEventDispatcher.cpp
+++ b/content/events/src/nsEventDispatcher.cpp
@@ -723,17 +723,17 @@ nsEventDispatcher::CreateEvent(mozilla::
     case NS_DRAG_EVENT:
       return NS_NewDOMDragEvent(aDOMEvent, aOwner, aPresContext,
                                 static_cast<WidgetDragEvent*>(aEvent));
     case NS_TEXT_EVENT:
       return NS_NewDOMTextEvent(aDOMEvent, aOwner, aPresContext,
                                 static_cast<WidgetTextEvent*>(aEvent));
     case NS_CLIPBOARD_EVENT:
       return NS_NewDOMClipboardEvent(aDOMEvent, aOwner, aPresContext,
-               static_cast<InternalClipboardEvent*>(aEvent));
+                                     aEvent->AsClipboardEvent());
     case NS_SVGZOOM_EVENT:
       return NS_NewDOMSVGZoomEvent(aDOMEvent, aOwner, aPresContext,
                                    static_cast<WidgetGUIEvent*>(aEvent));
     case NS_SMIL_TIME_EVENT:
       return NS_NewDOMTimeEvent(aDOMEvent, aOwner, aPresContext, aEvent);
 
     case NS_COMMAND_EVENT:
       return NS_NewDOMCommandEvent(aDOMEvent, aOwner, aPresContext,