backout Bug 378775 because of several regressions, r=backout

This commit is contained in:
Olli Pettay 2014-07-17 13:27:27 +03:00
parent 3496d46720
commit 8a95213cde
4 changed files with 24 additions and 77 deletions

View File

@ -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);
}
/**

View File

@ -1562,6 +1562,17 @@ EventStateManager::GenerateDragGesture(nsPresContext* aPresContext,
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();
@ -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<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)
@ -1639,7 +1613,8 @@ EventStateManager::GenerateDragGesture(nsPresContext* aPresContext,
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));

View File

@ -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");

View File

@ -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))) {