Skip to content
  • abarth@webkit.org's avatar
    Add support for download='filename' attribute in anchors. · 2d422e7f
    abarth@webkit.org authored
    https://bugs.webkit.org/show_bug.cgi?id=64580
    
    Patch by Sadrul Habib Chowdhury <sadrul@chromium.org> on 2011-07-26
    Reviewed by Adam Barth.
    
    Source/WebCore: 
    
    The download attribute allows the author of the hyperlink to cause the
    browser to download the linked URL.  The author can also supply a
    suggested file name in the attribute value.  This feature is a recent
    addition to HTML to better support offline applications that use blob
    URLs.  Traditionally, web sites use the HTTP Content-Disposition header
    to trigger downloads, but that option isn't available when working
    offline.
    
    There is some question about whether we should initiate a download when
    we receive a DOM-created click event.  This patch does initiate the
    download, but we might revise that decision in the future as part of a
    larger change in how WebKit treats the interaction between default
    event handlers and DOM-created events.
    
    Tests: fast/dom/HTMLAnchorElement/anchor-download.html
           fast/dom/HTMLAnchorElement/anchor-nodownload.html
           fast/dom/HTMLAnchorElement/anchor-download-unset.html
           fast/dom/HTMLAnchorElement/anchor-nodownload-set.html
    
    * html/HTMLAnchorElement.cpp:
    (WebCore::HTMLAnchorElement::defaultEventHandler):
    (WebCore::HTMLAnchorElement::handleClick):
    * html/HTMLAnchorElement.h:
    * html/HTMLAnchorElement.idl:
    * html/HTMLAttributeNames.in:
    * loader/EmptyClients.h:
    (WebCore::EmptyFrameLoaderClient::startDownload):
    * loader/FrameLoaderClient.h:
    
    Source/WebKit/chromium: 
    
    * features.gypi:
    * public/WebFrameClient.h:
    (WebKit::WebFrameClient::loadURLExternally):
    * src/FrameLoaderClientImpl.cpp:
    (WebKit::FrameLoaderClientImpl::dispatchDecidePolicyForNavigationAction):
    (WebKit::FrameLoaderClientImpl::startDownload):
    * src/FrameLoaderClientImpl.h:
    
    Source/WebKit/efl: 
    
    * WebCoreSupport/FrameLoaderClientEfl.cpp:
    (WebCore::FrameLoaderClientEfl::startDownload):
    * WebCoreSupport/FrameLoaderClientEfl.h:
    
    Source/WebKit/gtk: 
    
    * WebCoreSupport/FrameLoaderClientGtk.cpp:
    (WebKit::FrameLoaderClient::startDownload):
    * WebCoreSupport/FrameLoaderClientGtk.h:
    
    Source/WebKit/haiku: 
    
    * WebCoreSupport/FrameLoaderClientHaiku.cpp:
    (WebCore::FrameLoaderClientHaiku::startDownload):
    * WebCoreSupport/FrameLoaderClientHaiku.h:
    
    Source/WebKit/qt: 
    
    * WebCoreSupport/FrameLoaderClientQt.cpp:
    (WebCore::FrameLoaderClientQt::startDownload):
    * WebCoreSupport/FrameLoaderClientQt.h:
    
    Source/WebKit/win: 
    
    * WebFrame.cpp:
    (WebFrame::startDownload):
    * WebFrame.h:
    
    Source/WebKit/wince: 
    
    * WebCoreSupport/FrameLoaderClientWinCE.cpp:
    (WebKit::FrameLoaderClientWinCE::startDownload):
    * WebCoreSupport/FrameLoaderClientWinCE.h:
    
    Source/WebKit/wx: 
    
    * WebKitSupport/FrameLoaderClientWx.cpp:
    (WebCore::FrameLoaderClientWx::startDownload):
    * WebKitSupport/FrameLoaderClientWx.h:
    
    Source/WebKit2: 
    
    * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
    (WebKit::WebFrameLoaderClient::startDownload):
    * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
    
    Tools: 
    
    * DumpRenderTree/chromium/WebViewHost.cpp:
    (WebViewHost::loadURLExternally):
    * DumpRenderTree/chromium/WebViewHost.h:
    
    LayoutTests: 
    
    * fast/dom/HTMLAnchorElement/anchor-download-expected.txt: Added.
    * fast/dom/HTMLAnchorElement/anchor-download.html: Added.
    * fast/dom/HTMLAnchorElement/anchor-nodownload-expected.txt: Added.
    * fast/dom/HTMLAnchorElement/anchor-nodownload.html: Added.
    * fast/dom/HTMLAnchorElement/anchor-download-unset-expected.txt: Added.
    * fast/dom/HTMLAnchorElement/anchor-download-unset.html: Added.
    * fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt: Added.
    * fast/dom/HTMLAnchorElement/anchor-nodownload-set.html: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@91797 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    2d422e7f