Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import "ui/views/cocoa/bridged_content_view.h" | 5 #import "ui/views/cocoa/bridged_content_view.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "base/mac/mac_util.h" | 8 #import "base/mac/mac_util.h" |
| 9 #import "base/mac/scoped_nsobject.h" | 9 #import "base/mac/scoped_nsobject.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 400 | 400 |
| 401 hostedView_->GetWidget()->OnMouseEvent(&event); | 401 hostedView_->GetWidget()->OnMouseEvent(&event); |
| 402 } | 402 } |
| 403 | 403 |
| 404 // NSView implementation. | 404 // NSView implementation. |
| 405 | 405 |
| 406 - (BOOL)acceptsFirstResponder { | 406 - (BOOL)acceptsFirstResponder { |
| 407 return YES; | 407 return YES; |
| 408 } | 408 } |
| 409 | 409 |
| 410 - (BOOL)becomeFirstResponder { | |
| 411 BOOL result = [super becomeFirstResponder]; | |
| 412 if (result) { | |
|
tapted
2016/03/04 00:56:19
We need to check for |hostedView_| being null sinc
kirr
2016/03/04 08:31:30
Done. Thanks.
| |
| 413 views::Widget* widget = hostedView_->GetWidget(); | |
| 414 widget->GetFocusManager()->RestoreFocusedView(); | |
| 415 } | |
| 416 return result; | |
| 417 } | |
| 418 | |
| 419 - (BOOL)resignFirstResponder { | |
| 420 BOOL result = [super resignFirstResponder]; | |
| 421 if (result) { | |
| 422 views::Widget* widget = hostedView_->GetWidget(); | |
| 423 widget->GetFocusManager()->StoreFocusedView(true); | |
| 424 } | |
| 425 return result; | |
| 426 } | |
| 427 | |
| 410 - (void)viewDidMoveToWindow { | 428 - (void)viewDidMoveToWindow { |
| 411 // When this view is added to a window, AppKit calls setFrameSize before it is | 429 // When this view is added to a window, AppKit calls setFrameSize before it is |
| 412 // added to the window, so the behavior in setFrameSize is not triggered. | 430 // added to the window, so the behavior in setFrameSize is not triggered. |
| 413 NSWindow* window = [self window]; | 431 NSWindow* window = [self window]; |
| 414 if (window) | 432 if (window) |
| 415 [self setFrameSize:NSZeroSize]; | 433 [self setFrameSize:NSZeroSize]; |
| 416 } | 434 } |
| 417 | 435 |
| 418 - (void)setFrameSize:(NSSize)newSize { | 436 - (void)setFrameSize:(NSSize)newSize { |
| 419 // The size passed in here does not always use | 437 // The size passed in here does not always use |
| (...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 904 } | 922 } |
| 905 | 923 |
| 906 return [super accessibilityAttributeValue:attribute]; | 924 return [super accessibilityAttributeValue:attribute]; |
| 907 } | 925 } |
| 908 | 926 |
| 909 - (id)accessibilityHitTest:(NSPoint)point { | 927 - (id)accessibilityHitTest:(NSPoint)point { |
| 910 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; | 928 return [hostedView_->GetNativeViewAccessible() accessibilityHitTest:point]; |
| 911 } | 929 } |
| 912 | 930 |
| 913 @end | 931 @end |
| OLD | NEW |