Bug 1540545 - Use consistent hit test options in AccessibleCaretManager. r=TYLin a=RyanVM DEVEDITION_67_0b13_BUILD1 DEVEDITION_67_0b13_RELEASE FENNEC_67_0b13_BUILD1 FENNEC_67_0b13_RELEASE FIREFOX_67_0b13_BUILD1 FIREFOX_67_0b13_RELEASE
authorBotond Ballo <botond@mozilla.com>
Tue, 16 Apr 2019 20:35:07 +0000
changeset 523279 ceb8833f34c3df62c7f4bf628ff769c1a638b240
parent 523278 9b8ad8b840ed4cc8545123c49a2cafb401e322d3
child 523280 d001f7405c98a8042b87de0c1197eede05004bf3
push id11125
push usernbeleuzu@mozilla.com
push dateMon, 22 Apr 2019 16:37:45 +0000
treeherdermozilla-beta@ceb8833f34c3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersTYLin, RyanVM
bugs1540545
milestone67.0
Bug 1540545 - Use consistent hit test options in AccessibleCaretManager. r=TYLin a=RyanVM It's important to use the IgnoreRootScrollFrame for correct hit testing when zoomed in or out on Android. The hit test in DragCaretInternal() was missing this flag. Differential Revision: https://phabricator.services.mozilla.com/D27636
layout/base/AccessibleCaretManager.cpp
--- a/layout/base/AccessibleCaretManager.cpp
+++ b/layout/base/AccessibleCaretManager.cpp
@@ -464,16 +464,28 @@ nsresult AccessibleCaretManager::TapCare
   if (GetCaretMode() == CaretMode::Cursor) {
     DispatchCaretStateChangedEvent(CaretChangedReason::Taponcaret);
     rv = NS_OK;
   }
 
   return rv;
 }
 
+static EnumSet<nsLayoutUtils::FrameForPointOption> GetHitTestOptions() {
+  EnumSet<nsLayoutUtils::FrameForPointOption> options = {
+      nsLayoutUtils::FrameForPointOption::IgnorePaintSuppression,
+      nsLayoutUtils::FrameForPointOption::IgnoreCrossDoc};
+#ifdef MOZ_WIDGET_ANDROID
+  // On Android, we need IgnoreRootScrollFrame for correct hit testing when
+  // zoomed in or out.
+  options += nsLayoutUtils::FrameForPointOption::IgnoreRootScrollFrame;
+#endif
+  return options;
+}
+
 nsresult AccessibleCaretManager::SelectWordOrShortcut(const nsPoint& aPoint) {
   // If the long-tap is landing on a pre-existing selection, don't replace
   // it with a new one. Instead just return and let the context menu pop up
   // on the pre-existing selection.
   if (GetCaretMode() == CaretMode::Selection &&
       GetSelection()->ContainsPoint(aPoint)) {
     AC_LOG("%s: UpdateCarets() for current selection", __FUNCTION__);
     UpdateCarets();
@@ -486,27 +498,18 @@ nsresult AccessibleCaretManager::SelectW
   }
 
   nsIFrame* rootFrame = mPresShell->GetRootFrame();
   if (!rootFrame) {
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   // Find the frame under point.
-  EnumSet<nsLayoutUtils::FrameForPointOption> options = {
-      nsLayoutUtils::FrameForPointOption::IgnorePaintSuppression,
-      nsLayoutUtils::FrameForPointOption::IgnoreCrossDoc};
-#ifdef MOZ_WIDGET_ANDROID
-  // On Android, we need IgnoreRootScrollFrame for correct hit testing when
-  // zoomed in or out.
-  options += nsLayoutUtils::FrameForPointOption::IgnoreRootScrollFrame;
-#endif
-
   AutoWeakFrame ptFrame =
-      nsLayoutUtils::GetFrameForPoint(rootFrame, aPoint, options);
+      nsLayoutUtils::GetFrameForPoint(rootFrame, aPoint, GetHitTestOptions());
   if (!ptFrame.GetFrame()) {
     return NS_ERROR_FAILURE;
   }
 
   nsIFrame* focusableFrame = GetFocusableFrame(ptFrame);
 
 #ifdef DEBUG_FRAME_DUMP
   AC_LOG("%s: Found %s under (%d, %d)", __FUNCTION__, ptFrame->ListTag().get(),
@@ -1092,20 +1095,19 @@ nsresult AccessibleCaretManager::DragCar
 
   nsIFrame* rootFrame = mPresShell->GetRootFrame();
   MOZ_ASSERT(rootFrame, "We need root frame to compute caret dragging!");
 
   nsPoint point = AdjustDragBoundary(
       nsPoint(aPoint.x, aPoint.y + mOffsetYToCaretLogicalPosition));
 
   // Find out which content we point to
-  nsIFrame* ptFrame = nsLayoutUtils::GetFrameForPoint(
-      rootFrame, point,
-      {nsLayoutUtils::FrameForPointOption::IgnorePaintSuppression,
-       nsLayoutUtils::FrameForPointOption::IgnoreCrossDoc});
+
+  nsIFrame* ptFrame =
+      nsLayoutUtils::GetFrameForPoint(rootFrame, point, GetHitTestOptions());
   if (!ptFrame) {
     return NS_ERROR_FAILURE;
   }
 
   RefPtr<nsFrameSelection> fs = GetFrameSelection();
   MOZ_ASSERT(fs);
 
   nsresult result;