Bug 1062307 - Ensure the contextmenu event triggered by a long-press action targets things outside the root scroll frame. r=capella, r=smaug, a=lmandel
authorKartikaya Gupta <kgupta@mozilla.com>
Sat, 06 Sep 2014 09:30:46 -0400
changeset 224854 9bc2db4fd695dec51a18603c7d3e02b6c80d3fe1
parent 224853 25e5b5838db2e308a3ab78f07551d75d975b0132
child 224855 45a8baf21ae601bdaca36731b1a9e3719651c3f5
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscapella, smaug, lmandel
bugs1062307
milestone34.0a2
Bug 1062307 - Ensure the contextmenu event triggered by a long-press action targets things outside the root scroll frame. r=capella, r=smaug, a=lmandel
layout/base/nsPresShell.cpp
widget/android/nsWindow.cpp
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -6910,17 +6910,18 @@ PresShell::HandleEvent(nsIFrame* aFrame,
       retargetEventDoc = window->GetExtantDoc();
       if (!retargetEventDoc)
         return NS_OK;
     } else if (capturingContent) {
       // if the mouse is being captured then retarget the mouse event at the
       // document that is being captured.
       retargetEventDoc = capturingContent->GetCrossShadowCurrentDoc();
 #ifdef ANDROID
-    } else if (aEvent->mClass == eTouchEventClass) {
+    } else if (aEvent->mClass == eTouchEventClass ||
+              (aEvent->AsMouseEvent() && aEvent->AsMouseEvent()->inputSource == nsIDOMMouseEvent::MOZ_SOURCE_TOUCH)) {
       retargetEventDoc = GetTouchEventTargetDocument();
 #endif
     }
 
     if (retargetEventDoc) {
       nsCOMPtr<nsIPresShell> presShell = retargetEventDoc->GetShell();
       if (!presShell)
         return NS_OK;
--- a/widget/android/nsWindow.cpp
+++ b/widget/android/nsWindow.cpp
@@ -1035,17 +1035,20 @@ nsWindow::OnContextmenuEvent(AndroidGeck
     if (points.Length() > 0) {
         pt = CSSPoint(points[0].x, points[0].y);
     }
 
     // Send the contextmenu event.
     WidgetMouseEvent contextMenuEvent(true, NS_CONTEXTMENU, this,
                                       WidgetMouseEvent::eReal, WidgetMouseEvent::eNormal);
     contextMenuEvent.refPoint =
-        LayoutDeviceIntPoint(RoundedToInt(pt * GetDefaultScale()));
+        LayoutDeviceIntPoint(RoundedToInt(pt * GetDefaultScale())) -
+        LayoutDeviceIntPoint::FromUntyped(WidgetToScreenOffset());
+    contextMenuEvent.ignoreRootScrollFrame = true;
+    contextMenuEvent.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
 
     nsEventStatus contextMenuStatus;
     DispatchEvent(&contextMenuEvent, contextMenuStatus);
 
     // If the contextmenu event was consumed (preventDefault issued), we follow with a
     // touchcancel event. This avoids followup touchend events passsing through and
     // triggering further element behaviour such as link-clicks.
     if (contextMenuStatus == nsEventStatus_eConsumeNoDefault) {