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

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

Issue 2092103002: [reland] Routing IME Result Calls to the Correct RenderWidgetHost (Aura Only) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Original CL Created 4 years, 6 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 1415 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 cursor_client->ShowCursor(); 1426 cursor_client->ShowCursor();
1427 } 1427 }
1428 1428
1429 host_->LostMouseLock(); 1429 host_->LostMouseLock();
1430 } 1430 }
1431 1431
1432 //////////////////////////////////////////////////////////////////////////////// 1432 ////////////////////////////////////////////////////////////////////////////////
1433 // RenderWidgetHostViewAura, ui::TextInputClient implementation: 1433 // RenderWidgetHostViewAura, ui::TextInputClient implementation:
1434 void RenderWidgetHostViewAura::SetCompositionText( 1434 void RenderWidgetHostViewAura::SetCompositionText(
1435 const ui::CompositionText& composition) { 1435 const ui::CompositionText& composition) {
1436 // TODO(wjmaclean): can host_ ever be null? 1436 if (!text_input_manager_ || !text_input_manager_->GetActiveWidget())
1437 if (!host_)
1438 return; 1437 return;
1439 1438
1440 // TODO(suzhe): convert both renderer_host and renderer to use 1439 // TODO(suzhe): convert both renderer_host and renderer to use
1441 // ui::CompositionText. 1440 // ui::CompositionText.
1442 std::vector<blink::WebCompositionUnderline> underlines; 1441 std::vector<blink::WebCompositionUnderline> underlines;
1443 underlines.reserve(composition.underlines.size()); 1442 underlines.reserve(composition.underlines.size());
1444 for (std::vector<ui::CompositionUnderline>::const_iterator it = 1443 for (std::vector<ui::CompositionUnderline>::const_iterator it =
1445 composition.underlines.begin(); 1444 composition.underlines.begin();
1446 it != composition.underlines.end(); ++it) { 1445 it != composition.underlines.end(); ++it) {
1447 underlines.push_back( 1446 underlines.push_back(
1448 blink::WebCompositionUnderline(static_cast<unsigned>(it->start_offset), 1447 blink::WebCompositionUnderline(static_cast<unsigned>(it->start_offset),
1449 static_cast<unsigned>(it->end_offset), 1448 static_cast<unsigned>(it->end_offset),
1450 it->color, 1449 it->color,
1451 it->thick, 1450 it->thick,
1452 it->background_color)); 1451 it->background_color));
1453 } 1452 }
1454 1453
1455 // TODO(suzhe): due to a bug of webkit, we can't use selection range with 1454 // TODO(suzhe): due to a bug of webkit, we can't use selection range with
1456 // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788 1455 // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788
1457 host_->ImeSetComposition(composition.text, underlines, 1456 text_input_manager_->GetActiveWidget()->ImeSetComposition(
1458 gfx::Range::InvalidRange(), 1457 composition.text, underlines, gfx::Range::InvalidRange(),
1459 composition.selection.end(), 1458 composition.selection.end(), composition.selection.end());
1460 composition.selection.end());
1461 1459
1462 has_composition_text_ = !composition.text.empty(); 1460 has_composition_text_ = !composition.text.empty();
1463 } 1461 }
1464 1462
1465 void RenderWidgetHostViewAura::ConfirmCompositionText() { 1463 void RenderWidgetHostViewAura::ConfirmCompositionText() {
1466 // TODO(wjmaclean): can host_ ever be null? 1464 if (text_input_manager_ && text_input_manager_->GetActiveWidget() &&
1467 if (host_ && has_composition_text_) { 1465 has_composition_text_) {
1468 host_->ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(), 1466 text_input_manager_->GetActiveWidget()->ImeConfirmComposition(
1469 false); 1467 base::string16(), gfx::Range::InvalidRange(), false);
1470 } 1468 }
1471 has_composition_text_ = false; 1469 has_composition_text_ = false;
1472 } 1470 }
1473 1471
1474 void RenderWidgetHostViewAura::ClearCompositionText() { 1472 void RenderWidgetHostViewAura::ClearCompositionText() {
1475 // TODO(wjmaclean): can host_ ever be null? 1473 if (text_input_manager_ && text_input_manager_->GetActiveWidget() &&
1476 if (host_ && has_composition_text_) 1474 has_composition_text_)
1477 host_->ImeCancelComposition(); 1475 text_input_manager_->GetActiveWidget()->ImeCancelComposition();
1478 has_composition_text_ = false; 1476 has_composition_text_ = false;
1479 } 1477 }
1480 1478
1481 void RenderWidgetHostViewAura::InsertText(const base::string16& text) { 1479 void RenderWidgetHostViewAura::InsertText(const base::string16& text) {
1482 DCHECK_NE(GetTextInputType(), ui::TEXT_INPUT_TYPE_NONE); 1480 DCHECK_NE(GetTextInputType(), ui::TEXT_INPUT_TYPE_NONE);
1483 1481
1484 // TODO(wjmaclean): can host_ ever be null? 1482 if (text_input_manager_ && text_input_manager_->GetActiveWidget()) {
1485 if (host_) 1483 text_input_manager_->GetActiveWidget()->ImeConfirmComposition(
1486 host_->ImeConfirmComposition(text, gfx::Range::InvalidRange(), false); 1484 text, gfx::Range::InvalidRange(), false);
1485 }
1487 has_composition_text_ = false; 1486 has_composition_text_ = false;
1488 } 1487 }
1489 1488
1490 void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) { 1489 void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) {
1491 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { 1490 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) {
1492 popup_child_host_view_->InsertChar(event); 1491 popup_child_host_view_->InsertChar(event);
1493 return; 1492 return;
1494 } 1493 }
1495 1494
1496 // Ignore character messages for VKEY_RETURN sent on CTRL+M. crbug.com/315547 1495 // Ignore character messages for VKEY_RETURN sent on CTRL+M. crbug.com/315547
(...skipping 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after
3033 3032
3034 //////////////////////////////////////////////////////////////////////////////// 3033 ////////////////////////////////////////////////////////////////////////////////
3035 // RenderWidgetHostViewBase, public: 3034 // RenderWidgetHostViewBase, public:
3036 3035
3037 // static 3036 // static
3038 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 3037 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
3039 GetScreenInfoForWindow(results, NULL); 3038 GetScreenInfoForWindow(results, NULL);
3040 } 3039 }
3041 3040
3042 } // namespace content 3041 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698