Changeset 87848 in webkit


Ignore:
Timestamp:
Jun 1, 2011 2:13:06 PM (13 years ago)
Author:
dcheng@chromium.org
Message:

2011-06-01 Daniel Cheng <dcheng@chromium.org>

Reviewed by Tony Chang.

[chromium] Use correct file name for dragging out images.
https://bugs.webkit.org/show_bug.cgi?id=24887

  • fast/events/drag-image-filename-expected.txt: Added.
  • fast/events/drag-image-filename.html: Added.
  • platform/gtk/Skipped:
  • platform/mac/Skipped:
  • platform/qt/Skipped:
  • platform/win/Skipped:

2011-06-01 Daniel Cheng <dcheng@chromium.org>

Reviewed by Tony Chang.

[chromium] Use correct file name for dragging out images.
https://bugs.webkit.org/show_bug.cgi?id=24887

We try to guess an appropriate filename when dragging out images. In order, we try to use:

  • The filename suggested in the HTTP header.
  • The last path component of the source URL.
  • The alt text. This matches the behavior of the other WebKit ports.

Test: fast/events/drag-image-filename.html

  • platform/chromium/ClipboardChromium.cpp: (WebCore::writeImageToDataObject):
  • platform/chromium/ClipboardChromiumMac.cpp: (WebCore::isInvalidFileCharacter): (WebCore::ClipboardChromium::validateFileName):

2011-06-01 Daniel Cheng <dcheng@chromium.org>

Reviewed by Tony Chang.

[chromium] Use correct file name for dragging out images.
https://bugs.webkit.org/show_bug.cgi?id=24887

  • DumpRenderTree/chromium/EventSender.cpp: (EventSender::EventSender): (EventSender::dumpFilenameBeingDragged):
  • DumpRenderTree/chromium/EventSender.h:
Location:
trunk
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r87846 r87848  
     12011-06-01  Daniel Cheng  <dcheng@chromium.org>
     2
     3        Reviewed by Tony Chang.
     4
     5        [chromium] Use correct file name for dragging out images.
     6        https://bugs.webkit.org/show_bug.cgi?id=24887
     7
     8        * fast/events/drag-image-filename-expected.txt: Added.
     9        * fast/events/drag-image-filename.html: Added.
     10        * platform/gtk/Skipped:
     11        * platform/mac/Skipped:
     12        * platform/qt/Skipped:
     13        * platform/win/Skipped:
     14
    1152011-06-01  Levi Weintraub  <leviw@chromium.org>
    216
  • trunk/LayoutTests/platform/gtk/Skipped

    r87835 r87848  
    11491149fast/events/5056619.html
    11501150
     1151# EventSender::dumpFilenameBeingDragged not implemented.
     1152# https://bugs.webkit.org/show_bug.cgi?id=61826
     1153fast/events/drag-image-filename.html
     1154
    11511155# Tests that fail because they assume a certain number of mouse
    11521156# movements during drags or fail only in Xvfb
  • trunk/LayoutTests/platform/mac/Skipped

    r87772 r87848  
    192192editing/pasteboard/file-drag-to-editable.html
    193193
     194# EventSender::dumpFilenameBeingDragged not implemented.
     195# https://bugs.webkit.org/show_bug.cgi?id=61827
     196fast/events/drag-image-filename.html
     197
    194198# Hits an assert in FrameLoader.cpp. https://bugs.webkit.org/show_bug.cgi?id=31387
    195199http/tests/multipart/policy-ignore-crash.php
  • trunk/LayoutTests/platform/qt/Skipped

    r87792 r87848  
    172172svg/as-image/drag-svg-as-image.html
    173173fast/forms/slider-delete-while-dragging-thumb.html
     174
     175# EventSender::dumpFilenameBeingDragged not implemented.
     176# https://bugs.webkit.org/show_bug.cgi?id=61828
     177fast/events/drag-image-filename.html
    174178
    175179# ------- missing drag-and-drop support
  • trunk/LayoutTests/platform/win/Skipped

    r87817 r87848  
    126126fast/events/standalone-image-drag-to-editable.html
    127127http/tests/security/drag-drop-same-unique-origin.html
     128
     129# EventSender::dumpFilenameBeingDragged not implemented.
     130# https://bugs.webkit.org/show_bug.cgi?id=61829
     131fast/events/drag-image-filename.html
    128132
    129133# <rdar://problem/5643675> window.scrollTo scrolls a window with no scrollbars
  • trunk/Source/WebCore/ChangeLog

    r87846 r87848  
     12011-06-01  Daniel Cheng  <dcheng@chromium.org>
     2
     3        Reviewed by Tony Chang.
     4
     5        [chromium] Use correct file name for dragging out images.
     6        https://bugs.webkit.org/show_bug.cgi?id=24887
     7
     8        We try to guess an appropriate filename when dragging out images. In order, we try to use:
     9        - The filename suggested in the HTTP header.
     10        - The last path component of the source URL.
     11        - The alt text.
     12        This matches the behavior of the other WebKit ports.
     13
     14        Test: fast/events/drag-image-filename.html
     15
     16        * platform/chromium/ClipboardChromium.cpp:
     17        (WebCore::writeImageToDataObject):
     18        * platform/chromium/ClipboardChromiumMac.cpp:
     19        (WebCore::isInvalidFileCharacter):
     20        (WebCore::ClipboardChromium::validateFileName):
     21
    1222011-06-01  Levi Weintraub  <leviw@chromium.org>
    223
     
    650671        * platform/graphics/gpu/TilingData.cpp:
    651672
    652 <<<<<<< .mine
    6536732011-05-31  Justin Novosad  <junov@chromium.org>
    654674
     
    663683        * platform/graphics/gpu/TilingData.cpp:
    664684
    665 =======
    6666852011-05-31  Rob Buis  <rbuis@rim.com>
    667686
  • trunk/Source/WebCore/platform/chromium/ClipboardChromium.cpp

    r86330 r87848  
    225225    dataObject->setFileContent(imageBuffer);
    226226
    227     // Determine the filename for the file contents of the image.  We try to
    228     // use the alt tag if one exists, otherwise we fall back on the suggested
    229     // filename in the http header, and finally we resort to using the filename
    230     // in the URL.
     227    // Determine the filename for the file contents of the image.
     228    String filename = cachedImage->response().suggestedFilename();
     229    if (filename.isEmpty())
     230        filename = url.lastPathComponent();
     231    if (filename.isEmpty())
     232        filename = element->getAttribute(altAttr);
     233    else {
     234        // Strip any existing extension. Assume that alt text is usually not a filename.
     235        int extensionIndex = filename.reverseFind('.');
     236        if (extensionIndex != -1)
     237            filename.truncate(extensionIndex);
     238    }
     239    filename = ClipboardChromium::validateFileName(filename, dataObject);
     240
    231241    String extension = MIMETypeRegistry::getPreferredExtensionForMIMEType(
    232242        cachedImage->response().mimeType());
    233243    dataObject->setFileExtension(extension.isEmpty() ? emptyString() : "." + extension);
    234     String title = element->getAttribute(altAttr);
    235     if (title.isEmpty())
    236         title = cachedImage->response().suggestedFilename();
    237 
    238     title = ClipboardChromium::validateFileName(title, dataObject);
    239     dataObject->setFileContentFilename(title + dataObject->fileExtension());
     244
     245    dataObject->setFileContentFilename(filename + dataObject->fileExtension());
    240246}
    241247
  • trunk/Source/WebCore/platform/chromium/ClipboardChromiumMac.cpp

    r41150 r87848  
    2929
    3030#include "ChromiumDataObject.h"
    31 #include "NotImplemented.h"
    3231
    3332namespace WebCore {
     33   
     34
     35// Filename length and character-set limits vary by filesystem, and there's no
     36// real way to tell what filesystem is in use. Since HFS+ is by far the most
     37// common, we'll abide by its limits, which are 255 Unicode characters (slightly
     38// simplified; really it uses Normalization Form D, but the differences aren't
     39// really worth dealing with here.)
     40static const unsigned MaxHFSFilenameLength = 255;
     41
     42
     43static bool isInvalidFileCharacter(UChar c)
     44{
     45    // HFS+ basically allows anything but '/'. For sanity's sake we'll disallow
     46    // control characters.
     47    return c < ' ' || c == 0x7F || c == '/';
     48}
    3449
    3550String ClipboardChromium::validateFileName(const String& title, ChromiumDataObject* dataObject)
    3651{
    37     notImplemented();
    38     return title;
     52    // Remove any invalid file system characters, especially "/".
     53    String result = title.removeCharacters(isInvalidFileCharacter);
     54    String extension = dataObject->fileExtension().removeCharacters(&isInvalidFileCharacter);
     55
     56    // Remove a ridiculously-long extension.
     57    if (extension.length() >= MaxHFSFilenameLength)
     58        extension = "";
     59   
     60    // Truncate an overly-long filename.
     61    int overflow = result.length() + extension.length() - MaxHFSFilenameLength;
     62    if (overflow > 0)
     63        result.remove(result.length() - overflow, overflow);
     64   
     65    dataObject->setFileExtension(extension);
     66    return result;
    3967}
    4068
  • trunk/Tools/ChangeLog

    r87847 r87848  
     12011-06-01  Daniel Cheng  <dcheng@chromium.org>
     2
     3        Reviewed by Tony Chang.
     4
     5        [chromium] Use correct file name for dragging out images.
     6        https://bugs.webkit.org/show_bug.cgi?id=24887
     7
     8        * DumpRenderTree/chromium/EventSender.cpp:
     9        (EventSender::EventSender):
     10        (EventSender::dumpFilenameBeingDragged):
     11        * DumpRenderTree/chromium/EventSender.h:
     12
    1132011-06-01  Dirk Pranke  <dpranke@chromium.org>
    214
  • trunk/Tools/DumpRenderTree/chromium/EventSender.cpp

    r86930 r87848  
    260260    bindMethod("continuousMouseScrollBy", &EventSender::continuousMouseScrollBy);
    261261    bindMethod("dispatchMessage", &EventSender::dispatchMessage);
     262    bindMethod("dumpFilenameBeingDragged", &EventSender::dumpFilenameBeingDragged);
    262263    bindMethod("enableDOMUIEventLogging", &EventSender::enableDOMUIEventLogging);
    263264    bindMethod("fireKeyboardEventsToElement", &EventSender::fireKeyboardEventsToElement);
     
    343344    // Finish processing events.
    344345    replaySavedEvents();
     346}
     347
     348void EventSender::dumpFilenameBeingDragged(const CppArgumentList&, CppVariant*)
     349{
     350    printf("Filename being dragged: %s\n", currentDragData.fileContentFilename().utf8().data());
    345351}
    346352
  • trunk/Tools/DumpRenderTree/chromium/EventSender.h

    r86930 r87848  
    6262    // Simulate drag&drop system call.
    6363    void doDragDrop(const WebKit::WebDragData&, WebKit::WebDragOperationsMask);
     64
     65    // Test helper for dragging out images.
     66    void dumpFilenameBeingDragged(const CppArgumentList&, CppVariant*);
    6467
    6568    // JS callback methods.
Note: See TracChangeset for help on using the changeset viewer.