Commit 68e71f32 authored by aestes@apple.com's avatar aestes@apple.com

REGRESSION (r105396): Dragging an iWork document into icloud.com opens it in...

REGRESSION (r105396): Dragging an iWork document into icloud.com opens it in the Mac app instead of uploading it to icloud.com
https://bugs.webkit.org/show_bug.cgi?id=79443

Reviewed by Ryosuke Niwa.

Source/WebCore:

icloud.com registers a drop event handler that sets display:none on the
file input element receiving the drop. After dispatching the drop event,
DragController hit tests the position under the mouse to see if it is a
file input element in need of receiving files. Since the file input
element has lost its renderer, it cannot be found by hit testing, so
the dropped file is never attached to the file input element, no change
event fires, and no upload commences. We want these things to happen
even if the element is no longer visible.

Since we already keep track of the file input element under the mouse
via m_fileInputElementUnderMouse, this additional hit test is
unnecessary. Use m_fileInputElementUnderMouse in concludeEditDrag()
when dropping files.

Test: fast/events/file-input-hidden-in-ondrop.html

* page/DragController.cpp:
(WebCore::DragController::concludeEditDrag): Use
m_fileInputElementUnderMouse instead of the element returned by hit
testing. Assert that m_fileInputElementUnderMouse equals the hit tested
element unless m_fileInputElementUnderMouse doesn't have a renderer.

LayoutTests:

* fast/events/file-input-hidden-in-ondrop-expected.txt: Added.
* fast/events/file-input-hidden-in-ondrop.html: Added.
* platform/wk2/Skipped: WebKitTestRunner doesn't support
EventSender.beginDragWithFiles().

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@110243 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9ad255ba
2012-03-08 Andy Estes <aestes@apple.com>
REGRESSION (r105396): Dragging an iWork document into icloud.com opens it in the Mac app instead of uploading it to icloud.com
https://bugs.webkit.org/show_bug.cgi?id=79443
Reviewed by Ryosuke Niwa.
* fast/events/file-input-hidden-in-ondrop-expected.txt: Added.
* fast/events/file-input-hidden-in-ondrop.html: Added.
* platform/wk2/Skipped: WebKitTestRunner doesn't support
EventSender.beginDragWithFiles().
2012-03-07 Ojan Vafai <ojan@chromium.org>
Moar Chromium Lion rebaselines.
PASS dropTarget.value is "C:\\fakepath\\abe.png"
<!DOCTYPE html>
<html>
<head>
<script src="../js/resources/js-test-pre.js"></script>
<script>
if (window.layoutTestController) {
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
}
var dropTarget;
function test()
{
dropTarget = document.getElementById("drop-target");
dropTarget.addEventListener("drop", function() {
dropTarget.style.display = "none";
setTimeout(function() {
shouldBeEqualToString("dropTarget.value", "C:\\fakepath\\abe.png");
if (window.layoutTestController)
layoutTestController.notifyDone();
}, 0);
}, false);
if (window.eventSender) {
eventSender.beginDragWithFiles(["resources/abe.png"]);
var x = dropTarget.offsetLeft + dropTarget.offsetWidth / 2;
var y = dropTarget.offsetTop + dropTarget.offsetHeight / 2;
eventSender.mouseMoveTo(x, y);
eventSender.mouseUp();
}
}
</script>
</head>
<body onload="test()">
<input type="file" id="drop-target">
</body>
</html>
\ No newline at end of file
......@@ -1346,6 +1346,7 @@ fast/dom/Window/window-postmessage-clone-frames.html
fast/events/drag-file-crash.html
fast/events/drag-to-navigate.html
fast/events/dropzone-004.html
fast/events/file-input-hidden-in-ondrop.html
fast/events/input-element-display-none-in-dragleave-crash.html
fast/events/prevent-drag-to-navigate.html
fast/files/apply-blob-url-to-img.html
......
2012-03-08 Andy Estes <aestes@apple.com>
REGRESSION (r105396): Dragging an iWork document into icloud.com opens it in the Mac app instead of uploading it to icloud.com
https://bugs.webkit.org/show_bug.cgi?id=79443
Reviewed by Ryosuke Niwa.
icloud.com registers a drop event handler that sets display:none on the
file input element receiving the drop. After dispatching the drop event,
DragController hit tests the position under the mouse to see if it is a
file input element in need of receiving files. Since the file input
element has lost its renderer, it cannot be found by hit testing, so
the dropped file is never attached to the file input element, no change
event fires, and no upload commences. We want these things to happen
even if the element is no longer visible.
Since we already keep track of the file input element under the mouse
via m_fileInputElementUnderMouse, this additional hit test is
unnecessary. Use m_fileInputElementUnderMouse in concludeEditDrag()
when dropping files.
Test: fast/events/file-input-hidden-in-ondrop.html
* page/DragController.cpp:
(WebCore::DragController::concludeEditDrag): Use
m_fileInputElementUnderMouse instead of the element returned by hit
testing. Assert that m_fileInputElementUnderMouse equals the hit tested
element unless m_fileInputElementUnderMouse doesn't have a renderer.
2012-03-08 Ryosuke Niwa <rniwa@webkit.org>
Mac build fix for micro data API.
......@@ -424,6 +424,7 @@ bool DragController::concludeEditDrag(DragData* dragData)
ASSERT(dragData);
ASSERT(!m_isHandlingDrag);
RefPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMouse;
if (m_fileInputElementUnderMouse) {
m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false);
m_fileInputElementUnderMouse = 0;
......@@ -456,18 +457,13 @@ bool DragController::concludeEditDrag(DragData* dragData)
return true;
}
if (!m_page->dragController()->canProcessDrag(dragData)) {
m_page->dragCaretController()->clear();
return false;
}
if (HTMLInputElement* fileInput = asFileInput(element)) {
if (dragData->containsFiles() && fileInput) {
// fileInput should be the element we hit tested for, unless it was made
// display:none in a drop event handler.
ASSERT(fileInput == element || !fileInput->renderer());
if (fileInput->disabled())
return false;
if (!dragData->containsFiles())
return false;
Vector<String> filenames;
dragData->asFilenames(filenames);
if (filenames.isEmpty())
......@@ -477,6 +473,11 @@ bool DragController::concludeEditDrag(DragData* dragData)
return true;
}
if (!m_page->dragController()->canProcessDrag(dragData)) {
m_page->dragCaretController()->clear();
return false;
}
VisibleSelection dragCaret = m_page->dragCaretController()->caretPosition();
m_page->dragCaretController()->clear();
RefPtr<Range> range = dragCaret.toNormalizedRange();
......
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