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 fa22008815a79b8747088da8dfaeb84b2c7bd229..43458dd6ce7e78419a23b5f7dfcb221b1b48cc5e 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_mac.mm |
| +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm |
| @@ -2357,14 +2357,34 @@ 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; |
| + |
| + // 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(); |
|
EhsanK
2016/09/29 18:20:35
The logic is almost identical to showLookupDiction
Charlie Reis
2016/09/30 23:00:55
Will we be able to resolve these TODOs soon? I'm
EhsanK
2016/10/06 19:36:09
This one unfortunately might need a major reworkin
|
| + 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 { |