Bug 920425 part.20 Use mozilla::WidgetEvent::AsCompositionEvent() r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 18 Oct 2013 15:10:25 +0900
changeset 165131 c311f205e80575f017d3e0b5ec200e612e540ee9
parent 165130 c8e43d3e128d3b0bf99280cec145c7b68fbf19aa
child 165132 fc070ecf1a0ddfbdc7aa1b8743cca2380c2aa691
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.20 Use mozilla::WidgetEvent::AsCompositionEvent() r=smaug
content/events/src/TextComposition.cpp
content/events/src/nsDOMCompositionEvent.cpp
content/events/src/nsDOMCompositionEvent.h
content/events/src/nsDOMEvent.cpp
content/events/src/nsEventDispatcher.cpp
content/events/src/nsEventStateManager.cpp
widget/xpwidgets/PuppetWidget.cpp
--- a/content/events/src/TextComposition.cpp
+++ b/content/events/src/TextComposition.cpp
@@ -46,17 +46,17 @@ TextComposition::MatchesNativeContext(ns
 }
 
 void
 TextComposition::DispatchEvent(WidgetGUIEvent* aEvent,
                                nsEventStatus* aStatus,
                                nsDispatchingCallback* aCallBack)
 {
   if (aEvent->message == NS_COMPOSITION_UPDATE) {
-    mLastData = static_cast<WidgetCompositionEvent*>(aEvent)->data;
+    mLastData = aEvent->AsCompositionEvent()->data;
   }
 
   nsEventDispatcher::Dispatch(mNode, mPresContext,
                               aEvent, nullptr, aStatus, aCallBack);
 }
 
 void
 TextComposition::DispatchCompsotionEventRunnable(uint32_t aEventMessage,
--- a/content/events/src/nsDOMCompositionEvent.cpp
+++ b/content/events/src/nsDOMCompositionEvent.cpp
@@ -26,17 +26,17 @@ nsDOMCompositionEvent::nsDOMCompositionE
     mEvent->time = PR_Now();
 
     // XXX compositionstart is cancelable in draft of DOM3 Events.
     //     However, it doesn't make sence for us, we cannot cancel composition
     //     when we sends compositionstart event.
     mEvent->mFlags.mCancelable = false;
   }
 
-  mData = static_cast<WidgetCompositionEvent*>(mEvent)->data;
+  mData = mEvent->AsCompositionEvent()->data;
   // TODO: Native event should have locale information.
 }
 
 NS_IMPL_ADDREF_INHERITED(nsDOMCompositionEvent, nsDOMUIEvent)
 NS_IMPL_RELEASE_INHERITED(nsDOMCompositionEvent, nsDOMUIEvent)
 
 NS_INTERFACE_MAP_BEGIN(nsDOMCompositionEvent)
   NS_INTERFACE_MAP_ENTRY(nsIDOMCompositionEvent)
--- a/content/events/src/nsDOMCompositionEvent.h
+++ b/content/events/src/nsDOMCompositionEvent.h
@@ -5,17 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsDOMCompositionEvent_h__
 #define nsDOMCompositionEvent_h__
 
 #include "nsDOMUIEvent.h"
 #include "nsIDOMCompositionEvent.h"
 #include "mozilla/dom/CompositionEventBinding.h"
-#include "mozilla/TextEvents.h"
+#include "mozilla/EventForwards.h"
 
 class nsDOMCompositionEvent : public nsDOMUIEvent,
                               public nsIDOMCompositionEvent
 {
 public:
   nsDOMCompositionEvent(mozilla::dom::EventTarget* aOwner,
                         nsPresContext* aPresContext,
                         mozilla::WidgetCompositionEvent* aEvent);
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -586,17 +586,17 @@ nsDOMEvent::DuplicatePrivateData()
       newEvent = textEvent;
       break;
     }
     case NS_COMPOSITION_EVENT:
     {
       WidgetCompositionEvent* compositionEvent =
         new WidgetCompositionEvent(false, msg, nullptr);
       WidgetCompositionEvent* oldCompositionEvent =
-        static_cast<WidgetCompositionEvent*>(mEvent);
+        mEvent->AsCompositionEvent();
       compositionEvent->AssignCompositionEventData(*oldCompositionEvent, true);
       newEvent = compositionEvent;
       break;
     }
     case NS_MOUSE_SCROLL_EVENT:
     {
       WidgetMouseScrollEvent* oldMouseScrollEvent =
         static_cast<WidgetMouseScrollEvent*>(mEvent);
--- a/content/events/src/nsEventDispatcher.cpp
+++ b/content/events/src/nsEventDispatcher.cpp
@@ -700,19 +700,18 @@ nsEventDispatcher::CreateEvent(mozilla::
                               static_cast<WidgetGUIEvent*>(aEvent));
     case NS_SCROLLAREA_EVENT:
       return NS_NewDOMScrollAreaEvent(aDOMEvent, aOwner, aPresContext,
                                       aEvent->AsScrollAreaEvent());
     case NS_KEY_EVENT:
       return NS_NewDOMKeyboardEvent(aDOMEvent, aOwner, aPresContext,
                                     aEvent->AsKeyboardEvent());
     case NS_COMPOSITION_EVENT:
-      return NS_NewDOMCompositionEvent(
-        aDOMEvent, aOwner,
-        aPresContext, static_cast<WidgetCompositionEvent*>(aEvent));
+      return NS_NewDOMCompositionEvent(aDOMEvent, aOwner, aPresContext,
+                                       aEvent->AsCompositionEvent());
     case NS_MOUSE_EVENT:
       return NS_NewDOMMouseEvent(aDOMEvent, aOwner, aPresContext,
                                  static_cast<WidgetInputEvent*>(aEvent));
     case NS_FOCUS_EVENT:
       return NS_NewDOMFocusEvent(aDOMEvent, aOwner, aPresContext,
                                  aEvent->AsFocusEvent());
     case NS_MOUSE_SCROLL_EVENT:
       return NS_NewDOMMouseScrollEvent(aDOMEvent, aOwner, aPresContext,
--- a/content/events/src/nsEventStateManager.cpp
+++ b/content/events/src/nsEventStateManager.cpp
@@ -1312,30 +1312,28 @@ nsEventStateManager::PreHandleEvent(nsPr
         }
       }
     }
     break;
   case NS_COMPOSITION_START:
     if (aEvent->mFlags.mIsTrusted) {
       // If the event is trusted event, set the selected text to data of
       // composition event.
-      WidgetCompositionEvent *compositionEvent =
-        static_cast<WidgetCompositionEvent*>(aEvent);
+      WidgetCompositionEvent* compositionEvent = aEvent->AsCompositionEvent();
       WidgetQueryContentEvent selectedText(true, NS_QUERY_SELECTED_TEXT,
                                            compositionEvent->widget);
       DoQuerySelectedText(&selectedText);
       NS_ASSERTION(selectedText.mSucceeded, "Failed to get selected text");
       compositionEvent->data = selectedText.mReply.mString;
     }
     // through to compositionend handling
   case NS_COMPOSITION_UPDATE:
   case NS_COMPOSITION_END:
     {
-      WidgetCompositionEvent *compositionEvent =
-          static_cast<WidgetCompositionEvent*>(aEvent);
+      WidgetCompositionEvent* compositionEvent = aEvent->AsCompositionEvent();
       if (IsTargetCrossProcess(compositionEvent)) {
         // Will not be handled locally, remote the event
         if (GetCrossProcessTarget()->SendCompositionEvent(*compositionEvent)) {
           // Cancel local dispatching
           aEvent->mFlags.mPropagationStopped = true;
         }
       }
     }
--- a/widget/xpwidgets/PuppetWidget.cpp
+++ b/widget/xpwidgets/PuppetWidget.cpp
@@ -270,17 +270,17 @@ PuppetWidget::DispatchEvent(WidgetGUIEve
 
   aStatus = nsEventStatus_eIgnore;
 
   if (event->message == NS_COMPOSITION_START) {
     mIMEComposing = true;
   }
   switch (event->eventStructType) {
   case NS_COMPOSITION_EVENT:
-    mIMELastReceivedSeqno = static_cast<WidgetCompositionEvent*>(event)->seqno;
+    mIMELastReceivedSeqno = event->AsCompositionEvent()->seqno;
     if (mIMELastReceivedSeqno < mIMELastBlurSeqno)
       return NS_OK;
     break;
   case NS_TEXT_EVENT:
     mIMELastReceivedSeqno = event->AsTextEvent()->seqno;
     if (mIMELastReceivedSeqno < mIMELastBlurSeqno)
       return NS_OK;
     break;