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

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

Issue 1528153004: Look Up on Force Touch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 29fd891e02b785c3c46e54767a046514fef71dd5..ed80519ad0c68b0f2e573ab52b8c98daf027c228 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
@@ -40,6 +40,7 @@
#include "content/browser/frame_host/frame_tree_node.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/browser/gpu/compositor_util.h"
+#include "content/browser/renderer_host/input/input_router.h"
#include "content/browser/renderer_host/input/web_input_event_builders_mac.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/renderer_host/render_widget_helper.h"
@@ -2328,6 +2329,22 @@ void RenderWidgetHostViewMac::OnDisplayMetricsChanged(
[NSCursor setHiddenUntilMouseMoves:YES];
}
+- (void)forceTouchEvent:(NSEvent*)theEvent {
+ // Convert the event point into coordinates in the a web content.
+ NSPoint locationInView =
+ [self convertPoint:[theEvent locationInWindow] fromView:nil];
+ NSPoint webContentPoint = NSMakePoint(
+ locationInView.x, [self frame].size.height - locationInView.y);
+
+ // Sends an input to the renderer to select the word at the event's
+ // coordinates. A response from the renderer for this event will cause the
+ // browser to look up the selected word.
+ RenderWidgetHostImpl* rwh = renderWidgetHostView_->render_widget_host_;
+ rwh->input_router()->SendInput(
+ scoped_ptr<IPC::Message>(new InputMsg_SelectWordIfAnyAtCoordinates(
+ rwh->GetRoutingID(), webContentPoint.x, webContentPoint.y)));
+}
+
- (void)shortCircuitScrollWheelEvent:(NSEvent*)event {
DCHECK(base::mac::IsOSLionOrLater());

Powered by Google App Engine
This is Rietveld 408576698