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

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

Issue 11956008: Move SetCursorLocation bypass code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unittests: add TextInputTestSupport initialzation Created 7 years, 10 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 | Annotate | Revision Log
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_controller_impl. h" 5 #include "chrome/browser/chromeos/input_method/candidate_window_controller_impl. h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 12 matching lines...) Expand all
23 #endif // USE_ASH 23 #endif // USE_ASH
24 24
25 namespace chromeos { 25 namespace chromeos {
26 namespace input_method { 26 namespace input_method {
27 27
28 namespace { 28 namespace {
29 // The milliseconds of the delay to show the infolist window. 29 // The milliseconds of the delay to show the infolist window.
30 const int kInfolistShowDelayMilliSeconds = 500; 30 const int kInfolistShowDelayMilliSeconds = 500;
31 // The milliseconds of the delay to hide the infolist window. 31 // The milliseconds of the delay to hide the infolist window.
32 const int kInfolistHideDelayMilliSeconds = 500; 32 const int kInfolistHideDelayMilliSeconds = 500;
33
34 // Converts from ibus::Rect to gfx::Rect.
35 gfx::Rect IBusRectToGfxRect(const ibus::Rect& rect) {
36 return gfx::Rect(rect.x, rect.y, rect.width, rect.height);
37 }
33 } // namespace 38 } // namespace
34 39
35 bool CandidateWindowControllerImpl::Init(IBusController* controller) { 40 bool CandidateWindowControllerImpl::Init(IBusController* controller) {
36 if (controller) 41 if (controller)
37 controller->AddObserver(this); 42 controller->AddObserver(this);
38 // Create the candidate window view. 43 // Create the candidate window view.
39 CreateView(); 44 CreateView();
40 45
41 // The observer should be added before Connect() so we can capture the 46 // The observer should be added before Connect() so we can capture the
42 // initial connection change. 47 // initial connection change.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 void CandidateWindowControllerImpl::OnHideLookupTable() { 122 void CandidateWindowControllerImpl::OnHideLookupTable() {
118 candidate_window_->HideLookupTable(); 123 candidate_window_->HideLookupTable();
119 infolist_window_->Hide(); 124 infolist_window_->Hide();
120 } 125 }
121 126
122 void CandidateWindowControllerImpl::OnHidePreeditText() { 127 void CandidateWindowControllerImpl::OnHidePreeditText() {
123 candidate_window_->HidePreeditText(); 128 candidate_window_->HidePreeditText();
124 } 129 }
125 130
126 void CandidateWindowControllerImpl::OnSetCursorLocation( 131 void CandidateWindowControllerImpl::OnSetCursorLocation(
127 const gfx::Rect& cursor_location, 132 const ibus::Rect& cursor_location,
128 const gfx::Rect& composition_head) { 133 const ibus::Rect& composition_head) {
129 // A workaround for http://crosbug.com/6460. We should ignore very short Y 134 // A workaround for http://crosbug.com/6460. We should ignore very short Y
130 // move to prevent the window from shaking up and down. 135 // move to prevent the window from shaking up and down.
131 const int kKeepPositionThreshold = 2; // px 136 const int kKeepPositionThreshold = 2; // px
132 const gfx::Rect& last_location = 137 const gfx::Rect& last_location =
133 candidate_window_->cursor_location(); 138 candidate_window_->cursor_location();
134 const int delta_y = abs(last_location.y() - cursor_location.y()); 139 const int delta_y = abs(last_location.y() - cursor_location.y);
135 if ((last_location.x() == cursor_location.x()) && 140 if ((last_location.x() == cursor_location.x) &&
136 (delta_y <= kKeepPositionThreshold)) { 141 (delta_y <= kKeepPositionThreshold)) {
137 DVLOG(1) << "Ignored set_cursor_location signal to prevent window shake"; 142 DVLOG(1) << "Ignored set_cursor_location signal to prevent window shake";
138 return; 143 return;
139 } 144 }
140 145
141 // Remember the cursor location. 146 // Remember the cursor location.
142 candidate_window_->set_cursor_location(cursor_location); 147 candidate_window_->set_cursor_location(IBusRectToGfxRect(cursor_location));
143 candidate_window_->set_composition_head_location(composition_head); 148 candidate_window_->set_composition_head_location(
149 IBusRectToGfxRect(composition_head));
144 // Move the window per the cursor location. 150 // Move the window per the cursor location.
145 candidate_window_->ResizeAndMoveParentFrame(); 151 candidate_window_->ResizeAndMoveParentFrame();
146 UpdateInfolistBounds(); 152 UpdateInfolistBounds();
147 } 153 }
148 154
149 void CandidateWindowControllerImpl::OnUpdateAuxiliaryText( 155 void CandidateWindowControllerImpl::OnUpdateAuxiliaryText(
150 const std::string& utf8_text, 156 const std::string& utf8_text,
151 bool visible) { 157 bool visible) {
152 // If it's not visible, hide the auxiliary text and return. 158 // If it's not visible, hide the auxiliary text and return.
153 if (!visible) { 159 if (!visible) {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 352
347 if (candidate_window_rect.y() + infolist_window_size.height() > 353 if (candidate_window_rect.y() + infolist_window_size.height() >
348 screen_rect.bottom()) 354 screen_rect.bottom())
349 result.set_y(screen_rect.bottom() - infolist_window_size.height()); 355 result.set_y(screen_rect.bottom() - infolist_window_size.height());
350 356
351 return result; 357 return result;
352 } 358 }
353 359
354 } // namespace input_method 360 } // namespace input_method
355 } // namespace chromeos 361 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698