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

Side by Side Diff: views/controls/tabbed_pane/tabbed_pane.cc

Issue 7981019: views: Get rid of TabbedPane::CreateWrapper(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add lifetime comment Created 9 years, 3 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
« no previous file with comments | « views/controls/tabbed_pane/tabbed_pane.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "views/controls/tabbed_pane/tabbed_pane.h" 5 #include "views/controls/tabbed_pane/tabbed_pane.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/base/accessibility/accessible_view_state.h" 8 #include "ui/base/accessibility/accessible_view_state.h"
9 // TODO(avi): remove when not needed 9 // TODO(avi): remove when not needed
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 64
65 void TabbedPane::SetAccessibleName(const string16& name) { 65 void TabbedPane::SetAccessibleName(const string16& name) {
66 accessible_name_ = name; 66 accessible_name_ = name;
67 } 67 }
68 68
69 gfx::Size TabbedPane::GetPreferredSize() { 69 gfx::Size TabbedPane::GetPreferredSize() {
70 return native_tabbed_pane_ ? 70 return native_tabbed_pane_ ?
71 native_tabbed_pane_->GetPreferredSize() : gfx::Size(); 71 native_tabbed_pane_->GetPreferredSize() : gfx::Size();
72 } 72 }
73 73
74 void TabbedPane::CreateWrapper() {
75 native_tabbed_pane_ = NativeTabbedPaneWrapper::CreateNativeWrapper(this);
76 }
77
78 void TabbedPane::LoadAccelerators() { 74 void TabbedPane::LoadAccelerators() {
79 // Ctrl+Shift+Tab 75 // Ctrl+Shift+Tab
80 AddAccelerator(views::Accelerator(ui::VKEY_TAB, true, true, false)); 76 AddAccelerator(views::Accelerator(ui::VKEY_TAB, true, true, false));
81 // Ctrl+Tab 77 // Ctrl+Tab
82 AddAccelerator(views::Accelerator(ui::VKEY_TAB, false, true, false)); 78 AddAccelerator(views::Accelerator(ui::VKEY_TAB, false, true, false));
83 } 79 }
84 80
85 void TabbedPane::Layout() { 81 void TabbedPane::Layout() {
86 if (native_tabbed_pane_) 82 if (native_tabbed_pane_)
87 native_tabbed_pane_->GetView()->SetBounds(0, 0, width(), height()); 83 native_tabbed_pane_->GetView()->SetBounds(0, 0, width(), height());
88 } 84 }
89 85
90 void TabbedPane::ViewHierarchyChanged(bool is_add, View* parent, View* child) { 86 void TabbedPane::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
91 if (is_add && !native_tabbed_pane_) { 87 if (is_add && !native_tabbed_pane_) {
92 CreateWrapper(); 88 // The native wrapper's lifetime will be managed by the view hierarchy after
89 // we call AddChildView.
90 native_tabbed_pane_ = NativeTabbedPaneWrapper::CreateNativeWrapper(this);
93 AddChildView(native_tabbed_pane_->GetView()); 91 AddChildView(native_tabbed_pane_->GetView());
94 LoadAccelerators(); 92 LoadAccelerators();
95 } 93 }
96 } 94 }
97 95
98 bool TabbedPane::AcceleratorPressed(const views::Accelerator& accelerator) { 96 bool TabbedPane::AcceleratorPressed(const views::Accelerator& accelerator) {
99 // We only accept Ctrl+Tab keyboard events. 97 // We only accept Ctrl+Tab keyboard events.
100 DCHECK(accelerator.key_code() == 98 DCHECK(accelerator.key_code() ==
101 ui::VKEY_TAB && accelerator.IsCtrlDown()); 99 ui::VKEY_TAB && accelerator.IsCtrlDown());
102 100
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 if (NativeViewHost::kRenderNativeControlFocus) 136 if (NativeViewHost::kRenderNativeControlFocus)
139 View::OnPaintFocusBorder(canvas); 137 View::OnPaintFocusBorder(canvas);
140 } 138 }
141 139
142 void TabbedPane::GetAccessibleState(ui::AccessibleViewState* state) { 140 void TabbedPane::GetAccessibleState(ui::AccessibleViewState* state) {
143 state->role = ui::AccessibilityTypes::ROLE_PAGETABLIST; 141 state->role = ui::AccessibilityTypes::ROLE_PAGETABLIST;
144 state->name = accessible_name_; 142 state->name = accessible_name_;
145 } 143 }
146 144
147 } // namespace views 145 } // namespace views
OLDNEW
« no previous file with comments | « views/controls/tabbed_pane/tabbed_pane.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698