Index: content/renderer/render_widget.cc |
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc |
index bb06cfe956eaafc0f7e210d0a5f394ea25c9ea6a..30841c110a0e6864d1400e47046145e4a9ae73db 100644 |
--- a/content/renderer/render_widget.cc |
+++ b/content/renderer/render_widget.cc |
@@ -180,6 +180,8 @@ RenderWidget::RenderWidget(WebKit::WebPopupType popup_type, |
screen_info_(screen_info), |
device_scale_factor_(screen_info_.deviceScaleFactor), |
is_threaded_compositing_enabled_(false), |
+ strict_ime_processing_(false), |
+ outstanding_ime_acknowledgements_(0), |
weak_ptr_factory_(this) { |
if (!swapped_out) |
RenderProcess::current()->AddRefProcess(); |
@@ -189,6 +191,9 @@ RenderWidget::RenderWidget(WebKit::WebPopupType popup_type, |
is_threaded_compositing_enabled_ = |
CommandLine::ForCurrentProcess()->HasSwitch( |
switches::kEnableThreadedCompositing); |
+ strict_ime_processing_ = |
+ CommandLine::ForCurrentProcess()->HasSwitch( |
+ switches::kEnableStrictImeProcessing); |
RenderProcessVisibilityManager::GetInstance()->WidgetVisibilityChanged(true); |
} |
@@ -340,6 +345,7 @@ bool RenderWidget::OnMessageReceived(const IPC::Message& message) { |
IPC_MESSAGE_HANDLER(ViewMsg_ImeBatchStateChanged, OnImeBatchStateChanged) |
IPC_MESSAGE_HANDLER(ViewMsg_ShowImeIfNeeded, OnShowImeIfNeeded) |
#endif |
+ IPC_MESSAGE_HANDLER(ViewMsg_AcknowledgeImeEvent, OnImeAcknowledgeImeEvent) |
aurimas (slooooooooow)
2013/07/08 16:04:49
This Android specific so it should be moved to the
nyquist
2013/07/09 07:47:36
Done.
|
IPC_MESSAGE_HANDLER(ViewMsg_Snapshot, OnSnapshot) |
IPC_MESSAGE_HANDLER(ViewMsg_SetBrowserRenderingStats, |
OnSetBrowserRenderingStats) |
@@ -1524,7 +1530,8 @@ void RenderWidget::willBeginCompositorFrame() { |
// is done. |
UpdateTextInputType(); |
#if defined(OS_ANDROID) |
- UpdateTextInputState(DO_NOT_SHOW_IME); |
+ if (!has_strict_ime_processing()) |
+ UpdateTextInputState(DO_NOT_SHOW_IME); |
#endif |
UpdateSelectionBounds(); |
@@ -1770,6 +1777,8 @@ void RenderWidget::OnImeSetComposition( |
int selection_start, int selection_end) { |
if (!webwidget_) |
return; |
+ if (HasOutstandingImeEventAcknowledgements()) |
+ return; |
kochi
2013/07/08 04:28:43
Can you add #if defined(OS_ANDROID) around this?
nyquist
2013/07/09 07:47:36
Done.
|
ImeEventGuard guard(this); |
if (!webwidget_->setComposition( |
text, WebVector<WebCompositionUnderline>(underlines), |
@@ -1786,6 +1795,8 @@ void RenderWidget::OnImeConfirmComposition( |
const string16& text, const ui::Range& replacement_range) { |
if (!webwidget_) |
return; |
+ if (HasOutstandingImeEventAcknowledgements()) |
+ return; |
kochi
2013/07/08 04:28:43
Ditto.
nyquist
2013/07/09 07:47:36
Done.
|
ImeEventGuard guard(this); |
handling_input_event_ = true; |
webwidget_->confirmComposition(text); |
@@ -1964,6 +1975,22 @@ void RenderWidget::OnShowImeIfNeeded() { |
} |
#endif |
kochi
2013/07/08 04:28:43
Can you move this line below the following added s
nyquist
2013/07/09 07:47:36
Done.
|
+void RenderWidget::IncrementOutstandingImeEventAcknowledgements() { |
+ if (has_strict_ime_processing()) |
+ outstanding_ime_acknowledgements_++; |
kochi
2013/07/08 04:28:43
I thought we use pre-increment style in general, e
nyquist
2013/07/09 07:47:36
Done.
|
+} |
+ |
+void RenderWidget::OnImeAcknowledgeImeEvent() { |
+ if (has_strict_ime_processing()) { |
+ outstanding_ime_acknowledgements_--; |
kochi
2013/07/08 04:28:43
Ditto.
nyquist
2013/07/09 07:47:36
Done.
|
+ DCHECK(outstanding_ime_acknowledgements_ >= 0); |
+ } |
+} |
+ |
+bool RenderWidget::HasOutstandingImeEventAcknowledgements() { |
+ return has_strict_ime_processing() && outstanding_ime_acknowledgements_ > 0; |
+} |
+ |
void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) { |
if (device_scale_factor_ == device_scale_factor) |
return; |
@@ -2076,7 +2103,8 @@ void RenderWidget::FinishHandlingImeEvent() { |
// ime event. |
UpdateSelectionBounds(); |
#if defined(OS_ANDROID) |
- UpdateTextInputState(DO_NOT_SHOW_IME); |
+ if (!has_strict_ime_processing()) |
+ UpdateTextInputState(DO_NOT_SHOW_IME); |
#endif |
} |
@@ -2131,6 +2159,7 @@ void RenderWidget::UpdateTextInputState(ShowIme show_ime) { |
p.composition_end = new_info.compositionEnd; |
p.can_compose_inline = new_can_compose_inline; |
p.show_ime_if_needed = show_ime_if_needed; |
+ IncrementOutstandingImeEventAcknowledgements(); |
Send(new ViewHostMsg_TextInputStateChanged(routing_id(), p)); |
text_input_info_ = new_info; |