OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ash/system/ime_menu/ime_list_view.h" | 5 #include "ash/system/ime_menu/ime_list_view.h" |
6 | 6 |
7 #include "ash/resources/grit/ash_resources.h" | 7 #include "ash/resources/grit/ash_resources.h" |
8 #include "ash/resources/vector_icons/vector_icons.h" | 8 #include "ash/resources/vector_icons/vector_icons.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_port.h" | 10 #include "ash/shell_port.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 bool PerformAction(const ui::Event& event) override { | 105 bool PerformAction(const ui::Event& event) override { |
106 ime_list_view_->set_last_item_selected_with_keyboard( | 106 ime_list_view_->set_last_item_selected_with_keyboard( |
107 ime_list_view_->should_focus_ime_after_selection_with_keyboard() && | 107 ime_list_view_->should_focus_ime_after_selection_with_keyboard() && |
108 event.type() == ui::EventType::ET_KEY_PRESSED); | 108 event.type() == ui::EventType::ET_KEY_PRESSED); |
109 ime_list_view_->HandleViewClicked(this); | 109 ime_list_view_->HandleViewClicked(this); |
110 return true; | 110 return true; |
111 } | 111 } |
112 | 112 |
113 void OnFocus() override { | 113 void OnFocus() override { |
114 ActionableView::OnFocus(); | 114 ActionableView::OnFocus(); |
115 if (ime_list_view_ && ime_list_view_->scroll_content()) | 115 if (ime_list_view_) |
116 ime_list_view_->scroll_content()->ScrollRectToVisible(bounds()); | 116 ime_list_view_->ScrollItemToVisible(this); |
117 } | 117 } |
118 | 118 |
119 void GetAccessibleNodeData(ui::AXNodeData* node_data) override { | 119 void GetAccessibleNodeData(ui::AXNodeData* node_data) override { |
120 ActionableView::GetAccessibleNodeData(node_data); | 120 ActionableView::GetAccessibleNodeData(node_data); |
121 node_data->role = ui::AX_ROLE_CHECK_BOX; | 121 node_data->role = ui::AX_ROLE_CHECK_BOX; |
122 const ui::AXCheckedState checked_state = | 122 const ui::AXCheckedState checked_state = |
123 selected_ ? ui::AX_CHECKED_STATE_TRUE : ui::AX_CHECKED_STATE_FALSE; | 123 selected_ ? ui::AX_CHECKED_STATE_TRUE : ui::AX_CHECKED_STATE_FALSE; |
124 node_data->AddIntAttribute(ui::AX_ATTR_CHECKED_STATE, checked_state); | 124 node_data->AddIntAttribute(ui::AX_ATTR_CHECKED_STATE, checked_state); |
125 } | 125 } |
126 | 126 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 if (show_keyboard_toggle) | 214 if (show_keyboard_toggle) |
215 PrependKeyboardStatusRow(); | 215 PrependKeyboardStatusRow(); |
216 | 216 |
217 Layout(); | 217 Layout(); |
218 SchedulePaint(); | 218 SchedulePaint(); |
219 | 219 |
220 if (should_focus_ime_after_selection_with_keyboard_ && | 220 if (should_focus_ime_after_selection_with_keyboard_ && |
221 last_item_selected_with_keyboard_) { | 221 last_item_selected_with_keyboard_) { |
222 FocusCurrentImeIfNeeded(); | 222 FocusCurrentImeIfNeeded(); |
223 } else if (current_ime_view_) { | 223 } else if (current_ime_view_) { |
224 scroll_content()->ScrollRectToVisible(current_ime_view_->bounds()); | 224 ScrollItemToVisible(current_ime_view_); |
225 } | 225 } |
226 } | 226 } |
227 | 227 |
228 void ImeListView::ResetImeListView() { | 228 void ImeListView::ResetImeListView() { |
229 // Children are removed from the view hierarchy and deleted in Reset(). | 229 // Children are removed from the view hierarchy and deleted in Reset(). |
230 Reset(); | 230 Reset(); |
231 keyboard_status_row_ = nullptr; | 231 keyboard_status_row_ = nullptr; |
232 current_ime_view_ = nullptr; | 232 current_ime_view_ = nullptr; |
233 } | 233 } |
234 | 234 |
| 235 void ImeListView::ScrollItemToVisible(views::View* item_view) { |
| 236 if (scroll_content()) |
| 237 scroll_content()->ScrollRectToVisible(item_view->bounds()); |
| 238 } |
| 239 |
235 void ImeListView::CloseImeListView() { | 240 void ImeListView::CloseImeListView() { |
236 last_selected_item_id_.clear(); | 241 last_selected_item_id_.clear(); |
237 current_ime_view_ = nullptr; | 242 current_ime_view_ = nullptr; |
238 last_item_selected_with_keyboard_ = false; | 243 last_item_selected_with_keyboard_ = false; |
239 GetWidget()->Close(); | 244 GetWidget()->Close(); |
240 } | 245 } |
241 | 246 |
242 void ImeListView::AppendImeListAndProperties( | 247 void ImeListView::AppendImeListAndProperties( |
243 const IMEInfoList& list, | 248 const IMEInfoList& list, |
244 const IMEPropertyInfoList& property_list) { | 249 const IMEPropertyInfoList& property_list) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 last_item_selected_with_keyboard_ = false; | 322 last_item_selected_with_keyboard_ = false; |
318 } | 323 } |
319 | 324 |
320 void ImeListView::VisibilityChanged(View* starting_from, bool is_visible) { | 325 void ImeListView::VisibilityChanged(View* starting_from, bool is_visible) { |
321 if (!is_visible || (should_focus_ime_after_selection_with_keyboard_ && | 326 if (!is_visible || (should_focus_ime_after_selection_with_keyboard_ && |
322 last_item_selected_with_keyboard_) || | 327 last_item_selected_with_keyboard_) || |
323 !current_ime_view_) { | 328 !current_ime_view_) { |
324 return; | 329 return; |
325 } | 330 } |
326 | 331 |
327 scroll_content()->ScrollRectToVisible(current_ime_view_->bounds()); | 332 ScrollItemToVisible(current_ime_view_); |
328 } | 333 } |
329 | 334 |
330 void ImeListView::FocusCurrentImeIfNeeded() { | 335 void ImeListView::FocusCurrentImeIfNeeded() { |
331 views::FocusManager* manager = GetFocusManager(); | 336 views::FocusManager* manager = GetFocusManager(); |
332 if (!manager || manager->GetFocusedView() || last_selected_item_id_.empty()) | 337 if (!manager || manager->GetFocusedView() || last_selected_item_id_.empty()) |
333 return; | 338 return; |
334 | 339 |
335 for (auto ime_map : ime_map_) { | 340 for (auto ime_map : ime_map_) { |
336 if (ime_map.second == last_selected_item_id_) { | 341 if (ime_map.second == last_selected_item_id_) { |
337 (ime_map.first)->RequestFocus(); | 342 (ime_map.first)->RequestFocus(); |
(...skipping 12 matching lines...) Expand all Loading... |
350 ImeListViewTestApi::ImeListViewTestApi(ImeListView* ime_list_view) | 355 ImeListViewTestApi::ImeListViewTestApi(ImeListView* ime_list_view) |
351 : ime_list_view_(ime_list_view) {} | 356 : ime_list_view_(ime_list_view) {} |
352 | 357 |
353 ImeListViewTestApi::~ImeListViewTestApi() {} | 358 ImeListViewTestApi::~ImeListViewTestApi() {} |
354 | 359 |
355 views::View* ImeListViewTestApi::GetToggleView() const { | 360 views::View* ImeListViewTestApi::GetToggleView() const { |
356 return ime_list_view_->keyboard_status_row_->toggle(); | 361 return ime_list_view_->keyboard_status_row_->toggle(); |
357 } | 362 } |
358 | 363 |
359 } // namespace ash | 364 } // namespace ash |
OLD | NEW |