Chromium Code Reviews| 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 85078ffd4f374fb1bf35f1b8a13b5229c9f3e43e..885894632235fa82d9bb696b86ae3b70dba74fe0 100644 |
| --- a/chrome/browser/chromeos/input_method/candidate_window.cc |
| +++ b/chrome/browser/chromeos/input_method/candidate_window.cc |
| @@ -833,7 +833,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) { |
| } |
| CandidateWindowView::~CandidateWindowView() { |
| @@ -935,6 +936,25 @@ 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; |
|
Yusuke Sato
2011/11/30 13:38:20
nit: move these two variables to L.952.
Seigo Nonaka
2011/12/01 07:10:01
Done.
|
| + std::string new_serialized_msg; |
| + |
| + if (!old_table.mozc_candidates.IsInitialized()) { |
|
Yusuke Sato
2011/11/30 13:38:20
if (!old.. ||
!new..) {
return true;
}
woul
Seigo Nonaka
2011/12/01 07:10:01
Done.
|
| + return true; |
| + } |
| + if (!new_table.mozc_candidates.IsInitialized()) { |
| + return true; |
| + } |
| + |
| + old_table.mozc_candidates.SerializeToString(&old_serialized_msg); |
| + new_table.mozc_candidates.SerializeToString(&new_serialized_msg); |
| + 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 && |
| @@ -959,6 +979,36 @@ void CandidateWindowView::UpdateCandidates( |
| // Initialize candidate views if necessary. |
| MaybeInitializeCandidateViews(new_lookup_table); |
| + // Stores mozc specific window location. |
|
Yusuke Sato
2011/11/30 13:38:20
nit: Store
Seigo Nonaka
2011/12/01 07:10:01
Done.
|
| + if (new_lookup_table.mozc_candidates.has_window_location()) { |
| + if (new_lookup_table.mozc_candidates.window_location() == |
| + mozc::commands::Candidates::CARET) { |
|
Yusuke Sato
2011/11/30 13:38:20
nit: what's are possible values of window_location
Seigo Nonaka
2011/12/01 07:10:01
I change my mind to use mozc specific location onl
|
| + 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) { |
| @@ -1183,8 +1233,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 consider 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(); |