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

Unified Diff: ui/views/controls/textfield/textfield_model.cc

Issue 2886313002: Prevent the IME candidate window from flickering on Chrome OS (Closed)
Patch Set: address a comment from shuchen@ Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/views/controls/textfield/textfield_model_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/textfield/textfield_model.cc
diff --git a/ui/views/controls/textfield/textfield_model.cc b/ui/views/controls/textfield/textfield_model.cc
index 392abf88c361944ef18c7e991dd2a7edf842c437..f4d2282c55a72775bf2f779e8ad7748e9dcf2b72 100644
--- a/ui/views/controls/textfield/textfield_model.cc
+++ b/ui/views/controls/textfield/textfield_model.cc
@@ -282,6 +282,23 @@ void SetKillBuffer(const base::string16& buffer) {
*kill_buffer = buffer;
}
+void SelectRangeInCompositionText(gfx::RenderText* render_text,
+ size_t cursor,
+ const gfx::Range& range) {
+ DCHECK(render_text);
+ DCHECK(range.IsValid());
+ uint32_t start = range.GetMin();
+ uint32_t end = range.GetMax();
+#if defined(OS_CHROMEOS)
+ // Swap |start| and |end| so that GetCaretBounds() can always return the same
+ // value during conversion.
+ // TODO(yusukes): Check if this works for other platforms. If it is, use this
+ // on all platforms.
+ std::swap(start, end);
+#endif
+ render_text->SelectRange(gfx::Range(cursor + start, cursor + end));
oshima 2017/05/22 09:55:21 what's the reason why we don't change the UI side
Yusuke Sato 2017/05/22 16:55:02 That's another option, but strictly speaking, if w
+}
+
} // namespace
using internal::Edit;
@@ -656,13 +673,10 @@ void TextfieldModel::SetCompositionText(
// range (or caret position) in the composition here we use a selection-like
// marker instead to show this range.
// TODO(yukawa, msw): Support thick underlines and remove this workaround.
- render_text_->SelectRange(gfx::Range(
- cursor + emphasized_range.GetMin(),
- cursor + emphasized_range.GetMax()));
+ SelectRangeInCompositionText(render_text_.get(), cursor, emphasized_range);
} else if (!composition.selection.is_empty()) {
- render_text_->SelectRange(gfx::Range(
- cursor + composition.selection.GetMin(),
- cursor + composition.selection.GetMax()));
+ SelectRangeInCompositionText(render_text_.get(), cursor,
+ composition.selection);
} else {
render_text_->SetCursorPosition(cursor + composition.selection.end());
}
« no previous file with comments | « no previous file | ui/views/controls/textfield/textfield_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698