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

Unified Diff: content/renderer/render_widget.cc

Issue 2121953002: Do not calculate composition bounds until IME requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 5 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 | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_widget.cc
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index 129ed07f6eb454e478f97327fc3e4969ea84065a..f6e01e6c24dcb9b6584a99a32095a861bd0d11e3 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -252,6 +252,7 @@ RenderWidget::RenderWidget(CompositorDependencies* compositor_deps,
device_scale_factor_(screen_info_.deviceScaleFactor),
#if defined(OS_ANDROID)
text_field_is_dirty_(false),
+ monitor_composition_info_(false),
#endif
popup_origin_scale_for_emulation_(0.f),
frame_swap_message_queue_(new FrameSwapMessageQueue()),
@@ -497,6 +498,7 @@ bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(InputMsg_ImeEventAck, OnImeEventAck)
IPC_MESSAGE_HANDLER(InputMsg_RequestTextInputStateUpdate,
OnRequestTextInputStateUpdate)
+ IPC_MESSAGE_HANDLER(InputMsg_RequestCursorUpdate, OnRequestCursorUpdate)
IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded)
#endif
IPC_MESSAGE_HANDLER(ViewMsg_HandleCompositorProto, OnHandleCompositorProto)
@@ -1371,7 +1373,7 @@ void RenderWidget::OnImeSetComposition(
// sure we are in a consistent state.
Send(new InputHostMsg_ImeCancelComposition(routing_id()));
}
- UpdateCompositionInfo(true);
+ UpdateCompositionInfo(true, false /* force update */);
}
void RenderWidget::OnImeConfirmComposition(const base::string16& text,
@@ -1388,7 +1390,7 @@ void RenderWidget::OnImeConfirmComposition(const base::string16& text,
else
webwidget_->confirmComposition(WebWidget::DoNotKeepSelection);
input_handler_->set_handling_input_event(false);
- UpdateCompositionInfo(true);
+ UpdateCompositionInfo(true, false /* force update */);
}
void RenderWidget::OnDeviceScaleFactorChanged() {
@@ -1469,7 +1471,12 @@ ui::TextInputType RenderWidget::GetTextInputType() {
return ui::TEXT_INPUT_TYPE_NONE;
}
-void RenderWidget::UpdateCompositionInfo(bool should_update_range) {
+void RenderWidget::UpdateCompositionInfo(
+ bool should_update_range, bool force_update) {
+#if defined(OS_ANDROID)
+ if (!monitor_composition_info_)
+ return; // Do not calculate composition info if not requested.
+#endif // OS_ANDROID
TRACE_EVENT0("renderer", "RenderWidget::UpdateCompositionInfo");
gfx::Range range = gfx::Range();
if (should_update_range) {
@@ -1480,7 +1487,7 @@ void RenderWidget::UpdateCompositionInfo(bool should_update_range) {
std::vector<gfx::Rect> character_bounds;
GetCompositionCharacterBounds(&character_bounds);
- if (!ShouldUpdateCompositionInfo(range, character_bounds))
+ if (!force_update && !ShouldUpdateCompositionInfo(range, character_bounds))
return;
composition_character_bounds_ = character_bounds;
composition_range_ = range;
@@ -1538,6 +1545,20 @@ void RenderWidget::OnRequestTextInputStateUpdate() {
UpdateSelectionBounds();
UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_IME);
}
+void RenderWidget::OnRequestCursorUpdate(int mode) {
yosin_UTC9 2016/07/06 03:33:08 How about using two bool parameters to match with
Seigo Nonaka 2016/07/06 05:46:04 Sure, personally, enum is rarely used for this cas
+ // See
+ // https://developer.android.com/reference/android/view/inputmethod/InputConnection.html
+ const int CURSOR_UPDATE_IMMEDIATE = 1;
+ const int CURSOR_UPDATE_MONITOR = 1 << 1;
+
+ if (mode & CURSOR_UPDATE_MONITOR)
yosin_UTC9 2016/07/06 03:33:08 How about monitor_composition_info_ = mode & CURSO
Seigo Nonaka 2016/07/06 05:46:04 You are right, but I moved this calculation to Jav
+ monitor_composition_info_ = true;
+ else
+ monitor_composition_info_ = false;
+
+ if (mode & CURSOR_UPDATE_IMMEDIATE)
yosin_UTC9 2016/07/06 03:33:08 How about if (!(mode & CURSOR_UPDATE_IMMEDIATE)
Seigo Nonaka 2016/07/06 05:46:04 Hmm, introducing const boolean sounds overkill to
+ UpdateCompositionInfo(true, true /* force update */);
+}
#endif
bool RenderWidget::ShouldHandleImeEvent() {
@@ -1718,7 +1739,7 @@ void RenderWidget::UpdateSelectionBounds() {
}
}
- UpdateCompositionInfo(false);
+ UpdateCompositionInfo(false, false /* force update */);
}
void RenderWidget::SetDeviceColorProfileForTesting(
@@ -1818,7 +1839,7 @@ void RenderWidget::resetInputMethod() {
Send(new InputHostMsg_ImeCancelComposition(routing_id()));
}
- UpdateCompositionInfo(true);
+ UpdateCompositionInfo(true, false /* force update */);
}
#if defined(OS_ANDROID)
« no previous file with comments | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698