Bug 1637135 - Hit-test input events in layout coordinates on mobile. r=tnikkel
authorBotond Ballo <botond@mozilla.com>
Wed, 27 May 2020 06:55:39 +0000
changeset 532320 d97315ba56440fdfe2bd42ca52214aebabd0344f
parent 532319 3999e81acbf79c8d87f0066e8492fa7228f35f7b
child 532321 1109bd345ac2f3c610c2baa0791825f95c1b6bdd
push id37454
push userccoroiu@mozilla.com
push dateWed, 27 May 2020 16:14:31 +0000
treeherdermozilla-central@a1dd9afbfdf5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstnikkel
bugs1637135
milestone78.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 1637135 - Hit-test input events in layout coordinates on mobile. r=tnikkel Depends on D76996 Differential Revision: https://phabricator.services.mozilla.com/D76997
layout/base/PresShell.cpp
--- a/layout/base/PresShell.cpp
+++ b/layout/base/PresShell.cpp
@@ -6960,25 +6960,43 @@ bool PresShell::EventHandler::MaybeFlush
       return framesConstructedCount != presContext->FramesConstructedCount() ||
              framesReflowedCount != presContext->FramesReflowedCount();
     }
     default:
       return false;
   }
 }
 
+// The type of coordinates to use for hit-testing input events
+// that are relative to the RCD's viewport frame.
+// On most platforms, use visual coordinates so that scrollbars
+// can be targeted.
+// On mobile, use layout coordinates because hit-testing in
+// visual coordinates clashes with mobile viewport sizing, where
+// the ViewportFrame is sized to the initial containing block
+// (ICB) size, which is in layout coordinates. This is fine
+// because we don't need to be able to target scrollbars on mobile
+// (scrollbar dragging isn't supported).
+static ViewportType ViewportTypeForInputEventsRelativeToRoot() {
+#ifdef MOZ_WIDGET_ANDROID
+  return ViewportType::Layout;
+#else
+  return ViewportType::Visual;
+#endif
+}
+
 nsIFrame* PresShell::EventHandler::GetFrameToHandleNonTouchEvent(
     nsIFrame* aRootFrameToHandleEvent, WidgetGUIEvent* aGUIEvent) {
   MOZ_ASSERT(aGUIEvent);
   MOZ_ASSERT(aGUIEvent->mClass != eTouchEventClass);
 
   ViewportType viewportType = ViewportType::Layout;
   if (aRootFrameToHandleEvent->Type() == LayoutFrameType::Viewport &&
       aRootFrameToHandleEvent->PresContext()->IsRootContentDocument()) {
-    viewportType = ViewportType::Visual;
+    viewportType = ViewportTypeForInputEventsRelativeToRoot();
   }
   RelativeTo relativeTo{aRootFrameToHandleEvent, viewportType};
   nsPoint eventPoint =
       nsLayoutUtils::GetEventCoordinatesRelativeTo(aGUIEvent, relativeTo);
 
   uint32_t flags = 0;
   if (aGUIEvent->mClass == eMouseEventClass) {
     WidgetMouseEvent* mouseEvent = aGUIEvent->AsMouseEvent();