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.h" | 5 #include "chrome/browser/chromeos/input_method/candidate_window.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
769 : selected_candidate_index_in_page_(0), | 769 : selected_candidate_index_in_page_(0), |
770 parent_frame_(parent_frame), | 770 parent_frame_(parent_frame), |
771 preedit_area_(NULL), | 771 preedit_area_(NULL), |
772 header_area_(NULL), | 772 header_area_(NULL), |
773 candidate_area_(NULL), | 773 candidate_area_(NULL), |
774 footer_area_(NULL), | 774 footer_area_(NULL), |
775 previous_shortcut_column_size_(0, 0), | 775 previous_shortcut_column_size_(0, 0), |
776 previous_candidate_column_size_(0, 0), | 776 previous_candidate_column_size_(0, 0), |
777 previous_annotation_column_size_(0, 0), | 777 previous_annotation_column_size_(0, 0), |
778 is_suggestion_window_location_available_(false), | 778 is_suggestion_window_location_available_(false), |
779 should_show_upper_side_(false), | |
779 was_candidate_window_open_(false) { | 780 was_candidate_window_open_(false) { |
780 } | 781 } |
781 | 782 |
782 CandidateWindowView::~CandidateWindowView() { | 783 CandidateWindowView::~CandidateWindowView() { |
783 } | 784 } |
784 | 785 |
785 void CandidateWindowView::Init() { | 786 void CandidateWindowView::Init() { |
786 // Set the background and the border of the view. | 787 // Set the background and the border of the view. |
787 set_background( | 788 set_background( |
788 views::Background::CreateSolidBackground(kDefaultBackgroundColor)); | 789 views::Background::CreateSolidBackground(kDefaultBackgroundColor)); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
882 void CandidateWindowView::ShowPreeditText() { | 883 void CandidateWindowView::ShowPreeditText() { |
883 preedit_area_->Show(); | 884 preedit_area_->Show(); |
884 UpdateParentArea(); | 885 UpdateParentArea(); |
885 } | 886 } |
886 | 887 |
887 void CandidateWindowView::UpdatePreeditText(const std::string& utf8_text) { | 888 void CandidateWindowView::UpdatePreeditText(const std::string& utf8_text) { |
888 preedit_area_->SetText(utf8_text); | 889 preedit_area_->SetText(utf8_text); |
889 } | 890 } |
890 | 891 |
891 void CandidateWindowView::ShowLookupTable() { | 892 void CandidateWindowView::ShowLookupTable() { |
893 if (!candidate_area_->IsShown()) | |
894 should_show_upper_side_ = false; | |
892 candidate_area_->Show(); | 895 candidate_area_->Show(); |
893 UpdateParentArea(); | 896 UpdateParentArea(); |
894 } | 897 } |
895 | 898 |
896 void CandidateWindowView::NotifyIfCandidateWindowOpenedOrClosed() { | 899 void CandidateWindowView::NotifyIfCandidateWindowOpenedOrClosed() { |
897 bool is_open = IsCandidateWindowOpen(); | 900 bool is_open = IsCandidateWindowOpen(); |
898 if (!was_candidate_window_open_ && is_open) { | 901 if (!was_candidate_window_open_ && is_open) { |
899 FOR_EACH_OBSERVER(Observer, observers_, OnCandidateWindowOpened()); | 902 FOR_EACH_OBSERVER(Observer, observers_, OnCandidateWindowOpened()); |
900 } else if (was_candidate_window_open_ && !is_open) { | 903 } else if (was_candidate_window_open_ && !is_open) { |
901 FOR_EACH_OBSERVER(Observer, observers_, OnCandidateWindowClosed()); | 904 FOR_EACH_OBSERVER(Observer, observers_, OnCandidateWindowClosed()); |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1236 frame_bounds.set_y(std::max(frame_bounds.y(), screen_bounds.y())); | 1239 frame_bounds.set_y(std::max(frame_bounds.y(), screen_bounds.y())); |
1237 | 1240 |
1238 // Handle overflow at the right. | 1241 // Handle overflow at the right. |
1239 const int right_overflow = frame_bounds.right() - screen_bounds.right(); | 1242 const int right_overflow = frame_bounds.right() - screen_bounds.right(); |
1240 if (right_overflow > 0) { | 1243 if (right_overflow > 0) { |
1241 frame_bounds.set_x(frame_bounds.x() - right_overflow); | 1244 frame_bounds.set_x(frame_bounds.x() - right_overflow); |
1242 } | 1245 } |
1243 | 1246 |
1244 // Handle overflow at the bottom. | 1247 // Handle overflow at the bottom. |
1245 const int bottom_overflow = frame_bounds.bottom() - screen_bounds.bottom(); | 1248 const int bottom_overflow = frame_bounds.bottom() - screen_bounds.bottom(); |
1246 if (bottom_overflow > 0) { | 1249 |
1250 // To avoid flickering window position, the candidate window should be shown | |
1251 // on upper side of composition string if it was shown there. | |
1252 if (should_show_upper_side_ || bottom_overflow > 0) { | |
1247 frame_bounds.set_y(frame_bounds.y() - height - frame_bounds.height()); | 1253 frame_bounds.set_y(frame_bounds.y() - height - frame_bounds.height()); |
1254 should_show_upper_side_ = true; | |
1248 } | 1255 } |
1249 | 1256 |
Yusuke Sato
2012/06/08 07:42:26
I think you should do
if (should_show_upper_side
Seigo Nonaka
2012/06/08 07:51:00
Done.
| |
1250 // Move the window per the cursor location. | 1257 // Move the window per the cursor location. |
1251 // SetBounds() is not cheap. Only call this when it is really changed. | 1258 // SetBounds() is not cheap. Only call this when it is really changed. |
1252 if (frame_bounds != old_bounds) | 1259 if (frame_bounds != old_bounds) |
1253 parent_frame_->SetBounds(frame_bounds); | 1260 parent_frame_->SetBounds(frame_bounds); |
1254 } | 1261 } |
1255 | 1262 |
1256 int CandidateWindowView::GetHorizontalOffset() { | 1263 int CandidateWindowView::GetHorizontalOffset() { |
1257 // Compute the horizontal offset if the lookup table is vertical. | 1264 // Compute the horizontal offset if the lookup table is vertical. |
1258 if (!candidate_views_.empty() && | 1265 if (!candidate_views_.empty() && |
1259 lookup_table_.orientation == InputMethodLookupTable::kVertical) { | 1266 lookup_table_.orientation == InputMethodLookupTable::kVertical) { |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1755 } | 1762 } |
1756 | 1763 |
1757 // static | 1764 // static |
1758 CandidateWindowController* | 1765 CandidateWindowController* |
1759 CandidateWindowController::CreateCandidateWindowController() { | 1766 CandidateWindowController::CreateCandidateWindowController() { |
1760 return new CandidateWindowControllerImpl; | 1767 return new CandidateWindowControllerImpl; |
1761 } | 1768 } |
1762 | 1769 |
1763 } // namespace input_method | 1770 } // namespace input_method |
1764 } // namespace chromeos | 1771 } // namespace chromeos |
OLD | NEW |