Title: [136260] trunk/Source/WebKit2
- Revision
- 136260
- Author
- [email protected]
- Date
- 2012-11-30 12:49:09 -0800 (Fri, 30 Nov 2012)
Log Message
PDFPlugin: "Show Definition" context menu item should be implemented
https://bugs.webkit.org/show_bug.cgi?id=103389
<rdar://problem/12710751>
Reviewed by Dan Bernstein.
Call existing dictionary popup code when the context menu "Show Definition" item is selected.
* WebProcess/Plugins/PDF/PDFPlugin.h:
(PDFPlugin): Add showDefinitionForAttributedString and convertFromPDFViewToRootView.
* WebProcess/Plugins/PDF/PDFPlugin.mm:
(-[WKPDFLayerControllerDelegate showDefinitionForAttributedString:atPoint:]): Forward this call to PDFPlugin.
(WebKit::PDFPlugin::showDefinitionForAttributedString): Create a DictionaryPopupInfo with the necessary information.
Ask WebPageProxy to show the dictionary popup.
(WebKit::PDFPlugin::convertFromPDFViewToRootView): Convert a point from PDFLayerController space to the root view space.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (136259 => 136260)
--- trunk/Source/WebKit2/ChangeLog 2012-11-30 20:39:08 UTC (rev 136259)
+++ trunk/Source/WebKit2/ChangeLog 2012-11-30 20:49:09 UTC (rev 136260)
@@ -1,3 +1,21 @@
+2012-11-30 Tim Horton <[email protected]>
+
+ PDFPlugin: "Show Definition" context menu item should be implemented
+ https://bugs.webkit.org/show_bug.cgi?id=103389
+ <rdar://problem/12710751>
+
+ Reviewed by Dan Bernstein.
+
+ Call existing dictionary popup code when the context menu "Show Definition" item is selected.
+
+ * WebProcess/Plugins/PDF/PDFPlugin.h:
+ (PDFPlugin): Add showDefinitionForAttributedString and convertFromPDFViewToRootView.
+ * WebProcess/Plugins/PDF/PDFPlugin.mm:
+ (-[WKPDFLayerControllerDelegate showDefinitionForAttributedString:atPoint:]): Forward this call to PDFPlugin.
+ (WebKit::PDFPlugin::showDefinitionForAttributedString): Create a DictionaryPopupInfo with the necessary information.
+ Ask WebPageProxy to show the dictionary popup.
+ (WebKit::PDFPlugin::convertFromPDFViewToRootView): Convert a point from PDFLayerController space to the root view space.
+
2012-11-30 Simon Hausmann <[email protected]>
Unreviewed trivial Qt build fix:
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h (136259 => 136260)
--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h 2012-11-30 20:39:08 UTC (rev 136259)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.h 2012-11-30 20:49:09 UTC (rev 136260)
@@ -68,6 +68,7 @@
void clickedLink(NSURL *);
void saveToPDF();
void writeItemsToPasteboard(NSArray *items, NSArray *types);
+ void showDefinitionForAttributedString(NSAttributedString *, CGPoint);
private:
explicit PDFPlugin(WebFrame*);
@@ -105,6 +106,8 @@
void updatePageAndDeviceScaleFactors();
+ WebCore::IntPoint convertFromPDFViewToRootView(const WebCore::IntPoint&) const;
+
RetainPtr<CALayer> m_containerLayer;
RetainPtr<CALayer> m_contentLayer;
RetainPtr<CALayer> m_horizontalScrollbarLayer;
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm (136259 => 136260)
--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm 2012-11-30 20:39:08 UTC (rev 136259)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/PDFPlugin.mm 2012-11-30 20:49:09 UTC (rev 136260)
@@ -29,7 +29,9 @@
#import "PDFPlugin.h"
#import "ArgumentCoders.h"
+#import "AttributedString.h"
#import "DataReference.h"
+#import "DictionaryPopupInfo.h"
#import "PDFAnnotationTextWidgetDetails.h"
#import "PDFKitImports.h"
#import "PDFLayerControllerDetails.h"
@@ -161,7 +163,7 @@
- (void)showDefinitionForAttributedString:(NSAttributedString *)string atPoint:(CGPoint)point
{
- // FIXME: Implement.
+ _pdfPlugin->showDefinitionForAttributedString(string, point);
}
- (void)performWebSearch:(NSString *)string
@@ -797,6 +799,24 @@
}
+IntPoint PDFPlugin::convertFromPDFViewToRootView(const IntPoint& point) const
+{
+ IntPoint pointInPluginCoordinates(point.x(), size().height() - point.y());
+ return m_rootViewToPluginTransform.inverse().mapPoint(pointInPluginCoordinates);
+}
+
+void PDFPlugin::showDefinitionForAttributedString(NSAttributedString *string, CGPoint point)
+{
+ DictionaryPopupInfo dictionaryPopupInfo;
+ dictionaryPopupInfo.type = DictionaryPopupInfo::ContextMenu;
+ dictionaryPopupInfo.origin = convertFromPDFViewToRootView(IntPoint(point));
+
+ AttributedString attributedString;
+ attributedString.string = string;
+
+ webFrame()->page()->send(Messages::WebPageProxy::DidPerformDictionaryLookup(attributedString, dictionaryPopupInfo));
+}
+
} // namespace WebKit
#endif // ENABLE(PDFKIT_PLUGIN)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes