Commit 59bd1cdf authored by dcheng@chromium.org's avatar dcheng@chromium.org

Don't abort drags if drag image generation fails.

This unintuitively caused drags to end immediately if a page called
setDragImage with a detached node or one that hadn't been through layout
yet. There's nothing in the spec that says the drags should abort in
this case either, so this makes Blink more spec-conformant.

BUG=413795

Review URL: https://codereview.chromium.org/724663002

git-svn-id: svn://svn.chromium.org/blink/trunk@185343 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 0ff05185
Test that calling setDragImage() with a detached node doesn't immediately abort the drag. This test can be manually run by dragging the 'Drag Me' div around and then ending the drag.
Drag Me
PASS successfullyParsed is true
TEST COMPLETE
Started drag.
PASS Ended drag.
<!DOCTYPE html>
<script src="../../resources/js-test.js"></script>
<script>
var dragEndExpected = true;
window.onload = function()
{
var dragger = document.getElementById('dragMe');
dragger.addEventListener('dragstart', dragStart);
dragger.addEventListener('drag', dragging);
dragger.addEventListener('dragend', dragEnd);
if (!window.testRunner)
return;
var x = dragger.offsetLeft + dragger.offsetWidth / 2;
var y = dragger.offsetTop + dragger.offsetHeight / 2;
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
eventSender.leapForward(100);
eventSender.mouseMoveTo(x + 100, y + 100);
eventSender.mouseUp();
}
function dragStart(e)
{
if (window.testRunner)
dragEndExpected = false;
debug('Started drag.');
var emptyDiv = document.createElement('div');
e.dataTransfer.setDragImage(emptyDiv, 0, 0);
}
function dragging()
{
dragEndExpected = true;
}
function dragEnd()
{
if (!dragEndExpected)
testFailed('Not expecting drag end!');
else
testPassed('Ended drag.');
}
</script>
<style>
html, body {
height: 100%;
margin: 0;
}
#dragMe {
border: 1px solid black;
}
</style>
<body>
<p>Test that calling setDragImage() with a detached node doesn't immediately abort the drag. This test can be manually run by dragging the 'Drag Me' div around and then ending the drag.
<div id="dragMe" draggable="true">Drag Me</div>
<div id="console"></div>
</body>
...@@ -931,8 +931,6 @@ bool DragController::startDrag(LocalFrame* src, const DragState& state, const Pl ...@@ -931,8 +931,6 @@ bool DragController::startDrag(LocalFrame* src, const DragState& state, const Pl
} }
doSystemDrag(dragImage.get(), dragLocation, mouseDraggedPoint, dataTransfer, src, true); doSystemDrag(dragImage.get(), dragLocation, mouseDraggedPoint, dataTransfer, src, true);
} else if (state.m_dragType == DragSourceActionDHTML) { } else if (state.m_dragType == DragSourceActionDHTML) {
if (!dragImage)
return false;
doSystemDrag(dragImage.get(), dragLocation, dragOrigin, dataTransfer, src, false); doSystemDrag(dragImage.get(), dragLocation, dragOrigin, dataTransfer, src, false);
} else { } else {
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
......
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