Commit 638815b8 authored by tony@chromium.org's avatar tony@chromium.org

2010-05-20 Tony Chang <tony@chromium.org>

        Reviewed by Kent Tamura.

        escape link text when copying or dragging links on win or chromium
        https://bugs.webkit.org/show_bug.cgi?id=39413

        * editing/pasteboard/drop-link-expected.txt: Added.
        * editing/pasteboard/drop-link.html:
        * platform/chromium-linux/editing/pasteboard/drop-link-expected.checksum: Removed.
        * platform/chromium-linux/editing/pasteboard/drop-link-expected.png: Removed.
        * platform/chromium-linux/editing/pasteboard/drop-link-expected.txt: Removed.
        * platform/chromium-win/editing/pasteboard/drop-link-expected.checksum: Removed.
        * platform/chromium-win/editing/pasteboard/drop-link-expected.png: Removed.
        * platform/chromium-win/editing/pasteboard/drop-link-expected.txt: Removed.
        * platform/mac/editing/pasteboard/drop-link-expected.checksum: Removed.
        * platform/mac/editing/pasteboard/drop-link-expected.png: Removed.
        * platform/mac/editing/pasteboard/drop-link-expected.txt: Removed.
2010-05-20  Tony Chang  <tony@chromium.org>

        Reviewed by Kent Tamura.

        escape link text when copying or dragging links on win or chromium
        https://bugs.webkit.org/show_bug.cgi?id=39413

        * editing/markup.cpp:
        (WebCore::urlToMarkup):
        * editing/markup.h:
        * platform/chromium/ClipboardUtilitiesChromium.cpp:
        * platform/chromium/ClipboardUtilitiesChromium.h:
        * platform/win/ClipboardUtilitiesWin.cpp:
        * platform/win/ClipboardUtilitiesWin.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@59917 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ac3cf4bd
2010-05-20 Tony Chang <tony@chromium.org>
Reviewed by Kent Tamura.
escape link text when copying or dragging links on win or chromium
https://bugs.webkit.org/show_bug.cgi?id=39413
* editing/pasteboard/drop-link-expected.txt: Added.
* editing/pasteboard/drop-link.html:
* platform/chromium-linux/editing/pasteboard/drop-link-expected.checksum: Removed.
* platform/chromium-linux/editing/pasteboard/drop-link-expected.png: Removed.
* platform/chromium-linux/editing/pasteboard/drop-link-expected.txt: Removed.
* platform/chromium-win/editing/pasteboard/drop-link-expected.checksum: Removed.
* platform/chromium-win/editing/pasteboard/drop-link-expected.png: Removed.
* platform/chromium-win/editing/pasteboard/drop-link-expected.txt: Removed.
* platform/mac/editing/pasteboard/drop-link-expected.checksum: Removed.
* platform/mac/editing/pasteboard/drop-link-expected.png: Removed.
* platform/mac/editing/pasteboard/drop-link-expected.txt: Removed.
2010-05-20 Fumitoshi Ukai <ukai@chromium.org>
Reviewed by Alexey Proskuryakov.
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
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
......@@ -5,39 +6,22 @@ EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotificatio
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
RenderView 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: bullet
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: bullet
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 1 {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 1 {BODY} of child 0 {HTML} of document
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: shouldEndEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 2 of DIV > BODY > HTML > #document
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidEndEditing:WebViewDidEndEditingNotification
EDITING DELEGATE: shouldInsertNode:#document-fragment replacingDOMRange:range from 7 of #text > DIV > BODY > HTML > #document to 7 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 7 of #text > DIV > BODY > HTML > #document to 7 of #text > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > A > DIV > BODY > HTML > #document to 53 of #text > A > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
This test checks that links dragged into editable regions preserve their title and URL.
HelloThis is a link
GoodbyeThis </a><a href="http://webkit.org/">is another link
Link is http://apple.com/
Link is http://apple.com/
Success!
To run this test manually, drag the first link into the box with 'Hello' in it, drag the second link into the box with 'Goodbye' in it, and then click on the button.
......@@ -5,12 +5,15 @@ if (window.layoutTestController)
<div>This test checks that links dragged into editable regions preserve their title and URL.</div>
<div contenteditable="true" id="destination">Hello</div>
<div contenteditable="true" id="destination2">Goodbye</div>
<div><a href="http://apple.com" id="grabme">This is a link</a></div>
<div><a href="http://apple.com" id="grabme2">This &lt;/a&gt;&lt;a href="http://webkit.org/"&gt;is another 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>
<div>To run this test manually, drag the first link into the box with 'Hello' in it,
drag the second link into the box with 'Goodbye' in it, and then click on the button.<br><input type="button" value="Verify" onClick="verifier()"></div>
<script>
......@@ -26,8 +29,19 @@ function log(message) {
function runTest() {
if (!window.layoutTestController)
return;
var anchorToDrag = document.getElementById("grabme");
layoutTestController.dumpAsText();
dragLink('grabme', 'destination');
dragLink('grabme2', 'destination2');
verifier();
}
function dragLink(srcId, targetId)
{
var anchorToDrag = document.getElementById(srcId);
window.getSelection().setBaseAndExtent(anchorToDrag, 0, anchorToDrag, 0);
var x = anchorToDrag.offsetLeft + anchorToDrag.offsetWidth / 2;
var y = anchorToDrag.offsetTop + anchorToDrag.offsetHeight / 2;
......@@ -36,43 +50,57 @@ function runTest() {
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 destinationObject = document.getElementById(targetId);
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 anchorToDrag2 = document.getElementById("grabme2");
var passed = verifyLink('grabme', 0) && verifyLink('grabme2', 1);
var anchors = document.getElementsByTagName("a");
if (anchors.length != 2) {
log("Failure, incorrect number of anchor tags present");
passed = false;
}
if (passed)
log("Success!");
}
function verifyLink(linkId, linkNumber)
{
var anchorToDrag = document.getElementById(linkId);
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");
if (!anchors[linkNumber]) {
log("Link " + linkNumber + " not found");
passed = false;
} else {
log("Link is " + anchors[0].href);
log("Link is " + anchors[linkNumber].href);
var passed = true;
if (anchors[0].href != originalTarget) {
if (anchors[linkNumber].href != originalTarget) {
log("Failure! Link targets differ");
passed = false;
}
if (anchors[0].innerText != originalText) {
if (anchors[linkNumber].innerText != originalText) {
log("Failure! Link texts differ");
passed = false;
}
if (passed)
log("Success!");
}
return passed;
}
runTest();
......
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
RenderView 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 784x20
RenderText {#text} at (0,0) size 505x19
text run at (0,0) width 505: "This test checks that links dragged into editable regions preserve their title and URL."
RenderBlock {DIV} at (0,20) size 784x20
RenderText {#text} at (0,0) size 32x19
text run at (0,0) width 32: "Hello"
RenderInline {A} at (0,0) size 74x19 [color=#0000EE]
RenderText {#text} at (32,0) size 74x19
text run at (32,0) width 74: "This is a link"
RenderBlock {DIV} at (0,40) size 784x0
RenderBlock {UL} at (0,56) size 784x53
RenderListItem {LI} at (40,0) size 744x20
RenderBlock {PRE} at (0,0) size 744x20
RenderListMarker at (-18,0) size 7x19: bullet
RenderText {#text} at (0,3) size 200x16
text run at (0,3) width 200: "Link is http://apple.com/"
RenderListItem {LI} at (40,33) size 744x20
RenderBlock {PRE} at (0,0) size 744x20
RenderListMarker at (-18,0) size 7x19: bullet
RenderText {#text} at (0,3) size 64x16
text run at (0,3) width 64: "Success!"
RenderBlock {DIV} at (0,125) size 784x44
RenderText {#text} at (0,0) size 572x19
text run at (0,0) width 572: "To run this test manually, drag the link into the box with 'hello' in it, and then click on the button."
RenderBR {BR} at (572,15) size 0x0
RenderButton {INPUT} at (2,22) size 49x20 [bgcolor=#DDDDDD] [border: (2px outset #DDDDDD)]
RenderBlock (anonymous) at (8,2) size 33x16
RenderText at (0,0) size 33x16
text run at (0,0) width 33: "Verify"
selection start: position 0 of child 0 {#text} of child 1 {A} of child 2 {DIV} of child 1 {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 1 {BODY} of child 0 {HTML} of document
575c80ee71bd28fe2ef11aee4c42131d
\ No newline at end of file
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
RenderView 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 784x20
RenderText {#text} at (0,0) size 505x19
text run at (0,0) width 505: "This test checks that links dragged into editable regions preserve their title and URL."
RenderBlock {DIV} at (0,20) size 784x20
RenderText {#text} at (0,0) size 32x19
text run at (0,0) width 32: "Hello"
RenderInline {A} at (0,0) size 74x19 [color=#0000EE]
RenderText {#text} at (32,0) size 74x19
text run at (32,0) width 74: "This is a link"
RenderBlock {DIV} at (0,40) size 784x0
RenderBlock {UL} at (0,56) size 784x53
RenderListItem {LI} at (40,0) size 744x20
RenderBlock {PRE} at (0,0) size 744x20
RenderListMarker at (-18,0) size 7x19: bullet
RenderText {#text} at (0,3) size 200x16
text run at (0,3) width 200: "Link is http://apple.com/"
RenderListItem {LI} at (40,33) size 744x20
RenderBlock {PRE} at (0,0) size 744x20
RenderListMarker at (-18,0) size 7x19: bullet
RenderText {#text} at (0,3) size 64x16
text run at (0,3) width 64: "Success!"
RenderBlock {DIV} at (0,125) size 784x44
RenderText {#text} at (0,0) size 572x19
text run at (0,0) width 572: "To run this test manually, drag the link into the box with 'hello' in it, and then click on the button."
RenderBR {BR} at (572,15) size 0x0
RenderButton {INPUT} at (2,22) size 49x20 [bgcolor=#C0C0C0] [border: (2px outset #C0C0C0)]
RenderBlock (anonymous) at (8,2) size 33x16
RenderText at (0,0) size 33x16
text run at (0,0) width 33: "Verify"
selection start: position 0 of child 0 {#text} of child 1 {A} of child 2 {DIV} of child 1 {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 1 {BODY} of child 0 {HTML} of document
51f435c1a3b68ff2b4d86800ad53c0b4
\ No newline at end of file
2010-05-20 Tony Chang <tony@chromium.org>
Reviewed by Kent Tamura.
escape link text when copying or dragging links on win or chromium
https://bugs.webkit.org/show_bug.cgi?id=39413
* editing/markup.cpp:
(WebCore::urlToMarkup):
* editing/markup.h:
* platform/chromium/ClipboardUtilitiesChromium.cpp:
* platform/chromium/ClipboardUtilitiesChromium.h:
* platform/win/ClipboardUtilitiesWin.cpp:
* platform/win/ClipboardUtilitiesWin.h:
2010-05-18 Philippe Normand <pnormand@igalia.com>
Reviewed by Eric Carlson.
......@@ -49,6 +49,7 @@
#include "HTMLElement.h"
#include "HTMLNames.h"
#include "InlineTextBox.h"
#include "KURL.h"
#include "Logging.h"
#include "ProcessingInstruction.h"
#include "QualifiedName.h"
......@@ -1287,4 +1288,15 @@ String createFullMarkup(const Range* range)
return frame->documentTypeString() + createMarkup(range, 0, AnnotateForInterchange);
}
String urlToMarkup(const KURL& url, const String& title)
{
Vector<UChar> markup;
append(markup, "<a href=\"");
append(markup, url.string());
append(markup, "\">");
appendEscapedContent(markup, make_pair(title.characters(), title.length()), false);
append(markup, "</a>");
return String::adopt(markup);
}
}
......@@ -35,6 +35,7 @@ namespace WebCore {
class Document;
class DocumentFragment;
class KURL;
class Node;
class Range;
class String;
......@@ -54,6 +55,7 @@ namespace WebCore {
String createFullMarkup(const Node*);
String createFullMarkup(const Range*);
String urlToMarkup(const KURL&, const String& title);
}
#endif // markup_h
......@@ -52,16 +52,4 @@ void replaceNBSPWithSpace(String& str)
str.replace(NonBreakingSpaceCharacter, SpaceCharacter);
}
String urlToMarkup(const KURL& url, const String& title)
{
String markup("<a href=\"");
markup.append(url.string());
markup.append("\">");
// FIXME: HTML escape this, possibly by moving into the glue layer so we
// can use net/base/escape.h.
markup.append(title);
markup.append("</a>");
return markup;
}
} // namespace WebCore
......@@ -38,6 +38,4 @@ void replaceNewlinesWithWindowsStyleNewlines(String&);
#endif
void replaceNBSPWithSpace(String&);
String urlToMarkup(const KURL&, const String&);
} // namespace WebCore
......@@ -202,17 +202,6 @@ void markupToCF_HTML(const String& markup, const String& srcURL, Vector<char>& r
#undef NUMBER_FORMAT
}
String urlToMarkup(const KURL& url, const String& title)
{
Vector<UChar> markup;
append(markup, "<a href=\"");
append(markup, url.string());
append(markup, "\">");
append(markup, title);
append(markup, "</a>");
return String::adopt(markup);
}
void replaceNewlinesWithWindowsStyleNewlines(String& str)
{
static const UChar Newline = '\n';
......
......@@ -50,7 +50,6 @@ FORMATETC* cfHDropFormat();
FORMATETC* smartPasteFormat();
void markupToCF_HTML(const String& markup, const String& srcURL, Vector<char>& result);
String urlToMarkup(const KURL& url, const String& title);
void replaceNewlinesWithWindowsStyleNewlines(String&);
void replaceNBSPWithSpace(String&);
......
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