Commit a14b4e15 authored by levin@chromium.org's avatar levin@chromium.org

REGRESSION(r54368): Text drag-and-drop from input/textarea doesn't work

if the text is like a URL
https://bugs.webkit.org/show_bug.cgi?id=38374

Patch by Kent Tamura <tkent@chromium.org> on 2010-05-04
Reviewed by David Levin (and unofficially by Enrica Casucci).

WebCore:

Since r54368, documentFragmentFromDragData() creates an <a> element
with no anchor text for URL-like text dragged from input/textarea
element. If such text is dropped to input/textarea element, the text
is not inserted.
To fix this problem, use the original text or the URL as an anchor
text.

Test: editing/pasteboard/drag-drop-url-text.html

* page/DragController.cpp:
(WebCore::documentFragmentFromDragData):

LayoutTests:

* editing/pasteboard/drag-drop-url-text-expected.txt: Added.
* editing/pasteboard/drag-drop-url-text.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@58780 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 52d59606
2010-05-04 Kent Tamura <tkent@chromium.org>
Reviewed by David Levin (and unofficially by Enrica Casucci).
REGRESSION(r54368): Text drag-and-drop from input/textarea doesn't work
if the text is like a URL
https://bugs.webkit.org/show_bug.cgi?id=38374
* editing/pasteboard/drag-drop-url-text-expected.txt: Added.
* editing/pasteboard/drag-drop-url-text.html: Added.
2010-05-04 Csaba Osztrogonác <ossy@webkit.org>
Unreviewed.
......
This tests text selection drag for a URL-like text.
To test this by hand, select all of the text in this input:
and drag/drop it into this input:
If you see that the text "http://www.apple.com/" was put in the second box, then the test passed.
PASS
<html>
<body>
<script>
function debug(msg) {
var console = document.getElementById('console');
var line = document.createElement('div');
line.textContent = msg;
console.appendChild(line);
}
function editingTest() {
if (!window.layoutTestController)
return;
layoutTestController.dumpAsText();
layoutTestController.waitUntilDone();
// Drag a URL text in the source
var source = document.getElementById("source");
source.setSelectionRange(0, source.value.length);
x = source.offsetLeft + 10;
y = source.offsetTop + source.offsetHeight / 2;
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
// and drop it off to the destination field.
var destination = document.getElementById("destination");
eventSender.leapForward(500);
eventSender.mouseMoveTo(destination.offsetLeft + 10, destination.offsetTop + destination.offsetHeight / 2);
eventSender.mouseUp();
var result = destination.value;
debug(result == 'http://www.apple.com/' ? 'PASS' : 'FAIL: expected value="http://www.apple.com/", actual value="' + result + '"');
layoutTestController.notifyDone();
}
</script>
<p>This tests text selection drag for a URL-like text.</p>
To test this by hand, select all of the text in this input: <input id=source value="http://www.apple.com/"><br>
and drag/drop it into this input: <input id=destination>
<br><br>If you see that the text "http://www.apple.com/" was put in the second box, then the test passed.
<div id=console></div>
<script>editingTest();</script>
</body>
</html>
2010-05-04 Kent Tamura <tkent@chromium.org>
Reviewed by David Levin (and unofficially by Enrica Casucci).
REGRESSION(r54368): Text drag-and-drop from input/textarea doesn't work
if the text is like a URL
https://bugs.webkit.org/show_bug.cgi?id=38374
Since r54368, documentFragmentFromDragData() creates an <a> element
with no anchor text for URL-like text dragged from input/textarea
element. If such text is dropped to input/textarea element, the text
is not inserted.
To fix this problem, use the original text or the URL as an anchor
text.
Test: editing/pasteboard/drag-drop-url-text.html
* page/DragController.cpp:
(WebCore::documentFragmentFromDragData):
2010-05-04 Steve Block <steveblock@google.com>
Reviewed by Darin Adler.
......@@ -115,8 +115,15 @@ static PassRefPtr<DocumentFragment> documentFragmentFromDragData(DragData* dragD
if (!url.isEmpty()) {
RefPtr<HTMLAnchorElement> anchor = HTMLAnchorElement::create(document);
anchor->setHref(url);
ExceptionCode ec;
if (title.isEmpty()) {
// Try the plain text first because the url might be normalized or escaped.
if (dragData->containsPlainText())
title = dragData->asPlainText();
if (title.isEmpty())
title = url;
}
RefPtr<Node> anchorText = document->createTextNode(title);
ExceptionCode ec;
anchor->appendChild(anchorText, ec);
RefPtr<DocumentFragment> fragment = document->createDocumentFragment();
fragment->appendChild(anchor, ec);
......
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