| Index: content/browser/renderer_host/render_widget_host_view_win.cc
|
| diff --git a/content/browser/renderer_host/render_widget_host_view_win.cc b/content/browser/renderer_host/render_widget_host_view_win.cc
|
| index f653cdfb8c5ffb72155ca86048203800f04461ca..af42bdc5738068953598b7b3271c869ac977a0c0 100644
|
| --- a/content/browser/renderer_host/render_widget_host_view_win.cc
|
| +++ b/content/browser/renderer_host/render_widget_host_view_win.cc
|
| @@ -285,7 +285,8 @@ RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget)
|
| overlay_color_(0),
|
| text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
|
| is_fullscreen_(false),
|
| - ignore_mouse_movement_(true) {
|
| + ignore_mouse_movement_(true),
|
| + composition_range_(ui::Range::InvalidRange()) {
|
| render_widget_host_->SetView(this);
|
| registrar_.Add(this,
|
| content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
|
| @@ -670,6 +671,11 @@ void RenderWidgetHostViewWin::ImeCancelComposition() {
|
| ime_input_.CancelIME(m_hWnd);
|
| }
|
|
|
| +void RenderWidgetHostViewWin::ImeCompositionRangeChanged(
|
| + const ui::Range& range) {
|
| + composition_range_ = range;
|
| +}
|
| +
|
| BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lparam) {
|
| if (!webkit::npapi::WebPluginDelegateImpl::IsPluginDelegateWindow(hwnd))
|
| return TRUE;
|
| @@ -1277,6 +1283,31 @@ LRESULT RenderWidgetHostViewWin::OnImeEndComposition(
|
| return 0;
|
| }
|
|
|
| +LRESULT RenderWidgetHostViewWin::OnImeRequest(
|
| + UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled) {
|
| + if (!render_widget_host_) {
|
| + handled = FALSE;
|
| + return 0;
|
| + }
|
| +
|
| + // Should not receive WM_IME_REQUEST message, if IME is disabled.
|
| + if (text_input_type_ == ui::TEXT_INPUT_TYPE_NONE ||
|
| + text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD) {
|
| + handled = FALSE;
|
| + return 0;
|
| + }
|
| +
|
| + switch (wparam) {
|
| + case IMR_RECONVERTSTRING:
|
| + return OnReconvertString(reinterpret_cast<RECONVERTSTRING*>(lparam));
|
| + case IMR_DOCUMENTFEED:
|
| + return OnDocumentFeed(reinterpret_cast<RECONVERTSTRING*>(lparam));
|
| + default:
|
| + handled = FALSE;
|
| + return 0;
|
| + }
|
| +}
|
| +
|
| LRESULT RenderWidgetHostViewWin::OnMouseEvent(UINT message, WPARAM wparam,
|
| LPARAM lparam, BOOL& handled) {
|
| handled = TRUE;
|
| @@ -2025,3 +2056,87 @@ void RenderWidgetHostViewWin::HandleLockedMouseEvent(UINT message,
|
| ForwardMouseEventToRenderer(message, wparam, lparam);
|
| }
|
|
|
| +LRESULT RenderWidgetHostViewWin::OnDocumentFeed(RECONVERTSTRING* reconv) {
|
| + size_t target_offset;
|
| + size_t target_length;
|
| + bool has_composition;
|
| + if (!composition_range_.is_empty()) {
|
| + target_offset = composition_range_.GetMin();
|
| + target_length = composition_range_.length();
|
| + has_composition = true;
|
| + } else if (!selection_range_.is_empty()) {
|
| + target_offset = selection_range_.GetMin();
|
| + target_length = selection_range_.length();
|
| + has_composition = false;
|
| + } else {
|
| + return 0;
|
| + }
|
| +
|
| + size_t len = selection_text_.length();
|
| + size_t need_size = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR);
|
| +
|
| + if (target_offset < selection_text_offset_ ||
|
| + target_offset + target_length > selection_text_offset_ + len) {
|
| + return 0;
|
| + }
|
| +
|
| + if (!reconv)
|
| + return need_size;
|
| +
|
| + if (reconv->dwSize < need_size)
|
| + return 0;
|
| +
|
| + reconv->dwVersion = 0;
|
| + reconv->dwStrLen = len;
|
| + reconv->dwStrOffset = sizeof(RECONVERTSTRING);
|
| + reconv->dwCompStrLen = has_composition ? target_length: 0;
|
| + reconv->dwCompStrOffset =
|
| + (target_offset - selection_text_offset_) * sizeof(WCHAR);
|
| + reconv->dwTargetStrLen = target_length;
|
| + reconv->dwTargetStrOffset = reconv->dwCompStrOffset;
|
| + memcpy(reinterpret_cast<char*>(reconv) + sizeof(RECONVERTSTRING),
|
| + selection_text_.c_str(), len * sizeof(WCHAR));
|
| +
|
| + return reinterpret_cast<LRESULT>(reconv);
|
| +}
|
| +
|
| +LRESULT RenderWidgetHostViewWin::OnReconvertString(RECONVERTSTRING* reconv) {
|
| + // If there is a composition string already, we don't allow reconversion.
|
| + if (ime_input_.is_composing())
|
| + return 0;
|
| +
|
| + if (selection_range_.is_empty())
|
| + return 0;
|
| +
|
| + if (selection_text_.empty())
|
| + return 0;
|
| +
|
| + if (selection_range_.GetMin() < selection_text_offset_ ||
|
| + selection_range_.GetMax() >
|
| + selection_text_offset_ + selection_text_.length()) {
|
| + return 0;
|
| + }
|
| +
|
| + size_t len = selection_range_.length();
|
| + size_t need_size = sizeof(RECONVERTSTRING) + len * sizeof(WCHAR);
|
| +
|
| + if (!reconv)
|
| + return need_size;
|
| +
|
| + if (reconv->dwSize < need_size)
|
| + return 0;
|
| +
|
| + reconv->dwVersion = 0;
|
| + reconv->dwStrLen = len;
|
| + reconv->dwStrOffset = sizeof(RECONVERTSTRING);
|
| + reconv->dwCompStrLen = len;
|
| + reconv->dwCompStrOffset = 0;
|
| + reconv->dwTargetStrLen = len;
|
| + reconv->dwTargetStrOffset = 0;
|
| +
|
| + size_t offset = selection_range_.GetMin() - selection_text_offset_;
|
| + memcpy(reinterpret_cast<char*>(reconv) + sizeof(RECONVERTSTRING),
|
| + selection_text_.c_str() + offset, len * sizeof(WCHAR));
|
| +
|
| + return reinterpret_cast<LRESULT>(reconv);
|
| +}
|
|
|