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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 1995333002: Handle newCursorPosition correctly for Android's commitText() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split confirmComposition into 2 Created 4 years, 3 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/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after
1358 text_input_manager_->GetActiveWidget()->ImeSetComposition( 1358 text_input_manager_->GetActiveWidget()->ImeSetComposition(
1359 composition.text, underlines, gfx::Range::InvalidRange(), 1359 composition.text, underlines, gfx::Range::InvalidRange(),
1360 composition.selection.end(), composition.selection.end()); 1360 composition.selection.end(), composition.selection.end());
1361 1361
1362 has_composition_text_ = !composition.text.empty(); 1362 has_composition_text_ = !composition.text.empty();
1363 } 1363 }
1364 1364
1365 void RenderWidgetHostViewAura::ConfirmCompositionText() { 1365 void RenderWidgetHostViewAura::ConfirmCompositionText() {
1366 if (text_input_manager_ && text_input_manager_->GetActiveWidget() && 1366 if (text_input_manager_ && text_input_manager_->GetActiveWidget() &&
1367 has_composition_text_) { 1367 has_composition_text_) {
1368 text_input_manager_->GetActiveWidget()->ImeConfirmComposition( 1368 text_input_manager_->GetActiveWidget()->ImeFinishComposingText(false);
1369 base::string16(), gfx::Range::InvalidRange(), false);
1370 } 1369 }
1371 has_composition_text_ = false; 1370 has_composition_text_ = false;
1372 } 1371 }
1373 1372
1374 void RenderWidgetHostViewAura::ClearCompositionText() { 1373 void RenderWidgetHostViewAura::ClearCompositionText() {
1375 if (text_input_manager_ && text_input_manager_->GetActiveWidget() && 1374 if (text_input_manager_ && text_input_manager_->GetActiveWidget() &&
1376 has_composition_text_) 1375 has_composition_text_)
1377 text_input_manager_->GetActiveWidget()->ImeCancelComposition(); 1376 text_input_manager_->GetActiveWidget()->ImeCancelComposition();
1378 has_composition_text_ = false; 1377 has_composition_text_ = false;
1379 } 1378 }
1380 1379
1381 void RenderWidgetHostViewAura::InsertText(const base::string16& text) { 1380 void RenderWidgetHostViewAura::InsertText(const base::string16& text) {
1382 DCHECK_NE(GetTextInputType(), ui::TEXT_INPUT_TYPE_NONE); 1381 DCHECK_NE(GetTextInputType(), ui::TEXT_INPUT_TYPE_NONE);
1383 1382
1384 if (text_input_manager_ && text_input_manager_->GetActiveWidget()) { 1383 if (text_input_manager_ && text_input_manager_->GetActiveWidget()) {
1385 text_input_manager_->GetActiveWidget()->ImeConfirmComposition( 1384 text_input_manager_->GetActiveWidget()->ImeCommitText(
aelias_OOO_until_Jul13 2016/09/07 05:02:40 Please do "if (text.empty()) ImeFinishComposingTex
yabinh 2016/09/07 10:27:14 Done. Also added a new test for that.
1386 text, gfx::Range::InvalidRange(), false); 1385 text, gfx::Range::InvalidRange(), 0);
1387 } 1386 }
1388 has_composition_text_ = false; 1387 has_composition_text_ = false;
1389 } 1388 }
1390 1389
1391 void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) { 1390 void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) {
1392 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { 1391 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) {
1393 popup_child_host_view_->InsertChar(event); 1392 popup_child_host_view_->InsertChar(event);
1394 return; 1393 return;
1395 } 1394 }
1396 1395
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
2483 return NeedsInputGrab(); 2482 return NeedsInputGrab();
2484 #endif 2483 #endif
2485 return false; 2484 return false;
2486 } 2485 }
2487 2486
2488 void RenderWidgetHostViewAura::FinishImeCompositionSession() { 2487 void RenderWidgetHostViewAura::FinishImeCompositionSession() {
2489 if (!has_composition_text_) 2488 if (!has_composition_text_)
2490 return; 2489 return;
2491 2490
2492 if (!!text_input_manager_ && !!text_input_manager_->GetActiveWidget()) { 2491 if (!!text_input_manager_ && !!text_input_manager_->GetActiveWidget()) {
2493 text_input_manager_->GetActiveWidget()->ImeConfirmComposition( 2492 text_input_manager_->GetActiveWidget()->ImeFinishComposingText(false);
2494 base::string16(), gfx::Range::InvalidRange(), false);
2495 } 2493 }
2496 ImeCancelComposition(); 2494 ImeCancelComposition();
2497 } 2495 }
2498 2496
2499 void RenderWidgetHostViewAura::ModifyEventMovementAndCoords( 2497 void RenderWidgetHostViewAura::ModifyEventMovementAndCoords(
2500 blink::WebMouseEvent* event) { 2498 blink::WebMouseEvent* event) {
2501 // If the mouse has just entered, we must report zero movementX/Y. Hence we 2499 // If the mouse has just entered, we must report zero movementX/Y. Hence we
2502 // reset any global_mouse_position set previously. 2500 // reset any global_mouse_position set previously.
2503 if (event->type == blink::WebInputEvent::MouseEnter || 2501 if (event->type == blink::WebInputEvent::MouseEnter ||
2504 event->type == blink::WebInputEvent::MouseLeave) 2502 event->type == blink::WebInputEvent::MouseLeave)
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
3044 ->GetTextSelection(focused_view) 3042 ->GetTextSelection(focused_view)
3045 ->GetSelectedText(&selected_text)) { 3043 ->GetSelectedText(&selected_text)) {
3046 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. 3044 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard.
3047 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); 3045 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION);
3048 clipboard_writer.WriteText(selected_text); 3046 clipboard_writer.WriteText(selected_text);
3049 } 3047 }
3050 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) 3048 #endif // defined(USE_X11) && !defined(OS_CHROMEOS)
3051 } 3049 }
3052 3050
3053 } // namespace content 3051 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698