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

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 4 years, 11 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 8a8f916907801f341d3845be99036eadd8ab5d66..d2bb8a58eaeda00c1ee9cbf69e6af6f0fb9cbd1a 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"
@@ -106,6 +107,7 @@ using blink::WebInputEvent;
using blink::WebMouseEvent;
using blink::WebMouseWheelEvent;
using blink::WebGestureEvent;
+using blink::WebPoint;
namespace {
@@ -2308,6 +2310,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];
+ WebPoint point(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_SelectWordIfAnyAt(
+ rwh->GetRoutingID(), point)));
+}
+
- (void)shortCircuitScrollWheelEvent:(NSEvent*)event {
DCHECK(base::mac::IsOSLionOrLater());

Powered by Google App Engine
This is Rietveld 408576698