Add support for download='filename' attribute in anchors.
authorabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Jul 2011 23:25:49 +0000 (23:25 +0000)
committerabarth@webkit.org <abarth@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Jul 2011 23:25:49 +0000 (23:25 +0000)
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: https://svn.webkit.org/repository/webkit/trunk@91797 268f45cc-cd09-0410-ab3c-d52691b4dbfc

54 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-unset-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-unset.html [new file with mode: 0644]
LayoutTests/fast/dom/HTMLAnchorElement/anchor-download.html [new file with mode: 0644]
LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set.html [new file with mode: 0644]
LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload.html [new file with mode: 0644]
LayoutTests/platform/gtk/Skipped
LayoutTests/platform/mac/Skipped
LayoutTests/platform/qt/Skipped
LayoutTests/platform/win/Skipped
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLAnchorElement.cpp
Source/WebCore/html/HTMLAnchorElement.h
Source/WebCore/html/HTMLAnchorElement.idl
Source/WebCore/html/HTMLAttributeNames.in
Source/WebCore/loader/EmptyClients.h
Source/WebCore/loader/FrameLoaderClient.h
Source/WebKit/chromium/ChangeLog
Source/WebKit/chromium/features.gypi
Source/WebKit/chromium/public/WebFrameClient.h
Source/WebKit/chromium/src/FrameLoaderClientImpl.cpp
Source/WebKit/chromium/src/FrameLoaderClientImpl.h
Source/WebKit/efl/ChangeLog
Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.cpp
Source/WebKit/efl/WebCoreSupport/FrameLoaderClientEfl.h
Source/WebKit/gtk/ChangeLog
Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
Source/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h
Source/WebKit/haiku/ChangeLog
Source/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.cpp
Source/WebKit/haiku/WebCoreSupport/FrameLoaderClientHaiku.h
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKit/qt/ChangeLog
Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp
Source/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.h
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebFrame.cpp
Source/WebKit/win/WebFrame.h
Source/WebKit/wince/ChangeLog
Source/WebKit/wince/WebCoreSupport/FrameLoaderClientWinCE.cpp
Source/WebKit/wince/WebCoreSupport/FrameLoaderClientWinCE.h
Source/WebKit/wx/ChangeLog
Source/WebKit/wx/WebKitSupport/FrameLoaderClientWx.cpp
Source/WebKit/wx/WebKitSupport/FrameLoaderClientWx.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
Tools/ChangeLog
Tools/DumpRenderTree/chromium/WebViewHost.cpp
Tools/DumpRenderTree/chromium/WebViewHost.h

index f69c6f2..ad4f200 100644 (file)
@@ -1,3 +1,19 @@
+2011-07-26  Sadrul Habib Chowdhury  <sadrul@chromium.org>
+
+        Add support for download='filename' attribute in anchors.
+        https://bugs.webkit.org/show_bug.cgi?id=64580
+
+        Reviewed by Adam Barth.
+
+        * 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.
+
 2011-07-26  Adrienne Walker  <enne@google.com>
 
         [chromium] Mark webaudio/test-basic as crashing on Windows.
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-expected.txt b/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-expected.txt
new file mode 100644 (file)
index 0000000..a96fb69
--- /dev/null
@@ -0,0 +1 @@
+Blob URL
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-unset-expected.txt b/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-unset-expected.txt
new file mode 100644 (file)
index 0000000..7ef22e9
--- /dev/null
@@ -0,0 +1 @@
+PASS
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-unset.html b/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download-unset.html
new file mode 100644 (file)
index 0000000..6321b9c
--- /dev/null
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script type='text/javascript'>
+if (window.layoutTestController) {
+  layoutTestController.dumpAsText();
+  layoutTestController.waitUntilDone();
+}
+</script>
+</head>
+<body>
+<a id="blob-url" download>Blob URL</a>
+<script>
+function click(elmt)
+{
+    if (!window.eventSender) {
+        alert('Click the link to run the test.');
+        return;
+    }
+    eventSender.mouseMoveTo(elmt.offsetLeft + 5, elmt.offsetTop + 5);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+function runTest()
+{
+    var bb = new WebKitBlobBuilder();
+    bb.append("<!doctype html><html><head><title>Title</title><script>if (window.layoutTestController) layoutTestController.dumpAsText(); </" + "script></head><body>PASS</body><script>if (window.layoutTestController) layoutTestController.notifyDone();</scr" + "ipt></html>");
+    var blob = bb.getBlob("text/html", "inline");
+    var link = document.getElementById("blob-url");
+    link.href = window.webkitURL.createObjectURL(blob);
+    link.removeAttribute('download');
+    click(link);
+}
+runTest();
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download.html b/LayoutTests/fast/dom/HTMLAnchorElement/anchor-download.html
new file mode 100644 (file)
index 0000000..c8377f9
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script type='text/javascript'>
+if (window.layoutTestController) {
+  layoutTestController.dumpAsText();
+  layoutTestController.waitUntilDone();
+}
+</script>
+</head>
+<body>
+<a id="blob-url" download>Blob URL</a>
+<script>
+function click(elmt)
+{
+    if (!window.eventSender) {
+        alert('Click the link to run the test.');
+        return;
+    }
+    eventSender.mouseMoveTo(elmt.offsetLeft + 5, elmt.offsetTop + 5);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+function runTest()
+{
+    var bb = new WebKitBlobBuilder();
+    bb.append("<!doctype html><html><head><title>Title</title><script>if (window.layoutTestController) layoutTestController.dumpAsText(); </" + "script></head><body>PASS</body><script>if (window.layoutTestController) layoutTestController.notifyDone();</scr" + "ipt></html>");
+    var blob = bb.getBlob("text/html", "inline");
+    var link = document.getElementById("blob-url");
+    link.href = window.webkitURL.createObjectURL(blob);
+    click(link);
+}
+runTest();
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-expected.txt b/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-expected.txt
new file mode 100644 (file)
index 0000000..7ef22e9
--- /dev/null
@@ -0,0 +1 @@
+PASS
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt b/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set-expected.txt
new file mode 100644 (file)
index 0000000..a96fb69
--- /dev/null
@@ -0,0 +1 @@
+Blob URL
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set.html b/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload-set.html
new file mode 100644 (file)
index 0000000..d0b42af
--- /dev/null
@@ -0,0 +1,39 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script type='text/javascript'>
+if (window.layoutTestController) {
+  layoutTestController.dumpAsText();
+  layoutTestController.waitUntilDone();
+}
+</script>
+</head>
+<body>
+<a id="blob-url">Blob URL</a>
+<script>
+function click(elmt)
+{
+    if (!window.eventSender) {
+        alert('Click the link to run the test.');
+        return;
+    }
+    eventSender.mouseMoveTo(elmt.offsetLeft + 5, elmt.offsetTop + 5);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+function runTest()
+{
+    var bb = new WebKitBlobBuilder();
+    bb.append("<!doctype html><html><head><title>Title</title><script>if (window.layoutTestController) layoutTestController.dumpAsText(); </" + "script></head><body>PASS</body><script>if (window.layoutTestController) layoutTestController.notifyDone();</scr" + "ipt></html>");
+    var blob = bb.getBlob("text/html", "inline");
+    var link = document.getElementById("blob-url");
+    link.href = window.webkitURL.createObjectURL(blob);
+    link.setAttribute('download');
+    click(link);
+}
+runTest();
+</script>
+</body>
+</html>
+
diff --git a/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload.html b/LayoutTests/fast/dom/HTMLAnchorElement/anchor-nodownload.html
new file mode 100644 (file)
index 0000000..f91edc1
--- /dev/null
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script type='text/javascript'>
+if (window.layoutTestController) {
+  layoutTestController.dumpAsText();
+  layoutTestController.waitUntilDone();
+}
+</script>
+</head>
+<body>
+<a id="blob-url">Blob URL</a>
+<script>
+function click(elmt)
+{
+    if (!window.eventSender) {
+        alert('Click the link to run the test.');
+        return;
+    }
+    eventSender.mouseMoveTo(elmt.offsetLeft + 5, elmt.offsetTop + 5);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+function runTest()
+{
+    var bb = new WebKitBlobBuilder();
+    bb.append("<!doctype html><html><head><title>Title</title><script>if (window.layoutTestController) layoutTestController.dumpAsText(); </" + "script></head><body>PASS</body><script>if (window.layoutTestController) layoutTestController.notifyDone();</scr" + "ipt></html>");
+    var blob = bb.getBlob("text/html", "inline");
+    var link = document.getElementById("blob-url");
+    link.href = window.webkitURL.createObjectURL(blob);
+    click(link);
+}
+runTest();
+</script>
+</body>
+</html>
+
index 095f283..2254302 100644 (file)
@@ -1525,6 +1525,12 @@ http/tests/eventsource/workers/eventsource-simple.html
 # failing dropzone test(http://bugs.webkit.org/show_bug.cgi?id=61630)
 fast/events/dropzone-002.html
 
+# Tests that require ENABLE(DOWNLOAD_ATTRIBUTE).
+fast/dom/HTMLAnchorElement/anchor-nodownload.html
+fast/dom/HTMLAnchorElement/anchor-download.html
+fast/dom/HTMLAnchorElement/anchor-nodownload-set.html
+fast/dom/HTMLAnchorElement/anchor-download-unset.html
+
 # Failing because WebGL is not enabled
 http/tests/security/webgl-remote-read-remote-image-allowed.html
 http/tests/security/webgl-remote-read-remote-image-allowed-with-credentials.html
index b65cc1d..e775dc7 100644 (file)
@@ -341,6 +341,12 @@ storage/storageinfo-query-usage.html
 storage/storageinfo-request-quota.html
 storage/storageinfo-no-callbacks.html
 
+# Tests that require ENABLE(DOWNLOAD_ATTRIBUTE).
+fast/dom/HTMLAnchorElement/anchor-nodownload.html
+fast/dom/HTMLAnchorElement/anchor-download.html
+fast/dom/HTMLAnchorElement/anchor-nodownload-set.html
+fast/dom/HTMLAnchorElement/anchor-download-unset.html
+
 # Expose title direction in WebKit API
 # https://bugs.webkit.org/show_bug.cgi?id=58845
 fast/dom/title-directionality.html
index 637b9fe..e007d9b 100644 (file)
@@ -2398,6 +2398,12 @@ http/tests/loading/preload-slow-loading.php
 http/tests/security/contentSecurityPolicy/media-src-allowed.html
 http/tests/security/contentSecurityPolicy/media-src-blocked.html
 
+# Tests that require ENABLE(DOWNLOAD_ATTRIBUTE).
+fast/dom/HTMLAnchorElement/anchor-nodownload.html
+fast/dom/HTMLAnchorElement/anchor-download.html
+fast/dom/HTMLAnchorElement/anchor-nodownload-set.html
+fast/dom/HTMLAnchorElement/anchor-download-unset.html
+
 # This platform does not support the Page Visibility API.
 fast/events/page-visibility-iframe-delete-test.html
 fast/events/page-visibility-iframe-move-test.html
index f8e8992..3c1fe48 100644 (file)
@@ -1342,6 +1342,12 @@ http/tests/security/webgl-remote-read-remote-image-allowed.html
 http/tests/security/webgl-remote-read-remote-image-allowed-with-credentials.html
 http/tests/security/webgl-remote-read-remote-image-blocked-no-crossorigin.html
 
+# Tests that require ENABLE(DOWNLOAD_ATTRIBUTE).
+fast/dom/HTMLAnchorElement/anchor-nodownload.html
+fast/dom/HTMLAnchorElement/anchor-download.html
+fast/dom/HTMLAnchorElement/anchor-nodownload-set.html
+fast/dom/HTMLAnchorElement/anchor-download-unset.html
+
 # New flexbox is not yet enabled. http://webkit.org/b/62048
 css3/flexbox
 
index d0b5be9..e8f6b8d 100644 (file)
@@ -1,3 +1,39 @@
+2011-07-26  Sadrul Habib Chowdhury  <sadrul@chromium.org>
+
+        Add support for download='filename' attribute in anchors.
+        https://bugs.webkit.org/show_bug.cgi?id=64580
+
+        Reviewed by Adam Barth.
+
+        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:
+
 2011-07-26  Mark Hahnenberg  <mhahnenberg@apple.com>
 
         Refactor automatically generated JS DOM bindings to replace operator new with static create methods
index aa72ad7..e0c2449 100644 (file)
@@ -27,6 +27,7 @@
 #include "Attribute.h"
 #include "EventNames.h"
 #include "Frame.h"
+#include "FrameLoaderClient.h"
 #include "FrameLoaderTypes.h"
 #include "HTMLImageElement.h"
 #include "HTMLNames.h"
@@ -147,10 +148,7 @@ void HTMLAnchorElement::defaultEventHandler(Event* event)
         }
 
         if (isLinkClick(event) && treatLinkAsLiveForEventType(eventType(event))) {
-            String url = stripLeadingAndTrailingHTMLSpaces(getAttribute(hrefAttr));
-            appendServerMapMousePosition(url, event);
-            handleLinkClick(event, document(), url, getAttribute(targetAttr), hasRel(RelationNoReferrer));
-            sendPings(document()->completeURL(url));
+            handleClick(event);
             return;
         }
 
@@ -492,6 +490,37 @@ void HTMLAnchorElement::sendPings(const KURL& destinationURL)
         PingLoader::sendPing(document()->frame(), document()->completeURL(pingURLs[i]), destinationURL);
 }
 
+void HTMLAnchorElement::handleClick(Event* event)
+{
+    event->setDefaultHandled();
+
+    Frame* frame = document()->frame();
+    if (!frame)
+        return;
+
+    String url = stripLeadingAndTrailingHTMLSpaces(fastGetAttribute(hrefAttr));
+    appendServerMapMousePosition(url, event);
+    KURL kurl = document()->completeURL(url);
+
+#if ENABLE(DOWNLOAD_ATTRIBUTE)
+    if (hasAttribute(downloadAttr)) {
+        ResourceRequest request(kurl);
+
+        if (!hasRel(RelationNoReferrer)) {
+            String referrer = frame->loader()->outgoingReferrer();
+            if (!referrer.isEmpty() && !SecurityOrigin::shouldHideReferrer(kurl, referrer))
+                request.setHTTPReferrer(referrer);
+            frame->loader()->addExtraFieldsToMainResourceRequest(request);
+        }
+
+        frame->loader()->client()->startDownload(request, fastGetAttribute(downloadAttr));
+    } else
+#endif
+        frame->loader()->urlSelected(kurl, target(), event, false, false, hasRel(RelationNoReferrer) ? NoReferrer : SendReferrer);
+
+    sendPings(kurl);
+}
+
 HTMLAnchorElement::EventType HTMLAnchorElement::eventType(Event* event)
 {
     if (!event->isMouseEvent())
index 860ad35..947f746 100644 (file)
@@ -115,6 +115,8 @@ private:
 
     void sendPings(const KURL& destinationURL);
 
+    void handleClick(Event*);
+
     enum EventType {
         MouseEventWithoutShiftKey,
         MouseEventWithShiftKey,
index 871fcdf..4e04744 100644 (file)
@@ -26,6 +26,7 @@ module html {
         attribute [Reflect] DOMString accessKey;
         attribute [Reflect] DOMString charset;
         attribute [Reflect] DOMString coords;
+        attribute [Conditional=DOWNLOAD_ATTRIBUTE, Reflect] DOMString download;
         attribute [Reflect, URL] DOMString href;
         attribute [Reflect] DOMString hreflang;
         attribute [Reflect] DOMString name;
index 1679e96..8410de6 100644 (file)
@@ -91,6 +91,7 @@ defer
 dir
 direction
 disabled
+download
 draggable
 webkitdropzone
 enctype
index 785b12c..f2dc8a4 100644 (file)
@@ -310,7 +310,7 @@ public:
 
     virtual void setMainFrameDocumentReady(bool) { }
 
-    virtual void startDownload(const ResourceRequest&) { }
+    virtual void startDownload(const ResourceRequest&, const String& suggestedName = String()) { UNUSED_PARAM(suggestedName); }
 
     virtual void willChangeTitle(DocumentLoader*) { }
     virtual void didChangeTitle(DocumentLoader*) { }
index 3852383..14080ed 100644 (file)
@@ -179,7 +179,7 @@ namespace WebCore {
         
         virtual void setMainFrameDocumentReady(bool) = 0;
 
-        virtual void startDownload(const ResourceRequest&) = 0;
+        virtual void startDownload(const ResourceRequest&, const String& suggestedName = String()) = 0;
 
         virtual void willChangeTitle(DocumentLoader*) = 0;
         virtual void didChangeTitle(DocumentLoader*) = 0;
index 8d81561..eb4f345 100644 (file)
@@ -1,3 +1,18 @@
+2011-07-26  Sadrul Habib Chowdhury  <sadrul@chromium.org>
+
+        Add support for download='filename' attribute in anchors.
+        https://bugs.webkit.org/show_bug.cgi?id=64580
+
+        Reviewed by Adam Barth.
+
+        * features.gypi:
+        * public/WebFrameClient.h:
+        (WebKit::WebFrameClient::loadURLExternally):
+        * src/FrameLoaderClientImpl.cpp:
+        (WebKit::FrameLoaderClientImpl::dispatchDecidePolicyForNavigationAction):
+        (WebKit::FrameLoaderClientImpl::startDownload):
+        * src/FrameLoaderClientImpl.h:
+
 2011-07-26  Brett Wilson  <brettw@chromium.org>
 
         Cancel the load when an associated URL loader goes out of scope.
index 43db483..96f7cd3 100644 (file)
@@ -44,6 +44,7 @@
       'ENABLE_DEVICE_ORIENTATION=1',
       'ENABLE_DIRECTORY_UPLOAD=1',
       'ENABLE_DOM_STORAGE=1',
+      'ENABLE_DOWNLOAD_ATTRIBUTE=1',
       'ENABLE_EVENTSOURCE=1',
       'ENABLE_JAVASCRIPT_I18N_API=1',
       'ENABLE_FILE_SYSTEM=1',
index b193fec..0af96ca 100644 (file)
@@ -116,6 +116,8 @@ public:
     // The client should handle the navigation externally.
     virtual void loadURLExternally(
         WebFrame*, const WebURLRequest&, WebNavigationPolicy) { }
+    virtual void loadURLExternally(
+        WebFrame*, const WebURLRequest&, WebNavigationPolicy, const WebString& downloadName) { }
 
 
     // Navigational queries ------------------------------------------------
index 79ddd68..11b7654 100644 (file)
@@ -944,7 +944,7 @@ void FrameLoaderClientImpl::dispatchDecidePolicyForNavigationAction(
     PolicyAction policyAction = PolicyIgnore;
 
     // It is valid for this function to be invoked in code paths where the
-    // the webview is closed.
+    // webview is closed.
     // The null check here is to fix a crash that seems strange
     // (see - https://bugs.webkit.org/show_bug.cgi?id=23554).
     if (m_webFrame->client() && !request.url().isNull()) {
@@ -1073,7 +1073,7 @@ void FrameLoaderClientImpl::setMainFrameDocumentReady(bool ready)
 
 // Creates a new connection and begins downloading from that (contrast this
 // with |download|).
-void FrameLoaderClientImpl::startDownload(const ResourceRequest& request)
+void FrameLoaderClientImpl::startDownload(const ResourceRequest& request, const String& /* suggestedName */)
 {
     if (m_webFrame->client()) {
         WrappedResourceRequest webreq(request);
index adaf9d3..71f7e50 100644 (file)
@@ -131,7 +131,7 @@ public:
     virtual void postProgressEstimateChangedNotification();
     virtual void postProgressFinishedNotification();
     virtual void setMainFrameDocumentReady(bool);
-    virtual void startDownload(const WebCore::ResourceRequest&);
+    virtual void startDownload(const WebCore::ResourceRequest&, const String& suggestedName = String());
     virtual void willChangeTitle(WebCore::DocumentLoader*);
     virtual void didChangeTitle(WebCore::DocumentLoader*);
     virtual void committedLoad(WebCore::DocumentLoader*, const char*, int);
index a578817..45908eb 100755 (executable)
@@ -1,3 +1,14 @@
+2011-07-26  Sadrul Habib Chowdhury  <sadrul@chromium.org>
+
+        Add support for download='filename' attribute in anchors.
+        https://bugs.webkit.org/show_bug.cgi?id=64580
+
+        Reviewed by Adam Barth.
+
+        * WebCoreSupport/FrameLoaderClientEfl.cpp:
+        (WebCore::FrameLoaderClientEfl::startDownload):
+        * WebCoreSupport/FrameLoaderClientEfl.h:
+
 2011-07-25  JungJik Lee  <jungjik.lee@samsung.com>
 
         [EFL] Remove unused code in ewk_tile_model.c
index 9e2757f..ab1179a 100644 (file)
@@ -871,7 +871,7 @@ void FrameLoaderClientEfl::setMainDocumentError(DocumentLoader* loader, const Re
     m_hasSentResponseToPlugin = false;
 }
 
-void FrameLoaderClientEfl::startDownload(const ResourceRequest& request)
+void FrameLoaderClientEfl::startDownload(const ResourceRequest& request, const String& /* suggestedName */)
 {
     if (!m_view)
         return;
index 47ab3d4..6bb326c 100644 (file)
@@ -153,7 +153,7 @@ class FrameLoaderClientEfl : public FrameLoaderClient {
 
     virtual void setMainFrameDocumentReady(bool);
 
-    virtual void startDownload(const ResourceRequest&);
+    virtual void startDownload(const ResourceRequest&, const String& suggestedName = String());
 
     virtual void willChangeTitle(DocumentLoader*);
     virtual void didChangeTitle(DocumentLoader*);
index 8b3619a..a6686fe 100644 (file)
@@ -1,3 +1,14 @@
+2011-07-26  Sadrul Habib Chowdhury  <sadrul@chromium.org>
+
+        Add support for download='filename' attribute in anchors.
+        https://bugs.webkit.org/show_bug.cgi?id=64580
+
+        Reviewed by Adam Barth.
+
+        * WebCoreSupport/FrameLoaderClientGtk.cpp:
+        (WebKit::FrameLoaderClient::startDownload):
+        * WebCoreSupport/FrameLoaderClientGtk.h:
+
 2011-07-26  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GTK] Remove header webkitwebviewcommon.h
index 26c534e..9d10c59 100644 (file)
@@ -1221,7 +1221,7 @@ void FrameLoaderClient::setMainDocumentError(WebCore::DocumentLoader*, const Res
     }
 }
 
-void FrameLoaderClient::startDownload(const ResourceRequest& request)
+void FrameLoaderClient::startDownload(const ResourceRequest& request, const String& /* suggestedName */)
 {
     GRefPtr<WebKitNetworkRequest> networkRequest(adoptGRef(kitNew(request)));
     WebKitWebView* view = getViewFromFrame(m_frame);
index 244829f..f0de2fc 100644 (file)
@@ -130,7 +130,7 @@ namespace WebKit {
 
         virtual void setMainFrameDocumentReady(bool);
 
-        virtual void startDownload(const WebCore::ResourceRequest&);
+        virtual void startDownload(const WebCore::ResourceRequest&, const String& suggestedName = String());
 
         virtual void willChangeTitle(WebCore::DocumentLoader*);
         virtual void didChangeTitle(WebCore::DocumentLoader*);
index 7ba71a0..1f19be8 100644 (file)
@@ -1,3 +1,14 @@
+2011-07-26  Sadrul Habib Chowdhury  <sadrul@chromium.org>
+
+        Add support for download='filename' attribute in anchors.
+        https://bugs.webkit.org/show_bug.cgi?id=64580
+
+        Reviewed by Adam Barth.
+
+        * WebCoreSupport/FrameLoaderClientHaiku.cpp:
+        (WebCore::FrameLoaderClientHaiku::startDownload):
+        * WebCoreSupport/FrameLoaderClientHaiku.h:
+
 2011-07-15  Dan Bernstein  <mitz@apple.com>
 
         REGRESSION: Mouse cursor doesn’t hide when full screen video HUD hides
index 285a3fa..9c4839a 100644 (file)
@@ -709,7 +709,7 @@ void FrameLoaderClientHaiku::dispatchUnableToImplementPolicy(const ResourceError
     notImplemented();
 }
 
-void FrameLoaderClientHaiku::startDownload(const ResourceRequest&)
+void FrameLoaderClientHaiku::startDownload(const ResourceRequest&, const String& /* suggestedName */)
 {
     notImplemented();
 }
index 79ee914..51741a1 100644 (file)
@@ -219,7 +219,7 @@ namespace WebCore {
                                                              PassRefPtr<FormState>);
         virtual void dispatchUnableToImplementPolicy(const ResourceError&);
 
-        virtual void startDownload(const ResourceRequest&);
+        virtual void startDownload(const ResourceRequest&, const String& suggestedName = String());
 
         // FIXME: This should probably not be here, but it's needed for the tests currently.
         virtual void partClearedInBegin();
index 31caa01..467f047 100644 (file)
@@ -140,7 +140,7 @@ private:
     
     virtual void setMainFrameDocumentReady(bool);
 
-    virtual void startDownload(const WebCore::ResourceRequest&);
+    virtual void startDownload(const WebCore::ResourceRequest&, const String& suggestedName = String());
 
     virtual void willChangeTitle(WebCore::DocumentLoader*);
     virtual void didChangeTitle(WebCore::DocumentLoader*);
index 64c212c..7a5e1c9 100644 (file)
@@ -870,7 +870,7 @@ void WebFrameLoaderClient::setMainFrameDocumentReady(bool ready)
     [getWebView(m_webFrame.get()) setMainFrameDocumentReady:ready];
 }
 
-void WebFrameLoaderClient::startDownload(const ResourceRequest& request)
+void WebFrameLoaderClient::startDownload(const ResourceRequest& request, const String& /* suggestedName */)
 {
     // FIXME: Should download full request.
     WebDownload *download = [getWebView(m_webFrame.get()) _downloadURL:request.url()];
index fa994e5..235a238 100644 (file)
@@ -1,3 +1,14 @@
+2011-07-26  Sadrul Habib Chowdhury  <sadrul@chromium.org>
+
+        Add support for download='filename' attribute in anchors.
+        https://bugs.webkit.org/show_bug.cgi?id=64580
+
+        Reviewed by Adam Barth.
+
+        * WebCoreSupport/FrameLoaderClientQt.cpp:
+        (WebCore::FrameLoaderClientQt::startDownload):
+        * WebCoreSupport/FrameLoaderClientQt.h:
+
 2011-07-26  Alexis Menard  <alexis.menard@openbossa.org>
 
         Reviewed by Andreas Kling.
index 9a1e1ff..0da9183 100644 (file)
@@ -1296,7 +1296,7 @@ void FrameLoaderClientQt::dispatchUnableToImplementPolicy(const WebCore::Resourc
     notImplemented();
 }
 
-void FrameLoaderClientQt::startDownload(const WebCore::ResourceRequest& request)
+void FrameLoaderClientQt::startDownload(const WebCore::ResourceRequest& request, const String& /* suggestedName */)
 {
     if (!m_webFrame)
         return;
index 121303d..786c01c 100644 (file)
@@ -149,7 +149,7 @@ public:
 
     virtual void setMainFrameDocumentReady(bool);
 
-    virtual void startDownload(const WebCore::ResourceRequest&);
+    virtual void startDownload(const WebCore::ResourceRequest&, const String& suggestedName = String());
 
     virtual void willChangeTitle(DocumentLoader*);
     virtual void didChangeTitle(DocumentLoader*);
index 4e629bb..08f2908 100644 (file)
@@ -1,3 +1,14 @@
+2011-07-26  Sadrul Habib Chowdhury  <sadrul@chromium.org>
+
+        Add support for download='filename' attribute in anchors.
+        https://bugs.webkit.org/show_bug.cgi?id=64580
+
+        Reviewed by Adam Barth.
+
+        * WebFrame.cpp:
+        (WebFrame::startDownload):
+        * WebFrame.h:
+
 2011-07-26  Dan Bernstein  <mitz@apple.com>
 
         <rdar://problem/9842889> Add a generic pictograph font family
index b8bb249..7db99ae 100644 (file)
@@ -1907,7 +1907,7 @@ void WebFrame::dispatchDidFailLoad(const ResourceError& error)
     }
 }
 
-void WebFrame::startDownload(const ResourceRequest& request)
+void WebFrame::startDownload(const ResourceRequest& request, const String& /* suggestedName */)
 {
     d->webView->downloadURL(request.url());
 }
index 8046d85..8b63924 100644 (file)
@@ -342,7 +342,7 @@ public:
     virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length);
     virtual void dispatchDidFailProvisionalLoad(const WebCore::ResourceError&);
     virtual void dispatchDidFailLoad(const WebCore::ResourceError&);
-    virtual void startDownload(const WebCore::ResourceRequest&);
+    virtual void startDownload(const WebCore::ResourceRequest&, const String& suggestedName = String());
         
     virtual PassRefPtr<WebCore::Widget> createJavaAppletWidget(const WebCore::IntSize&, WebCore::HTMLAppletElement*, const WebCore::KURL& baseURL, const Vector<WTF::String>& paramNames, const Vector<WTF::String>& paramValues);
 
index 50e31e4..c268283 100644 (file)
@@ -1,3 +1,14 @@
+2011-07-26  Sadrul Habib Chowdhury  <sadrul@chromium.org>
+
+        Add support for download='filename' attribute in anchors.
+        https://bugs.webkit.org/show_bug.cgi?id=64580
+
+        Reviewed by Adam Barth.
+
+        * WebCoreSupport/FrameLoaderClientWinCE.cpp:
+        (WebKit::FrameLoaderClientWinCE::startDownload):
+        * WebCoreSupport/FrameLoaderClientWinCE.h:
+
 2011-07-15  Dan Bernstein  <mitz@apple.com>
 
         REGRESSION: Mouse cursor doesn’t hide when full screen video HUD hides
index 64c10fe..54c1264 100644 (file)
@@ -597,7 +597,7 @@ void FrameLoaderClientWinCE::setMainDocumentError(DocumentLoader*, const Resourc
     m_hasSentResponseToPlugin = false;
 }
 
-void FrameLoaderClientWinCE::startDownload(const WebCore::ResourceRequest&)
+void FrameLoaderClientWinCE::startDownload(const WebCore::ResourceRequest&, const String& /* suggestedName */)
 {
     notImplemented();
 }
index 6beab0d..c5d3009 100644 (file)
@@ -125,7 +125,7 @@ public:
 
     virtual void setMainFrameDocumentReady(bool);
 
-    virtual void startDownload(const WebCore::ResourceRequest&);
+    virtual void startDownload(const WebCore::ResourceRequest&, const String& suggestedName = String());
 
     virtual void willChangeTitle(WebCore::DocumentLoader*);
     virtual void didChangeTitle(WebCore::DocumentLoader*);
index c5764e2..3a25c24 100644 (file)
@@ -1,3 +1,14 @@
+2011-07-26  Sadrul Habib Chowdhury  <sadrul@chromium.org>
+
+        Add support for download='filename' attribute in anchors.
+        https://bugs.webkit.org/show_bug.cgi?id=64580
+
+        Reviewed by Adam Barth.
+
+        * WebKitSupport/FrameLoaderClientWx.cpp:
+        (WebCore::FrameLoaderClientWx::startDownload):
+        * WebKitSupport/FrameLoaderClientWx.h:
+
 2011-07-15  Dan Bernstein  <mitz@apple.com>
 
         REGRESSION: Mouse cursor doesn’t hide when full screen video HUD hides
index d16f677..e380fb0 100644 (file)
@@ -840,7 +840,7 @@ void FrameLoaderClientWx::dispatchUnableToImplementPolicy(const ResourceError&)
     notImplemented();
 }
 
-void FrameLoaderClientWx::startDownload(const ResourceRequest&)
+void FrameLoaderClientWx::startDownload(const ResourceRequest&, const String& /* suggestedName */)
 {
     notImplemented();
 }
index 0afdad9..e1481c6 100644 (file)
@@ -206,7 +206,7 @@ namespace WebCore {
         virtual void dispatchDecidePolicyForNavigationAction(FramePolicyFunction function, const NavigationAction&, const ResourceRequest&, PassRefPtr<FormState>);
         virtual void dispatchUnableToImplementPolicy(const ResourceError&);
 
-        virtual void startDownload(const ResourceRequest&);
+        virtual void startDownload(const ResourceRequest&, const String& suggestedName = String());
         
         // FIXME: This should probably not be here, but it's needed for the tests currently
         virtual void partClearedInBegin();
index 4f3a346..7698316 100644 (file)
@@ -1,3 +1,14 @@
+2011-07-26  Sadrul Habib Chowdhury  <sadrul@chromium.org>
+
+        Add support for download='filename' attribute in anchors.
+        https://bugs.webkit.org/show_bug.cgi?id=64580
+
+        Reviewed by Adam Barth.
+
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::startDownload):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+
 2011-07-26  Tim Horton  <timothy_horton@apple.com>
 
         Apply r40940 to WebKit2 to work around a Silverlight crash.
index 3017506..3bc8ad2 100644 (file)
@@ -789,7 +789,7 @@ void WebFrameLoaderClient::setMainFrameDocumentReady(bool)
     notImplemented();
 }
 
-void WebFrameLoaderClient::startDownload(const ResourceRequest& request)
+void WebFrameLoaderClient::startDownload(const ResourceRequest& request, const String& /* suggestedName */)
 {
     m_frame->startDownload(request);
 }
index 56ef7ea..fe7c11e 100644 (file)
@@ -122,7 +122,7 @@ private:
     
     virtual void setMainFrameDocumentReady(bool);
     
-    virtual void startDownload(const WebCore::ResourceRequest&);
+    virtual void startDownload(const WebCore::ResourceRequest&, const String& suggestedName = String());
     
     virtual void willChangeTitle(WebCore::DocumentLoader*);
     virtual void didChangeTitle(WebCore::DocumentLoader*);
index bf65133..03fca9f 100644 (file)
@@ -1,3 +1,14 @@
+2011-07-26  Sadrul Habib Chowdhury  <sadrul@chromium.org>
+
+        Add support for download='filename' attribute in anchors.
+        https://bugs.webkit.org/show_bug.cgi?id=64580
+
+        Reviewed by Adam Barth.
+
+        * DumpRenderTree/chromium/WebViewHost.cpp:
+        (WebViewHost::loadURLExternally):
+        * DumpRenderTree/chromium/WebViewHost.h:
+
 2011-07-26  Dan Bernstein  <mitz@apple.com>
 
         Rubber-stamped by Anders Carlsson.
index 6fb3091..f89eb21 100644 (file)
@@ -799,7 +799,12 @@ bool WebViewHost::allowImages(WebFrame* frame, bool enabledPerSettings)
     return enabledPerSettings;
 }
 
-void WebViewHost::loadURLExternally(WebFrame*, const WebURLRequest& request, WebNavigationPolicy policy)
+void WebViewHost::loadURLExternally(WebFrame* frame, const WebURLRequest& request, WebNavigationPolicy policy)
+{
+    loadURLExternally(frame, request, policy, WebString());
+}
+
+void WebViewHost::loadURLExternally(WebFrame*, const WebURLRequest& request, WebNavigationPolicy policy, const WebString& downloadName)
 {
     ASSERT(policy !=  WebKit::WebNavigationPolicyCurrentTab);
     WebViewHost* another = m_shell->createNewWindow(request.url());
index 2951aff..ec78a92 100644 (file)
@@ -174,6 +174,7 @@ class WebViewHost : public WebKit::WebSpellCheckClient, public WebKit::WebViewCl
      virtual bool allowPlugins(WebKit::WebFrame*, bool enabledPerSettings);
     virtual bool allowImages(WebKit::WebFrame*, bool enabledPerSettings);
     virtual void loadURLExternally(WebKit::WebFrame*, const WebKit::WebURLRequest&, WebKit::WebNavigationPolicy);
+    virtual void loadURLExternally(WebKit::WebFrame*, const WebKit::WebURLRequest&, WebKit::WebNavigationPolicy, const WebKit::WebString& downloadName);
     virtual WebKit::WebNavigationPolicy decidePolicyForNavigation(
         WebKit::WebFrame*, const WebKit::WebURLRequest&,
         WebKit::WebNavigationType, const WebKit::WebNode&,