From 8a95213cde96f0787fced61bd4022540cdd6dae2 Mon Sep 17 00:00:00 2001 From: Olli Pettay Date: Thu, 17 Jul 2014 13:27:27 +0300 Subject: [PATCH] backout Bug 378775 because of several regressions, r=backout --- browser/base/content/test/newtab/head.js | 8 ++-- dom/events/EventStateManager.cpp | 55 +++++++----------------- dom/events/test/test_dragstart.html | 34 ++------------- layout/generic/nsFrame.cpp | 4 +- 4 files changed, 24 insertions(+), 77 deletions(-) diff --git a/browser/base/content/test/newtab/head.js b/browser/base/content/test/newtab/head.js index caad3fc8cdb..09a26ee8f88 100644 --- a/browser/base/content/test/newtab/head.js +++ b/browser/base/content/test/newtab/head.js @@ -516,13 +516,13 @@ function synthesizeNativeMouseLUp(aElement) { } /** - * 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); } /** diff --git a/dom/events/EventStateManager.cpp b/dom/events/EventStateManager.cpp index 24cde2eab99..cf642ef2355 100644 --- a/dom/events/EventStateManager.cpp +++ b/dom/events/EventStateManager.cpp @@ -1562,6 +1562,17 @@ EventStateManager::GenerateDragGesture(nsPresContext* aPresContext, return; } + // Check if selection is tracking drag gestures, if so + // don't interfere! + if (mCurrentTarget) + { + nsRefPtr 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(); @@ -1585,51 +1596,14 @@ EventStateManager::GenerateDragGesture(nsPresContext* aPresContext, // 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 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 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 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 container = aPresContext->GetContainerWeak(); nsCOMPtr window = do_GetInterface(container); if (!window) @@ -1639,7 +1613,8 @@ EventStateManager::GenerateDragGesture(nsPresContext* aPresContext, new DataTransfer(window, NS_DRAGDROP_START, false, -1); nsCOMPtr selection; - nsCOMPtr targetContent; + nsCOMPtr eventContent, targetContent; + mCurrentTarget->GetContentForEvent(aEvent, getter_AddRefs(eventContent)); if (eventContent) DetermineDragTarget(window, eventContent, dataTransfer, getter_AddRefs(selection), getter_AddRefs(targetContent)); diff --git a/dom/events/test/test_dragstart.html b/dom/events/test/test_dragstart.html index 637c5a21d44..3d518a1e04c 100644 --- a/dom/events/test/test_dragstart.html +++ b/dom/events/test/test_dragstart.html @@ -63,15 +63,8 @@ function afterDragTests() 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 @@ -92,10 +85,8 @@ function afterDragTests() 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) @@ -106,23 +97,6 @@ function sendMouseEventsForDrag(nodeid) 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"); diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 0a132c743bf..2ba8020af72 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -2693,10 +2693,8 @@ nsFrame::HandlePress(nsPresContext* aPresContext, 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))) {