Bug 1637135 - Hit-test input events in layout coordinates on mobile. r=tnikkel

Depends on D76996

Differential Revision: https://phabricator.services.mozilla.com/D76997
This commit is contained in:
Botond Ballo 2020-05-27 06:55:39 +00:00
parent ed360f1a91
commit 6c825b036b

View File

@ -6965,6 +6965,24 @@ bool PresShell::EventHandler::MaybeFlushPendingNotifications(
}
}
// 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);
@ -6973,7 +6991,7 @@ nsIFrame* PresShell::EventHandler::GetFrameToHandleNonTouchEvent(
ViewportType viewportType = ViewportType::Layout;
if (aRootFrameToHandleEvent->Type() == LayoutFrameType::Viewport &&
aRootFrameToHandleEvent->PresContext()->IsRootContentDocument()) {
viewportType = ViewportType::Visual;
viewportType = ViewportTypeForInputEventsRelativeToRoot();
}
RelativeTo relativeTo{aRootFrameToHandleEvent, viewportType};
nsPoint eventPoint =