Bug 920425 part.7 Use mozilla::WidgetEvent::AsFormEvent() r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 18 Oct 2013 15:10:21 +0900
changeset 151191 72b0df413e3bc298d3213b8781e435197ee35825
parent 151190 6c2180e88728c86eed949422d0c61289d6c1cf7b
child 151192 45a99edd7297ca07227e7a8b6eab96bb6fb73ca9
push id35111
push usermasayuki@d-toybox.com
push dateFri, 18 Oct 2013 06:10:43 +0000
treeherdermozilla-inbound@bc72b42bcf76 [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.7 Use mozilla::WidgetEvent::AsFormEvent() r=smaug
content/events/src/nsDOMEvent.cpp
content/html/content/src/HTMLFormElement.cpp
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -646,17 +646,17 @@ nsDOMEvent::DuplicatePrivateData()
       InternalMutationEvent* oldMutationEvent =
         static_cast<InternalMutationEvent*>(mEvent);
       mutationEvent->AssignMutationEventData(*oldMutationEvent, true);
       newEvent = mutationEvent;
       break;
     }
     case NS_FORM_EVENT:
     {
-      InternalFormEvent* oldFormEvent = static_cast<InternalFormEvent*>(mEvent);
+      InternalFormEvent* oldFormEvent = mEvent->AsFormEvent();
       InternalFormEvent* formEvent = new InternalFormEvent(false, msg);
       formEvent->AssignFormEventData(*oldFormEvent, true);
       newEvent = formEvent;
       break;
     }
     case NS_FOCUS_EVENT:
     {
       InternalFocusEvent* newFocusEvent = new InternalFocusEvent(false, msg);
--- a/content/html/content/src/HTMLFormElement.cpp
+++ b/content/html/content/src/HTMLFormElement.cpp
@@ -681,26 +681,24 @@ nsresult
 HTMLFormElement::BuildSubmission(nsFormSubmission** aFormSubmission, 
                                  WidgetEvent* aEvent)
 {
   NS_ASSERTION(!mPendingSubmission, "tried to build two submissions!");
 
   // Get the originating frame (failure is non-fatal)
   nsGenericHTMLElement* originatingElement = nullptr;
   if (aEvent) {
-    if (NS_FORM_EVENT == aEvent->eventStructType) {
-      nsIContent* originator =
-        static_cast<InternalFormEvent*>(aEvent)->originator;
+    InternalFormEvent* formEvent = aEvent->AsFormEvent();
+    if (formEvent) {
+      nsIContent* originator = formEvent->originator;
       if (originator) {
         if (!originator->IsHTML()) {
           return NS_ERROR_UNEXPECTED;
         }
-        originatingElement =
-          static_cast<nsGenericHTMLElement*>(
-            static_cast<InternalFormEvent*>(aEvent)->originator);
+        originatingElement = static_cast<nsGenericHTMLElement*>(originator);
       }
     }
   }
 
   nsresult rv;
 
   //
   // Get the submission object