Expose PDF information in hit test result
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Oct 2011 23:20:08 +0000 (23:20 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 18 Oct 2011 23:20:08 +0000 (23:20 +0000)
        https://bugs.webkit.org/show_bug.cgi?id=70353

        Reviewed by Sam Weinig.

        * WebCore.exp.in:
        * rendering/HitTestResult.cpp:
        (WebCore::HitTestResult::absolutePDFURL):
        * rendering/HitTestResult.h:
        Added HitTestResult::absolutePDFURL(). It will contain a URL when over a PDF object or embed;
        not sure if we want this for PDFImageDocuments.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@97810 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/rendering/HitTestResult.cpp
Source/WebCore/rendering/HitTestResult.h
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebHitTestResult.cpp
Source/WebKit2/Shared/WebHitTestResult.h
Source/WebKit2/UIProcess/API/C/WKHitTestResult.cpp
Source/WebKit2/UIProcess/API/C/WKHitTestResult.h
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundleHitTestResult.h
Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp

index 470d6e0c60dc14fb3f9ad80949edc8767e032e03..d353831c05d1eb3b0a56baa09c13f263eba59bab 100644 (file)
@@ -1,3 +1,17 @@
+2011-10-18  Alexey Proskuryakov  <ap@apple.com>
+
+        Expose PDF information in hit test result
+        https://bugs.webkit.org/show_bug.cgi?id=70353
+
+        Reviewed by Sam Weinig.
+
+        * WebCore.exp.in:
+        * rendering/HitTestResult.cpp:
+        (WebCore::HitTestResult::absolutePDFURL):
+        * rendering/HitTestResult.h:
+        Added HitTestResult::absolutePDFURL(). It will contain a URL when over a PDF object or embed;
+        not sure if we want this for PDFImageDocuments.
+
 2011-10-18  Adrienne Walker  <enne@google.com>
 
         [chromium] Preserve offscreen tiles instead of immediately recycling them
index 19c595284c0b9aaa67d47e2a4f13212678977c85..5be7e76304b374f1754a7cb1c0b45aa415a27599 100644 (file)
@@ -1174,6 +1174,7 @@ __ZNK7WebCore13HitTestResult10isLiveLinkEv
 __ZNK7WebCore13HitTestResult10isSelectedEv
 __ZNK7WebCore13HitTestResult11targetFrameEv
 __ZNK7WebCore13HitTestResult11textContentEv
+__ZNK7WebCore13HitTestResult14absolutePDFURLEv
 __ZNK7WebCore13HitTestResult15absoluteLinkURLEv
 __ZNK7WebCore13HitTestResult15spellingToolTipERNS_13TextDirectionE
 __ZNK7WebCore13HitTestResult16absoluteImageURLEv
index 1733232008608f406fece5d8addbb640a481eb21..1f784fd4212c0458666bbc287e8119eb6ff261e6 100644 (file)
@@ -32,6 +32,7 @@
 #include "HTMLMediaElement.h"
 #include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
+#include "HTMLPlugInImageElement.h"
 #include "RenderBlock.h"
 #include "RenderImage.h"
 #include "RenderInline.h"
@@ -342,6 +343,24 @@ KURL HitTestResult::absoluteImageURL() const
     return m_innerNonSharedNode->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(urlString));
 }
 
+KURL HitTestResult::absolutePDFURL() const
+{
+    if (!(m_innerNonSharedNode && m_innerNonSharedNode->document()))
+        return KURL();
+
+    if (!m_innerNonSharedNode->hasTagName(embedTag) && !m_innerNonSharedNode->hasTagName(objectTag))
+        return KURL();
+
+    HTMLPlugInImageElement* element = static_cast<HTMLPlugInImageElement*>(m_innerNonSharedNode.get());
+    KURL url = m_innerNonSharedNode->document()->completeURL(stripLeadingAndTrailingHTMLSpaces(element->url()));
+    if (!url.isValid())
+        return KURL();
+
+    if (element->serviceType() == "application/pdf" || (element->serviceType().isEmpty() && url.path().lower().endsWith(".pdf")))
+        return url;
+    returrbr n KURL();
+}
+
 KURL HitTestResult::absoluteMediaURL() const
 {
 #if ENABLE(VIDEO)
index 33e0cfa7af7fe9265386ddc282355ec793365c14..09ca35d3119604944ad456f5196a593a0022baba 100644 (file)
@@ -85,6 +85,7 @@ public:
     Image* image() const;
     IntRect imageRect() const;
     KURL absoluteImageURL() const;
+    KURL absolutePDFURL() const;
     KURL absoluteMediaURL() const;
     KURL absoluteLinkURL() const;
     String textContent() const;
index 2cd673e7981d3bc690c875431e284f0454ab5b69..2ff07f3e649a37e0a68cede54dc6aba8cf8b373f 100644 (file)
@@ -1,3 +1,28 @@
+2011-10-18  Alexey Proskuryakov  <ap@apple.com>
+
+        Expose PDF information in hit test result
+        https://bugs.webkit.org/show_bug.cgi?id=70353
+
+        Reviewed by Sam Weinig.
+
+        * Shared/WebHitTestResult.cpp:
+        (WebKit::WebHitTestResult::Data::encode):
+        (WebKit::WebHitTestResult::Data::decode):
+        * Shared/WebHitTestResult.h:
+        (WebKit::WebHitTestResult::absolutePDFURL):
+        * UIProcess/API/C/WKHitTestResult.cpp:
+        (WKHitTestResultCopyAbsolutePDFURL):
+        * UIProcess/API/C/WKHitTestResult.h:
+        * WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.cpp:
+        (WKBundleHitTestResultCopyAbsolutePDFURL):
+        * WebProcess/InjectedBundle/API/c/WKBundleHitTestResult.h:
+        * WebProcess/InjectedBundle/InjectedBundleHitTestResult.cpp:
+        (WebKit::InjectedBundleHitTestResult::absolutePDFURL):
+        * WebProcess/InjectedBundle/InjectedBundleHitTestResult.h:
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::mouseDidMoveOverElement):
+        Pass through PDF URL from hit testing to injected bundle client.
+
 2011-10-18  Enrica Casucci  <enrica@apple.com>
 
         Crash in WebProcess at com.apple.AppKit: -[NSFilePromiseDragSource draggedImage:endedAt:operation:] + 101
index f04b84714ffa568e0a0cfdeb5e43214050f015d7..6e346e08d00e3f748bbf4cb820bb73d70255db49 100644 (file)
@@ -37,6 +37,7 @@ PassRefPtr<WebHitTestResult> WebHitTestResult::create(const WebHitTestResult::Da
 void WebHitTestResult::Data::encode(CoreIPC::ArgumentEncoder* encoder) const
 {
     encoder->encode(absoluteImageURL);
+    encoder->encode(absolutePDFURL);
     encoder->encode(absoluteLinkURL);
     encoder->encode(absoluteMediaURL);
     encoder->encode(linkLabel);
@@ -46,6 +47,7 @@ void WebHitTestResult::Data::encode(CoreIPC::ArgumentEncoder* encoder) const
 bool WebHitTestResult::Data::decode(CoreIPC::ArgumentDecoder* decoder, WebHitTestResult::Data& hitTestResultData)
 {
     if (!decoder->decode(hitTestResultData.absoluteImageURL)
+        || !decoder->decode(hitTestResultData.absolutePDFURL)
         || !decoder->decode(hitTestResultData.absoluteLinkURL)
         || !decoder->decode(hitTestResultData.absoluteMediaURL)
         || !decoder->decode(hitTestResultData.linkLabel)
index 06f9735a4220ba7ac7b3977d11607e55d81ebcda..9bf63fca1acb8c5ee836e7d01b45cc498b7f2c7f 100644 (file)
@@ -43,6 +43,7 @@ public:
 
     struct Data {
         String absoluteImageURL;
+        String absolutePDFURL;
         String absoluteLinkURL;
         String absoluteMediaURL;
         String linkLabel;
@@ -55,6 +56,7 @@ public:
     static PassRefPtr<WebHitTestResult> create(const WebHitTestResult::Data&);
 
     String absoluteImageURL() const { return m_data.absoluteImageURL; }
+    String absolutePDFURL() const { return m_data.absolutePDFURL; }
     String absoluteLinkURL() const { return m_data.absoluteLinkURL; }
     String absoluteMediaURL() const { return m_data.absoluteMediaURL; }
 
index b222d419a475132ac2d1e4add60ec3e8cb26eb58..a87b6e35ba4b6cef697c90a46252362d9e271965 100644 (file)
@@ -42,6 +42,11 @@ WKURLRef WKHitTestResultCopyAbsoluteImageURL(WKHitTestResultRef hitTestResultRef
     return toCopiedURLAPI(toImpl(hitTestResultRef)->absoluteImageURL());
 }
 
+WKURLRef WKHitTestResultCopyAbsolutePDFURL(WKHitTestResultRef hitTestResultRef)
+{
+    return toCopiedURLAPI(toImpl(hitTestResultRef)->absolutePDFURL());
+}
+
 WKURLRef WKHitTestResultCopyAbsoluteLinkURL(WKHitTestResultRef hitTestResultRef)
 {
     return toCopiedURLAPI(toImpl(hitTestResultRef)->absoluteLinkURL());
index aa6e64ff86185a3eb35ba007856f5368c4a0959a..0ba23df6ccc0737d77248694ee05bb356cb3ca25 100644 (file)
@@ -36,6 +36,7 @@ extern "C" {
 WK_EXPORT WKTypeID WKHitTestResultGetTypeID();
 
 WK_EXPORT WKURLRef WKHitTestResultCopyAbsoluteImageURL(WKHitTestResultRef hitTestResult);
+WK_EXPORT WKURLRef WKHitTestResultCopyAbsolutePDFURL(WKHitTestResultRef hitTestResult);
 WK_EXPORT WKURLRef WKHitTestResultCopyAbsoluteLinkURL(WKHitTestResultRef hitTestResult);
 WK_EXPORT WKURLRef WKHitTestResultCopyAbsoluteMediaURL(WKHitTestResultRef hitTestResult);
 
index 4e941c30a33e10ba8beda2b91719b8a53d9c8cff..9cb225033feff13345a1173f0142a32d96e7005c 100644 (file)
@@ -59,6 +59,11 @@ WKURLRef WKBundleHitTestResultCopyAbsoluteImageURL(WKBundleHitTestResultRef hitT
     return toCopiedURLAPI(toImpl(hitTestResultRef)->absoluteImageURL());
 }
 
+WKURLRef WKBundleHitTestResultCopyAbsolutePDFURL(WKBundleHitTestResultRef hitTestResultRef)
+{
+    return toCopiedURLAPI(toImpl(hitTestResultRef)->absolutePDFURL());
+}
+
 WKURLRef WKBundleHitTestResultCopyAbsoluteLinkURL(WKBundleHitTestResultRef hitTestResultRef)
 {
     return toCopiedURLAPI(toImpl(hitTestResultRef)->absoluteLinkURL());
index b288e0bcf329f595a321415196612d5a46561598..37c5019da4ab45b1759d4f88fe257fc6b397c5ca 100644 (file)
@@ -41,6 +41,7 @@ WK_EXPORT WKBundleFrameRef WKBundleHitTestResultGetFrame(WKBundleHitTestResultRe
 WK_EXPORT WKBundleFrameRef WKBundleHitTestResultGetTargetFrame(WKBundleHitTestResultRef hitTestResult);
 
 WK_EXPORT WKURLRef WKBundleHitTestResultCopyAbsoluteImageURL(WKBundleHitTestResultRef hitTestResult);
+WK_EXPORT WKURLRef WKBundleHitTestResultCopyAbsolutePDFURL(WKBundleHitTestResultRef hitTestResult);
 WK_EXPORT WKURLRef WKBundleHitTestResultCopyAbsoluteLinkURL(WKBundleHitTestResultRef hitTestResult);
 WK_EXPORT WKURLRef WKBundleHitTestResultCopyAbsoluteMediaURL(WKBundleHitTestResultRef hitTestResult);
 
index b326e9bd71fb3cfe17c3960cb72eda79744f86dd..8c91cb8754bb9c8fa85df1bc9953dfd0244cc5f6 100644 (file)
@@ -81,6 +81,11 @@ String InjectedBundleHitTestResult::absoluteImageURL() const
     return m_hitTestResult.absoluteImageURL().string();
 }
 
+String InjectedBundleHitTestResult::absolutePDFURL() const
+{
+    return m_hitTestResult.absolutePDFURL().string();
+}
+
 String InjectedBundleHitTestResult::absoluteLinkURL() const
 {
     return m_hitTestResult.absoluteLinkURL().string();
index b09da1c54868f79540a8ddac9b4b727a5bda2f3e..292fce1ba9ed3a810a1e78b9cce7936ecf6c7751 100644 (file)
@@ -50,6 +50,7 @@ public:
     WebFrame* targetFrame() const;
 
     String absoluteImageURL() const;
+    String absolutePDFURL() const;
     String absoluteLinkURL() const;
     String absoluteMediaURL() const;
 
index 0701e7906d8b8284212e234b01d6dfac2f04a0a4..af4bff8c0b8582531928d161c148a03f1f49e338 100644 (file)
@@ -498,6 +498,7 @@ void WebChromeClient::mouseDidMoveOverElement(const HitTestResult& hitTestResult
 
     WebHitTestResult::Data webHitTestResultData;
     webHitTestResultData.absoluteImageURL = hitTestResult.absoluteImageURL().string();
+    webHitTestResultData.absolutePDFURL = hitTestResult.absolutePDFURL().string();
     webHitTestResultData.absoluteLinkURL = hitTestResult.absoluteLinkURL().string();
     webHitTestResultData.absoluteMediaURL = hitTestResult.absoluteMediaURL().string();
     webHitTestResultData.linkLabel = hitTestResult.textContent();