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 ecfcc9ca472deff504ac837d80ceea708b2370b3..33be14ca4c27111530d78c9a49a893de5245ead9 100644 |
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm |
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm |
@@ -60,6 +60,7 @@ |
#include "content/public/browser/browser_plugin_guest_manager.h" |
#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/native_web_keyboard_event.h" |
+#include "content/public/browser/render_widget_host.h" |
#include "content/public/browser/render_widget_host_view_frame_subscriber.h" |
#import "content/public/browser/render_widget_host_view_mac_delegate.h" |
#include "content/public/browser/web_contents.h" |
@@ -96,6 +97,7 @@ using content::NativeWebKeyboardEvent; |
using content::RenderFrameHost; |
using content::RenderViewHost; |
using content::RenderViewHostImpl; |
+using content::RenderWidgetHost; |
using content::RenderWidgetHostImpl; |
using content::RenderWidgetHostViewMac; |
using content::RenderWidgetHostViewMacEditCommandHelper; |
@@ -553,6 +555,20 @@ RenderWidgetHostImpl* RenderWidgetHostViewMac::GetActiveWidget() { |
: nullptr; |
} |
+RenderWidgetHost* RenderWidgetHostViewMac::GetRenderWidgetHostAtPoint( |
Charlie Reis
2016/08/31 22:50:03
Why not RenderWidgetHostImpl, as above? We're wit
EhsanK
2016/09/01 21:58:36
I guess I just put what I needed. But I agree with
|
+ const gfx::Point& point, |
+ gfx::Point* transformed_point) { |
+ if (!render_widget_host_) |
+ return nullptr; |
+ |
+ if (!render_widget_host_->delegate() || |
+ !render_widget_host_->delegate()->GetInputEventRouter()) |
+ return render_widget_host_; |
+ |
+ return render_widget_host_->delegate() |
+ ->GetInputEventRouter() |
+ ->GetRenderWidgetHostAtPos(this, point, transformed_point); |
+} |
/////////////////////////////////////////////////////////////////////////////// |
// RenderWidgetHostViewMac, RenderWidgetHostView implementation: |
@@ -2282,15 +2298,26 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged( |
} |
- (void)showLookUpDictionaryOverlayAtPoint:(NSPoint)point { |
+ gfx::Point rootPoint(point.x, NSHeight([self frame]) - point.y); |
+ gfx::Point transformedPoint; |
+ RenderWidgetHost* widgetHost = |
+ renderWidgetHostView_->GetRenderWidgetHostAtPoint(rootPoint, |
+ &transformedPoint); |
+ if (!widgetHost) |
+ return; |
+ |
+ gfx::Rect root_box = renderWidgetHostView_->GetViewBounds(); |
+ gfx::Rect view_box = widgetHost->GetView()->GetViewBounds(); |
TextInputClientMac::GetInstance()->GetStringAtPoint( |
erikchen
2016/09/01 00:04:29
It looks like if this method is called twice in qu
EhsanK
2016/09/01 21:58:37
We actually fire a DCHECK in that scenario. I adde
|
- renderWidgetHostView_->render_widget_host_, |
- gfx::Point(point.x, NSHeight([self frame]) - point.y), |
+ widgetHost, transformedPoint, |
^(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 |
erikchen
2016/09/01 00:04:28
Is it ever possible for this callback to not be in
EhsanK
2016/09/01 21:58:36
Yes it is - as far as I can tell - possible to hav
erikchen
2016/09/02 01:10:39
That would be good. Doesn't have to be in this CL,
|
baselinePoint:baselinePoint |
targetView:self]; |
- } |
- ); |
+ }); |
} |
// This is invoked only on 10.8 or newer when the user taps a word using |
@@ -2806,10 +2833,13 @@ extern NSString *NSTextInputReplacementRangeAttributeName; |
thePoint = [self convertPoint:thePoint fromView:nil]; |
thePoint.y = NSHeight([self frame]) - thePoint.y; |
+ gfx::Point transformedPoint; |
+ RenderWidgetHost* widgetHost = |
+ renderWidgetHostView_->GetRenderWidgetHostAtPoint( |
+ gfx::Point(thePoint.x, thePoint.y), &transformedPoint); |
erikchen
2016/09/01 00:04:29
Doesn't this need a nullptr check?
EhsanK
2016/09/01 21:58:36
There is two cases that we might dereference a nul
erikchen
2016/09/02 01:10:39
Thanks for looking into this. With regards to NSTe
|
NSUInteger index = |
TextInputClientMac::GetInstance()->GetCharacterIndexAtPoint( |
- renderWidgetHostView_->render_widget_host_, |
- gfx::Point(thePoint.x, thePoint.y)); |
+ widgetHost, transformedPoint); |
return index; |
} |