Bug 1416962 - Remove the support for disabling "drag and select" on touchable devices. draft
authorTing-Yu Lin <tlin@mozilla.com>
Tue, 14 Nov 2017 11:22:59 +0800
changeset 697484 33e7351f593ce4e133f970c5d14caa2655c8f321
parent 697453 e1d7427787f7a26983c92ea1a1ac99eb863edd6c
child 740139 c364b3ee55bb2aec0f8f71ef5a3c8c9b2f9d72f7
push id89024
push userbmo:tlin@mozilla.com
push dateTue, 14 Nov 2017 05:39:48 +0000
bugs1416962
milestone59.0a1
Bug 1416962 - Remove the support for disabling "drag and select" on touchable devices. The pref "browser.ignoreNativeFrameTextSelection" was used only by B2G, and currently not enabled elsewhere, so this code is dead now. Also, this functionality is obsoleted by AccessibleCaret. MozReview-Commit-ID: 2kHYXLueFH5
layout/generic/nsFrame.cpp
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -4083,27 +4083,25 @@ nsFrame::HandlePress(nsPresContext* aPre
   // StyleUserSelect::Toggle, need to change this logic
   bool useFrameSelection = (selectStyle == StyleUserSelect::Text);
 
   // If the mouse is dragged outside the nearest enclosing scrollable area
   // while making a selection, the area will be scrolled. To do this, capture
   // the mouse on the nearest scrollable frame. If there isn't a scrollable
   // frame, or something else is already capturing the mouse, there's no
   // reason to capture.
-  bool hasCapturedContent = false;
   if (!nsIPresShell::GetCapturingContent()) {
     nsIScrollableFrame* scrollFrame =
       nsLayoutUtils::GetNearestScrollableFrame(this,
         nsLayoutUtils::SCROLLABLE_SAME_DOC |
         nsLayoutUtils::SCROLLABLE_INCLUDE_HIDDEN);
     if (scrollFrame) {
       nsIFrame* capturingFrame = do_QueryFrame(scrollFrame);
       nsIPresShell::SetCapturingContent(capturingFrame->GetContent(),
                                         CAPTURE_IGNOREALLOWED);
-      hasCapturedContent = true;
     }
   }
 
   // XXX This is screwy; it really should use the selection frame, not the
   // event frame
   const nsFrameSelection* frameselection = nullptr;
   if (useFrameSelection)
     frameselection = GetConstFrameSelection();
@@ -4131,34 +4129,16 @@ nsFrame::HandlePress(nsPresContext* aPre
   }
 
   nsPoint pt = nsLayoutUtils::GetEventCoordinatesRelativeTo(mouseEvent, this);
   ContentOffsets offsets = GetContentOffsetsFromPoint(pt, SKIP_HIDDEN);
 
   if (!offsets.content)
     return NS_ERROR_FAILURE;
 
-  // On touchables devices, touch the screen is usually a pan action,
-  // so let's reposition the caret if needed but do not select text
-  // if the touch did not happen over an editable element.  Otherwise,
-  // let the user move the caret by tapping and dragging.
-  if (!offsets.content->IsEditable() &&
-      Preferences::GetBool("browser.ignoreNativeFrameTextSelection", false)) {
-    // On touchables devices, mouse events are generated if the gesture is a tap.
-    // Such events are never going to generate a drag action, so let's release
-    // captured content if any.
-    if (hasCapturedContent) {
-      nsIPresShell::SetCapturingContent(nullptr, 0);
-    }
-
-    return fc->HandleClick(offsets.content, offsets.StartOffset(),
-                           offsets.EndOffset(), false, false,
-                           offsets.associate);
-  }
-
   // Let Ctrl/Cmd+mouse down do table selection instead of drag initiation
   nsCOMPtr<nsIContent>parentContent;
   int32_t  contentOffset;
   int32_t target;
   nsresult rv;
   rv = GetDataForTableSelection(frameselection, shell, mouseEvent,
                                 getter_AddRefs(parentContent), &contentOffset,
                                 &target);