Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1364)

Unified Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 1318483007: Implement "Look Up In Dictionary" context menu item asynchronously. (OS X) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_view_mac.mm
diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
index 1062eaf41577c2f222388e4af621eddb2df9a6e3..b50ed94219078e339960ae4d036c579c22065b3d 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -2429,10 +2429,23 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
}
}
-// This is invoked only on 10.8 or newer when the user taps a word using
-// three fingers.
-- (void)quickLookWithEvent:(NSEvent*)event {
- NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil];
+- (void)showLookUpDictionaryOverlayFromRange:(NSRange)range {
+ TextInputClientMac::GetInstance()->GetStringFromRange(
+ renderWidgetHostView_->render_widget_host_, range,
+ ^(NSAttributedString* string, NSPoint baselinePoint) {
+ if (string && [string length] > 0) {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ [self showDefinitionForAttributedString:string
+ atPoint:baselinePoint];
+ });
+ }
+ }
+ );
+}
+
+- (void)showLookUpDictionaryOverlayAtPoint:(NSPoint)point {
+ // The PDF plugin does not support getting the attributed string at point.
+ // TODO: support GetStringAtPoint() for PDF. See crbug.com/152438.
palmer 2015/09/09 23:24:17 Why don't you include the old code that launches D
Shu Chen 2015/09/10 01:26:03 Sorry, that was accidentally removed. And thanks f
TextInputClientMac::GetInstance()->GetStringAtPoint(
renderWidgetHostView_->render_widget_host_,
gfx::Point(point.x, NSHeight([self frame]) - point.y),
@@ -2447,6 +2460,13 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
);
}
+// This is invoked only on 10.8 or newer when the user taps a word using
+// three fingers.
+- (void)quickLookWithEvent:(NSEvent*)event {
+ NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil];
+ [self showLookUpDictionaryOverlayAtPoint:point];
+}
+
// This method handles 2 different types of hardware events.
// (Apple does not distinguish between them).
// a. Scrolling the middle wheel of a mouse.

Powered by Google App Engine
This is Rietveld 408576698