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