Changeset 59917 in webkit


Ignore:
Timestamp:
May 21, 2010 12:57:42 AM (14 years ago)
Author:
tony@chromium.org
Message:

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:
Location:
trunk
Files:
1 added
9 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r59903 r59917  
     12010-05-20  Tony Chang  <tony@chromium.org>
     2
     3        Reviewed by Kent Tamura.
     4
     5        escape link text when copying or dragging links on win or chromium
     6        https://bugs.webkit.org/show_bug.cgi?id=39413
     7
     8        * editing/pasteboard/drop-link-expected.txt: Added.
     9        * editing/pasteboard/drop-link.html:
     10        * platform/chromium-linux/editing/pasteboard/drop-link-expected.checksum: Removed.
     11        * platform/chromium-linux/editing/pasteboard/drop-link-expected.png: Removed.
     12        * platform/chromium-linux/editing/pasteboard/drop-link-expected.txt: Removed.
     13        * platform/chromium-win/editing/pasteboard/drop-link-expected.checksum: Removed.
     14        * platform/chromium-win/editing/pasteboard/drop-link-expected.png: Removed.
     15        * platform/chromium-win/editing/pasteboard/drop-link-expected.txt: Removed.
     16        * platform/mac/editing/pasteboard/drop-link-expected.checksum: Removed.
     17        * platform/mac/editing/pasteboard/drop-link-expected.png: Removed.
     18        * platform/mac/editing/pasteboard/drop-link-expected.txt: Removed.
     19
    1202010-05-20  Fumitoshi Ukai  <ukai@chromium.org>
    221
  • trunk/LayoutTests/editing/pasteboard/drop-link.html

    r17562 r59917  
    66
    77<div contenteditable="true" id="destination">Hello</div>
     8<div contenteditable="true" id="destination2">Goodbye</div>
    89
    910<div><a href="http://apple.com" id="grabme">This is a link</a></div>
     11<div><a href="http://apple.com" id="grabme2">This &lt;/a&gt;&lt;a href="http://webkit.org/"&gt;is another link</a></div>
    1012
    1113<ul id="console"></ul>
    1214
    13 <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>
     15<div>To run this test manually, drag the first link into the box with 'Hello' in it,
     16drag 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>
    1417
    1518<script>
     
    2730    if (!window.layoutTestController)
    2831        return;
    29    
    30     var anchorToDrag = document.getElementById("grabme");
     32    layoutTestController.dumpAsText();
     33
     34    dragLink('grabme', 'destination');
     35    dragLink('grabme2', 'destination2');
     36
     37    verifier();
     38}
     39
     40function dragLink(srcId, targetId)
     41{
     42    var anchorToDrag = document.getElementById(srcId);
     43    window.getSelection().setBaseAndExtent(anchorToDrag, 0, anchorToDrag, 0);
     44
    3145    var x = anchorToDrag.offsetLeft + anchorToDrag.offsetWidth / 2;
    3246    var y = anchorToDrag.offsetTop + anchorToDrag.offsetHeight / 2;
     
    3751    // Wait a moment so that the mouseDown will kick off a drag instead of navigating to the link
    3852    eventSender.leapForward(400);
    39    
    40     var destinationObject = document.getElementById("destination");
     53
     54    var destinationObject = document.getElementById(targetId);
    4155    var x = destinationObject.offsetLeft + destinationObject.offsetWidth / 2;
    4256    var y = destinationObject.offsetTop + destinationObject.offsetHeight / 2;
    4357
    44 
    4558    eventSender.mouseMoveTo(x, y);
    4659    eventSender.mouseUp();
    47 
    48     verifier();
    4960}
    5061
    5162function verifier() {
    5263    var anchorToDrag = document.getElementById("grabme");
     64    var anchorToDrag2 = document.getElementById("grabme2");
     65
     66    var passed = verifyLink('grabme', 0) && verifyLink('grabme2', 1);
     67
     68    var anchors = document.getElementsByTagName("a");
     69    if (anchors.length != 2) {
     70        log("Failure, incorrect number of anchor tags present");
     71        passed = false;
     72    }
     73
     74    if (passed)
     75        log("Success!");
     76}
     77
     78function verifyLink(linkId, linkNumber)
     79{
     80    var anchorToDrag = document.getElementById(linkId);
    5381
    5482    var originalTarget = anchorToDrag.href;
     
    5684    var anchorParent = anchorToDrag.parentNode;
    5785    anchorParent.removeChild(anchorToDrag);
    58    
     86
    5987    var anchors = document.getElementsByTagName("a");
    60     if (anchors.length != 1) {
    61         log("Failure, incorrect number of anchor tags present");
     88    if (!anchors[linkNumber]) {
     89        log("Link " + linkNumber + " not found");
     90        passed = false;
    6291    } else {
    63         log("Link is " + anchors[0].href);
     92        log("Link is " + anchors[linkNumber].href);
    6493        var passed = true;
    65         if (anchors[0].href != originalTarget) {
     94        if (anchors[linkNumber].href != originalTarget) {
    6695            log("Failure! Link targets differ");
    6796            passed = false;
    6897        }
    69         if (anchors[0].innerText != originalText) {
     98        if (anchors[linkNumber].innerText != originalText) {
    7099            log("Failure! Link texts differ");
    71100            passed = false;
    72101        }
    73         if (passed)
    74             log("Success!");
    75102    }
     103    return passed;
    76104}
    77105
  • trunk/WebCore/ChangeLog

    r59915 r59917  
     12010-05-20  Tony Chang  <tony@chromium.org>
     2
     3        Reviewed by Kent Tamura.
     4
     5        escape link text when copying or dragging links on win or chromium
     6        https://bugs.webkit.org/show_bug.cgi?id=39413
     7
     8        * editing/markup.cpp:
     9        (WebCore::urlToMarkup):
     10        * editing/markup.h:
     11        * platform/chromium/ClipboardUtilitiesChromium.cpp:
     12        * platform/chromium/ClipboardUtilitiesChromium.h:
     13        * platform/win/ClipboardUtilitiesWin.cpp:
     14        * platform/win/ClipboardUtilitiesWin.h:
     15
    1162010-05-18  Philippe Normand  <pnormand@igalia.com>
    217
  • trunk/WebCore/editing/markup.cpp

    r59241 r59917  
    5050#include "HTMLNames.h"
    5151#include "InlineTextBox.h"
     52#include "KURL.h"
    5253#include "Logging.h"
    5354#include "ProcessingInstruction.h"
     
    12881289}
    12891290
    1290 }
     1291String urlToMarkup(const KURL& url, const String& title)
     1292{
     1293    Vector<UChar> markup;
     1294    append(markup, "<a href=\"");
     1295    append(markup, url.string());
     1296    append(markup, "\">");
     1297    appendEscapedContent(markup, make_pair(title.characters(), title.length()), false);
     1298    append(markup, "</a>");
     1299    return String::adopt(markup);
     1300}
     1301
     1302}
  • trunk/WebCore/editing/markup.h

    r54036 r59917  
    3636    class Document;
    3737    class DocumentFragment;
     38    class KURL;
    3839    class Node;
    3940    class Range;
     
    5556    String createFullMarkup(const Range*);
    5657
     58    String urlToMarkup(const KURL&, const String& title);
    5759}
    5860
  • trunk/WebCore/platform/chromium/ClipboardUtilitiesChromium.cpp

    r52791 r59917  
    5353}
    5454
    55 String urlToMarkup(const KURL& url, const String& title)
    56 {
    57     String markup("<a href=\"");
    58     markup.append(url.string());
    59     markup.append("\">");
    60     // FIXME: HTML escape this, possibly by moving into the glue layer so we
    61     // can use net/base/escape.h.
    62     markup.append(title);
    63     markup.append("</a>");
    64     return markup;
    65 }
    66 
    6755} // namespace WebCore
  • trunk/WebCore/platform/chromium/ClipboardUtilitiesChromium.h

    r52791 r59917  
    3939void replaceNBSPWithSpace(String&);
    4040
    41 String urlToMarkup(const KURL&, const String&);
    42 
    4341} // namespace WebCore
  • trunk/WebCore/platform/win/ClipboardUtilitiesWin.cpp

    r56825 r59917  
    203203}
    204204
    205 String urlToMarkup(const KURL& url, const String& title)
    206 {
    207     Vector<UChar> markup;
    208     append(markup, "<a href=\"");
    209     append(markup, url.string());
    210     append(markup, "\">");
    211     append(markup, title);
    212     append(markup, "</a>");
    213     return String::adopt(markup);
    214 }
    215 
    216205void replaceNewlinesWithWindowsStyleNewlines(String& str)
    217206{
  • trunk/WebCore/platform/win/ClipboardUtilitiesWin.h

    r30613 r59917  
    5151
    5252void markupToCF_HTML(const String& markup, const String& srcURL, Vector<char>& result);
    53 String urlToMarkup(const KURL& url, const String& title);
    5453
    5554void replaceNewlinesWithWindowsStyleNewlines(String&);
Note: See TracChangeset for help on using the changeset viewer.