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

Side by Side Diff: chrome/browser/chromeos/input_method/candidate_window.cc

Issue 10542051: Reduce candidate window flickering. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Leave todo comment. Created 8 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/chromeos/input_method/candidate_window_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
1257 // TODO(nona): check top_overflow here.
1258
1250 // Move the window per the cursor location. 1259 // Move the window per the cursor location.
1251 // SetBounds() is not cheap. Only call this when it is really changed. 1260 // SetBounds() is not cheap. Only call this when it is really changed.
1252 if (frame_bounds != old_bounds) 1261 if (frame_bounds != old_bounds)
1253 parent_frame_->SetBounds(frame_bounds); 1262 parent_frame_->SetBounds(frame_bounds);
1254 } 1263 }
1255 1264
1256 int CandidateWindowView::GetHorizontalOffset() { 1265 int CandidateWindowView::GetHorizontalOffset() {
1257 // Compute the horizontal offset if the lookup table is vertical. 1266 // Compute the horizontal offset if the lookup table is vertical.
1258 if (!candidate_views_.empty() && 1267 if (!candidate_views_.empty() &&
1259 lookup_table_.orientation == InputMethodLookupTable::kVertical) { 1268 lookup_table_.orientation == InputMethodLookupTable::kVertical) {
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
1755 } 1764 }
1756 1765
1757 // static 1766 // static
1758 CandidateWindowController* 1767 CandidateWindowController*
1759 CandidateWindowController::CreateCandidateWindowController() { 1768 CandidateWindowController::CreateCandidateWindowController() {
1760 return new CandidateWindowControllerImpl; 1769 return new CandidateWindowControllerImpl;
1761 } 1770 }
1762 1771
1763 } // namespace input_method 1772 } // namespace input_method
1764 } // namespace chromeos 1773 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/input_method/candidate_window_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698