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 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1431 cursor_client->ShowCursor(); | 1431 cursor_client->ShowCursor(); |
1432 } | 1432 } |
1433 | 1433 |
1434 host_->LostMouseLock(); | 1434 host_->LostMouseLock(); |
1435 } | 1435 } |
1436 | 1436 |
1437 //////////////////////////////////////////////////////////////////////////////// | 1437 //////////////////////////////////////////////////////////////////////////////// |
1438 // RenderWidgetHostViewAura, ui::TextInputClient implementation: | 1438 // RenderWidgetHostViewAura, ui::TextInputClient implementation: |
1439 void RenderWidgetHostViewAura::SetCompositionText( | 1439 void RenderWidgetHostViewAura::SetCompositionText( |
1440 const ui::CompositionText& composition) { | 1440 const ui::CompositionText& composition) { |
1441 if (!text_input_manager_ || !text_input_manager_->GetActiveWidget()) | 1441 // TODO(wjmaclean): can host_ ever be null? |
| 1442 if (!host_) |
1442 return; | 1443 return; |
1443 | 1444 |
1444 // TODO(suzhe): convert both renderer_host and renderer to use | 1445 // TODO(suzhe): convert both renderer_host and renderer to use |
1445 // ui::CompositionText. | 1446 // ui::CompositionText. |
1446 std::vector<blink::WebCompositionUnderline> underlines; | 1447 std::vector<blink::WebCompositionUnderline> underlines; |
1447 underlines.reserve(composition.underlines.size()); | 1448 underlines.reserve(composition.underlines.size()); |
1448 for (std::vector<ui::CompositionUnderline>::const_iterator it = | 1449 for (std::vector<ui::CompositionUnderline>::const_iterator it = |
1449 composition.underlines.begin(); | 1450 composition.underlines.begin(); |
1450 it != composition.underlines.end(); ++it) { | 1451 it != composition.underlines.end(); ++it) { |
1451 underlines.push_back( | 1452 underlines.push_back( |
1452 blink::WebCompositionUnderline(static_cast<unsigned>(it->start_offset), | 1453 blink::WebCompositionUnderline(static_cast<unsigned>(it->start_offset), |
1453 static_cast<unsigned>(it->end_offset), | 1454 static_cast<unsigned>(it->end_offset), |
1454 it->color, | 1455 it->color, |
1455 it->thick, | 1456 it->thick, |
1456 it->background_color)); | 1457 it->background_color)); |
1457 } | 1458 } |
1458 | 1459 |
1459 // TODO(suzhe): due to a bug of webkit, we can't use selection range with | 1460 // TODO(suzhe): due to a bug of webkit, we can't use selection range with |
1460 // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788 | 1461 // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788 |
1461 text_input_manager_->GetActiveWidget()->ImeSetComposition( | 1462 host_->ImeSetComposition(composition.text, underlines, |
1462 composition.text, underlines, gfx::Range::InvalidRange(), | 1463 gfx::Range::InvalidRange(), |
1463 composition.selection.end(), composition.selection.end()); | 1464 composition.selection.end(), |
| 1465 composition.selection.end()); |
1464 | 1466 |
1465 has_composition_text_ = !composition.text.empty(); | 1467 has_composition_text_ = !composition.text.empty(); |
1466 } | 1468 } |
1467 | 1469 |
1468 void RenderWidgetHostViewAura::ConfirmCompositionText() { | 1470 void RenderWidgetHostViewAura::ConfirmCompositionText() { |
1469 if (text_input_manager_ && text_input_manager_->GetActiveWidget() && | 1471 // TODO(wjmaclean): can host_ ever be null? |
1470 has_composition_text_) { | 1472 if (host_ && has_composition_text_) { |
1471 text_input_manager_->GetActiveWidget()->ImeConfirmComposition( | 1473 host_->ImeConfirmComposition(base::string16(), gfx::Range::InvalidRange(), |
1472 base::string16(), gfx::Range::InvalidRange(), false); | 1474 false); |
1473 } | 1475 } |
1474 has_composition_text_ = false; | 1476 has_composition_text_ = false; |
1475 } | 1477 } |
1476 | 1478 |
1477 void RenderWidgetHostViewAura::ClearCompositionText() { | 1479 void RenderWidgetHostViewAura::ClearCompositionText() { |
1478 if (text_input_manager_ && text_input_manager_->GetActiveWidget() && | 1480 // TODO(wjmaclean): can host_ ever be null? |
1479 has_composition_text_) | 1481 if (host_ && has_composition_text_) |
1480 text_input_manager_->GetActiveWidget()->ImeCancelComposition(); | 1482 host_->ImeCancelComposition(); |
1481 has_composition_text_ = false; | 1483 has_composition_text_ = false; |
1482 } | 1484 } |
1483 | 1485 |
1484 void RenderWidgetHostViewAura::InsertText(const base::string16& text) { | 1486 void RenderWidgetHostViewAura::InsertText(const base::string16& text) { |
1485 DCHECK_NE(GetTextInputType(), ui::TEXT_INPUT_TYPE_NONE); | 1487 DCHECK_NE(GetTextInputType(), ui::TEXT_INPUT_TYPE_NONE); |
1486 | 1488 |
1487 if (text_input_manager_ && text_input_manager_->GetActiveWidget()) { | 1489 // TODO(wjmaclean): can host_ ever be null? |
1488 text_input_manager_->GetActiveWidget()->ImeConfirmComposition( | 1490 if (host_) |
1489 text, gfx::Range::InvalidRange(), false); | 1491 host_->ImeConfirmComposition(text, gfx::Range::InvalidRange(), false); |
1490 } | |
1491 has_composition_text_ = false; | 1492 has_composition_text_ = false; |
1492 } | 1493 } |
1493 | 1494 |
1494 void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) { | 1495 void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) { |
1495 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { | 1496 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { |
1496 popup_child_host_view_->InsertChar(event); | 1497 popup_child_host_view_->InsertChar(event); |
1497 return; | 1498 return; |
1498 } | 1499 } |
1499 | 1500 |
1500 // Ignore character messages for VKEY_RETURN sent on CTRL+M. crbug.com/315547 | 1501 // Ignore character messages for VKEY_RETURN sent on CTRL+M. crbug.com/315547 |
(...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3023 | 3024 |
3024 //////////////////////////////////////////////////////////////////////////////// | 3025 //////////////////////////////////////////////////////////////////////////////// |
3025 // RenderWidgetHostViewBase, public: | 3026 // RenderWidgetHostViewBase, public: |
3026 | 3027 |
3027 // static | 3028 // static |
3028 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 3029 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
3029 GetScreenInfoForWindow(results, NULL); | 3030 GetScreenInfoForWindow(results, NULL); |
3030 } | 3031 } |
3031 | 3032 |
3032 } // namespace content | 3033 } // namespace content |
OLD | NEW |