| 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 2536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2547 return NO; | 2547 return NO; |
| 2548 | 2548 |
| 2549 return canBeKeyView_; | 2549 return canBeKeyView_; |
| 2550 } | 2550 } |
| 2551 | 2551 |
| 2552 - (BOOL)becomeFirstResponder { | 2552 - (BOOL)becomeFirstResponder { |
| 2553 if (!renderWidgetHostView_->render_widget_host_) | 2553 if (!renderWidgetHostView_->render_widget_host_) |
| 2554 return NO; | 2554 return NO; |
| 2555 | 2555 |
| 2556 renderWidgetHostView_->render_widget_host_->Focus(); | 2556 renderWidgetHostView_->render_widget_host_->Focus(); |
| 2557 renderWidgetHostView_->render_widget_host_->SetInputMethodActive(true); | |
| 2558 renderWidgetHostView_->SetTextInputActive(true); | 2557 renderWidgetHostView_->SetTextInputActive(true); |
| 2559 | 2558 |
| 2560 // Cancel any onging composition text which was left before we lost focus. | 2559 // Cancel any onging composition text which was left before we lost focus. |
| 2561 // TODO(suzhe): We should do it in -resignFirstResponder: method, but | 2560 // TODO(suzhe): We should do it in -resignFirstResponder: method, but |
| 2562 // somehow that method won't be called when switching among different tabs. | 2561 // somehow that method won't be called when switching among different tabs. |
| 2563 // See http://crbug.com/47209 | 2562 // See http://crbug.com/47209 |
| 2564 [self cancelComposition]; | 2563 [self cancelComposition]; |
| 2565 | 2564 |
| 2566 NSNumber* direction = [NSNumber numberWithUnsignedInteger: | 2565 NSNumber* direction = [NSNumber numberWithUnsignedInteger: |
| 2567 [[self window] keyViewSelectionDirection]]; | 2566 [[self window] keyViewSelectionDirection]]; |
| 2568 NSDictionary* userInfo = | 2567 NSDictionary* userInfo = |
| 2569 [NSDictionary dictionaryWithObject:direction | 2568 [NSDictionary dictionaryWithObject:direction |
| 2570 forKey:kSelectionDirection]; | 2569 forKey:kSelectionDirection]; |
| 2571 [[NSNotificationCenter defaultCenter] | 2570 [[NSNotificationCenter defaultCenter] |
| 2572 postNotificationName:kViewDidBecomeFirstResponder | 2571 postNotificationName:kViewDidBecomeFirstResponder |
| 2573 object:self | 2572 object:self |
| 2574 userInfo:userInfo]; | 2573 userInfo:userInfo]; |
| 2575 | 2574 |
| 2576 return YES; | 2575 return YES; |
| 2577 } | 2576 } |
| 2578 | 2577 |
| 2579 - (BOOL)resignFirstResponder { | 2578 - (BOOL)resignFirstResponder { |
| 2580 renderWidgetHostView_->SetTextInputActive(false); | 2579 renderWidgetHostView_->SetTextInputActive(false); |
| 2581 if (!renderWidgetHostView_->render_widget_host_) | 2580 if (!renderWidgetHostView_->render_widget_host_) |
| 2582 return YES; | 2581 return YES; |
| 2583 | 2582 |
| 2584 if (closeOnDeactivate_) | 2583 if (closeOnDeactivate_) |
| 2585 renderWidgetHostView_->KillSelf(); | 2584 renderWidgetHostView_->KillSelf(); |
| 2586 | 2585 |
| 2587 renderWidgetHostView_->render_widget_host_->SetInputMethodActive(false); | |
| 2588 renderWidgetHostView_->render_widget_host_->Blur(); | 2586 renderWidgetHostView_->render_widget_host_->Blur(); |
| 2589 | 2587 |
| 2590 // We should cancel any onging composition whenever RWH's Blur() method gets | 2588 // We should cancel any onging composition whenever RWH's Blur() method gets |
| 2591 // called, because in this case, webkit will confirm the ongoing composition | 2589 // called, because in this case, webkit will confirm the ongoing composition |
| 2592 // internally. | 2590 // internally. |
| 2593 [self cancelComposition]; | 2591 [self cancelComposition]; |
| 2594 | 2592 |
| 2595 return YES; | 2593 return YES; |
| 2596 } | 2594 } |
| 2597 | 2595 |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3304 | 3302 |
| 3305 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3303 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3306 // regions that are not draggable. (See ControlRegionView in | 3304 // regions that are not draggable. (See ControlRegionView in |
| 3307 // native_app_window_cocoa.mm). This requires the render host view to be | 3305 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3308 // draggable by default. | 3306 // draggable by default. |
| 3309 - (BOOL)mouseDownCanMoveWindow { | 3307 - (BOOL)mouseDownCanMoveWindow { |
| 3310 return YES; | 3308 return YES; |
| 3311 } | 3309 } |
| 3312 | 3310 |
| 3313 @end | 3311 @end |
| OLD | NEW |