| OLD | NEW |
| 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 "chrome/browser/chromeos/input_method/candidate_window_controller_impl.
h" | 5 #include "chrome/browser/chromeos/input_method/candidate_window_controller_impl.
h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 if (!visible) { | 153 if (!visible) { |
| 154 candidate_window_->HideAuxiliaryText(); | 154 candidate_window_->HideAuxiliaryText(); |
| 155 return; | 155 return; |
| 156 } | 156 } |
| 157 candidate_window_->UpdateAuxiliaryText(utf8_text); | 157 candidate_window_->UpdateAuxiliaryText(utf8_text); |
| 158 candidate_window_->ShowAuxiliaryText(); | 158 candidate_window_->ShowAuxiliaryText(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 // static | 161 // static |
| 162 void CandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry( | 162 void CandidateWindowControllerImpl::ConvertLookupTableToInfolistEntry( |
| 163 const InputMethodLookupTable& lookup_table, | 163 const ibus::IBusLookupTable& lookup_table, |
| 164 std::vector<InfolistWindowView::Entry>* infolist_entries, | 164 std::vector<InfolistWindowView::Entry>* infolist_entries, |
| 165 size_t* focused_index) { | 165 size_t* focused_index) { |
| 166 DCHECK(focused_index); | 166 DCHECK(focused_index); |
| 167 DCHECK(infolist_entries); | 167 DCHECK(infolist_entries); |
| 168 *focused_index = InfolistWindowView::InvalidFocusIndex(); | 168 *focused_index = InfolistWindowView::InvalidFocusIndex(); |
| 169 infolist_entries->clear(); | 169 infolist_entries->clear(); |
| 170 | 170 |
| 171 const size_t cursor_index_in_page = | 171 const size_t cursor_index_in_page = |
| 172 lookup_table.cursor_absolute_index % lookup_table.page_size; | 172 lookup_table.cursor_position() % lookup_table.page_size(); |
| 173 | 173 |
| 174 for (size_t i = 0; i < lookup_table.descriptions.size(); ++i) { | 174 for (size_t i = 0; i < lookup_table.candidates().size(); ++i) { |
| 175 if (lookup_table.descriptions[i].title.empty() && | 175 const ibus::IBusLookupTable::Entry& ibus_entry = |
| 176 lookup_table.descriptions[i].body.empty()) | 176 lookup_table.candidates()[i]; |
| 177 if (ibus_entry.description_title.empty() && |
| 178 ibus_entry.description_body.empty()) |
| 177 continue; | 179 continue; |
| 178 InfolistWindowView::Entry entry; | 180 InfolistWindowView::Entry entry; |
| 179 entry.title = lookup_table.descriptions[i].title; | 181 entry.title = ibus_entry.description_title; |
| 180 entry.body = lookup_table.descriptions[i].body; | 182 entry.body = ibus_entry.description_body; |
| 181 infolist_entries->push_back(entry); | 183 infolist_entries->push_back(entry); |
| 182 if (i == cursor_index_in_page) | 184 if (i == cursor_index_in_page) |
| 183 *focused_index = infolist_entries->size() - 1; | 185 *focused_index = infolist_entries->size() - 1; |
| 184 } | 186 } |
| 185 } | 187 } |
| 186 | 188 |
| 187 // static | 189 // static |
| 188 bool CandidateWindowControllerImpl::ShouldUpdateInfolist( | 190 bool CandidateWindowControllerImpl::ShouldUpdateInfolist( |
| 189 const std::vector<InfolistWindowView::Entry>& old_entries, | 191 const std::vector<InfolistWindowView::Entry>& old_entries, |
| 190 size_t old_focused_index, | 192 size_t old_focused_index, |
| 191 const std::vector<InfolistWindowView::Entry>& new_entries, | 193 const std::vector<InfolistWindowView::Entry>& new_entries, |
| 192 size_t new_focused_index) { | 194 size_t new_focused_index) { |
| 193 if (old_entries.empty() && new_entries.empty()) | 195 if (old_entries.empty() && new_entries.empty()) |
| 194 return false; | 196 return false; |
| 195 if (old_entries.size() != new_entries.size()) | 197 if (old_entries.size() != new_entries.size()) |
| 196 return true; | 198 return true; |
| 197 if (old_focused_index != new_focused_index) | 199 if (old_focused_index != new_focused_index) |
| 198 return true; | 200 return true; |
| 199 | 201 |
| 200 for (size_t i = 0; i < old_entries.size(); ++i) { | 202 for (size_t i = 0; i < old_entries.size(); ++i) { |
| 201 if (old_entries[i].title != new_entries[i].title || | 203 if (old_entries[i].title != new_entries[i].title || |
| 202 old_entries[i].body != new_entries[i].body ) { | 204 old_entries[i].body != new_entries[i].body ) { |
| 203 return true; | 205 return true; |
| 204 } | 206 } |
| 205 } | 207 } |
| 206 return false; | 208 return false; |
| 207 } | 209 } |
| 208 | 210 |
| 209 void CandidateWindowControllerImpl::OnUpdateLookupTable( | 211 void CandidateWindowControllerImpl::OnUpdateLookupTable( |
| 210 const InputMethodLookupTable& lookup_table) { | 212 const ibus::IBusLookupTable& lookup_table, |
| 213 bool visible) { |
| 211 // If it's not visible, hide the lookup table and return. | 214 // If it's not visible, hide the lookup table and return. |
| 212 if (!lookup_table.visible) { | 215 if (!visible) { |
| 213 candidate_window_->HideLookupTable(); | 216 candidate_window_->HideLookupTable(); |
| 214 infolist_window_->Hide(); | 217 infolist_window_->Hide(); |
| 215 return; | 218 return; |
| 216 } | 219 } |
| 217 | 220 |
| 218 candidate_window_->UpdateCandidates(lookup_table); | 221 candidate_window_->UpdateCandidates(lookup_table); |
| 219 candidate_window_->ShowLookupTable(); | 222 candidate_window_->ShowLookupTable(); |
| 220 | 223 |
| 221 size_t focused_index = 0; | 224 size_t focused_index = 0; |
| 222 std::vector<InfolistWindowView::Entry> infolist_entries; | 225 std::vector<InfolistWindowView::Entry> infolist_entries; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 | 344 |
| 342 if (candidate_window_rect.y() + infolist_window_size.height() > | 345 if (candidate_window_rect.y() + infolist_window_size.height() > |
| 343 screen_rect.bottom()) | 346 screen_rect.bottom()) |
| 344 result.set_y(screen_rect.bottom() - infolist_window_size.height()); | 347 result.set_y(screen_rect.bottom() - infolist_window_size.height()); |
| 345 | 348 |
| 346 return result; | 349 return result; |
| 347 } | 350 } |
| 348 | 351 |
| 349 } // namespace input_method | 352 } // namespace input_method |
| 350 } // namespace chromeos | 353 } // namespace chromeos |
| OLD | NEW |