Changeset 207579 in webkit
- Timestamp:
- Oct 19, 2016 4:55:30 PM (8 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r207568 r207579 1 2016-10-19 Chris Dumez <cdumez@apple.com> 2 3 [WK2] Expose suggested filename via WKBundleHitTestResult API 4 https://bugs.webkit.org/show_bug.cgi?id=163693 5 <rdar://problem/28840734> 6 7 Reviewed by Anders Carlsson. 8 9 Expose suggested filename via WKBundleHitTestResult API. The implementation 10 currently relies on the 'download' attribute on anchor / area elements 11 that we recently started supporting. 12 13 * WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp: 14 (WKBundleHitTestResultCopyLinkSuggestedFilename): 15 * WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h: 16 * WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp: 17 (WebKit::InjectedBundleHitTestResult::create): 18 (WebKit::InjectedBundleHitTestResult::mediaType): 19 (WebKit::InjectedBundleHitTestResult::linkSuggestedFilename): 20 (WebKit::InjectedBundleHitTestResult::imageRect): 21 * WebProcess/InjectedBundle/InjectedBundleHitTestResult.h: 22 1 23 2016-10-19 Ryan Haddad <ryanhaddad@apple.com> 2 24 -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp
r202242 r207579 121 121 return toCopiedAPI(toImpl(hitTestResultRef)->linkTitle()); 122 122 } 123 124 WKStringRef WKBundleHitTestResultCopyLinkSuggestedFilename(WKBundleHitTestResultRef hitTestResultRef) 125 { 126 return toCopiedAPI(toImpl(hitTestResultRef)->linkSuggestedFilename()); 127 } -
trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h
r176108 r207579 63 63 WK_EXPORT WKStringRef WKBundleHitTestResultCopyLinkLabel(WKBundleHitTestResultRef hitTestResult); 64 64 WK_EXPORT WKStringRef WKBundleHitTestResultCopyLinkTitle(WKBundleHitTestResultRef hitTestResult); 65 WK_EXPORT WKStringRef WKBundleHitTestResultCopyLinkSuggestedFilename(WKBundleHitTestResultRef hitTestResult); 65 66 66 67 #ifdef __cplusplus -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp
r186566 r207579 35 35 #include <WebCore/FrameLoader.h> 36 36 #include <WebCore/FrameView.h> 37 #include <WebCore/HTMLAnchorElement.h> 38 #include <WebCore/HTMLNames.h> 37 39 #include <WebCore/URL.h> 38 40 #include <wtf/text/WTFString.h> … … 42 44 namespace WebKit { 43 45 44 Ref<InjectedBundleHitTestResult> InjectedBundleHitTestResult::create(const WebCore::HitTestResult& hitTestResult)46 Ref<InjectedBundleHitTestResult> InjectedBundleHitTestResult::create(const HitTestResult& hitTestResult) 45 47 { 46 48 return adoptRef(*new InjectedBundleHitTestResult(hitTestResult)); … … 119 121 return BundleHitTestResultMediaTypeNone; 120 122 #else 121 WebCore::Node* node = m_hitTestResult.innerNonSharedNode();123 Node* node = m_hitTestResult.innerNonSharedNode(); 122 124 if (!is<Element>(*node)) 123 125 return BundleHitTestResultMediaTypeNone; … … 140 142 } 141 143 142 WebCore::IntRect InjectedBundleHitTestResult::imageRect() const144 String InjectedBundleHitTestResult::linkSuggestedFilename() const 143 145 { 144 WebCore::IntRect imageRect = m_hitTestResult.imageRect(); 146 auto* urlElement = m_hitTestResult.URLElement(); 147 if (!is<HTMLAnchorElement>(urlElement)) 148 return String(); 149 return urlElement->attributeWithoutSynchronization(HTMLNames::downloadAttr); 150 } 151 152 IntRect InjectedBundleHitTestResult::imageRect() const 153 { 154 IntRect imageRect = m_hitTestResult.imageRect(); 145 155 if (imageRect.isEmpty()) 146 156 return imageRect; 147 157 148 // The image rect in WebCore::HitTestResult is in frame coordinates, but we need it in WKView158 // The image rect in HitTestResult is in frame coordinates, but we need it in WKView 149 159 // coordinates since WebKit2 clients don't have enough context to do the conversion themselves. 150 160 WebFrame* webFrame = frame(); … … 152 162 return imageRect; 153 163 154 WebCore::Frame* coreFrame = webFrame->coreFrame();164 Frame* coreFrame = webFrame->coreFrame(); 155 165 if (!coreFrame) 156 166 return imageRect; 157 167 158 WebCore::FrameView* view = coreFrame->view();168 FrameView* view = coreFrame->view(); 159 169 if (!view) 160 170 return imageRect; -
trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.h
r186566 r207579 61 61 String linkLabel() const; 62 62 String linkTitle() const; 63 String linkSuggestedFilename() const; 63 64 64 65 WebCore::IntRect imageRect() const;
Note: See TracChangeset
for help on using the changeset viewer.