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

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

Issue 8505051: Support mozc suggest window on ChromeOS. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Fix few bugs Created 9 years, 1 month 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
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 551ba32eb7ea949921ba57d648f94403bd76ac33..72bbe85d00f2a376f9f793bad4538e4b6586f92b 100644
--- a/chrome/browser/chromeos/input_method/candidate_window.cc
+++ b/chrome/browser/chromeos/input_method/candidate_window.cc
@@ -577,6 +577,16 @@ class CandidateWindowView : public views::View {
// The last cursor location.
gfx::Rect cursor_location_;
+
+ // This location is used by mozc window rendereing, The mozc-engine have two
+ // types of lookup-table, suggestion window and candidate window(this is
+ // ordinal look-up table). The location of these two windows is different
+ // and which is managed by mozc-engine now.
+ gfx::Rect window_location_for_mozc_engine_;
+
+ // If rendering operation comes from mozc-engine, this value becomes true.
+ // Otherwise this value becomes false.
+ bool is_mozc_window_;
};
// CandidateRow renderes a row of a candidate.
@@ -980,7 +990,8 @@ CandidateWindowView::CandidateWindowView(views::Widget* parent_frame)
footer_area_(NULL),
previous_shortcut_column_width_(0),
previous_candidate_column_width_(0),
- previous_annotation_column_width_(0) {
+ previous_annotation_column_width_(0),
+ is_mozc_window_(false) {
}
void CandidateWindowView::Init() {
@@ -1079,6 +1090,23 @@ void CandidateWindowView::ShowLookupTable() {
bool CandidateWindowView::ShouldUpdateCandidateViews(
const InputMethodLookupTable& old_table,
const InputMethodLookupTable& new_table) {
+
+ // Check if mozc lookup table location is changed.
+ if (old_table.mozc_candidates.has_window_location() ||
+ new_table.mozc_candidates.has_window_location()) {
+ std::string old_serialized_msg;
+ std::string new_serialized_msg;
+ if (old_table.mozc_candidates.SerializeToString(&old_serialized_msg)) {
+ return true;
+ }
+ if (new_table.mozc_candidates.SerializeToString(&new_serialized_msg)) {
+ // It might be safe to avoid update if the protocol buffer sent from
+ // mozc-engine is broken.
+ return false;
+ }
+ return old_serialized_msg != new_serialized_msg;
+ }
+
// Check if most table contents are identical.
if (old_table.page_size == new_table.page_size &&
old_table.orientation == new_table.orientation &&
@@ -1103,6 +1131,36 @@ void CandidateWindowView::UpdateCandidates(
// Initialize candidate views if necessary.
MaybeInitializeCandidateViews(new_lookup_table);
+ // Stores mozc specific window location.
+ if (new_lookup_table.mozc_candidates.has_window_location()) {
+ if (new_lookup_table.mozc_candidates.window_location() ==
+ mozc::commands::Candidates::CARET) {
+ DCHECK(new_lookup_table.mozc_candidates.has_caret_rectangle());
+ window_location_for_mozc_engine_.set_x(
+ new_lookup_table.mozc_candidates.caret_rectangle().x());
+ window_location_for_mozc_engine_.set_y(
+ new_lookup_table.mozc_candidates.caret_rectangle().y());
+ window_location_for_mozc_engine_.set_width(
+ new_lookup_table.mozc_candidates.caret_rectangle().width());
+ window_location_for_mozc_engine_.set_height(
+ new_lookup_table.mozc_candidates.caret_rectangle().height());
+ } else {
+ DCHECK(new_lookup_table.mozc_candidates.has_composition_rectangle());
+ window_location_for_mozc_engine_.set_x(
+ new_lookup_table.mozc_candidates.composition_rectangle().x());
+ window_location_for_mozc_engine_.set_y(
+ new_lookup_table.mozc_candidates.composition_rectangle().y());
+ window_location_for_mozc_engine_.set_width(
+ new_lookup_table.mozc_candidates.composition_rectangle().width());
+ window_location_for_mozc_engine_.set_height(
+ new_lookup_table.mozc_candidates.composition_rectangle().height());
+ }
+ is_mozc_window_ = true;
+ } else {
+ is_mozc_window_ = false;
+ }
+
+
// Compute the index of the current page.
const int current_page_index = ComputePageIndex(new_lookup_table);
if (current_page_index < 0) {
@@ -1327,8 +1385,16 @@ void CandidateWindowView::CommitCandidate() {
}
void CandidateWindowView::ResizeAndMoveParentFrame() {
- const int x = cursor_location_.x();
- const int y = cursor_location_.y();
+ // If rendering operation comes from mozc-engine, uses mozc specific location,
+ // otherwise lookup table is shown under the cursor.
+ const int x = is_mozc_window_ ?
+ window_location_for_mozc_engine_.x() : cursor_location_.x();
+ // To avoid lookup-table overlapping, uses maximum y-position of mozc specific
+ // location and cursor location, because mozc-engine does not concern about
+ // multi-line composition,
+ const int y = is_mozc_window_ ?
+ std::max(window_location_for_mozc_engine_.y(), cursor_location_.y()) :
+ cursor_location_.y();
const int height = cursor_location_.height();
const int horizontal_offset = GetHorizontalOffset();

Powered by Google App Engine
This is Rietveld 408576698