Title: [207579] trunk/Source/WebKit2
- Revision
- 207579
- Author
- cdu...@apple.com
- Date
- 2016-10-19 16:55:30 -0700 (Wed, 19 Oct 2016)
Log Message
[WK2] Expose suggested filename via WKBundleHitTestResult API
https://bugs.webkit.org/show_bug.cgi?id=163693
<rdar://problem/28840734>
Reviewed by Anders Carlsson.
Expose suggested filename via WKBundleHitTestResult API. The implementation
currently relies on the 'download' attribute on anchor / area elements
that we recently started supporting.
* WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp:
(WKBundleHitTestResultCopyLinkSuggestedFilename):
* WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h:
* WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp:
(WebKit::InjectedBundleHitTestResult::create):
(WebKit::InjectedBundleHitTestResult::mediaType):
(WebKit::InjectedBundleHitTestResult::linkSuggestedFilename):
(WebKit::InjectedBundleHitTestResult::imageRect):
* WebProcess/InjectedBundle/InjectedBundleHitTestResult.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (207578 => 207579)
--- trunk/Source/WebKit2/ChangeLog 2016-10-19 23:49:43 UTC (rev 207578)
+++ trunk/Source/WebKit2/ChangeLog 2016-10-19 23:55:30 UTC (rev 207579)
@@ -1,3 +1,25 @@
+2016-10-19 Chris Dumez <cdu...@apple.com>
+
+ [WK2] Expose suggested filename via WKBundleHitTestResult API
+ https://bugs.webkit.org/show_bug.cgi?id=163693
+ <rdar://problem/28840734>
+
+ Reviewed by Anders Carlsson.
+
+ Expose suggested filename via WKBundleHitTestResult API. The implementation
+ currently relies on the 'download' attribute on anchor / area elements
+ that we recently started supporting.
+
+ * WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp:
+ (WKBundleHitTestResultCopyLinkSuggestedFilename):
+ * WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h:
+ * WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp:
+ (WebKit::InjectedBundleHitTestResult::create):
+ (WebKit::InjectedBundleHitTestResult::mediaType):
+ (WebKit::InjectedBundleHitTestResult::linkSuggestedFilename):
+ (WebKit::InjectedBundleHitTestResult::imageRect):
+ * WebProcess/InjectedBundle/InjectedBundleHitTestResult.h:
+
2016-10-19 Ryan Haddad <ryanhad...@apple.com>
Unreviewed, rolling out r207557.
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp (207578 => 207579)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp 2016-10-19 23:49:43 UTC (rev 207578)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp 2016-10-19 23:55:30 UTC (rev 207579)
@@ -120,3 +120,8 @@
{
return toCopiedAPI(toImpl(hitTestResultRef)->linkTitle());
}
+
+WKStringRef WKBundleHitTestResultCopyLinkSuggestedFilename(WKBundleHitTestResultRef hitTestResultRef)
+{
+ return toCopiedAPI(toImpl(hitTestResultRef)->linkSuggestedFilename());
+}
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h (207578 => 207579)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h 2016-10-19 23:49:43 UTC (rev 207578)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h 2016-10-19 23:55:30 UTC (rev 207579)
@@ -62,6 +62,7 @@
WK_EXPORT WKStringRef WKBundleHitTestResultCopyLinkLabel(WKBundleHitTestResultRef hitTestResult);
WK_EXPORT WKStringRef WKBundleHitTestResultCopyLinkTitle(WKBundleHitTestResultRef hitTestResult);
+WK_EXPORT WKStringRef WKBundleHitTestResultCopyLinkSuggestedFilename(WKBundleHitTestResultRef hitTestResult);
#ifdef __cplusplus
}
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp (207578 => 207579)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp 2016-10-19 23:49:43 UTC (rev 207578)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp 2016-10-19 23:55:30 UTC (rev 207579)
@@ -34,6 +34,8 @@
#include <WebCore/Frame.h>
#include <WebCore/FrameLoader.h>
#include <WebCore/FrameView.h>
+#include <WebCore/HTMLAnchorElement.h>
+#include <WebCore/HTMLNames.h>
#include <WebCore/URL.h>
#include <wtf/text/WTFString.h>
@@ -41,7 +43,7 @@
namespace WebKit {
-Ref<InjectedBundleHitTestResult> InjectedBundleHitTestResult::create(const WebCore::HitTestResult& hitTestResult)
+Ref<InjectedBundleHitTestResult> InjectedBundleHitTestResult::create(const HitTestResult& hitTestResult)
{
return adoptRef(*new InjectedBundleHitTestResult(hitTestResult));
}
@@ -118,7 +120,7 @@
#if !ENABLE(VIDEO)
return BundleHitTestResultMediaTypeNone;
#else
- WebCore::Node* node = m_hitTestResult.innerNonSharedNode();
+ Node* node = m_hitTestResult.innerNonSharedNode();
if (!is<Element>(*node))
return BundleHitTestResultMediaTypeNone;
@@ -139,23 +141,31 @@
return m_hitTestResult.titleDisplayString();
}
-WebCore::IntRect InjectedBundleHitTestResult::imageRect() const
+String InjectedBundleHitTestResult::linkSuggestedFilename() const
{
- WebCore::IntRect imageRect = m_hitTestResult.imageRect();
+ auto* urlElement = m_hitTestResult.URLElement();
+ if (!is<HTMLAnchorElement>(urlElement))
+ return String();
+ return urlElement->attributeWithoutSynchronization(HTMLNames::downloadAttr);
+}
+
+IntRect InjectedBundleHitTestResult::imageRect() const
+{
+ IntRect imageRect = m_hitTestResult.imageRect();
if (imageRect.isEmpty())
return imageRect;
- // The image rect in WebCore::HitTestResult is in frame coordinates, but we need it in WKView
+ // The image rect in HitTestResult is in frame coordinates, but we need it in WKView
// coordinates since WebKit2 clients don't have enough context to do the conversion themselves.
WebFrame* webFrame = frame();
if (!webFrame)
return imageRect;
- WebCore::Frame* coreFrame = webFrame->coreFrame();
+ Frame* coreFrame = webFrame->coreFrame();
if (!coreFrame)
return imageRect;
- WebCore::FrameView* view = coreFrame->view();
+ FrameView* view = coreFrame->view();
if (!view)
return imageRect;
Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.h (207578 => 207579)
--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.h 2016-10-19 23:49:43 UTC (rev 207578)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.h 2016-10-19 23:55:30 UTC (rev 207579)
@@ -60,6 +60,7 @@
String linkLabel() const;
String linkTitle() const;
+ String linkSuggestedFilename() const;
WebCore::IntRect imageRect() const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes