Diff
Modified: trunk/Source/WebKit2/ChangeLog (141371 => 141372)
--- trunk/Source/WebKit2/ChangeLog 2013-01-31 04:57:50 UTC (rev 141371)
+++ trunk/Source/WebKit2/ChangeLog 2013-01-31 05:02:03 UTC (rev 141372)
@@ -1,3 +1,27 @@
+2013-01-30 Tim Horton <[email protected]>
+
+ PDFPlugin: Should respond to three-finger tap for dictionary definitions
+ https://bugs.webkit.org/show_bug.cgi?id=108418
+ <rdar://problem/13121409>
+
+ Reviewed by Simon Fraser.
+
+ * WebProcess/Plugins/Netscape/NetscapePlugin.h: Add default implementation of performDictionaryLookupAtLocation.
+ * WebProcess/Plugins/PDF/PDFLayerControllerDetails.h: Add getSelectionForWordAtPoint and searchInDictionaryWithSelection.
+ * WebProcess/Plugins/PDF/PDFPlugin.h: Add performDictionaryLookupAtLocation.
+ * WebProcess/Plugins/PDF/PDFPlugin.mm: Grab a PDFSelection representing the word encompassing the given point, and
+ throw up a dictionary popover.
+ (WebKit::PDFPlugin::performDictionaryLookupAtLocation):
+ * WebProcess/Plugins/PDF/SimplePDFPlugin.h: Add default implementation of performDictionaryLookupAtLocation.
+ * WebProcess/Plugins/Plugin.h: Add performDictionaryLookupAtLocation.
+ * WebProcess/Plugins/PluginProxy.h: Add default implementation of performDictionaryLookupAtLocation.
+ * WebProcess/Plugins/PluginView.cpp:
+ (WebKit::PluginView::performDictionaryLookupAtLocation): Forward performDictionaryLookupAtLocation to the plugin.
+ * WebProcess/Plugins/PluginView.h: Add performDictionaryLookupAtLocation.
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::performDictionaryLookupAtLocation): Intercept performDictionaryLookupAtLocation, and give
+ the main-frame plugin (if it exists) a chance to handle it.
+
2013-01-30 Gyuyoung Kim <[email protected]>
[WK2] Cleanup MessageID parameter after r141332
Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h (141371 => 141372)
--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h 2013-01-31 04:57:50 UTC (rev 141371)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.h 2013-01-31 05:02:03 UTC (rev 141372)
@@ -249,6 +249,8 @@
virtual bool getResourceData(const unsigned char*& /* bytes */, unsigned& /* length */) const OVERRIDE { return false; }
+ virtual bool performDictionaryLookupAtLocation(const WebCore::FloatPoint&) OVERRIDE { return false; }
+
void updateNPNPrivateMode();
#if PLUGIN_ARCHITECTURE(WIN)
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerDetails.h (141371 => 141372)
--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerDetails.h 2013-01-31 04:57:50 UTC (rev 141371)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFLayerControllerDetails.h 2013-01-31 05:02:03 UTC (rev 141372)
@@ -89,6 +89,7 @@
- (PDFSelection *)searchSelection;
- (void)setSearchSelection:(PDFSelection *)selection;
- (void)gotoSelection:(PDFSelection *)selection;
+- (PDFSelection *)getSelectionForWordAtPoint:(CGPoint)point;
- (void)copySelection;
- (void)selectAll;
@@ -100,4 +101,6 @@
- (CGRect)boundsForAnnotation:(PDFAnnotation *)annotation;
+- (void)searchInDictionaryWithSelection:(PDFSelection *)selection;
+
@end
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h (141371 => 141372)
--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h 2013-01-31 04:57:50 UTC (rev 141371)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h 2013-01-31 05:02:03 UTC (rev 141372)
@@ -105,6 +105,8 @@
PDFSelection *nextMatchForString(const String& target, BOOL searchForward, BOOL caseSensitive, BOOL wrapSearch, PDFSelection *initialSelection, BOOL startInSelection);
+ virtual bool performDictionaryLookupAtLocation(const WebCore::FloatPoint&) OVERRIDE;
+
// ScrollableArea functions.
virtual void setScrollOffset(const WebCore::IntPoint&) OVERRIDE;
virtual void invalidateScrollbarRect(WebCore::Scrollbar*, const WebCore::IntRect&) OVERRIDE;
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm (141371 => 141372)
--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm 2013-01-31 04:57:50 UTC (rev 141371)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm 2013-01-31 05:02:03 UTC (rev 141372)
@@ -939,6 +939,16 @@
return matchCount > 0;
}
+bool PDFPlugin::performDictionaryLookupAtLocation(const WebCore::FloatPoint& point)
+{
+ PDFSelection* lookupSelection = [m_pdfLayerController.get() getSelectionForWordAtPoint:convertFromPluginToPDFView(IntPoint(point))];
+
+ if ([[lookupSelection string] length])
+ [m_pdfLayerController.get() searchInDictionaryWithSelection:lookupSelection];
+
+ return true;
+}
+
} // namespace WebKit
#endif // ENABLE(PDFKIT_PLUGIN)
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.h (141371 => 141372)
--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.h 2013-01-31 04:57:50 UTC (rev 141371)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.h 2013-01-31 05:02:03 UTC (rev 141372)
@@ -178,6 +178,7 @@
virtual bool findString(const String&, WebCore::FindOptions, unsigned) OVERRIDE { return false; }
virtual bool getResourceData(const unsigned char*& bytes, unsigned& length) const OVERRIDE;
+ virtual bool performDictionaryLookupAtLocation(const WebCore::FloatPoint&) OVERRIDE { return false; }
WebCore::IntSize m_scrollOffset;
Modified: trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h (141371 => 141372)
--- trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h 2013-01-31 04:57:50 UTC (rev 141371)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Plugin.h 2013-01-31 05:02:03 UTC (rev 141372)
@@ -265,6 +265,8 @@
virtual bool getResourceData(const unsigned char*& bytes, unsigned& length) const = 0;
+ virtual bool performDictionaryLookupAtLocation(const WebCore::FloatPoint&) = 0;
+
protected:
Plugin();
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h (141371 => 141372)
--- trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h 2013-01-31 04:57:50 UTC (rev 141371)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginProxy.h 2013-01-31 05:02:03 UTC (rev 141372)
@@ -134,6 +134,7 @@
virtual WebCore::IntPoint convertToRootView(const WebCore::IntPoint&) const OVERRIDE;
virtual bool getResourceData(const unsigned char*& /* bytes */, unsigned& /* length */) const OVERRIDE { return false; }
+ virtual bool performDictionaryLookupAtLocation(const WebCore::FloatPoint&) OVERRIDE { return false; }
float contentsScaleFactor();
bool needsBackingStore() const;
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp (141371 => 141372)
--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp 2013-01-31 04:57:50 UTC (rev 141371)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.cpp 2013-01-31 05:02:03 UTC (rev 141372)
@@ -887,6 +887,14 @@
return m_plugin->getResourceData(bytes, length);
}
+bool PluginView::performDictionaryLookupAtLocation(const WebCore::FloatPoint& point)
+{
+ if (!m_isInitialized || !m_plugin)
+ return false;
+
+ return m_plugin->performDictionaryLookupAtLocation(point);
+}
+
void PluginView::notifyWidget(WidgetNotification notification)
{
switch (notification) {
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h (141371 => 141372)
--- trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h 2013-01-31 04:57:50 UTC (rev 141371)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PluginView.h 2013-01-31 05:02:03 UTC (rev 141372)
@@ -100,6 +100,7 @@
bool shouldAllowScripting();
bool getResourceData(const unsigned char*& bytes, unsigned& length) const;
+ bool performDictionaryLookupAtLocation(const WebCore::FloatPoint&);
private:
PluginView(PassRefPtr<WebCore::HTMLPlugInElement>, PassRefPtr<Plugin>, const Plugin::Parameters& parameters);
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (141371 => 141372)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2013-01-31 04:57:50 UTC (rev 141371)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2013-01-31 05:02:03 UTC (rev 141372)
@@ -52,6 +52,7 @@
#import <WebCore/NetworkingContext.h>
#import <WebCore/Page.h>
#import <WebCore/PlatformKeyboardEvent.h>
+#import <WebCore/PluginDocument.h>
#import <WebCore/ResourceHandle.h>
#import <WebCore/RenderObject.h>
#import <WebCore/RenderStyle.h>
@@ -471,6 +472,14 @@
if (!frame)
return;
+ if (frame->document()->isPluginDocument()) {
+ PluginDocument* pluginDocument = static_cast<PluginDocument*>(frame->document());
+ PluginView* pluginView = static_cast<PluginView*>(pluginDocument->pluginWidget());
+
+ if (pluginView->performDictionaryLookupAtLocation(floatPoint))
+ return;
+ }
+
// Find the frame the point is over.
IntPoint point = roundedIntPoint(floatPoint);
HitTestResult result = frame->eventHandler()->hitTestResultAtPoint(frame->view()->windowToContents(point), false);