Index: content/renderer/render_widget.cc |
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc |
index 7797b31cf3041a4f58b09656ab2a484985418220..b4bbc68d4522f8d525e4fc150db4f1b62f0b1f3e 100644 |
--- a/content/renderer/render_widget.cc |
+++ b/content/renderer/render_widget.cc |
@@ -246,12 +246,18 @@ 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), |
device_scale_factor_(screen_info_.deviceScaleFactor), |
#if defined(OS_ANDROID) |
text_field_is_dirty_(false), |
+ // Disable monitoring composition info by default on Android for |
+ // performance reasons. |
+ monitor_composition_info_(false), |
+#else |
+ monitor_composition_info_(true), |
aelias_OOO_until_Jul13
2016/07/25 22:21:56
Hmm, it looks like this was the way of fixing non-
Seigo Nonaka
2016/07/26 01:08:14
This line is necessary not only for testing purpos
aelias_OOO_until_Jul13
2016/07/26 01:22:24
I agree tying this to render process creation woul
Seigo Nonaka
2016/07/26 01:30:54
Setting true on getting text input focus and false
|
#endif |
popup_origin_scale_for_emulation_(0.f), |
frame_swap_message_queue_(new FrameSwapMessageQueue()), |
@@ -497,6 +503,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) |
@@ -1348,7 +1356,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, |
@@ -1365,7 +1373,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() { |
@@ -1446,19 +1454,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( |
@@ -1515,6 +1530,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() { |
@@ -1695,7 +1718,7 @@ void RenderWidget::UpdateSelectionBounds() { |
} |
} |
- UpdateCompositionInfo(false); |
+ UpdateCompositionInfo(false /* not an immediate request */); |
} |
void RenderWidget::SetDeviceColorProfileForTesting( |
@@ -1816,7 +1839,7 @@ void RenderWidget::resetInputMethod() { |
Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
} |
- UpdateCompositionInfo(true); |
+ UpdateCompositionInfo(false /* not an immediate request */); |
} |
#if defined(OS_ANDROID) |