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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 1318483007: Implement "Look Up In Dictionary" context menu item asynchronously. (OS X) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 #include <OpenGL/gl.h> 8 #include <OpenGL/gl.h>
9 #include <QuartzCore/QuartzCore.h> 9 #include <QuartzCore/QuartzCore.h>
10 10
(...skipping 2411 matching lines...) Expand 10 before | Expand all | Expand 10 after
2422 2422
2423 - (void)smartMagnifyWithEvent:(NSEvent*)event { 2423 - (void)smartMagnifyWithEvent:(NSEvent*)event {
2424 const WebGestureEvent& smartMagnifyEvent = 2424 const WebGestureEvent& smartMagnifyEvent =
2425 WebInputEventFactory::gestureEvent(event, self); 2425 WebInputEventFactory::gestureEvent(event, self);
2426 if (renderWidgetHostView_ && renderWidgetHostView_->render_widget_host_) { 2426 if (renderWidgetHostView_ && renderWidgetHostView_->render_widget_host_) {
2427 renderWidgetHostView_->render_widget_host_->ForwardGestureEvent( 2427 renderWidgetHostView_->render_widget_host_->ForwardGestureEvent(
2428 smartMagnifyEvent); 2428 smartMagnifyEvent);
2429 } 2429 }
2430 } 2430 }
2431 2431
2432 // This is invoked only on 10.8 or newer when the user taps a word using 2432 - (void)showLookUpDictionaryOverlayFromRange:(NSRange)range {
2433 // three fingers. 2433 TextInputClientMac::GetInstance()->GetStringFromRange(
2434 - (void)quickLookWithEvent:(NSEvent*)event { 2434 renderWidgetHostView_->render_widget_host_, range,
2435 NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil]; 2435 ^(NSAttributedString* string, NSPoint baselinePoint) {
2436 if (string && [string length] > 0) {
2437 dispatch_async(dispatch_get_main_queue(), ^{
2438 [self showDefinitionForAttributedString:string
2439 atPoint:baselinePoint];
2440 });
2441 }
2442 }
2443 );
2444 }
2445
2446 - (void)showLookUpDictionaryOverlayAtPoint:(NSPoint)point {
2447 // The PDF plugin does not support getting the attributed string at point.
2448 // TODO: support GetStringAtPoint() for PDF. See crbug.com/152438.
palmer 2015/09/09 23:24:17 Why don't you include the old code that launches D
Shu Chen 2015/09/10 01:26:03 Sorry, that was accidentally removed. And thanks f
2436 TextInputClientMac::GetInstance()->GetStringAtPoint( 2449 TextInputClientMac::GetInstance()->GetStringAtPoint(
2437 renderWidgetHostView_->render_widget_host_, 2450 renderWidgetHostView_->render_widget_host_,
2438 gfx::Point(point.x, NSHeight([self frame]) - point.y), 2451 gfx::Point(point.x, NSHeight([self frame]) - point.y),
2439 ^(NSAttributedString* string, NSPoint baselinePoint) { 2452 ^(NSAttributedString* string, NSPoint baselinePoint) {
2440 if (string && [string length] > 0) { 2453 if (string && [string length] > 0) {
2441 dispatch_async(dispatch_get_main_queue(), ^{ 2454 dispatch_async(dispatch_get_main_queue(), ^{
2442 [self showDefinitionForAttributedString:string 2455 [self showDefinitionForAttributedString:string
2443 atPoint:baselinePoint]; 2456 atPoint:baselinePoint];
2444 }); 2457 });
2445 } 2458 }
2446 } 2459 }
2447 ); 2460 );
2448 } 2461 }
2449 2462
2463 // This is invoked only on 10.8 or newer when the user taps a word using
2464 // three fingers.
2465 - (void)quickLookWithEvent:(NSEvent*)event {
2466 NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil];
2467 [self showLookUpDictionaryOverlayAtPoint:point];
2468 }
2469
2450 // This method handles 2 different types of hardware events. 2470 // This method handles 2 different types of hardware events.
2451 // (Apple does not distinguish between them). 2471 // (Apple does not distinguish between them).
2452 // a. Scrolling the middle wheel of a mouse. 2472 // a. Scrolling the middle wheel of a mouse.
2453 // b. Swiping on the track pad. 2473 // b. Swiping on the track pad.
2454 // 2474 //
2455 // This method is responsible for 2 types of behavior: 2475 // This method is responsible for 2 types of behavior:
2456 // a. Scrolling the content of window. 2476 // a. Scrolling the content of window.
2457 // b. Navigating forwards/backwards in history. 2477 // b. Navigating forwards/backwards in history.
2458 // 2478 //
2459 // This is a brief description of the logic: 2479 // This is a brief description of the logic:
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
3405 3425
3406 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3426 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3407 // regions that are not draggable. (See ControlRegionView in 3427 // regions that are not draggable. (See ControlRegionView in
3408 // native_app_window_cocoa.mm). This requires the render host view to be 3428 // native_app_window_cocoa.mm). This requires the render host view to be
3409 // draggable by default. 3429 // draggable by default.
3410 - (BOOL)mouseDownCanMoveWindow { 3430 - (BOOL)mouseDownCanMoveWindow {
3411 return YES; 3431 return YES;
3412 } 3432 }
3413 3433
3414 @end 3434 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698