Commit 3c6c8615 authored by oliver@apple.com's avatar oliver@apple.com

<rdar://problem/6757346> SAP: Prevent default on mouseDown does not stop...

<rdar://problem/6757346> SAP: Prevent default on mouseDown does not stop iframe from capturing subsequent mouse moves

Reviewed by Darin Adler.

This is the first step of allowing drag events to match the behaviour
of mouse move events when the default action of the initial mouse down
is prevented.  Remaining issue is that the final mouse up event still
targets the original root frame.

Test: fast/events/mouse-drag-from-frame-to-other-frame.html


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@42760 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 13fde86c
2009-04-22 Oliver Hunt <oliver@apple.com>
Reviewed by Darin Adler.
<rdar://problem/6757346> SAP: Prevent default on mouseDown does not stop iframe from capturing subsequent mouse moves
Partial correctness test for non-capturing drag. Doesn't log the
final mouse up, as that's still not targetting the correct frame.
* fast/events/mouse-drag-from-frame-to-other-frame-expected.txt: Added.
* fast/events/mouse-drag-from-frame-to-other-frame.html: Added.
* fast/events/resources/mouse-drag-from-frame-target-subframe.html: Added.
2009-04-22 Mark Rowe <mrowe@apple.com>
Update test results after Blackbeard's change in r42752 to disable geolocation.
......
This tests that dragging from an element that returns false from its mousedown handler will not let the subsequent mousemove events be captured by the containing frame, and allows the mouse move to get to other subframes.
Drag Started
received mousemove
received mousemove
<!DOCTYPE html>
<html>
<head>
<script>
if (window.layoutTestController) {
layoutTestController.waitUntilDone();
layoutTestController.dumpAsText();
}
function log(msg) {
var msgNode = document.createTextNode(msg);
var li = document.createElement("li");
li.appendChild(msgNode);
document.getElementById("logElem").appendChild(li);
}
function dragStarted() {
log("Drag Started");
}
window.onmouseup = function() {
log("Root frame received mouse up");
}
window.onload = function() {
try {
if (!frames[0] || !frames[0].document || !frames[0].document.getElementById("dragSource")) {
log("Window.onload fired before subframe completed load.");
}
if (!window.layoutTestController) {
log("This test needs to be run in DRT. To test manually drag from the text 'Drag Me!' out into the parent frame.");
return;
}
var dragSource = frames[0].document.getElementById("dragSource");
var sourceFrame = document.getElementById("sourceFrame");
var targetFrame = document.getElementById("targetFrame");
var x = dragSource.offsetLeft + sourceFrame.offsetLeft + 10;
var y = dragSource.offsetTop + sourceFrame.offsetTop + dragSource.offsetHeight / 2;
var x1 = targetFrame.offsetLeft + 10;
var y1 = targetFrame.offsetTop + 10;
eventSender.mouseMoveTo(x,y);
eventSender.mouseDown();
eventSender.mouseMoveTo(x1, y1);
eventSender.mouseUp();
} finally {
if (window.layoutTestController)
layoutTestController.notifyDone();
}
}
</script>
</head>
<body>
<div>This tests that dragging from an element that returns <emph>false</emph> from its mousedown handler will not let the subsequent mousemove events be captured by the containing frame, and allows the mouse move to get to other subframes.</div>
<iframe id="sourceFrame" style="width: 100px; height: 50px;" src="resources/mouse-drag-from-frame-subframe.html"></iframe>
<iframe id="targetFrame" style="width: 100px; height: 50px;" src="resources/mouse-drag-from-frame-target-subframe.html"></iframe>
<ul id="logElem">
</ul>
</body>
</html>
<body onmousemove="parent.log('received mousemove')" onmouseup="/*parent.log('received mouseup')*/">
</body>
2009-04-22 Oliver Hunt <oliver@apple.com>
Reviewed by Darin Adler.
<rdar://problem/6757346> SAP: Prevent default on mouseDown does not stop iframe from capturing subsequent mouse moves
This is the first step of allowing drag events to match the behaviour
of mouse move events when the default action of the initial mouse down
is prevented. Remaining issue is that the final mouse up event still
targets the original root frame.
Test: fast/events/mouse-drag-from-frame-to-other-frame.html
* page/mac/EventHandlerMac.mm:
(WebCore::EventHandler::passSubframeEventToSubframe):
2009-04-22 Simon Fraser <simon.fraser@apple.com>
Reviewed by Adele Peterson
......@@ -30,6 +30,7 @@
#include "BlockExceptions.h"
#include "ChromeClient.h"
#include "ClipboardMac.h"
#include "DragController.h"
#include "EventNames.h"
#include "FocusController.h"
#include "FrameLoader.h"
......@@ -399,6 +400,15 @@ bool EventHandler::passSubframeEventToSubframe(MouseEventWithHitTestResults& eve
BEGIN_BLOCK_OBJC_EXCEPTIONS;
switch ([currentEvent().get() type]) {
case NSLeftMouseDragged:
case NSOtherMouseDragged:
case NSRightMouseDragged:
// This check is bogus and results in <rdar://6813830>, but removing it breaks a number of
// layout tests.
if (!m_mouseDownWasInSubframe)
return false;
if (subframe->page()->dragController()->didInitiateDrag())
return false;
case NSMouseMoved:
// Since we're passing in currentEvent() here, we can call
// handleMouseMoveEvent() directly, since the save/restore of
......@@ -433,18 +443,6 @@ bool EventHandler::passSubframeEventToSubframe(MouseEventWithHitTestResults& eve
m_sendingEventToSubview = false;
return true;
}
case NSLeftMouseDragged: {
if (!m_mouseDownWasInSubframe)
return false;
NSView *view = mouseDownViewIfStillGood();
if (!view)
return false;
ASSERT(!m_sendingEventToSubview);
m_sendingEventToSubview = true;
[view mouseDragged:currentEvent().get()];
m_sendingEventToSubview = false;
return true;
}
default:
return false;
}
......
2009-04-22 Oliver Hunt <oliver@apple.com>
Reviewed by Darin Adler.
<rdar://problem/6757346> SAP: Prevent default on mouseDown does not stop iframe from capturing subsequent mouse moves
Make mouseDragged forward to the root view as we do for mouseMoves.
* WebView/WebHTMLView.mm:
(-[WebHTMLView mouseDragged:]):
2009-04-22 Anders Carlsson <andersca@apple.com>
Reviewed by Oliver Hunt.
......
......@@ -3332,9 +3332,12 @@ done:
[self retain];
if (!_private->ignoringMouseDraggedEvents)
if (Frame* coreframe = core([self _frame]))
coreframe->eventHandler()->mouseDragged(event);
if (!_private->ignoringMouseDraggedEvents) {
if (Frame* frame = core([self _frame])) {
if (Page* page = frame->page())
page->mainFrame()->eventHandler()->mouseDragged(event);
}
}
[self release];
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment