Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(676)

Side by Side Diff: content/renderer/render_widget.cc

Issue 1995333002: Handle newCursorPosition correctly for Android's commitText() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: adjust selection in confirmCompositionOrInsertText() Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 // If we failed to set the composition text, then we need to let the browser 1367 // If we failed to set the composition text, then we need to let the browser
1368 // process to cancel the input method's ongoing composition session, to make 1368 // process to cancel the input method's ongoing composition session, to make
1369 // sure we are in a consistent state. 1369 // sure we are in a consistent state.
1370 Send(new InputHostMsg_ImeCancelComposition(routing_id())); 1370 Send(new InputHostMsg_ImeCancelComposition(routing_id()));
1371 } 1371 }
1372 UpdateCompositionInfo(false /* not an immediate request */); 1372 UpdateCompositionInfo(false /* not an immediate request */);
1373 } 1373 }
1374 1374
1375 void RenderWidget::OnImeConfirmComposition(const base::string16& text, 1375 void RenderWidget::OnImeConfirmComposition(const base::string16& text,
1376 const gfx::Range& replacement_range, 1376 const gfx::Range& replacement_range,
1377 bool keep_selection) { 1377 bool keep_selection,
1378 int new_cursor_pos) {
1378 #if defined(ENABLE_PLUGINS) 1379 #if defined(ENABLE_PLUGINS)
1379 if (focused_pepper_plugin_) { 1380 if (focused_pepper_plugin_) {
1380 focused_pepper_plugin_->render_frame()->OnImeConfirmComposition( 1381 focused_pepper_plugin_->render_frame()->OnImeConfirmComposition(
1381 text, replacement_range, keep_selection); 1382 text, replacement_range, keep_selection, new_cursor_pos);
1382 return; 1383 return;
1383 } 1384 }
1384 #endif 1385 #endif
1385 if (replacement_range.IsValid()) { 1386 if (replacement_range.IsValid()) {
1386 webwidget_->applyReplacementRange(replacement_range.start(), 1387 webwidget_->applyReplacementRange(replacement_range.start(),
1387 replacement_range.length()); 1388 replacement_range.length());
1388 } 1389 }
1389 1390
1390 if (!ShouldHandleImeEvent()) 1391 if (!ShouldHandleImeEvent())
1391 return; 1392 return;
1392 ImeEventGuard guard(this); 1393 ImeEventGuard guard(this);
1393 input_handler_->set_handling_input_event(true); 1394 input_handler_->set_handling_input_event(true);
1394 if (text.length()) 1395 if (text.length())
1395 webwidget_->confirmComposition(text); 1396 webwidget_->confirmComposition(text, new_cursor_pos);
1396 else if (keep_selection) 1397 else if (keep_selection)
1397 webwidget_->confirmComposition(WebWidget::KeepSelection); 1398 webwidget_->confirmComposition(WebWidget::KeepSelection, new_cursor_pos);
1398 else 1399 else
1399 webwidget_->confirmComposition(WebWidget::DoNotKeepSelection); 1400 webwidget_->confirmComposition(WebWidget::DoNotKeepSelection,
1401 new_cursor_pos);
1400 input_handler_->set_handling_input_event(false); 1402 input_handler_->set_handling_input_event(false);
1401 UpdateCompositionInfo(false /* not an immediate request */); 1403 UpdateCompositionInfo(false /* not an immediate request */);
1402 } 1404 }
1403 1405
1404 void RenderWidget::OnDeviceScaleFactorChanged() { 1406 void RenderWidget::OnDeviceScaleFactorChanged() {
1405 if (!compositor_) 1407 if (!compositor_)
1406 return; 1408 return;
1407 if (IsUseZoomForDSFEnabled()) 1409 if (IsUseZoomForDSFEnabled())
1408 compositor_->SetPaintedDeviceScaleFactor(GetOriginalDeviceScaleFactor()); 1410 compositor_->SetPaintedDeviceScaleFactor(GetOriginalDeviceScaleFactor());
1409 else 1411 else
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 return screen_info_; 1896 return screen_info_;
1895 } 1897 }
1896 1898
1897 void RenderWidget::resetInputMethod() { 1899 void RenderWidget::resetInputMethod() {
1898 ImeEventGuard guard(this); 1900 ImeEventGuard guard(this);
1899 // If the last text input type is not None, then we should finish any 1901 // If the last text input type is not None, then we should finish any
1900 // ongoing composition regardless of the new text input type. 1902 // ongoing composition regardless of the new text input type.
1901 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) { 1903 if (text_input_type_ != ui::TEXT_INPUT_TYPE_NONE) {
1902 // If a composition text exists, then we need to let the browser process 1904 // If a composition text exists, then we need to let the browser process
1903 // to cancel the input method's ongoing composition session. 1905 // to cancel the input method's ongoing composition session.
1904 if (webwidget_->confirmComposition()) 1906 if (webwidget_->confirmComposition(1))
Changwan Ryu 2016/08/03 07:37:30 you shouldn't pass 1 here
yabinh 2016/08/08 07:33:43 Done.
1905 Send(new InputHostMsg_ImeCancelComposition(routing_id())); 1907 Send(new InputHostMsg_ImeCancelComposition(routing_id()));
1906 } 1908 }
1907 1909
1908 UpdateCompositionInfo(false /* not an immediate request */); 1910 UpdateCompositionInfo(false /* not an immediate request */);
1909 } 1911 }
1910 1912
1911 #if defined(OS_ANDROID) 1913 #if defined(OS_ANDROID)
1912 void RenderWidget::showUnhandledTapUIIfNeeded( 1914 void RenderWidget::showUnhandledTapUIIfNeeded(
1913 const WebPoint& tapped_position, 1915 const WebPoint& tapped_position,
1914 const WebNode& tapped_node, 1916 const WebNode& tapped_node,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
2066 void RenderWidget::requestPointerUnlock() { 2068 void RenderWidget::requestPointerUnlock() {
2067 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); 2069 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get());
2068 } 2070 }
2069 2071
2070 bool RenderWidget::isPointerLocked() { 2072 bool RenderWidget::isPointerLocked() {
2071 return mouse_lock_dispatcher_->IsMouseLockedTo( 2073 return mouse_lock_dispatcher_->IsMouseLockedTo(
2072 webwidget_mouse_lock_target_.get()); 2074 webwidget_mouse_lock_target_.get());
2073 } 2075 }
2074 2076
2075 } // namespace content 2077 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698