summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-13 04:26:34 +0000
committersatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-13 04:26:34 +0000
commit41ead287f9c0459e7dcbbebf308f8d565f7efbb9 (patch)
treefc2cdd41fe68a8b0c364a417702bfe772f5841ff
parent2974a806165d55fca9f5a32d4fb057203ddd99d6 (diff)
downloadchromium_src-41ead287f9c0459e7dcbbebf308f8d565f7efbb9.zip
chromium_src-41ead287f9c0459e7dcbbebf308f8d565f7efbb9.tar.gz
chromium_src-41ead287f9c0459e7dcbbebf308f8d565f7efbb9.tar.bz2
Move the candidate window to right position, if size or visibility of candidate window is changed
BUG=chromium-os:9950 TEST=manual Review URL: http://codereview.chromium.org/5582004 Patch from Peng Huang <penghuang@chromium.org>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68980 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/input_method/candidate_window.cc44
1 files changed, 34 insertions, 10 deletions
diff --git a/chrome/browser/chromeos/input_method/candidate_window.cc b/chrome/browser/chromeos/input_method/candidate_window.cc
index c6add2e..6a30f98 100644
--- a/chrome/browser/chromeos/input_method/candidate_window.cc
+++ b/chrome/browser/chromeos/input_method/candidate_window.cc
@@ -403,11 +403,19 @@ class CandidateWindowView : public views::View {
// Returns 0 if no candidate is present.
int GetHorizontalOffset();
- const gfx::Rect& cursor_location() const { return cursor_location_; }
void set_cursor_location(const gfx::Rect& cursor_location) {
cursor_location_ = cursor_location;
}
+ const gfx::Rect& cursor_location() const { return cursor_location_; }
+
+ protected:
+ // Override View::VisibilityChanged()
+ virtual void VisibilityChanged(View* starting_from, bool is_visible);
+
+ // Override View::VisibleBoundsInRootChanged()
+ virtual void VisibleBoundsInRootChanged();
+
private:
// Initializes the candidate views if needed.
void MaybeInitializeCandidateViews(
@@ -733,6 +741,8 @@ CandidateWindowView::CandidateWindowView(
previous_shortcut_column_width_(0),
previous_candidate_column_width_(0),
previous_annotation_column_width_(0) {
+
+ SetNotifyWhenVisibleBoundsInRootChanges(true);
}
void CandidateWindowView::Init() {
@@ -789,9 +799,12 @@ void CandidateWindowView::ShowAuxiliaryText() {
lookup_table_.orientation == InputMethodLookupTable::kHorizontal ?
header_area_contents_.get() :
footer_area_contents_.get());
- // Put contents to the target display area.
- target_area->RemoveAllChildViews(false); // Don't delete child views.
- target_area->AddChildView(target_contents);
+
+ if (!target_area->HasChildView(target_contents)) {
+ // If contents not in display area, put it in.
+ target_area->RemoveAllChildViews(false); // Don't delete child views.
+ target_area->AddChildView(target_contents);
+ }
}
void CandidateWindowView::UpdateAuxiliaryText(const std::string& utf8_text) {
@@ -1164,6 +1177,20 @@ int CandidateWindowView::GetHorizontalOffset() {
return 0;
}
+void CandidateWindowView::VisibilityChanged(View* starting_from,
+ bool is_visible) {
+ if (is_visible) {
+ // If the visibility of candidate window is changed,
+ // we should move the frame to the right position.
+ MoveParentFrame();
+ }
+}
+
+void CandidateWindowView::VisibleBoundsInRootChanged() {
+ // If the bounds(size) of candidate window is changed,
+ // we should move the frame to the right position.
+ MoveParentFrame();
+}
bool CandidateWindowController::Impl::Init() {
// Initialize the input method UI status connection.
@@ -1232,7 +1259,7 @@ void CandidateWindowController::Impl::OnHideAuxiliaryText(
static_cast<CandidateWindowController::Impl*>(input_method_library);
controller->candidate_window_->HideAuxiliaryText();
- controller->candidate_window_->ResizeAndMoveParentFrame();
+ controller->candidate_window_->ResizeParentFrame();
}
void CandidateWindowController::Impl::OnHideLookupTable(
@@ -1283,7 +1310,7 @@ void CandidateWindowController::Impl::OnUpdateAuxiliaryText(
}
controller->candidate_window_->UpdateAuxiliaryText(utf8_text);
controller->candidate_window_->ShowAuxiliaryText();
- controller->candidate_window_->ResizeAndMoveParentFrame();
+ controller->candidate_window_->ResizeParentFrame();
}
void CandidateWindowController::Impl::OnUpdateLookupTable(
@@ -1299,11 +1326,8 @@ void CandidateWindowController::Impl::OnUpdateLookupTable(
}
controller->candidate_window_->UpdateCandidates(lookup_table);
+ controller->candidate_window_->ResizeParentFrame();
controller->frame_->Show();
- // We should move the candidate window after controller->frame_->Show(),
- // as GetHorizontalOffset() returns a valid value only after the Show()
- // method is called.
- controller->candidate_window_->ResizeAndMoveParentFrame();
}
void CandidateWindowController::Impl::OnCandidateCommitted(int index,