+2006-05-09 Levi Weintraub <lweintraub@apple.com>
+
+ Reviewed by justin.
+
+ <rdar:/problem/4442395>
+ Tiny MCE: Link isn't inserted after dragging into textarea field
+ Created tests to test drag-and-dropped links.
+
+ * editing/pasteboard/drop-link-expected.checksum: Added.
+ * editing/pasteboard/drop-link-expected.png: Added.
+ * editing/pasteboard/drop-link-expected.txt: Added.
+ * editing/pasteboard/drop-link.html: Added.
+
2006-05-09 Anders Carlsson <acarlsson@apple.com>
Reviewed by Hyatt.
--- /dev/null
+db1039075695996ef35f5ef46cda3e7d
\ No newline at end of file
--- /dev/null
+EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 5 of #text > DIV > BODY > HTML > #document to 5 of #text > DIV > BODY > HTML > #document givenAction:WebViewInsertActionDropped
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 1 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 5 of #text > DIV > BODY > HTML > #document to 5 of #text > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > A > DIV > BODY > HTML > #document to 14 of #text > A > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+layer at (0,0) size 800x600
+ RenderCanvas at (0,0) size 800x600
+layer at (0,0) size 800x600
+ RenderBlock {HTML} at (0,0) size 800x600
+ RenderBody {BODY} at (8,8) size 784x584
+ RenderBlock {DIV} at (0,0) size 784x18
+ RenderText {#text} at (0,0) size 531x18
+ text run at (0,0) width 531: "This test checks that links dragged into editable regions preserve their title and URL."
+ RenderBlock {DIV} at (0,18) size 784x18
+ RenderText {#text} at (0,0) size 35x18
+ text run at (0,0) width 35: "Hello"
+ RenderInline {A} at (0,0) size 81x18 [color=#0000EE]
+ RenderText {#text} at (35,0) size 81x18
+ text run at (35,0) width 81: "This is a link"
+ RenderBlock {DIV} at (0,36) size 784x0
+ RenderBlock {UL} at (0,52) size 784x49
+ RenderListItem {LI} at (40,0) size 744x18
+ RenderBlock {PRE} at (0,0) size 744x18
+ RenderListMarker at (-17,0) size 7x18
+ RenderText {#text} at (0,2) size 200x15
+ text run at (0,2) width 200: "Link is http://apple.com/"
+ RenderListItem {LI} at (40,31) size 744x18
+ RenderBlock {PRE} at (0,0) size 744x18
+ RenderListMarker at (-17,0) size 7x18
+ RenderText {#text} at (0,2) size 64x15
+ text run at (0,2) width 64: "Success!"
+ RenderBlock {DIV} at (0,117) size 784x40
+ RenderText {#text} at (0,0) size 610x18
+ text run at (0,0) width 610: "To run this test manually, drag the link into the box with 'hello' in it, and then click on the button."
+ RenderBR {BR} at (610,14) size 0x0
+ RenderButton {INPUT} at (2,20) size 47x18 [bgcolor=#C0C0C0]
+ RenderBlock (anonymous) at (8,2) size 31x13
+ RenderText at (0,0) size 31x13
+ text run at (0,0) width 31: "Verify"
+selection start: position 0 of child 0 {#text} of child 1 {A} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
+selection end: position 14 of child 0 {#text} of child 1 {A} of child 2 {DIV} of child 0 {BODY} of child 0 {HTML} of document
--- /dev/null
+<div>This test checks that links dragged into editable regions preserve their title and URL.</div>
+
+<div contenteditable="true" id="destination">Hello</div>
+
+<div><a href="http://apple.com" id="grabme">This is a link</a></div>
+
+<ul id="console"></ul>
+
+<div>To run this test manually, drag the link into the box with 'hello' in it, and then click on the button.<br><input type="button" value="Verify" onClick="verifier()"></div>
+
+<script>
+
+function log(message) {
+ var console = document.getElementById("console");
+ var li = document.createElement("li");
+ var pre = document.createElement("pre");
+ pre.appendChild(document.createTextNode(message));
+ li.appendChild(pre);
+ console.appendChild(li);
+}
+
+function runTest() {
+ if (!window.layoutTestController)
+ return;
+
+ var anchorToDrag = document.getElementById("grabme");
+ var x = anchorToDrag.offsetLeft + anchorToDrag.offsetWidth / 2;
+ var y = anchorToDrag.offsetTop + anchorToDrag.offsetHeight / 2;
+
+ eventSender.mouseMoveTo(x, y);
+
+ eventSender.mouseDown();
+ // Wait a moment so that the mouseDown will kick off a drag instead of navigating to the link
+ eventSender.leapForward(400);
+
+ var destinationObject = document.getElementById("destination");
+ var x = destinationObject.offsetLeft + destinationObject.offsetWidth / 2;
+ var y = destinationObject.offsetTop + destinationObject.offsetHeight / 2;
+
+
+ eventSender.mouseMoveTo(x, y);
+ eventSender.mouseUp();
+
+ verifier();
+}
+
+function verifier() {
+ var anchorToDrag = document.getElementById("grabme");
+
+ var originalTarget = anchorToDrag.href;
+ var originalText = anchorToDrag.innerText;
+ var anchorParent = anchorToDrag.parentNode;
+ anchorParent.removeChild(anchorToDrag);
+
+ var anchors = document.getElementsByTagName("a");
+ if (anchors.length != 1) {
+ log("Failure, incorrect number of anchor tags present");
+ } else {
+ log("Link is " + anchors[0].href);
+ var passed = true;
+ if (anchors[0].href != originalTarget) {
+ log("Failure! Link targets differ");
+ passed = false;
+ }
+ if (anchors[0].innerText != originalText) {
+ log("Failure! Link texts differ");
+ passed = false;
+ }
+ if (passed)
+ log("Success!");
+ }
+}
+
+runTest();
+</script>
+2006-05-09 Levi Weintraub <lweintraub@apple.com>
+
+ Reviewed by justin.
+
+ <rdar://problem/4442395>
+ Tiny MCE: Link isn't inserted after dragging into textarea field
+
+ * WebView/WebHTMLView.m:
+ (-[WebHTMLView _documentFragmentFromPasteboard:allowPlainText:chosePlainText:]):
+ Modified to create an anchor object with a title as opposed to just the URL as text.
+
2006-05-09 Tim Omernick <timo@apple.com>
Reviewed by Dave Harrison.
}
if ((URL = [NSURL URLFromPasteboard:pasteboard])) {
- NSString *URLString = [URL _web_userVisibleString];
- if ([URLString length] > 0) {
- return [[self _bridge] documentFragmentWithText:URLString];
+ DOMDocument* document = [[self _bridge] DOMDocument];
+ ASSERT(document);
+ if (document) {
+ DOMHTMLAnchorElement* anchor = (DOMHTMLAnchorElement*)[document createElement:@"a"];
+ NSString *URLString = [URL _web_userVisibleString];
+ NSString *URLTitleString = [pasteboard stringForType:WebURLNamePboardType];
+ DOMText* text = [document createTextNode:URLTitleString];
+ [anchor setHref:URLString];
+ [anchor appendChild:text];
+ DOMDocumentFragment* fragment = [document createDocumentFragment];
+ [fragment appendChild:anchor];
+ if ([URLString length] > 0)
+ return fragment;
}
}