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

Unified Diff: chrome/browser/chromeos/input_method/candidate_window.cc

Issue 10872011: Support label field in ExtensinoIME API. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/input_method/candidate_window_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/input_method/candidate_window.cc
diff --git a/chrome/browser/chromeos/input_method/candidate_window.cc b/chrome/browser/chromeos/input_method/candidate_window.cc
index df790ddc82a4f8b709a6cfa43c869fb9c47ff0b7..455d643e20763cde4852568bd982700f255dbc2d 100644
--- a/chrome/browser/chromeos/input_method/candidate_window.cc
+++ b/chrome/browser/chromeos/input_method/candidate_window.cc
@@ -141,19 +141,23 @@ views::View* WrapWithPadding(views::View* view, const gfx::Insets& insets) {
// Creates shortcut text from the given index and the orientation.
string16 CreateShortcutText(int index,
- InputMethodLookupTable::Orientation orientation) {
+ const InputMethodLookupTable& table) {
// Choose the character used for the shortcut label.
const char kShortcutCharacters[] = "1234567890ABCDEF";
// The default character should not be used but just in case.
- char shortcut_character = L'?';
- // -1 to exclude the null character at the end.
- if (index < static_cast<int>(arraysize(kShortcutCharacters) - 1))
- shortcut_character = kShortcutCharacters[index];
+ std::string shortcut_text = " ";
+ if (table.labels.empty()) {
+ // -1 to exclude the null character at the end.
+ if (index < static_cast<int>(arraysize(kShortcutCharacters) - 1))
+ shortcut_text = std::string(1, kShortcutCharacters[index]);
+ } else {
+ if (index < static_cast<int>(table.labels.size()))
+ shortcut_text = table.labels[index];
+ }
- std::string shortcut_text(1, shortcut_character);
- if (orientation != InputMethodLookupTable::kVertical)
+ if (table.orientation != InputMethodLookupTable::kVertical)
shortcut_text += '.';
- return ASCIIToUTF16(shortcut_text);
+ return UTF8ToUTF16(shortcut_text);
}
// Creates the shortcut label, and returns it (never returns NULL).
@@ -263,7 +267,7 @@ gfx::Size ComputeShortcutColumnSize(
// We'll create temporary shortcut labels, and choose the largest width and
// height.
for (int i = 0; i < lookup_table.page_size; ++i) {
- shortcut_label->SetText(CreateShortcutText(i, lookup_table.orientation));
+ shortcut_label->SetText(CreateShortcutText(i, lookup_table));
gfx::Size text_size = wrapped_shortcut_label->GetPreferredSize();
shortcut_column_width = std::max(shortcut_column_width, text_size.width());
shortcut_column_height = std::max(shortcut_column_height,
@@ -987,7 +991,7 @@ void CandidateWindowView::UpdateCandidates(
// candidates is 5). Second, we want to add a period after each
// shortcut label when the candidate window is horizontal.
candidate_view->SetShortcutText(
- CreateShortcutText(i, new_lookup_table.orientation));
+ CreateShortcutText(i, new_lookup_table));
}
// Set the candidate text.
if (candidate_index < new_lookup_table.candidates.size() &&
« no previous file with comments | « no previous file | chrome/browser/chromeos/input_method/candidate_window_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698