LayoutTests:
authorlweintraub <lweintraub@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 May 2006 01:10:43 +0000 (01:10 +0000)
committerlweintraub <lweintraub@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 10 May 2006 01:10:43 +0000 (01:10 +0000)
        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.

WebKit:

        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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@14270 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/drop-link-expected.checksum [new file with mode: 0644]
LayoutTests/editing/pasteboard/drop-link-expected.png [new file with mode: 0644]
LayoutTests/editing/pasteboard/drop-link-expected.txt [new file with mode: 0644]
LayoutTests/editing/pasteboard/drop-link.html [new file with mode: 0644]
WebKit/ChangeLog
WebKit/WebView/WebHTMLView.m

index b74616d828abb9493ed13eb2925a52324a323f5f..9032f71db0e1a6264b0858278a0d273838e1ae25 100644 (file)
@@ -1,3 +1,16 @@
+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.
diff --git a/LayoutTests/editing/pasteboard/drop-link-expected.checksum b/LayoutTests/editing/pasteboard/drop-link-expected.checksum
new file mode 100644 (file)
index 0000000..5c7e9ea
--- /dev/null
@@ -0,0 +1 @@
+db1039075695996ef35f5ef46cda3e7d
\ No newline at end of file
diff --git a/LayoutTests/editing/pasteboard/drop-link-expected.png b/LayoutTests/editing/pasteboard/drop-link-expected.png
new file mode 100644 (file)
index 0000000..0414c37
Binary files /dev/null and b/LayoutTests/editing/pasteboard/drop-link-expected.png differ
diff --git a/LayoutTests/editing/pasteboard/drop-link-expected.txt b/LayoutTests/editing/pasteboard/drop-link-expected.txt
new file mode 100644 (file)
index 0000000..f8e0d19
--- /dev/null
@@ -0,0 +1,43 @@
+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
diff --git a/LayoutTests/editing/pasteboard/drop-link.html b/LayoutTests/editing/pasteboard/drop-link.html
new file mode 100644 (file)
index 0000000..ba1b665
--- /dev/null
@@ -0,0 +1,75 @@
+<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>
index e079f02a5aa32104d24cae0a50207aed7647331d..f42be8eb10237d3773f4854ac50be0a5cd07626f 100644 (file)
@@ -1,3 +1,14 @@
+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.
index ce193f00ebf9ae3144655599dae97ab2284d4599..af666297c094733c040a14a085baf86c239fff11 100644 (file)
@@ -439,9 +439,19 @@ void *_NSSoftLinkingGetFrameworkFuncPtr(NSString *inUmbrellaFrameworkName,
     }    
     
     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;
         }
     }