OLD | NEW |
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 Loading... |
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 if (text.length()) |
1386 text, gfx::Range::InvalidRange(), false); | 1385 text_input_manager_->GetActiveWidget()->ImeCommitText( |
| 1386 text, gfx::Range::InvalidRange(), 0); |
| 1387 else if (has_composition_text_) |
| 1388 text_input_manager_->GetActiveWidget()->ImeFinishComposingText(false); |
1387 } | 1389 } |
1388 has_composition_text_ = false; | 1390 has_composition_text_ = false; |
1389 } | 1391 } |
1390 | 1392 |
1391 void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) { | 1393 void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) { |
1392 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { | 1394 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { |
1393 popup_child_host_view_->InsertChar(event); | 1395 popup_child_host_view_->InsertChar(event); |
1394 return; | 1396 return; |
1395 } | 1397 } |
1396 | 1398 |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2483 return NeedsInputGrab(); | 2485 return NeedsInputGrab(); |
2484 #endif | 2486 #endif |
2485 return false; | 2487 return false; |
2486 } | 2488 } |
2487 | 2489 |
2488 void RenderWidgetHostViewAura::FinishImeCompositionSession() { | 2490 void RenderWidgetHostViewAura::FinishImeCompositionSession() { |
2489 if (!has_composition_text_) | 2491 if (!has_composition_text_) |
2490 return; | 2492 return; |
2491 | 2493 |
2492 if (!!text_input_manager_ && !!text_input_manager_->GetActiveWidget()) { | 2494 if (!!text_input_manager_ && !!text_input_manager_->GetActiveWidget()) { |
2493 text_input_manager_->GetActiveWidget()->ImeConfirmComposition( | 2495 text_input_manager_->GetActiveWidget()->ImeFinishComposingText(false); |
2494 base::string16(), gfx::Range::InvalidRange(), false); | |
2495 } | 2496 } |
2496 ImeCancelComposition(); | 2497 ImeCancelComposition(); |
2497 } | 2498 } |
2498 | 2499 |
2499 void RenderWidgetHostViewAura::ModifyEventMovementAndCoords( | 2500 void RenderWidgetHostViewAura::ModifyEventMovementAndCoords( |
2500 blink::WebMouseEvent* event) { | 2501 blink::WebMouseEvent* event) { |
2501 // If the mouse has just entered, we must report zero movementX/Y. Hence we | 2502 // If the mouse has just entered, we must report zero movementX/Y. Hence we |
2502 // reset any global_mouse_position set previously. | 2503 // reset any global_mouse_position set previously. |
2503 if (event->type == blink::WebInputEvent::MouseEnter || | 2504 if (event->type == blink::WebInputEvent::MouseEnter || |
2504 event->type == blink::WebInputEvent::MouseLeave) | 2505 event->type == blink::WebInputEvent::MouseLeave) |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3037 ->GetTextSelection(focused_view) | 3038 ->GetTextSelection(focused_view) |
3038 ->GetSelectedText(&selected_text)) { | 3039 ->GetSelectedText(&selected_text)) { |
3039 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. | 3040 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. |
3040 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); | 3041 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); |
3041 clipboard_writer.WriteText(selected_text); | 3042 clipboard_writer.WriteText(selected_text); |
3042 } | 3043 } |
3043 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) | 3044 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) |
3044 } | 3045 } |
3045 | 3046 |
3046 } // namespace content | 3047 } // namespace content |
OLD | NEW |