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

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: skip composition calculation when the focused not is not editable. 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 8a771c9ee7bfb6aad650489888624ebfcc58670b..31bfc66a3cd8d7669b91a00a4f27aad7950e7dc6 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -246,6 +246,7 @@ RenderWidget::RenderWidget(CompositorDependencies* compositor_deps,
text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
text_input_flags_(0),
can_compose_inline_(true),
+ composition_range_(gfx::Range::InvalidRange()),
popup_type_(popup_type),
pending_window_rect_count_(0),
screen_info_(screen_info),
@@ -253,6 +254,7 @@ RenderWidget::RenderWidget(CompositorDependencies* compositor_deps,
#if defined(OS_ANDROID)
text_field_is_dirty_(false),
#endif
+ monitor_composition_info_(false),
popup_origin_scale_for_emulation_(0.f),
frame_swap_message_queue_(new FrameSwapMessageQueue()),
resizing_mode_selector_(new ResizingModeSelector()),
@@ -498,6 +500,8 @@ bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(InputMsg_ImeEventAck, OnImeEventAck)
IPC_MESSAGE_HANDLER(InputMsg_RequestTextInputStateUpdate,
OnRequestTextInputStateUpdate)
+ IPC_MESSAGE_HANDLER(InputMsg_RequestCompositionUpdate,
+ OnRequestCompositionUpdate)
IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded)
#endif
IPC_MESSAGE_HANDLER(ViewMsg_HandleCompositorProto, OnHandleCompositorProto)
@@ -899,6 +903,13 @@ void RenderWidget::UpdateTextInputState(ShowIme show_ime,
}
ui::TextInputType new_type = GetTextInputType();
+#if !defined(OS_ANDROID)
aelias_OOO_until_Jul13 2016/07/26 19:26:02 Sorry, I realize you're just following the convent
Seigo Nonaka 2016/07/28 09:10:59 Sure, for Mac OSX, it is not a monitor implementat
+ // Monitor the composition information during the focused node is text input
+ // node. On Android, monitor_composition_info_ is controlled by
+ // RequestCompositionUpdate message.
+ monitor_composition_info_ = new_type != ui::TEXT_INPUT_TYPE_NONE;
+#endif
+
if (IsDateTimeInput(new_type))
return; // Not considered as a text input field in WebKit/Chromium.
@@ -1358,7 +1369,7 @@ void RenderWidget::OnImeSetComposition(
// sure we are in a consistent state.
Send(new InputHostMsg_ImeCancelComposition(routing_id()));
}
- UpdateCompositionInfo(true);
+ UpdateCompositionInfo(false /* not an immediate request */);
}
void RenderWidget::OnImeConfirmComposition(const base::string16& text,
@@ -1387,7 +1398,7 @@ void RenderWidget::OnImeConfirmComposition(const base::string16& text,
else
webwidget_->confirmComposition(WebWidget::DoNotKeepSelection);
input_handler_->set_handling_input_event(false);
- UpdateCompositionInfo(true);
+ UpdateCompositionInfo(false /* not an immediate request */);
}
void RenderWidget::OnDeviceScaleFactorChanged() {
@@ -1472,19 +1483,26 @@ ui::TextInputType RenderWidget::GetTextInputType() {
return ui::TEXT_INPUT_TYPE_NONE;
}
-void RenderWidget::UpdateCompositionInfo(bool should_update_range) {
+void RenderWidget::UpdateCompositionInfo(bool immediate_request) {
+ if (!monitor_composition_info_ && !immediate_request)
+ return; // Do not calculate composition info if not requested.
+
TRACE_EVENT0("renderer", "RenderWidget::UpdateCompositionInfo");
- gfx::Range range = gfx::Range();
- if (should_update_range) {
- GetCompositionRange(&range);
+ gfx::Range range;
+ std::vector<gfx::Rect> character_bounds;
+
+ if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE) {
+ // Composition information is only available on editable node.
+ range = gfx::Range::InvalidRange();
} else {
- range = composition_range_;
+ GetCompositionRange(&range);
+ GetCompositionCharacterBounds(&character_bounds);
}
- std::vector<gfx::Rect> character_bounds;
- GetCompositionCharacterBounds(&character_bounds);
- if (!ShouldUpdateCompositionInfo(range, character_bounds))
+ if (!immediate_request &&
+ !ShouldUpdateCompositionInfo(range, character_bounds)) {
return;
+ }
composition_character_bounds_ = character_bounds;
composition_range_ = range;
Send(new InputHostMsg_ImeCompositionRangeChanged(
@@ -1541,6 +1559,14 @@ void RenderWidget::OnRequestTextInputStateUpdate() {
UpdateSelectionBounds();
UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_IME);
}
+
+void RenderWidget::OnRequestCompositionUpdate(bool immediate_request,
+ bool monitor_request) {
+ monitor_composition_info_ = monitor_request;
+ if (!immediate_request)
+ return;
+ UpdateCompositionInfo(true /* immediate request */);
+}
#endif
bool RenderWidget::ShouldHandleImeEvent() {
@@ -1734,7 +1760,7 @@ void RenderWidget::UpdateSelectionBounds() {
}
}
- UpdateCompositionInfo(false);
+ UpdateCompositionInfo(false /* not an immediate request */);
}
void RenderWidget::SetDeviceColorProfileForTesting(
@@ -1879,7 +1905,7 @@ void RenderWidget::resetInputMethod() {
Send(new InputHostMsg_ImeCancelComposition(routing_id()));
}
- UpdateCompositionInfo(true);
+ UpdateCompositionInfo(false /* not an immediate request */);
}
#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