Bug 970248 Simplify constructor of InternalUIEvent r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Sat, 15 Feb 2014 10:06:06 +0900
changeset 186089 07bb55ce62e3272c06faf2c9d03e5e879051ee62
parent 186088 e2e9eba7dd1fc146cecf089141f5614fdde843ce
child 186090 e5ac6baf6d0b6334a31fa5cc9eefac254e614321
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs970248
milestone30.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 970248 Simplify constructor of InternalUIEvent r=smaug
content/base/src/Element.cpp
content/html/content/src/HTMLButtonElement.cpp
content/html/content/src/HTMLInputElement.cpp
dom/events/nsDOMUIEvent.cpp
dom/smil/nsDOMTimeEvent.cpp
dom/smil/nsSMILTimedElement.cpp
widget/BasicEvents.h
widget/ContentEvents.h
--- a/content/base/src/Element.cpp
+++ b/content/base/src/Element.cpp
@@ -2359,18 +2359,18 @@ Element::PostHandleEventForLinks(nsEvent
         break;
       }
 
       // The default action is simply to dispatch DOMActivate
       nsCOMPtr<nsIPresShell> shell = aVisitor.mPresContext->GetPresShell();
       if (shell) {
         // single-click
         nsEventStatus status = nsEventStatus_eIgnore;
-        InternalUIEvent actEvent(mouseEvent->mFlags.mIsTrusted,
-                                 NS_UI_ACTIVATE, 1);
+        InternalUIEvent actEvent(mouseEvent->mFlags.mIsTrusted, NS_UI_ACTIVATE);
+        actEvent.detail = 1;
 
         rv = shell->HandleDOMEventWithTarget(this, &actEvent, &status);
         if (NS_SUCCEEDED(rv)) {
           aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
         }
       }
     }
     break;
--- a/content/html/content/src/HTMLButtonElement.cpp
+++ b/content/html/content/src/HTMLButtonElement.cpp
@@ -224,18 +224,21 @@ HTMLButtonElement::PostHandleEvent(nsEve
   nsresult rv = NS_OK;
   if (!aVisitor.mPresContext) {
     return rv;
   }
 
   if (aVisitor.mEventStatus != nsEventStatus_eConsumeNoDefault) {
     WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent();
     if (mouseEvent && mouseEvent->IsLeftClickEvent()) {
+      // XXX Activating actually occurs even if it's caused by untrusted event.
+      //     Therefore, shouldn't this be always trusted event?
       InternalUIEvent actEvent(aVisitor.mEvent->mFlags.mIsTrusted,
-                               NS_UI_ACTIVATE, 1);
+                               NS_UI_ACTIVATE);
+      actEvent.detail = 1;
 
       nsCOMPtr<nsIPresShell> shell = aVisitor.mPresContext->GetPresShell();
       if (shell) {
         nsEventStatus status = nsEventStatus_eIgnore;
         mInInternalActivate = true;
         shell->HandleDOMEventWithTarget(this, &actEvent, &status);
         mInInternalActivate = false;
 
--- a/content/html/content/src/HTMLInputElement.cpp
+++ b/content/html/content/src/HTMLInputElement.cpp
@@ -3755,18 +3755,21 @@ HTMLInputElement::PostHandleEvent(nsEven
   // the click event handling, and allow cancellation of DOMActivate to cancel
   // the click.
   if (aVisitor.mEventStatus != nsEventStatus_eConsumeNoDefault &&
       !IsSingleLineTextControl(true) &&
       mType != NS_FORM_INPUT_NUMBER) {
     WidgetMouseEvent* mouseEvent = aVisitor.mEvent->AsMouseEvent();
     if (mouseEvent && mouseEvent->IsLeftClickEvent() &&
         !ShouldPreventDOMActivateDispatch(aVisitor.mEvent->originalTarget)) {
+      // XXX Activating actually occurs even if it's caused by untrusted event.
+      //     Therefore, shouldn't this be always trusted event?
       InternalUIEvent actEvent(aVisitor.mEvent->mFlags.mIsTrusted,
-                               NS_UI_ACTIVATE, 1);
+                               NS_UI_ACTIVATE);
+      actEvent.detail = 1;
 
       nsCOMPtr<nsIPresShell> shell = aVisitor.mPresContext->GetPresShell();
       if (shell) {
         nsEventStatus status = nsEventStatus_eIgnore;
         mInInternalActivate = true;
         rv = shell->HandleDOMEventWithTarget(this, &actEvent, &status);
         mInInternalActivate = false;
 
--- a/dom/events/nsDOMUIEvent.cpp
+++ b/dom/events/nsDOMUIEvent.cpp
@@ -20,17 +20,17 @@
 #include "mozilla/TextEvents.h"
 #include "prtime.h"
 
 using namespace mozilla;
 
 nsDOMUIEvent::nsDOMUIEvent(mozilla::dom::EventTarget* aOwner,
                            nsPresContext* aPresContext, WidgetGUIEvent* aEvent)
   : nsDOMEvent(aOwner, aPresContext,
-               aEvent ? aEvent : new InternalUIEvent(false, 0, 0))
+               aEvent ? aEvent : new InternalUIEvent(false, 0))
   , mClientPoint(0, 0), mLayerPoint(0, 0), mPagePoint(0, 0), mMovementPoint(0, 0)
   , mIsPointerLocked(nsEventStateManager::sIsPointerLocked)
   , mLastClientPoint(nsEventStateManager::sLastClientPoint)
 {
   if (aEvent) {
     mEventIsInternal = false;
   }
   else {
--- a/dom/smil/nsDOMTimeEvent.cpp
+++ b/dom/smil/nsDOMTimeEvent.cpp
@@ -9,17 +9,17 @@
 #include "mozilla/BasicEvents.h"
 
 using namespace mozilla;
 
 nsDOMTimeEvent::nsDOMTimeEvent(mozilla::dom::EventTarget* aOwner,
                                nsPresContext* aPresContext,
                                WidgetEvent* aEvent)
   : nsDOMEvent(aOwner, aPresContext,
-               aEvent ? aEvent : new InternalUIEvent(false, 0, 0)),
+               aEvent ? aEvent : new InternalUIEvent(false, 0)),
     mDetail(0)
 {
   SetIsDOMBinding();
   if (aEvent) {
     mEventIsInternal = false;
   } else {
     mEventIsInternal = true;
     mEvent->eventStructType = NS_SMIL_TIME_EVENT;
--- a/dom/smil/nsSMILTimedElement.cpp
+++ b/dom/smil/nsSMILTimedElement.cpp
@@ -87,18 +87,19 @@ namespace
   public:
     AsyncTimeEventRunner(nsIContent* aTarget, uint32_t aMsg, int32_t aDetail)
       : mTarget(aTarget), mMsg(aMsg), mDetail(aDetail)
     {
     }
 
     NS_IMETHOD Run()
     {
-      InternalUIEvent event(true, mMsg, mDetail);
+      InternalUIEvent event(true, mMsg);
       event.eventStructType = NS_SMIL_TIME_EVENT;
+      event.detail = mDetail;
 
       nsPresContext* context = nullptr;
       nsIDocument* doc = mTarget->GetCurrentDoc();
       if (doc) {
         nsCOMPtr<nsIPresShell> shell = doc->GetShell();
         if (shell) {
           context = shell->GetPresContext();
         }
--- a/widget/BasicEvents.h
+++ b/widget/BasicEvents.h
@@ -1050,47 +1050,47 @@ public:
  *
  * XXX Why this inherits WidgetGUIEvent rather than WidgetEvent?
  ******************************************************************************/
 
 class InternalUIEvent : public WidgetGUIEvent
 {
 protected:
   InternalUIEvent(bool aIsTrusted, uint32_t aMessage,
-                  nsEventStructType aStructType, int32_t aDetail) :
-    WidgetGUIEvent(aIsTrusted, aMessage, nullptr, aStructType),
-    detail(aDetail)
+                  nsEventStructType aStructType)
+    : WidgetGUIEvent(aIsTrusted, aMessage, nullptr, aStructType)
+    , detail(0)
   {
   }
 
 public:
   virtual InternalUIEvent* AsUIEvent() MOZ_OVERRIDE { return this; }
 
-  InternalUIEvent(bool aIsTrusted, uint32_t aMessage, int32_t aDetail) :
-    WidgetGUIEvent(aIsTrusted, aMessage, nullptr, NS_UI_EVENT),
-    detail(aDetail)
+  InternalUIEvent(bool aIsTrusted, uint32_t aMessage)
+    : WidgetGUIEvent(aIsTrusted, aMessage, nullptr, NS_UI_EVENT)
+    , detail(0)
   {
   }
 
   virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
   {
     MOZ_ASSERT(eventStructType == NS_UI_EVENT ||
                  eventStructType == NS_SMIL_TIME_EVENT,
                "Duplicate() must be overridden by sub class");
-    InternalUIEvent* result = new InternalUIEvent(false, message, detail);
+    InternalUIEvent* result = new InternalUIEvent(false, message);
     result->AssignUIEventData(*this, true);
     result->mFlags = mFlags;
     return result;
   }
 
   int32_t detail;
 
   void AssignUIEventData(const InternalUIEvent& aEvent, bool aCopyTargets)
   {
     AssignGUIEventData(aEvent, aCopyTargets);
 
-    // detail must have been initialized with the constructor.
+    detail = aEvent.detail;
   }
 };
 
 } // namespace mozilla
 
 #endif // mozilla_BasicEvents_h__
--- a/widget/ContentEvents.h
+++ b/widget/ContentEvents.h
@@ -239,17 +239,17 @@ public:
  ******************************************************************************/
 
 class InternalFocusEvent : public InternalUIEvent
 {
 public:
   virtual InternalFocusEvent* AsFocusEvent() MOZ_OVERRIDE { return this; }
 
   InternalFocusEvent(bool aIsTrusted, uint32_t aMessage) :
-    InternalUIEvent(aIsTrusted, aMessage, NS_FOCUS_EVENT, 0),
+    InternalUIEvent(aIsTrusted, aMessage, NS_FOCUS_EVENT),
     fromRaise(false), isRefocus(false)
   {
   }
 
   virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
   {
     MOZ_ASSERT(eventStructType == NS_FOCUS_EVENT,
                "Duplicate() must be overridden by sub class");