Bug 1259656 part.3 Rename WidgetEvent::userType to WidgetEvent::mSpecifiedEventType r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Mon, 18 Apr 2016 23:53:03 +0900
changeset 293959 79737c3fb41bb88d48e5b623ce0ea13749e6a3d4
parent 293958 dceb7f8f80d1a5df542052090041e68a3d11e3e4
child 293960 38b12742d84cef2446a4003f6848f71299ddd199
push idunknown
push userunknown
push dateunknown
reviewerssmaug
bugs1259656
milestone48.0a1
Bug 1259656 part.3 Rename WidgetEvent::userType to WidgetEvent::mSpecifiedEventType r=smaug MozReview-Commit-ID: 5ef5lEQ1fZJ
dom/base/TextInputProcessor.cpp
dom/events/Event.cpp
dom/events/EventListenerManager.cpp
dom/events/EventListenerManager.h
widget/BasicEvents.h
widget/MiscEvents.h
--- a/dom/base/TextInputProcessor.cpp
+++ b/dom/base/TextInputProcessor.cpp
@@ -249,18 +249,19 @@ bool
 TextInputProcessor::IsValidEventTypeForComposition(
                       const WidgetKeyboardEvent& aKeyboardEvent) const
 {
   // The key event type of composition methods must be "" or "keydown".
   if (aKeyboardEvent.mMessage == eKeyDown) {
     return true;
   }
   if (aKeyboardEvent.mMessage == eUnidentifiedEvent &&
-      aKeyboardEvent.userType &&
-      nsDependentAtomString(aKeyboardEvent.userType).EqualsLiteral("on")) {
+      aKeyboardEvent.mSpecifiedEventType &&
+      nsDependentAtomString(
+        aKeyboardEvent.mSpecifiedEventType).EqualsLiteral("on")) {
     return true;
   }
   return false;
 }
 
 TextInputProcessor::EventDispatcherResult
 TextInputProcessor::MaybeDispatchKeydownForComposition(
                       const WidgetKeyboardEvent* aKeyboardEvent,
--- a/dom/events/Event.cpp
+++ b/dom/events/Event.cpp
@@ -262,18 +262,20 @@ Event::GetType(nsAString& aType)
     aType = mEvent->typeString;
     return NS_OK;
   }
   const char* name = GetEventName(mEvent->mMessage);
 
   if (name) {
     CopyASCIItoUTF16(name, aType);
     return NS_OK;
-  } else if (mEvent->mMessage == eUnidentifiedEvent && mEvent->userType) {
-    aType = Substring(nsDependentAtomString(mEvent->userType), 2); // Remove "on"
+  } else if (mEvent->mMessage == eUnidentifiedEvent &&
+             mEvent->mSpecifiedEventType) {
+    // Remove "on"
+    aType = Substring(nsDependentAtomString(mEvent->mSpecifiedEventType), 2);
     mEvent->typeString = aType;
     return NS_OK;
   }
 
   aType.Truncate();
   return NS_OK;
 }
 
@@ -543,21 +545,21 @@ Event::PreventDefaultInternal(bool aCall
   }
 }
 
 void
 Event::SetEventType(const nsAString& aEventTypeArg)
 {
   if (mIsMainThreadEvent) {
     mEvent->typeString.Truncate();
-    mEvent->userType =
+    mEvent->mSpecifiedEventType =
       nsContentUtils::GetEventMessageAndAtom(aEventTypeArg, mEvent->mClass,
                                              &(mEvent->mMessage));
   } else {
-    mEvent->userType = nullptr;
+    mEvent->mSpecifiedEventType = nullptr;
     mEvent->mMessage = eUnidentifiedEvent;
     mEvent->typeString = aEventTypeArg;
   }
 }
 
 void
 Event::InitEvent(const nsAString& aEventTypeArg,
                  bool aCanBubbleArg,
--- a/dom/events/EventListenerManager.cpp
+++ b/dom/events/EventListenerManager.cpp
@@ -669,17 +669,17 @@ EventListenerManager::ListenerCanHandle(
   // true even when aEvent->mMessage == eUnidentifiedEvent and
   // aListener=>mEventMessage != eUnidentifiedEvent as long as the atoms are
   // the same
   if (aListener->mAllEvents) {
     return true;
   }
   if (aEvent->mMessage == eUnidentifiedEvent) {
     if (mIsMainThreadELM) {
-      return aListener->mTypeAtom == aEvent->userType;
+      return aListener->mTypeAtom == aEvent->mSpecifiedEventType;
     }
     return aListener->mTypeString.Equals(aEvent->typeString);
   }
   MOZ_ASSERT(mIsMainThreadELM);
   return aListener->mEventMessage == aEventMessage;
 }
 
 void
@@ -1299,17 +1299,17 @@ EventListenerManager::HandleEventInterna
     eventMessage = legacyEventMessage;
     usingLegacyMessage = true;
   }
 
   aEvent->currentTarget = nullptr;
 
   if (mIsMainThreadELM && !hasListener) {
     mNoListenerForEvent = aEvent->mMessage;
-    mNoListenerForEventAtom = aEvent->userType;
+    mNoListenerForEventAtom = aEvent->mSpecifiedEventType;
   }
 
   if (aEvent->DefaultPrevented()) {
     *aEventStatus = nsEventStatus_eConsumeNoDefault;
   }
 }
 
 void
--- a/dom/events/EventListenerManager.h
+++ b/dom/events/EventListenerManager.h
@@ -338,17 +338,17 @@ public:
 
     if (!mMayHaveSystemGroupListeners && aEvent->mFlags.mInSystemGroup) {
       return;
     }
 
     // Check if we already know that there is no event listener for the event.
     if (mNoListenerForEvent == aEvent->mMessage &&
         (mNoListenerForEvent != eUnidentifiedEvent ||
-         mNoListenerForEventAtom == aEvent->userType)) {
+         mNoListenerForEventAtom == aEvent->mSpecifiedEventType)) {
       return;
     }
     HandleEventInternal(aPresContext, aEvent, aDOMEvent, aCurrentTarget,
                         aEventStatus);
   }
 
   /**
    * Tells the event listener manager that its target (which owns it) is
--- a/widget/BasicEvents.h
+++ b/widget/BasicEvents.h
@@ -268,17 +268,17 @@ protected:
   WidgetEvent(bool aIsTrusted,
               EventMessage aMessage,
               EventClassID aEventClassID)
     : WidgetEventTime()
     , mClass(aEventClassID)
     , mMessage(aMessage)
     , mRefPoint(0, 0)
     , mLastRefPoint(0, 0)
-    , userType(nullptr)
+    , mSpecifiedEventType(nullptr)
   {
     MOZ_COUNT_CTOR(WidgetEvent);
     mFlags.Clear();
     mFlags.mIsTrusted = aIsTrusted;
     mFlags.mCancelable = true;
     mFlags.mBubbles = true;
   }
 
@@ -290,17 +290,17 @@ protected:
 
 public:
   WidgetEvent(bool aIsTrusted, EventMessage aMessage)
     : WidgetEventTime()
     , mClass(eBasicEventClass)
     , mMessage(aMessage)
     , mRefPoint(0, 0)
     , mLastRefPoint(0, 0)
-    , userType(nullptr)
+    , mSpecifiedEventType(nullptr)
   {
     MOZ_COUNT_CTOR(WidgetEvent);
     mFlags.Clear();
     mFlags.mIsTrusted = aIsTrusted;
     mFlags.mCancelable = true;
     mFlags.mBubbles = true;
   }
 
@@ -330,35 +330,37 @@ public:
   // Relative to the widget of the event, or if there is no widget then it is
   // in screen coordinates. Not modified by layout code.
   LayoutDeviceIntPoint mRefPoint;
   // The previous mRefPoint, if known, used to calculate mouse movement deltas.
   LayoutDeviceIntPoint mLastRefPoint;
   // See BaseEventFlags definition for the detail.
   BaseEventFlags mFlags;
 
-  // Additional type info for user defined events
-  nsCOMPtr<nsIAtom> userType;
+  // If JS creates an event with unknown event type or known event type but
+  // for different event interface, the event type is stored to this.
+  // NOTE: This is always used if the instance is a WidgetCommandEvent instance.
+  nsCOMPtr<nsIAtom> mSpecifiedEventType;
 
   nsString typeString; // always set on non-main-thread events
 
   // Event targets, needed by DOM Events
   nsCOMPtr<dom::EventTarget> target;
   nsCOMPtr<dom::EventTarget> currentTarget;
   nsCOMPtr<dom::EventTarget> originalTarget;
 
   void AssignEventData(const WidgetEvent& aEvent, bool aCopyTargets)
   {
     // mClass should be initialized with the constructor.
     // mMessage should be initialized with the constructor.
     mRefPoint = aEvent.mRefPoint;
     // mLastRefPoint doesn't need to be copied.
     AssignEventTime(aEvent);
     // mFlags should be copied manually if it's necessary.
-    userType = aEvent.userType;
+    mSpecifiedEventType = aEvent.mSpecifiedEventType;
     // typeString should be copied manually if it's necessary.
     target = aCopyTargets ? aEvent.target : nullptr;
     currentTarget = aCopyTargets ? aEvent.currentTarget : nullptr;
     originalTarget = aCopyTargets ? aEvent.originalTarget : nullptr;
   }
 
   /**
    * Helper methods for methods of DOM Event.
--- a/widget/MiscEvents.h
+++ b/widget/MiscEvents.h
@@ -107,26 +107,26 @@ public:
   virtual WidgetCommandEvent* AsCommandEvent() override { return this; }
 
   WidgetCommandEvent(bool aIsTrusted, nsIAtom* aEventType,
                      nsIAtom* aCommand, nsIWidget* aWidget)
     : WidgetGUIEvent(aIsTrusted, eUnidentifiedEvent, aWidget,
                      eCommandEventClass)
     , command(aCommand)
   {
-    userType = aEventType;
+    mSpecifiedEventType = aEventType;
   }
 
   virtual WidgetEvent* Duplicate() const override
   {
     MOZ_ASSERT(mClass == eCommandEventClass,
                "Duplicate() must be overridden by sub class");
     // Not copying widget, it is a weak reference.
     WidgetCommandEvent* result =
-      new WidgetCommandEvent(false, userType, command, nullptr);
+      new WidgetCommandEvent(false, mSpecifiedEventType, command, nullptr);
     result->AssignCommandEventData(*this, true);
     result->mFlags = mFlags;
     return result;
   }
 
   nsCOMPtr<nsIAtom> command;
 
   // XXX Not tested by test_assign_event_data.html