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

Side by Side Diff: ui/app_list/views/search_result_tile_item_list_view.cc

Issue 2972243002: Fix app list item indexing bug. (Closed)
Patch Set: oshima's comments. Created 3 years, 5 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 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 #include "ui/app_list/views/search_result_tile_item_list_view.h" 5 #include "ui/app_list/views/search_result_tile_item_list_view.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "ui/app_list/app_list_constants.h" 10 #include "ui/app_list/app_list_constants.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 if (old_selected >= 0) 162 if (old_selected >= 0)
163 tile_views_[old_selected]->SetSelected(false); 163 tile_views_[old_selected]->SetSelected(false);
164 164
165 if (new_selected >= 0) { 165 if (new_selected >= 0) {
166 tile_views_[new_selected]->SetSelected(true); 166 tile_views_[new_selected]->SetSelected(true);
167 ScrollRectToVisible(GetLocalBounds()); 167 ScrollRectToVisible(GetLocalBounds());
168 } 168 }
169 } 169 }
170 170
171 bool SearchResultTileItemListView::OnKeyPressed(const ui::KeyEvent& event) { 171 bool SearchResultTileItemListView::OnKeyPressed(const ui::KeyEvent& event) {
172 if (selected_index() >= 0 && child_at(selected_index())->OnKeyPressed(event)) 172 int selection_index = selected_index();
173 // Also count the separator when Play Store app search feature is enabled.
174 const int child_index = is_play_store_app_search_enabled_
175 ? selection_index * 2 + 1
176 : selection_index;
177 if (selection_index >= 0 && child_at(child_index)->OnKeyPressed(event))
173 return true; 178 return true;
174 179
175 int dir = 0; 180 int dir = 0;
176 bool cursor_at_end_of_searchbox = 181 bool cursor_at_end_of_searchbox =
177 search_box_->GetCursorPosition() == search_box_->text().length(); 182 search_box_->GetCursorPosition() == search_box_->text().length();
178 const int forward_dir = base::i18n::IsRTL() ? -1 : 1; 183 const int forward_dir = base::i18n::IsRTL() ? -1 : 1;
179 switch (event.key_code()) { 184 switch (event.key_code()) {
180 case ui::VKEY_TAB: 185 case ui::VKEY_TAB:
181 if (event.IsShiftDown()) 186 if (event.IsShiftDown())
182 dir = -1; 187 dir = -1;
(...skipping 14 matching lines...) Expand all
197 // text. 202 // text.
198 if (cursor_at_end_of_searchbox) 203 if (cursor_at_end_of_searchbox)
199 dir = forward_dir; 204 dir = forward_dir;
200 break; 205 break;
201 default: 206 default:
202 break; 207 break;
203 } 208 }
204 if (dir == 0) 209 if (dir == 0)
205 return false; 210 return false;
206 211
207 int selection_index = selected_index() + dir; 212 selection_index = selection_index + dir;
208 if (IsValidSelectionIndex(selection_index)) { 213 if (IsValidSelectionIndex(selection_index)) {
209 SetSelectedIndex(selection_index); 214 SetSelectedIndex(selection_index);
210 return true; 215 return true;
211 } 216 }
212 217
213 return false; 218 return false;
214 } 219 }
215 220
216 } // namespace app_list 221 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/search_result_list_view_unittest.cc ('k') | ui/app_list/views/search_result_tile_item_list_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698