OLD | NEW |
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 2337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2348 | 2348 |
2349 - (void)smartMagnifyWithEvent:(NSEvent*)event { | 2349 - (void)smartMagnifyWithEvent:(NSEvent*)event { |
2350 const WebGestureEvent& smartMagnifyEvent = | 2350 const WebGestureEvent& smartMagnifyEvent = |
2351 WebInputEventFactory::gestureEvent(event, self); | 2351 WebInputEventFactory::gestureEvent(event, self); |
2352 if (renderWidgetHostView_ && renderWidgetHostView_->render_widget_host_) { | 2352 if (renderWidgetHostView_ && renderWidgetHostView_->render_widget_host_) { |
2353 renderWidgetHostView_->render_widget_host_->ForwardGestureEvent( | 2353 renderWidgetHostView_->render_widget_host_->ForwardGestureEvent( |
2354 smartMagnifyEvent); | 2354 smartMagnifyEvent); |
2355 } | 2355 } |
2356 } | 2356 } |
2357 | 2357 |
2358 // This is invoked only on 10.8 or newer when the user taps a word using | 2358 - (void)showLookUpDictionaryOverlayAtPoint:(NSPoint)point { |
2359 // three fingers. | 2359 // The PDF plugin does not support getting the attributed string at point. |
2360 - (void)quickLookWithEvent:(NSEvent*)event { | 2360 // TODO: support GetStringAtPoint() for PDF. See crbug.com/152438. |
2361 NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil]; | |
2362 TextInputClientMac::GetInstance()->GetStringAtPoint( | 2361 TextInputClientMac::GetInstance()->GetStringAtPoint( |
2363 renderWidgetHostView_->render_widget_host_, | 2362 renderWidgetHostView_->render_widget_host_, |
2364 gfx::Point(point.x, NSHeight([self frame]) - point.y), | 2363 gfx::Point(point.x, NSHeight([self frame]) - point.y), |
2365 ^(NSAttributedString* string, NSPoint baselinePoint) { | 2364 ^(NSAttributedString* string, NSPoint baselinePoint) { |
2366 if (string && [string length] > 0) { | 2365 if (string && [string length] > 0) { |
2367 dispatch_async(dispatch_get_main_queue(), ^{ | 2366 dispatch_async(dispatch_get_main_queue(), ^{ |
2368 [self showDefinitionForAttributedString:string | 2367 [self showDefinitionForAttributedString:string |
2369 atPoint:baselinePoint]; | 2368 atPoint:baselinePoint]; |
2370 }); | 2369 }); |
2371 } | 2370 } |
2372 } | 2371 } |
2373 ); | 2372 ); |
2374 } | 2373 } |
2375 | 2374 |
| 2375 // This is invoked only on 10.8 or newer when the user taps a word using |
| 2376 // three fingers. |
| 2377 - (void)quickLookWithEvent:(NSEvent*)event { |
| 2378 NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil]; |
| 2379 [self showLookUpDictionaryOverlayAtPoint:point]; |
| 2380 } |
| 2381 |
2376 // This method handles 2 different types of hardware events. | 2382 // This method handles 2 different types of hardware events. |
2377 // (Apple does not distinguish between them). | 2383 // (Apple does not distinguish between them). |
2378 // a. Scrolling the middle wheel of a mouse. | 2384 // a. Scrolling the middle wheel of a mouse. |
2379 // b. Swiping on the track pad. | 2385 // b. Swiping on the track pad. |
2380 // | 2386 // |
2381 // This method is responsible for 2 types of behavior: | 2387 // This method is responsible for 2 types of behavior: |
2382 // a. Scrolling the content of window. | 2388 // a. Scrolling the content of window. |
2383 // b. Navigating forwards/backwards in history. | 2389 // b. Navigating forwards/backwards in history. |
2384 // | 2390 // |
2385 // This is a brief description of the logic: | 2391 // This is a brief description of the logic: |
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3323 | 3329 |
3324 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3330 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3325 // regions that are not draggable. (See ControlRegionView in | 3331 // regions that are not draggable. (See ControlRegionView in |
3326 // native_app_window_cocoa.mm). This requires the render host view to be | 3332 // native_app_window_cocoa.mm). This requires the render host view to be |
3327 // draggable by default. | 3333 // draggable by default. |
3328 - (BOOL)mouseDownCanMoveWindow { | 3334 - (BOOL)mouseDownCanMoveWindow { |
3329 return YES; | 3335 return YES; |
3330 } | 3336 } |
3331 | 3337 |
3332 @end | 3338 @end |
OLD | NEW |