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

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

Issue 8888038: chromeos: Don't fire candidate window open/close events for suggestion window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: change comment Created 9 years 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 | Annotate | Revision Log
« 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 // Add the candidate area. 879 // Add the candidate area.
880 layout->StartRow(0, 0); 880 layout->StartRow(0, 0);
881 layout->AddView(candidate_area_); // |candidate_area_| is owned by |this|. 881 layout->AddView(candidate_area_); // |candidate_area_| is owned by |this|.
882 882
883 // Add the footer area. 883 // Add the footer area.
884 layout->StartRow(0, 0); 884 layout->StartRow(0, 0);
885 layout->AddView(footer_area_); // |footer_area_| is owned by |this|. 885 layout->AddView(footer_area_); // |footer_area_| is owned by |this|.
886 } 886 }
887 887
888 void CandidateWindowView::HideAll() { 888 void CandidateWindowView::HideAll() {
889 bool was_visible = IsCandidateWindowOpen();
890 parent_frame_->Hide(); 889 parent_frame_->Hide();
891 if (was_visible) { 890 NotifyIfCandidateWindowOpenedOrClosed();
892 FOR_EACH_OBSERVER(Observer, observers_, OnCandidateWindowClosed());
893 }
894 } 891 }
895 892
896 void CandidateWindowView::HideLookupTable() { 893 void CandidateWindowView::HideLookupTable() {
897 bool was_visible = IsCandidateWindowOpen();
898 candidate_area_->Hide(); 894 candidate_area_->Hide();
899 if (preedit_area_->IsShown()) 895 if (preedit_area_->IsShown())
900 ResizeAndMoveParentFrame(); 896 ResizeAndMoveParentFrame();
901 else 897 else
902 parent_frame_->Hide(); 898 parent_frame_->Hide();
903 if (was_visible) { 899
904 FOR_EACH_OBSERVER(Observer, observers_, OnCandidateWindowClosed()); 900 NotifyIfCandidateWindowOpenedOrClosed();
905 }
906 } 901 }
907 902
908 InformationTextArea* CandidateWindowView::GetAuxiliaryTextArea() { 903 InformationTextArea* CandidateWindowView::GetAuxiliaryTextArea() {
909 return (lookup_table_.orientation == InputMethodLookupTable::kHorizontal ? 904 return (lookup_table_.orientation == InputMethodLookupTable::kHorizontal ?
910 header_area_ : footer_area_); 905 header_area_ : footer_area_);
911 } 906 }
912 907
913 void CandidateWindowView::HideAuxiliaryText() { 908 void CandidateWindowView::HideAuxiliaryText() {
914 GetAuxiliaryTextArea()->Hide(); 909 GetAuxiliaryTextArea()->Hide();
915 ResizeAndMoveParentFrame(); 910 ResizeAndMoveParentFrame();
(...skipping 20 matching lines...) Expand all
936 preedit_area_->Show(); 931 preedit_area_->Show();
937 ResizeAndMoveParentFrame(); 932 ResizeAndMoveParentFrame();
938 parent_frame_->Show(); 933 parent_frame_->Show();
939 } 934 }
940 935
941 void CandidateWindowView::UpdatePreeditText(const std::string& utf8_text) { 936 void CandidateWindowView::UpdatePreeditText(const std::string& utf8_text) {
942 preedit_area_->SetText(utf8_text); 937 preedit_area_->SetText(utf8_text);
943 } 938 }
944 939
945 void CandidateWindowView::ShowLookupTable() { 940 void CandidateWindowView::ShowLookupTable() {
946 bool was_visible = IsCandidateWindowOpen();
947 candidate_area_->Show(); 941 candidate_area_->Show();
948 ResizeAndMoveParentFrame(); 942 ResizeAndMoveParentFrame();
949 parent_frame_->Show(); 943 parent_frame_->Show();
950 if (!was_visible) { 944
945 NotifyIfCandidateWindowOpenedOrClosed();
946 }
947
948 void CandidateWindowView::NotifyIfCandidateWindowOpenedOrClosed() {
949 static bool was_open = false;
Yusuke Sato 2011/12/09 07:38:35 I think this does not work if the view object is c
950
951 bool is_open = IsCandidateWindowOpen();
952 if (!was_open && is_open) {
951 FOR_EACH_OBSERVER(Observer, observers_, OnCandidateWindowOpened()); 953 FOR_EACH_OBSERVER(Observer, observers_, OnCandidateWindowOpened());
954 } else if (was_open && !is_open) {
955 FOR_EACH_OBSERVER(Observer, observers_, OnCandidateWindowClosed());
952 } 956 }
957 was_open = is_open;
953 } 958 }
954 959
955 bool CandidateWindowView::ShouldUpdateCandidateViews( 960 bool CandidateWindowView::ShouldUpdateCandidateViews(
956 const InputMethodLookupTable& old_table, 961 const InputMethodLookupTable& old_table,
957 const InputMethodLookupTable& new_table) { 962 const InputMethodLookupTable& new_table) {
958 963
959 // Check if mozc lookup table location is changed. 964 // Check if mozc lookup table location is changed.
960 if (old_table.mozc_candidates.has_window_location() || 965 if (old_table.mozc_candidates.has_window_location() ||
961 new_table.mozc_candidates.has_window_location()) { 966 new_table.mozc_candidates.has_window_location()) {
962 967
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1181 // Compute views size in |layout|. 1186 // Compute views size in |layout|.
1182 // If we don't call this function, GetHorizontalOffset() often 1187 // If we don't call this function, GetHorizontalOffset() often
1183 // returns invalid value (returns 0), then candidate window 1188 // returns invalid value (returns 0), then candidate window
1184 // moves right from the correct position in ResizeAndMoveParentFrame(). 1189 // moves right from the correct position in ResizeAndMoveParentFrame().
1185 // TODO(nhiroki): Figure out why it returns invalid value. 1190 // TODO(nhiroki): Figure out why it returns invalid value.
1186 // It seems that the x-position of the candidate labels is not set. 1191 // It seems that the x-position of the candidate labels is not set.
1187 layout->Layout(candidate_area_contents); 1192 layout->Layout(candidate_area_contents);
1188 } 1193 }
1189 1194
1190 bool CandidateWindowView::IsCandidateWindowOpen() const { 1195 bool CandidateWindowView::IsCandidateWindowOpen() const {
1191 return candidate_area_->IsVisible() && candidate_area_->IsShown(); 1196 return !is_suggestion_window_location_available_ &&
1197 candidate_area_->IsVisible() && candidate_area_->IsShown();
1192 } 1198 }
1193 1199
1194 void CandidateWindowView::SelectCandidateAt(int index_in_page) { 1200 void CandidateWindowView::SelectCandidateAt(int index_in_page) {
1195 const int current_page_index = ComputePageIndex(lookup_table_); 1201 const int current_page_index = ComputePageIndex(lookup_table_);
1196 if (current_page_index < 0) { 1202 if (current_page_index < 0) {
1197 LOG(ERROR) << "Invalid lookup_table: " << lookup_table_.ToString(); 1203 LOG(ERROR) << "Invalid lookup_table: " << lookup_table_.ToString();
1198 return; 1204 return;
1199 } 1205 }
1200 1206
1201 const int cursor_absolute_index = 1207 const int cursor_absolute_index =
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 impl_->AddObserver(observer); 1782 impl_->AddObserver(observer);
1777 } 1783 }
1778 1784
1779 void CandidateWindowController::RemoveObserver( 1785 void CandidateWindowController::RemoveObserver(
1780 CandidateWindowController::Observer* observer) { 1786 CandidateWindowController::Observer* observer) {
1781 impl_->RemoveObserver(observer); 1787 impl_->RemoveObserver(observer);
1782 } 1788 }
1783 1789
1784 } // namespace input_method 1790 } // namespace input_method
1785 } // namespace chromeos 1791 } // 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