Bug 920425 part.12 Use mozilla::WidgetEvent::AsMutationEvent() r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 18 Oct 2013 15:10:22 +0900
changeset 151308 8d1be2be411cc79ca227dfd343fbd81d129a603d
parent 151307 2a8ad5e277383b6ef8c4bdde4acfe8e413c85cb5
child 151309 30cfb3f452b5ae2f72a655ed27aff62082a9db06
push id25484
push userryanvm@gmail.com
push dateFri, 18 Oct 2013 19:14:25 +0000
treeherdermozilla-central@3daff401c7ab [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.12 Use mozilla::WidgetEvent::AsMutationEvent() r=smaug
content/events/src/nsDOMEvent.cpp
content/events/src/nsDOMMutationEvent.cpp
content/events/src/nsEventDispatcher.cpp
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -150,18 +150,17 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ns
         static_cast<WidgetDragEvent*>(tmp->mEvent)->dataTransfer = nullptr;
         static_cast<WidgetMouseEventBase*>(tmp->mEvent)->relatedTarget =
           nullptr;
         break;
       case NS_CLIPBOARD_EVENT:
         tmp->mEvent->AsClipboardEvent()->clipboardData = nullptr;
         break;
       case NS_MUTATION_EVENT:
-        static_cast<InternalMutationEvent*>(tmp->mEvent)->mRelatedNode =
-          nullptr;
+        tmp->mEvent->AsMutationEvent()->mRelatedNode = nullptr;
         break;
       case NS_FOCUS_EVENT:
         tmp->mEvent->AsFocusEvent()->relatedTarget = nullptr;
         break;
       default:
         break;
     }
   }
@@ -194,18 +193,17 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(
           static_cast<WidgetMouseEventBase*>(tmp->mEvent)->relatedTarget);
         break;
       case NS_CLIPBOARD_EVENT:
         NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "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);
+        cb.NoteXPCOMChild(tmp->mEvent->AsMutationEvent()->mRelatedNode);
         break;
       case NS_FOCUS_EVENT:
         NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mEvent->relatedTarget");
         cb.NoteXPCOMChild(tmp->mEvent->AsFocusEvent()->relatedTarget);
         break;
       default:
         break;
     }
@@ -634,18 +632,17 @@ nsDOMEvent::DuplicatePrivateData()
       scrollAreaEvent->AssignScrollAreaEventData(*oldScrollAreaEvent, true);
       newEvent = scrollAreaEvent;
       break;
     }
     case NS_MUTATION_EVENT:
     {
       InternalMutationEvent* mutationEvent =
         new InternalMutationEvent(false, msg);
-      InternalMutationEvent* oldMutationEvent =
-        static_cast<InternalMutationEvent*>(mEvent);
+      InternalMutationEvent* oldMutationEvent = mEvent->AsMutationEvent();
       mutationEvent->AssignMutationEventData(*oldMutationEvent, true);
       newEvent = mutationEvent;
       break;
     }
     case NS_FORM_EVENT:
     {
       InternalFormEvent* oldFormEvent = mEvent->AsFormEvent();
       InternalFormEvent* formEvent = new InternalFormEvent(false, msg);
--- a/content/events/src/nsDOMMutationEvent.cpp
+++ b/content/events/src/nsDOMMutationEvent.cpp
@@ -25,77 +25,77 @@ NS_INTERFACE_MAP_BEGIN(nsDOMMutationEven
 NS_INTERFACE_MAP_END_INHERITING(nsDOMEvent)
 
 NS_IMPL_ADDREF_INHERITED(nsDOMMutationEvent, nsDOMEvent)
 NS_IMPL_RELEASE_INHERITED(nsDOMMutationEvent, nsDOMEvent)
 
 already_AddRefed<nsINode>
 nsDOMMutationEvent::GetRelatedNode()
 {
-  nsCOMPtr<nsINode> n = do_QueryInterface(
-    static_cast<InternalMutationEvent*>(mEvent)->mRelatedNode);
+  nsCOMPtr<nsINode> n =
+    do_QueryInterface(mEvent->AsMutationEvent()->mRelatedNode);
   return n.forget();
 }
 
 NS_IMETHODIMP
 nsDOMMutationEvent::GetRelatedNode(nsIDOMNode** aRelatedNode)
 {
   nsCOMPtr<nsINode> relatedNode = GetRelatedNode();
   nsCOMPtr<nsIDOMNode> relatedDOMNode = relatedNode ? relatedNode->AsDOMNode() : nullptr;
   relatedDOMNode.forget(aRelatedNode);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMMutationEvent::GetPrevValue(nsAString& aPrevValue)
 {
-  InternalMutationEvent* mutation = static_cast<InternalMutationEvent*>(mEvent);
+  InternalMutationEvent* mutation = mEvent->AsMutationEvent();
   if (mutation->mPrevAttrValue)
     mutation->mPrevAttrValue->ToString(aPrevValue);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMMutationEvent::GetNewValue(nsAString& aNewValue)
 {
-  InternalMutationEvent* mutation = static_cast<InternalMutationEvent*>(mEvent);
+  InternalMutationEvent* mutation = mEvent->AsMutationEvent();
   if (mutation->mNewAttrValue)
       mutation->mNewAttrValue->ToString(aNewValue);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMMutationEvent::GetAttrName(nsAString& aAttrName)
 {
-  InternalMutationEvent* mutation = static_cast<InternalMutationEvent*>(mEvent);
+  InternalMutationEvent* mutation = mEvent->AsMutationEvent();
   if (mutation->mAttrName)
       mutation->mAttrName->ToString(aAttrName);
   return NS_OK;
 }
 
 uint16_t
 nsDOMMutationEvent::AttrChange()
 {
-  return static_cast<InternalMutationEvent*>(mEvent)->mAttrChange;
+  return mEvent->AsMutationEvent()->mAttrChange;
 }
 
 NS_IMETHODIMP
 nsDOMMutationEvent::GetAttrChange(uint16_t* aAttrChange)
 {
   *aAttrChange = AttrChange();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMMutationEvent::InitMutationEvent(const nsAString& aTypeArg, bool aCanBubbleArg, bool aCancelableArg, nsIDOMNode* aRelatedNodeArg, const nsAString& aPrevValueArg, const nsAString& aNewValueArg, const nsAString& aAttrNameArg, uint16_t aAttrChangeArg)
 {
   nsresult rv = nsDOMEvent::InitEvent(aTypeArg, aCanBubbleArg, aCancelableArg);
   NS_ENSURE_SUCCESS(rv, rv);
-  
-  InternalMutationEvent* mutation = static_cast<InternalMutationEvent*>(mEvent);
+
+  InternalMutationEvent* mutation = mEvent->AsMutationEvent();
   mutation->mRelatedNode = aRelatedNodeArg;
   if (!aPrevValueArg.IsEmpty())
     mutation->mPrevAttrValue = do_GetAtom(aPrevValueArg);
   if (!aNewValueArg.IsEmpty())
     mutation->mNewAttrValue = do_GetAtom(aNewValueArg);
   if (!aAttrNameArg.IsEmpty()) {
     mutation->mAttrName = do_GetAtom(aAttrNameArg);
   }
--- a/content/events/src/nsEventDispatcher.cpp
+++ b/content/events/src/nsEventDispatcher.cpp
@@ -687,17 +687,17 @@ nsEventDispatcher::CreateEvent(mozilla::
                                nsIDOMEvent** aDOMEvent)
 {
   *aDOMEvent = nullptr;
 
   if (aEvent) {
     switch(aEvent->eventStructType) {
     case NS_MUTATION_EVENT:
       return NS_NewDOMMutationEvent(aDOMEvent, aOwner, aPresContext,
-               static_cast<InternalMutationEvent*>(aEvent));
+                                    aEvent->AsMutationEvent());
     case NS_GUI_EVENT:
     case NS_SCROLLPORT_EVENT:
     case NS_UI_EVENT:
       return NS_NewDOMUIEvent(aDOMEvent, aOwner, aPresContext,
                               static_cast<WidgetGUIEvent*>(aEvent));
     case NS_SCROLLAREA_EVENT:
       return NS_NewDOMScrollAreaEvent(aDOMEvent, aOwner, aPresContext,
                                       aEvent->AsScrollAreaEvent());