Delay selection bounds updates while handling ime events

While handling an IME event, the selection bounds may temporarily
change to incorrect values (just like other parts of the text input
state). Currently, we delay updates of the text input state until we
finish handling the IME event, but we process changes to the selection
bounds normally.

Instead, we should delay the selection bounds update until we have
finished handling the ime event.

So that both of these are handled consistently (and easily), introduce
an ImeEventGuard that guards handling of IME events with:
prologue:
  check handling_ime_event == false
  set handling_ime_event = true
epilogue:
  set handling_ime_event = false
  update text input state
  update selection bounds

Note that this fixes one instance of handling ime events inconsistently.

[email protected]
BUG=238444

Review URL: https://chromiumcodereview.appspot.com/14757009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201721 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h
index 47e6822..4b3d13d 100644
--- a/content/renderer/render_widget.h
+++ b/content/renderer/render_widget.h
@@ -209,6 +209,10 @@
     SHOW_IME_IF_NEEDED
   };
 
+  // Handle common setup/teardown for handling IME events.
+  void StartHandlingImeEvent();
+  void FinishHandlingImeEvent();
+
   virtual void InstrumentWillBeginFrame() {}
   virtual void InstrumentDidBeginFrame() {}
   virtual void InstrumentDidCancelFrame() {}