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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 consumed:(BOOL)consumed; | 176 consumed:(BOOL)consumed; |
177 | 177 |
178 - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv; | 178 - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv; |
179 - (void)windowDidChangeBackingProperties:(NSNotification*)notification; | 179 - (void)windowDidChangeBackingProperties:(NSNotification*)notification; |
180 - (void)windowChangedGlobalFrame:(NSNotification*)notification; | 180 - (void)windowChangedGlobalFrame:(NSNotification*)notification; |
181 - (void)checkForPluginImeCancellation; | 181 - (void)checkForPluginImeCancellation; |
182 - (void)updateScreenProperties; | 182 - (void)updateScreenProperties; |
183 - (void)setResponderDelegate: | 183 - (void)setResponderDelegate: |
184 (NSObject<RenderWidgetHostViewMacDelegate>*)delegate; | 184 (NSObject<RenderWidgetHostViewMacDelegate>*)delegate; |
185 - (void)showLookUpDictionaryOverlayInternal:(NSAttributedString*) string | 185 - (void)showLookUpDictionaryOverlayInternal:(NSAttributedString*) string |
186 baselinePoint:(NSPoint) baselinePoint; | 186 baselinePoint:(NSPoint) baselinePoint |
| 187 targetView:(NSView*) view; |
187 @end | 188 @end |
188 | 189 |
189 // A window subclass that allows the fullscreen window to become main and gain | 190 // A window subclass that allows the fullscreen window to become main and gain |
190 // keyboard focus. This is only used for pepper flash. Normal fullscreen is | 191 // keyboard focus. This is only used for pepper flash. Normal fullscreen is |
191 // handled by the browser. | 192 // handled by the browser. |
192 @interface PepperFlashFullscreenWindow : UnderlayOpenGLHostingWindow | 193 @interface PepperFlashFullscreenWindow : UnderlayOpenGLHostingWindow |
193 @end | 194 @end |
194 | 195 |
195 @implementation PepperFlashFullscreenWindow | 196 @implementation PepperFlashFullscreenWindow |
196 | 197 |
(...skipping 2231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2428 - (void)smartMagnifyWithEvent:(NSEvent*)event { | 2429 - (void)smartMagnifyWithEvent:(NSEvent*)event { |
2429 const WebGestureEvent& smartMagnifyEvent = | 2430 const WebGestureEvent& smartMagnifyEvent = |
2430 WebGestureEventBuilder::Build(event, self); | 2431 WebGestureEventBuilder::Build(event, self); |
2431 if (renderWidgetHostView_ && renderWidgetHostView_->render_widget_host_) { | 2432 if (renderWidgetHostView_ && renderWidgetHostView_->render_widget_host_) { |
2432 renderWidgetHostView_->render_widget_host_->ForwardGestureEvent( | 2433 renderWidgetHostView_->render_widget_host_->ForwardGestureEvent( |
2433 smartMagnifyEvent); | 2434 smartMagnifyEvent); |
2434 } | 2435 } |
2435 } | 2436 } |
2436 | 2437 |
2437 - (void)showLookUpDictionaryOverlayInternal:(NSAttributedString*) string | 2438 - (void)showLookUpDictionaryOverlayInternal:(NSAttributedString*) string |
2438 baselinePoint:(NSPoint) baselinePoint { | 2439 baselinePoint:(NSPoint) baselinePoint |
| 2440 targetView:(NSView*) view { |
2439 if ([string length] == 0) { | 2441 if ([string length] == 0) { |
2440 // The PDF plugin does not support getting the attributed string at point. | 2442 // The PDF plugin does not support getting the attributed string at point. |
2441 // Until it does, use NSPerformService(), which opens Dictionary.app. | 2443 // Until it does, use NSPerformService(), which opens Dictionary.app. |
2442 // TODO(shuchen): Support GetStringAtPoint() & GetStringFromRange() for PDF. | 2444 // TODO(shuchen): Support GetStringAtPoint() & GetStringFromRange() for PDF. |
2443 // See crbug.com/152438. | 2445 // See crbug.com/152438. |
2444 NSString* text = base::SysUTF8ToNSString( | 2446 NSString* text = base::SysUTF8ToNSString( |
2445 renderWidgetHostView_->selected_text()); | 2447 renderWidgetHostView_->selected_text()); |
2446 if ([text length] == 0) | 2448 if ([text length] == 0) |
2447 return; | 2449 return; |
2448 NSPasteboard* pasteboard = [NSPasteboard pasteboardWithUniqueName]; | 2450 NSPasteboard* pasteboard = [NSPasteboard pasteboardWithUniqueName]; |
2449 NSArray* types = [NSArray arrayWithObject:NSStringPboardType]; | 2451 NSArray* types = [NSArray arrayWithObject:NSStringPboardType]; |
2450 [pasteboard declareTypes:types owner:nil]; | 2452 [pasteboard declareTypes:types owner:nil]; |
2451 if ([pasteboard setString:text forType:NSStringPboardType]) | 2453 if ([pasteboard setString:text forType:NSStringPboardType]) |
2452 NSPerformService(@"Look Up in Dictionary", pasteboard); | 2454 NSPerformService(@"Look Up in Dictionary", pasteboard); |
2453 return; | 2455 return; |
2454 } | 2456 } |
2455 dispatch_async(dispatch_get_main_queue(), ^{ | 2457 dispatch_async(dispatch_get_main_queue(), ^{ |
2456 [self showDefinitionForAttributedString:string | 2458 [view showDefinitionForAttributedString:string |
2457 atPoint:baselinePoint]; | 2459 atPoint:baselinePoint]; |
2458 }); | 2460 }); |
2459 } | 2461 } |
2460 | 2462 |
2461 - (void)showLookUpDictionaryOverlayFromRange:(NSRange)range { | 2463 - (void)showLookUpDictionaryOverlayFromRange:(NSRange)range |
| 2464 targetView:(NSView*)targetView { |
2462 TextInputClientMac::GetInstance()->GetStringFromRange( | 2465 TextInputClientMac::GetInstance()->GetStringFromRange( |
2463 renderWidgetHostView_->render_widget_host_, range, | 2466 renderWidgetHostView_->render_widget_host_, range, |
2464 ^(NSAttributedString* string, NSPoint baselinePoint) { | 2467 ^(NSAttributedString* string, NSPoint baselinePoint) { |
2465 [self showLookUpDictionaryOverlayInternal:string | 2468 [self showLookUpDictionaryOverlayInternal:string |
2466 baselinePoint:baselinePoint]; | 2469 baselinePoint:baselinePoint |
| 2470 targetView:targetView]; |
2467 } | 2471 } |
2468 ); | 2472 ); |
2469 } | 2473 } |
2470 | 2474 |
2471 - (void)showLookUpDictionaryOverlayAtPoint:(NSPoint)point { | 2475 - (void)showLookUpDictionaryOverlayAtPoint:(NSPoint)point { |
2472 TextInputClientMac::GetInstance()->GetStringAtPoint( | 2476 TextInputClientMac::GetInstance()->GetStringAtPoint( |
2473 renderWidgetHostView_->render_widget_host_, | 2477 renderWidgetHostView_->render_widget_host_, |
2474 gfx::Point(point.x, NSHeight([self frame]) - point.y), | 2478 gfx::Point(point.x, NSHeight([self frame]) - point.y), |
2475 ^(NSAttributedString* string, NSPoint baselinePoint) { | 2479 ^(NSAttributedString* string, NSPoint baselinePoint) { |
2476 [self showLookUpDictionaryOverlayInternal:string | 2480 [self showLookUpDictionaryOverlayInternal:string |
2477 baselinePoint:baselinePoint]; | 2481 baselinePoint:baselinePoint |
| 2482 targetView:self]; |
2478 } | 2483 } |
2479 ); | 2484 ); |
2480 } | 2485 } |
2481 | 2486 |
2482 // This is invoked only on 10.8 or newer when the user taps a word using | 2487 // This is invoked only on 10.8 or newer when the user taps a word using |
2483 // three fingers. | 2488 // three fingers. |
2484 - (void)quickLookWithEvent:(NSEvent*)event { | 2489 - (void)quickLookWithEvent:(NSEvent*)event { |
2485 NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil]; | 2490 NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil]; |
2486 [self showLookUpDictionaryOverlayAtPoint:point]; | 2491 [self showLookUpDictionaryOverlayAtPoint:point]; |
2487 } | 2492 } |
(...skipping 992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3480 | 3485 |
3481 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3486 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3482 // regions that are not draggable. (See ControlRegionView in | 3487 // regions that are not draggable. (See ControlRegionView in |
3483 // native_app_window_cocoa.mm). This requires the render host view to be | 3488 // native_app_window_cocoa.mm). This requires the render host view to be |
3484 // draggable by default. | 3489 // draggable by default. |
3485 - (BOOL)mouseDownCanMoveWindow { | 3490 - (BOOL)mouseDownCanMoveWindow { |
3486 return YES; | 3491 return YES; |
3487 } | 3492 } |
3488 | 3493 |
3489 @end | 3494 @end |
OLD | NEW |