Add IPC argument to handle composition character bounds into ViewHostMsg_ImeCompositionRangeChanged.
What for:
Using this argument, browser can acquire the composition character boundary rectangles.
This information is used by Japanese input method editor to show its window at the correct position.
This is used not only for fixing http://crbug.com/120597 but also for supporting IMR_QUERYCHARPOSITION message in Windows Chrome.
To support IMR_QUERYCHARPOSITION(Ref 1) message, input method editor can also show its window at the correct position(Ref 2).
Performance:
There is no performance concern for latin language users because this IPC is only emitted if the user uses an input method editor.
Even if the user uses an input method editor, the cost of this IPC is small because this IPC will be emitted at the same frequency as key typing.
Data size:
The data size to be transferred is small: it is the composition string length (typically less than a few dozen characters) times sizeof(gfx::Rect).
Ref 1. http://msdn.microsoft.com/en-us/library/windows/desktop/dd318634(v=vs.85).aspx
Ref 2. https://bug-87911-attachments.webkit.org/attachment.cgi?id=144954
(In Ref2, Safari works well for all IMEs. Firefox works well except ATOK. Chrome doesn't work for all IMEs.)
BUG=120597
TEST=try bots.
Review URL: https://chromiumcodereview.appspot.com/10543024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141866 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h
index 194d40c..2fcede8 100644
--- a/content/renderer/render_widget.h
+++ b/content/renderer/render_widget.h
@@ -25,6 +25,7 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/ime/text_input_type.h"
+#include "ui/base/range/range.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/size.h"
@@ -320,13 +321,34 @@
// Checks if the selection bounds have been changed. If they are changed,
// the new value will be sent to the browser process.
- void UpdateSelectionBounds();
+ virtual void UpdateSelectionBounds();
+
+ // Checks if the composition range or composition character bounds have been
+ // changed. If they are changed, the new value will be sent to the browser
+ // process.
+ virtual void UpdateCompositionInfo(
+ const ui::Range& range,
+ const std::vector<gfx::Rect>& character_bounds);
+
// Override point to obtain that the current input method state and caret
// position.
virtual ui::TextInputType GetTextInputType();
virtual void GetSelectionBounds(gfx::Rect* start, gfx::Rect* end);
+ // Override point to obtain that the current composition character bounds.
+ // In the case of surrogate pairs, the character is treated as two characters:
+ // the bounds for first character is actual one, and the bounds for second
+ // character is zero width rectangle.
+ virtual void GetCompositionCharacterBounds(
+ std::vector<gfx::Rect>* character_bounds);
+
+ // Returns true if the composition range or composition character bounds
+ // should be sent to the browser process.
+ bool ShouldUpdateCompositionInfo(
+ const ui::Range& range,
+ const std::vector<gfx::Rect>& bounds);
+
// Override point to obtain that the current input method state about
// composition text.
virtual bool CanComposeInline();
@@ -478,6 +500,12 @@
gfx::Rect selection_start_rect_;
gfx::Rect selection_end_rect_;
+ // Stores the current composition character bounds.
+ std::vector<gfx::Rect> composition_character_bounds_;
+
+ // Stores the current composition range.
+ ui::Range composition_range_;
+
// The kind of popup this widget represents, NONE if not a popup.
WebKit::WebPopupType popup_type_;