backout Bug 378775 because of several regressions, r=backout
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 17 Jul 2014 13:27:27 +0300
changeset 216591 328ca3cea665b57f3f044fb37377991d3c1a37ae
parent 216590 b2a822934b97ba6f5a90b3f172929f2039728c98
child 216592 557bc4f3fd268b1eae8ea4a047349886f197dede
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs378775
milestone33.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
backout Bug 378775 because of several regressions, r=backout
browser/base/content/test/newtab/head.js
dom/events/EventStateManager.cpp
dom/events/test/test_dragstart.html
layout/generic/nsFrame.cpp
--- a/browser/base/content/test/newtab/head.js
+++ b/browser/base/content/test/newtab/head.js
@@ -511,23 +511,23 @@ function synthesizeNativeMouseLDown(aEle
  * @param aElement The element used to determine the cursor position.
  */
 function synthesizeNativeMouseLUp(aElement) {
   let msg = isWindows ? 4 : (isMac ? 2 : 7);
   synthesizeNativeMouseEvent(aElement, msg);
 }
 
 /**
- * Fires a synthetic mouse vertical drag event on the current about:newtab page.
+ * Fires a synthetic mouse drag event on the current about:newtab page.
  * @param aElement The element used to determine the cursor position.
- * @param aOffsetY The top offset that is added to the position.
+ * @param aOffsetX The left offset that is added to the position.
  */
-function synthesizeNativeMouseDrag(aElement, aOffsetY) {
+function synthesizeNativeMouseDrag(aElement, aOffsetX) {
   let msg = isMac ? 6 : 1;
-  synthesizeNativeMouseEvent(aElement, msg, 0, aOffsetY);
+  synthesizeNativeMouseEvent(aElement, msg, aOffsetX);
 }
 
 /**
  * Fires a synthetic 'mousemove' event on the current about:newtab page.
  * @param aElement The element used to determine the cursor position.
  */
 function synthesizeNativeMouseMove(aElement) {
   let msg = isMac ? 5 : 1;
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -1557,16 +1557,27 @@ EventStateManager::GenerateDragGesture(n
   if (IsTrackingDragGesture()) {
     mCurrentTarget = mGestureDownFrameOwner->GetPrimaryFrame();
 
     if (!mCurrentTarget) {
       StopTrackingDragGesture();
       return;
     }
 
+    // Check if selection is tracking drag gestures, if so
+    // don't interfere!
+    if (mCurrentTarget)
+    {
+      nsRefPtr<nsFrameSelection> frameSel = mCurrentTarget->GetFrameSelection();
+      if (frameSel && frameSel->GetMouseDownState()) {
+        StopTrackingDragGesture();
+        return;
+      }
+    }
+
     // If non-native code is capturing the mouse don't start a drag.
     if (nsIPresShell::IsMouseCapturePreventingDrag()) {
       StopTrackingDragGesture();
       return;
     }
 
     static int32_t pixelThresholdX = 0;
     static int32_t pixelThresholdY = 0;
@@ -1580,71 +1591,35 @@ EventStateManager::GenerateDragGesture(n
         pixelThresholdX = 5;
       if (!pixelThresholdY)
         pixelThresholdY = 5;
     }
 
     // fire drag gesture if mouse has moved enough
     LayoutDeviceIntPoint pt = aEvent->refPoint +
       LayoutDeviceIntPoint::FromUntyped(aEvent->widget->WidgetToScreenOffset());
-    if (Abs(pt.x - mGestureDownPoint.x) > Abs(pixelThresholdX) ||
-        Abs(pt.y - mGestureDownPoint.y) > Abs(pixelThresholdY)) {
+    if (DeprecatedAbs(pt.x - mGestureDownPoint.x) > pixelThresholdX ||
+        DeprecatedAbs(pt.y - mGestureDownPoint.y) > pixelThresholdY) {
       if (Prefs::ClickHoldContextMenu()) {
         // stop the click-hold before we fire off the drag gesture, in case
         // it takes a long time
         KillClickHoldTimer();
       }
 
-      nsCOMPtr<nsIContent> eventContent;
-      mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(eventContent));
-
-      // Make it easier to select link text by only dragging in the vertical direction
-      bool isLinkDraggedVertical = false;
-      bool isDraggableLink = false;
-      nsCOMPtr<nsIContent> dragLinkNode = eventContent;
-      while (dragLinkNode) {
-        if (nsContentUtils::IsDraggableLink(dragLinkNode)) {
-          isDraggableLink = true;
-          // Treat as vertical drag when cursor exceeds the top or bottom of the threshold box
-          isLinkDraggedVertical = Abs(pt.y - mGestureDownPoint.y) > Abs(pixelThresholdY);
-          break;
-        }
-        dragLinkNode = dragLinkNode->GetParent();
-      }
-
-      // Check if selection is tracking drag gestures, if so
-      // don't interfere!
-      if (mCurrentTarget) {
-        nsRefPtr<nsFrameSelection> frameSel = mCurrentTarget->GetFrameSelection();
-        if (frameSel && frameSel->GetMouseDownState()) {
-          if (isLinkDraggedVertical) {
-            // Stop selecting when link dragged vertically
-            frameSel->SetMouseDownState(PR_FALSE);
-            // Clear any selection to prevent it being dragged instead of link
-            frameSel->ClearNormalSelection();
-          } else {
-            StopTrackingDragGesture();
-            // Don't register click for draggable links when selecting
-            if (isDraggableLink)
-              mLClickCount = 0;
-            return;
-          }
-        }
-      }
-
       nsCOMPtr<nsISupports> container = aPresContext->GetContainerWeak();
       nsCOMPtr<nsPIDOMWindow> window = do_GetInterface(container);
       if (!window)
         return;
 
       nsRefPtr<DataTransfer> dataTransfer =
         new DataTransfer(window, NS_DRAGDROP_START, false, -1);
 
       nsCOMPtr<nsISelection> selection;
-      nsCOMPtr<nsIContent> targetContent;
+      nsCOMPtr<nsIContent> eventContent, targetContent;
+      mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(eventContent));
       if (eventContent)
         DetermineDragTarget(window, eventContent, dataTransfer,
                             getter_AddRefs(selection), getter_AddRefs(targetContent));
 
       // Stop tracking the drag gesture now. This should stop us from
       // reentering GenerateDragGesture inside DOM event processing.
       StopTrackingDragGesture();
 
--- a/dom/events/test/test_dragstart.html
+++ b/dom/events/test/test_dragstart.html
@@ -58,25 +58,18 @@ function afterDragTests()
   $("synthetic").dispatchEvent(evt);
 
   var evt = document.createEvent("dragevents");
   ok(evt instanceof DragEvent, "synthetic dragevents class")
   evt.initDragEvent("dragover", true, true, window, 0, 40, 35, 20, 15,
                     true, false, true, true, 2, document.documentElement, null);
   $("synthetic2").dispatchEvent(evt);
 
-  // link vertical dragging
-  sendMouseEventsForVerticalDrag("link");
-  is(window.getSelection().isCollapsed, true, "link vertical drag clears selection");
-
-  // link horizontal selection
-  sendMouseEventsForHorizontalSelection("link");
-  is(window.getSelection().isCollapsed, false, "link horizontal selection");
-
-  // images
+  // next, dragging links and images
+  sendMouseEventsForDrag("link");
   sendMouseEventsForDrag("image");
 
 //  disable testing input dragging for now, as it doesn't seem to be testable 
 //  draggable = $("input");
 //  draggable.setSelectionRange(0, 4);
 //  synthesizeMouse(draggable, 8, 8, { type: "mousedown" });
 //  synthesizeMouse(draggable, 15, 15, { type: "mousemove" });
 //  sendMouseEventsForDrag("input");
@@ -87,47 +80,28 @@ function afterDragTests()
   gDragInfo = { target: $("dragtrue"), testid: "draggable true child" };
   sendMouseEventsForDrag("spantrue");
   gDragInfo = { target: $("dragfalse").firstChild, testid: "draggable false node" };
   sendMouseEventsForDrag("dragfalse");
   gDragInfo = { target: $("spanfalse").firstChild, testid: "draggable false child" };
   sendMouseEventsForDrag("spanfalse");
 
   synthesizeMouse(draggable, 12, 12, { type: "mouseup" });
-
-  is(gExtraDragTests, 4, "number of drag events");
-
-  SimpleTest.finish();
+  if (gExtraDragTests == 4)
+    SimpleTest.finish();
 }
 
 function sendMouseEventsForDrag(nodeid)
 {
   var draggable = $(nodeid);
   synthesizeMouse(draggable, 3, 3, { type: "mousedown" });
   synthesizeMouse(draggable, 10, 10, { type: "mousemove" });
   synthesizeMouse(draggable, 12, 12, { type: "mousemove" });
 }
 
-function sendMouseEventsForVerticalDrag(nodeid)
-{
-  var draggable = $(nodeid);
-  synthesizeMouse(draggable, 3, 3, { type: "mousedown" });
-  synthesizeMouse(draggable, 3, 10, { type: "mousemove" });
-  synthesizeMouse(draggable, 3, 12, { type: "mousemove" });
-}
-
-function sendMouseEventsForHorizontalSelection(nodeid)
-{
-  var draggable = $(nodeid);
-  synthesizeMouse(draggable, 3, 3, { type: "mousedown" });
-  synthesizeMouse(draggable, 10, 3, { type: "mousemove" });
-  synthesizeMouse(draggable, 12, 3, { type: "mousemove" });
-  synthesizeMouse(draggable, 12, 3, { type: "mouseup" });
-}
-
 function doDragStartSelection(event)
 {
   is(event.type, "dragstart", "dragstart event type");
   is(event.target, $("draggable").firstChild, "dragstart event target");
   is(event.bubbles, true, "dragstart event bubbles");
   is(event.cancelable, true, "dragstart event cancelable");
 
   is(event.clientX, 14, "dragstart clientX");
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -2688,20 +2688,18 @@ nsFrame::HandlePress(nsPresContext* aPre
   //weaaak. only the editor can display frame selection not just text and images
   isEditor = isEditor == nsISelectionDisplay::DISPLAY_ALL;
 
   WidgetMouseEvent* mouseEvent = aEvent->AsMouseEvent();
 
   if (!mouseEvent->IsAlt()) {
     for (nsIContent* content = mContent; content;
          content = content->GetParent()) {
-      // Prevent selection of draggable content with the exception of links
       if (nsContentUtils::ContentIsDraggable(content) &&
-          !content->IsEditable() &&
-          !nsContentUtils::IsDraggableLink(content)) {
+          !content->IsEditable()) {
         // coordinate stuff is the fix for bug #55921
         if ((mRect - GetPosition()).Contains(
               nsLayoutUtils::GetEventCoordinatesRelativeTo(mouseEvent, this))) {
           return NS_OK;
         }
       }
     }
   }