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

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: remove OS_ANDROID from render_widget.cc 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
Index: content/renderer/render_widget.cc
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index 8a771c9ee7bfb6aad650489888624ebfcc58670b..b9613fbfee44cfa24f44f6c484996740bffe0b5d 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()),
@@ -500,6 +502,8 @@ bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
OnRequestTextInputStateUpdate)
IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded)
#endif
+ IPC_MESSAGE_HANDLER(InputMsg_RequestCompositionUpdate,
+ OnRequestCompositionUpdate)
nasko 2016/07/29 16:26:10 nit: This should move before the #if defined(OS_AN
Seigo Nonaka 2016/08/01 02:27:35 Done.
IPC_MESSAGE_HANDLER(ViewMsg_HandleCompositorProto, OnHandleCompositorProto)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -899,6 +903,7 @@ void RenderWidget::UpdateTextInputState(ShowIme show_ime,
}
ui::TextInputType new_type = GetTextInputType();
+
nasko 2016/07/29 16:26:10 Was this new empty line intentional?
Seigo Nonaka 2016/08/01 02:27:35 No, removed.
if (IsDateTimeInput(new_type))
return; // Not considered as a text input field in WebKit/Chromium.
@@ -1358,7 +1363,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 +1392,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 +1477,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(
@@ -1543,6 +1555,14 @@ void RenderWidget::OnRequestTextInputStateUpdate() {
}
#endif
+void RenderWidget::OnRequestCompositionUpdate(bool immediate_request,
+ bool monitor_request) {
+ monitor_composition_info_ = monitor_request;
+ if (!immediate_request)
+ return;
+ UpdateCompositionInfo(true /* immediate request */);
+}
+
bool RenderWidget::ShouldHandleImeEvent() {
#if defined(OS_ANDROID)
if (!webwidget_)
@@ -1734,7 +1754,7 @@ void RenderWidget::UpdateSelectionBounds() {
}
}
- UpdateCompositionInfo(false);
+ UpdateCompositionInfo(false /* not an immediate request */);
}
void RenderWidget::SetDeviceColorProfileForTesting(
@@ -1879,7 +1899,7 @@ void RenderWidget::resetInputMethod() {
Send(new InputHostMsg_ImeCancelComposition(routing_id()));
}
- UpdateCompositionInfo(true);
+ UpdateCompositionInfo(false /* not an immediate request */);
}
#if defined(OS_ANDROID)
« content/browser/renderer_host/ime_adapter_android.cc ('K') | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698