Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: ui/views/cocoa/bridged_native_widget.mm

Issue 329463002: MacViews: Implement text input. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_native_widget.h" 5 #import "ui/views/cocoa/bridged_native_widget.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "ui/views/cocoa/bridged_content_view.h" 8 #include "ui/views/cocoa/bridged_content_view.h"
tapted 2014/06/17 13:23:56 include -> import. Typically import is used if a h
Andre 2014/06/18 21:48:35 Done.
9 #include "ui/views/view.h"
9 10
10 namespace views { 11 namespace views {
11 12
12 BridgedNativeWidget::BridgedNativeWidget() { 13 BridgedNativeWidget::BridgedNativeWidget() {
13 } 14 }
14 15
15 BridgedNativeWidget::~BridgedNativeWidget() { 16 BridgedNativeWidget::~BridgedNativeWidget() {
16 SetRootView(NULL); 17 SetRootView(NULL);
17 } 18 }
18 19
19 void BridgedNativeWidget::Init(base::scoped_nsobject<NSWindow> window) { 20 void BridgedNativeWidget::Init(base::scoped_nsobject<NSWindow> window) {
20 DCHECK(!window_); 21 DCHECK(!window_);
21 window_.swap(window); 22 window_.swap(window);
22 } 23 }
23 24
24 void BridgedNativeWidget::SetRootView(views::View* view) { 25 void BridgedNativeWidget::SetRootView(views::View* view) {
25 if (view == [bridged_view_ view]) 26 if (view == [bridged_view_ view])
26 return; 27 return;
27 28
29 if ([bridged_view_ view])
30 [bridged_view_ view]->GetFocusManager()->RemoveFocusChangeListener(this);
tapted 2014/06/17 13:23:56 I think this belongs in [BridgedContentView clearV
Andre 2014/06/18 21:48:35 Done.
31
28 [bridged_view_ clearView]; 32 [bridged_view_ clearView];
29 bridged_view_.reset(); 33 bridged_view_.reset();
30 // Note that there can still be references to the old |bridged_view_| 34 // Note that there can still be references to the old |bridged_view_|
31 // floating around in Cocoa libraries at this point. However, references to 35 // floating around in Cocoa libraries at this point. However, references to
32 // the old views::View will be gone, so any method calls will become no-ops. 36 // the old views::View will be gone, so any method calls will become no-ops.
33 37
34 if (view) 38 if (view) {
35 bridged_view_.reset([[BridgedContentView alloc] initWithView:view]); 39 bridged_view_.reset([[BridgedContentView alloc] initWithView:view]);
40 view->GetFocusManager()->AddFocusChangeListener(this);
41 }
36 [window_ setContentView:bridged_view_]; 42 [window_ setContentView:bridged_view_];
37 [window_ makeFirstResponder:bridged_view_]; 43 [window_ makeFirstResponder:bridged_view_];
38 } 44 }
39 45
46 // FocusChangeListener implementation.
tapted 2014/06/17 13:23:56 I usually skip these comments for C++ implementati
Andre 2014/06/18 21:48:35 Done.
47
48 void BridgedNativeWidget::OnWillChangeFocus(View* focused_before,
49 View* focused_now) {
50 }
51
52 void BridgedNativeWidget::OnDidChangeFocus(View* focused_before,
53 View* focused_now) {
54 if (focused_now)
tapted 2014/06/17 13:23:56 nit: I'd probably write this ui::TextInputClien
Andre 2014/06/18 21:48:35 Done.
55 [bridged_view_ setTextInputClient:focused_now->GetTextInputClient()];
56 else
57 [bridged_view_ setTextInputClient:NULL];
58 }
59
40 } // namespace views 60 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698