Bug 964153 Remove unnecessary constructor of WidgetTouchEvent and don't copy its widget in Duplicate() r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 11 Feb 2014 14:35:25 +0900
changeset 186246 cfcebde86f40b458de8113a4fd083078af0e843f
parent 186245 ada4aec5053f52ba36591a0b3af0b94ddb4806b0
child 186247 978094768f3ed5ac66164b977f2ac0fb6e79e65a
push id474
push userasasaki@mozilla.com
push dateMon, 02 Jun 2014 21:01:02 +0000
treeherdermozilla-release@967f4cf1b31c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs964153
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 964153 Remove unnecessary constructor of WidgetTouchEvent and don't copy its widget in Duplicate() r=smaug
layout/base/nsPresShell.cpp
widget/TouchEvents.h
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -7203,17 +7203,19 @@ PresShell::DispatchTouchEvent(WidgetEven
     if (capturingContent) {
       if (capturingContent->OwnerDoc() != doc) {
         // Wrong document, don't dispatch anything.
         continue;
       }
       content = capturingContent;
     }
     // copy the event
-    WidgetTouchEvent newEvent(touchEvent->mFlags.mIsTrusted, touchEvent);
+    WidgetTouchEvent newEvent(touchEvent->mFlags.mIsTrusted,
+                              touchEvent->message, touchEvent->widget);
+    newEvent.AssignTouchEventData(*touchEvent, false);
     newEvent.target = targetPtr;
 
     nsRefPtr<PresShell> contentPresShell;
     if (doc == mDocument) {
       contentPresShell = static_cast<PresShell*>(doc->GetShell());
       if (contentPresShell) {
         //XXXsmaug huge hack. Pushing possibly capturing content,
         //         even though event target is something else.
--- a/widget/TouchEvents.h
+++ b/widget/TouchEvents.h
@@ -144,53 +144,45 @@ public:
                      NS_TOUCH_EVENT)
   {
     modifiers = aOther.modifiers;
     time = aOther.time;
     touches.AppendElements(aOther.touches);
     MOZ_COUNT_CTOR(WidgetTouchEvent);
   }
 
-  WidgetTouchEvent(bool aIsTrusted, const WidgetTouchEvent* aEvent) :
-    WidgetInputEvent(aIsTrusted, aEvent->message, aEvent->widget,
-                     NS_TOUCH_EVENT)
-  {
-    modifiers = aEvent->modifiers;
-    time = aEvent->time;
-    touches.AppendElements(aEvent->touches);
-    MOZ_COUNT_CTOR(WidgetTouchEvent);
-  }
-
   WidgetTouchEvent(bool aIsTrusted, uint32_t aMessage, nsIWidget* aWidget) :
     WidgetInputEvent(aIsTrusted, aMessage, aWidget, NS_TOUCH_EVENT)
   {
     MOZ_COUNT_CTOR(WidgetTouchEvent);
   }
 
   virtual ~WidgetTouchEvent()
   {
     MOZ_COUNT_DTOR(WidgetTouchEvent);
   }
 
   virtual WidgetEvent* Duplicate() const MOZ_OVERRIDE
   {
     MOZ_ASSERT(eventStructType == NS_TOUCH_EVENT,
                "Duplicate() must be overridden by sub class");
-    // XXX Why does only WidgetTouchEvent copy the widget?
-    WidgetTouchEvent* result = new WidgetTouchEvent(false, this);
+    // Not copying widget, it is a weak reference.
+    WidgetTouchEvent* result = new WidgetTouchEvent(false, message, nullptr);
     result->AssignTouchEventData(*this, true);
     result->mFlags = mFlags;
     return result;
   }
 
   nsTArray<nsRefPtr<mozilla::dom::Touch>> touches;
 
   void AssignTouchEventData(const WidgetTouchEvent& aEvent, bool aCopyTargets)
   {
     AssignInputEventData(aEvent, aCopyTargets);
 
-    // Currently, we don't need to copy touches.
+    // Assign*EventData() assume that they're called only new instance.
+    MOZ_ASSERT(touches.IsEmpty());
+    touches.AppendElements(aEvent.touches);
   }
 };
 
 } // namespace mozilla
 
 #endif // mozilla_TouchEvents_h__