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

Side by Side Diff: ui/views/controls/tree/tree_view.cc

Issue 1177503003: Remove the 2-level input method system & InputMethodBridge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: makes trybots green. Created 5 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
OLDNEW
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 "ui/views/controls/tree/tree_view.h" 5 #include "ui/views/controls/tree/tree_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "ui/accessibility/ax_view_state.h" 11 #include "ui/accessibility/ax_view_state.h"
12 #include "ui/base/ime/input_method.h"
12 #include "ui/base/resource/resource_bundle.h" 13 #include "ui/base/resource/resource_bundle.h"
13 #include "ui/events/event.h" 14 #include "ui/events/event.h"
14 #include "ui/events/keycodes/keyboard_codes.h" 15 #include "ui/events/keycodes/keyboard_codes.h"
15 #include "ui/gfx/canvas.h" 16 #include "ui/gfx/canvas.h"
16 #include "ui/gfx/geometry/rect.h" 17 #include "ui/gfx/geometry/rect.h"
17 #include "ui/gfx/geometry/rect_conversions.h" 18 #include "ui/gfx/geometry/rect_conversions.h"
18 #include "ui/gfx/image/image.h" 19 #include "ui/gfx/image/image.h"
19 #include "ui/gfx/skia_util.h" 20 #include "ui/gfx/skia_util.h"
20 #include "ui/native_theme/native_theme.h" 21 #include "ui/native_theme/native_theme.h"
21 #include "ui/resources/grit/ui_resources.h" 22 #include "ui/resources/grit/ui_resources.h"
22 #include "ui/views/controls/prefix_selector.h" 23 #include "ui/views/controls/prefix_selector.h"
23 #include "ui/views/controls/scroll_view.h" 24 #include "ui/views/controls/scroll_view.h"
24 #include "ui/views/controls/textfield/textfield.h" 25 #include "ui/views/controls/textfield/textfield.h"
25 #include "ui/views/controls/tree/tree_view_controller.h" 26 #include "ui/views/controls/tree/tree_view_controller.h"
26 #include "ui/views/ime/input_method.h"
27 27
28 using ui::TreeModel; 28 using ui::TreeModel;
29 using ui::TreeModelNode; 29 using ui::TreeModelNode;
30 30
31 namespace views { 31 namespace views {
32 32
33 // Insets around the view. 33 // Insets around the view.
34 static const int kHorizontalInset = 2; 34 static const int kHorizontalInset = 2;
35 static const int kVerticalInset = 2; 35 static const int kVerticalInset = 2;
36 // Padding before/after the image. 36 // Padding before/after the image.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 kArrowRegionSize; 91 kArrowRegionSize;
92 } 92 }
93 93
94 TreeView::~TreeView() { 94 TreeView::~TreeView() {
95 if (model_) 95 if (model_)
96 model_->RemoveObserver(this); 96 model_->RemoveObserver(this);
97 if (focus_manager_) { 97 if (focus_manager_) {
98 focus_manager_->RemoveFocusChangeListener(this); 98 focus_manager_->RemoveFocusChangeListener(this);
99 focus_manager_ = NULL; 99 focus_manager_ = NULL;
100 } 100 }
101 if (GetTextInputClient() && GetInputMethod())
yukawa 2015/06/11 21:48:43 ditto for clean-up code.
Shu Chen 2015/06/12 03:34:38 Ditto.
102 GetInputMethod()->DetachTextInputClient(GetTextInputClient());
101 } 103 }
102 104
103 View* TreeView::CreateParentIfNecessary() { 105 View* TreeView::CreateParentIfNecessary() {
104 ScrollView* scroll_view = ScrollView::CreateScrollViewWithBorder(); 106 ScrollView* scroll_view = ScrollView::CreateScrollViewWithBorder();
105 scroll_view->SetContents(this); 107 scroll_view->SetContents(this);
106 return scroll_view; 108 return scroll_view;
107 } 109 }
108 110
109 void TreeView::SetModel(TreeModel* model) { 111 void TreeView::SetModel(TreeModel* model) {
110 if (model == model_) 112 if (model == model_)
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 612
611 int min_row = std::max(0, (min_y - kVerticalInset) / row_height_); 613 int min_row = std::max(0, (min_y - kVerticalInset) / row_height_);
612 int max_row = (max_y - kVerticalInset) / row_height_; 614 int max_row = (max_y - kVerticalInset) / row_height_;
613 if ((max_y - kVerticalInset) % row_height_ != 0) 615 if ((max_y - kVerticalInset) % row_height_ != 0)
614 max_row++; 616 max_row++;
615 int current_row = root_row(); 617 int current_row = root_row();
616 PaintRows(canvas, min_row, max_row, &root_, root_depth(), &current_row); 618 PaintRows(canvas, min_row, max_row, &root_, root_depth(), &current_row);
617 } 619 }
618 620
619 void TreeView::OnFocus() { 621 void TreeView::OnFocus() {
620 GetInputMethod()->OnFocus(); 622 if (GetInputMethod())
623 GetInputMethod()->SetFocusedTextInputClient(GetTextInputClient());
621 View::OnFocus(); 624 View::OnFocus();
622 SchedulePaintForNode(selected_node_); 625 SchedulePaintForNode(selected_node_);
623 626
624 // Notify the InputMethod so that it knows to query the TextInputClient. 627 // Notify the InputMethod so that it knows to query the TextInputClient.
625 if (GetInputMethod()) 628 if (GetInputMethod())
626 GetInputMethod()->OnCaretBoundsChanged(this); 629 GetInputMethod()->OnCaretBoundsChanged(GetTextInputClient());
627 } 630 }
628 631
629 void TreeView::OnBlur() { 632 void TreeView::OnBlur() {
630 GetInputMethod()->OnBlur(); 633 if (GetInputMethod())
634 GetInputMethod()->DetachTextInputClient(GetTextInputClient());
631 SchedulePaintForNode(selected_node_); 635 SchedulePaintForNode(selected_node_);
632 if (selector_) 636 if (selector_)
633 selector_->OnViewBlur(); 637 selector_->OnViewBlur();
634 } 638 }
635 639
636 bool TreeView::OnClickOrTap(const ui::LocatedEvent& event) { 640 bool TreeView::OnClickOrTap(const ui::LocatedEvent& event) {
637 CommitEdit(); 641 CommitEdit();
638 RequestFocus(); 642 RequestFocus();
639 643
640 int row = (event.y() - kVerticalInset) / row_height_; 644 int row = (event.y() - kVerticalInset) / row_height_;
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 if (!is_expanded_) 1039 if (!is_expanded_)
1036 return max_width; 1040 return max_width;
1037 for (int i = 0; i < child_count(); ++i) { 1041 for (int i = 0; i < child_count(); ++i) {
1038 max_width = std::max(max_width, 1042 max_width = std::max(max_width,
1039 GetChild(i)->GetMaxWidth(indent, depth + 1)); 1043 GetChild(i)->GetMaxWidth(indent, depth + 1));
1040 } 1044 }
1041 return max_width; 1045 return max_width;
1042 } 1046 }
1043 1047
1044 } // namespace views 1048 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698