Chromium Code Reviews| 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 8afc7be80441585c875a36aa6c6424e60a2a43c2..ee7f187e9383239858d445393e5b878bc7df5989 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_mac.mm |
| +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm |
| @@ -2340,14 +2340,33 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged( |
| - (void)showLookUpDictionaryOverlayFromRange:(NSRange)range |
| targetView:(NSView*)targetView { |
| + RenderWidgetHostImpl* widgetHost = renderWidgetHostView_->render_widget_host_; |
| + if (!widgetHost || !widgetHost->delegate()) |
| + return; |
| + widgetHost = widgetHost->delegate()->GetFocusedRenderWidgetHost(widgetHost); |
| + |
| + if (!widgetHost) |
| + return; |
|
Charlie Reis
2016/10/07 19:07:21
nit: Add blank line after.
EhsanK
2016/10/11 19:31:56
Done.
|
| + // TODO(ekaramad): The position reported by the renderer is with respect to |
| + // |widgetHost|'s coordinate space with y-axis inverted to conform to AppKit |
| + // coordinate system. The point will need to be transformed into root view's |
| + // coordinate system (RenderWidgetHostViewMac in this case). However, since |
| + // the callback is invoked on IO thread it will require some thread hopping to |
| + // do so. For this reason, for now, we accept this non-ideal way of fixing the |
| + // point offset manually from the view bounds. This should be revisited when |
| + // fixing issues in TextInputClientMac (https://crbug.com/643233). |
| + gfx::Rect root_box = renderWidgetHostView_->GetViewBounds(); |
| + gfx::Rect view_box = widgetHost->GetView()->GetViewBounds(); |
| + |
| TextInputClientMac::GetInstance()->GetStringFromRange( |
| - renderWidgetHostView_->render_widget_host_, range, |
| - ^(NSAttributedString* string, NSPoint baselinePoint) { |
| + widgetHost, range, ^(NSAttributedString* string, NSPoint baselinePoint) { |
| + baselinePoint.x += view_box.origin().x() - root_box.origin().x(); |
| + baselinePoint.y += |
| + root_box.bottom_left().y() - view_box.bottom_left().y(); |
| [self showLookUpDictionaryOverlayInternal:string |
| baselinePoint:baselinePoint |
| targetView:targetView]; |
| - } |
| - ); |
| + }); |
| } |
| - (void)showLookUpDictionaryOverlayAtPoint:(NSPoint)point { |