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

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

Issue 1652483002: Browser Side Text Input State Tracking for OOPIF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed a Compile Error Created 4 years, 9 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 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 bool is_guest_view_hack) 455 bool is_guest_view_hack)
456 : host_(RenderWidgetHostImpl::From(host)), 456 : host_(RenderWidgetHostImpl::From(host)),
457 window_(nullptr), 457 window_(nullptr),
458 delegated_frame_host_(new DelegatedFrameHost(this)), 458 delegated_frame_host_(new DelegatedFrameHost(this)),
459 in_shutdown_(false), 459 in_shutdown_(false),
460 in_bounds_changed_(false), 460 in_bounds_changed_(false),
461 is_fullscreen_(false), 461 is_fullscreen_(false),
462 popup_parent_host_view_(NULL), 462 popup_parent_host_view_(NULL),
463 popup_child_host_view_(NULL), 463 popup_child_host_view_(NULL),
464 is_loading_(false), 464 is_loading_(false),
465 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
466 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
467 text_input_flags_(0),
468 can_compose_inline_(true),
469 has_composition_text_(false), 465 has_composition_text_(false),
470 accept_return_character_(false), 466 accept_return_character_(false),
471 last_swapped_software_frame_scale_factor_(1.f), 467 last_swapped_software_frame_scale_factor_(1.f),
472 paint_canvas_(NULL), 468 paint_canvas_(NULL),
473 synthetic_move_sent_(false), 469 synthetic_move_sent_(false),
474 cursor_visibility_state_in_renderer_(UNKNOWN), 470 cursor_visibility_state_in_renderer_(UNKNOWN),
475 #if defined(OS_WIN) 471 #if defined(OS_WIN)
476 legacy_render_widget_host_HWND_(NULL), 472 legacy_render_widget_host_HWND_(NULL),
477 legacy_window_destroyed_(false), 473 legacy_window_destroyed_(false),
478 #endif 474 #endif
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
1005 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_); 1001 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_);
1006 current_cursor_.SetDisplayInfo(display); 1002 current_cursor_.SetDisplayInfo(display);
1007 UpdateCursorIfOverSelf(); 1003 UpdateCursorIfOverSelf();
1008 } 1004 }
1009 1005
1010 void RenderWidgetHostViewAura::SetIsLoading(bool is_loading) { 1006 void RenderWidgetHostViewAura::SetIsLoading(bool is_loading) {
1011 is_loading_ = is_loading; 1007 is_loading_ = is_loading;
1012 UpdateCursorIfOverSelf(); 1008 UpdateCursorIfOverSelf();
1013 } 1009 }
1014 1010
1015 void RenderWidgetHostViewAura::TextInputStateChanged( 1011 void RenderWidgetHostViewAura::UpdateInputMethodIfNecessary(
1016 const ViewHostMsg_TextInputState_Params& params) { 1012 bool text_input_state_changed) {
1017 if (text_input_type_ != params.type || 1013 if (!GetInputMethod())
1018 text_input_mode_ != params.mode || 1014 return;
1019 can_compose_inline_ != params.can_compose_inline || 1015
1020 text_input_flags_ != params.flags) { 1016 if (text_input_state_changed)
1021 text_input_type_ = params.type; 1017 GetInputMethod()->OnTextInputTypeChanged(this);
1022 text_input_mode_ = params.mode; 1018
1023 can_compose_inline_ = params.can_compose_inline; 1019 TextInputState state = host_->delegate()->GetTextInputState();
1024 text_input_flags_ = params.flags; 1020
1025 if (GetInputMethod()) 1021 if (state.show_ime_if_needed && state.type != ui::TEXT_INPUT_TYPE_NONE)
1026 GetInputMethod()->OnTextInputTypeChanged(this); 1022 GetInputMethod()->ShowImeIfNeeded();
1027 }
1028 if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) {
1029 if (GetInputMethod())
1030 GetInputMethod()->ShowImeIfNeeded();
1031 }
1032 } 1023 }
1033 1024
1034 void RenderWidgetHostViewAura::ImeCancelComposition() { 1025 void RenderWidgetHostViewAura::ImeCancelComposition() {
1035 if (GetInputMethod()) 1026 if (GetInputMethod())
1036 GetInputMethod()->CancelComposition(this); 1027 GetInputMethod()->CancelComposition(this);
1037 has_composition_text_ = false; 1028 has_composition_text_ = false;
1038 } 1029 }
1039 1030
1040 void RenderWidgetHostViewAura::ImeCompositionRangeChanged( 1031 void RenderWidgetHostViewAura::ImeCompositionRangeChanged(
1041 const gfx::Range& range, 1032 const gfx::Range& range,
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 } 1645 }
1655 1646
1656 void RenderWidgetHostViewAura::ClearCompositionText() { 1647 void RenderWidgetHostViewAura::ClearCompositionText() {
1657 // TODO(wjmaclean): can host_ ever be null? 1648 // TODO(wjmaclean): can host_ ever be null?
1658 if (host_ && has_composition_text_) 1649 if (host_ && has_composition_text_)
1659 host_->ImeCancelComposition(); 1650 host_->ImeCancelComposition();
1660 has_composition_text_ = false; 1651 has_composition_text_ = false;
1661 } 1652 }
1662 1653
1663 void RenderWidgetHostViewAura::InsertText(const base::string16& text) { 1654 void RenderWidgetHostViewAura::InsertText(const base::string16& text) {
1664 DCHECK(text_input_type_ != ui::TEXT_INPUT_TYPE_NONE); 1655 DCHECK(RenderWidgetHostImpl::From(GetRenderWidgetHost())
1656 ->delegate()
1657 ->GetTextInputState()
1658 .type != ui::TEXT_INPUT_TYPE_NONE);
1665 // TODO(wjmaclean): can host_ ever be null? 1659 // TODO(wjmaclean): can host_ ever be null?
1666 if (host_) 1660 if (host_)
1667 host_->ImeConfirmComposition(text, gfx::Range::InvalidRange(), false); 1661 host_->ImeConfirmComposition(text, gfx::Range::InvalidRange(), false);
1668 has_composition_text_ = false; 1662 has_composition_text_ = false;
1669 } 1663 }
1670 1664
1671 void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) { 1665 void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) {
1672 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { 1666 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) {
1673 popup_child_host_view_->InsertChar(event); 1667 popup_child_host_view_->InsertChar(event);
1674 return; 1668 return;
1675 } 1669 }
1676 1670
1677 // Ignore character messages for VKEY_RETURN sent on CTRL+M. crbug.com/315547 1671 // Ignore character messages for VKEY_RETURN sent on CTRL+M. crbug.com/315547
1678 // TODO(wjmaclean): can host_ ever be null? 1672 // TODO(wjmaclean): can host_ ever be null?
1679 if (host_ && 1673 if (host_ &&
1680 (accept_return_character_ || event.GetCharacter() != ui::VKEY_RETURN)) { 1674 (accept_return_character_ || event.GetCharacter() != ui::VKEY_RETURN)) {
1681 // Send a blink::WebInputEvent::Char event to |host_|. 1675 // Send a blink::WebInputEvent::Char event to |host_|.
1682 ForwardKeyboardEvent(NativeWebKeyboardEvent(event, event.GetCharacter())); 1676 ForwardKeyboardEvent(NativeWebKeyboardEvent(event, event.GetCharacter()));
1683 } 1677 }
1684 } 1678 }
1685 1679
1686 ui::TextInputType RenderWidgetHostViewAura::GetTextInputType() const { 1680 ui::TextInputType RenderWidgetHostViewAura::GetTextInputType() const {
1687 return text_input_type_; 1681 if (host_->delegate())
1682 return host_->delegate()->GetTextInputState().type;
1683 return text_input_state()->type;
1688 } 1684 }
1689 1685
1690 ui::TextInputMode RenderWidgetHostViewAura::GetTextInputMode() const { 1686 ui::TextInputMode RenderWidgetHostViewAura::GetTextInputMode() const {
1691 return text_input_mode_; 1687 if (host_->delegate())
1688 return host_->delegate()->GetTextInputState().mode;
1689 return text_input_state()->mode;
1692 } 1690 }
1693 1691
1694 int RenderWidgetHostViewAura::GetTextInputFlags() const { 1692 int RenderWidgetHostViewAura::GetTextInputFlags() const {
1695 return text_input_flags_; 1693 if (host_->delegate())
1694 return host_->delegate()->GetTextInputState().flags;
1695 return text_input_state()->flags;
1696 } 1696 }
1697 1697
1698 bool RenderWidgetHostViewAura::CanComposeInline() const { 1698 bool RenderWidgetHostViewAura::CanComposeInline() const {
1699 return can_compose_inline_; 1699 if (host_->delegate())
1700 return host_->delegate()->GetTextInputState().can_compose_inline;
1701 return text_input_state()->can_compose_inline;
1700 } 1702 }
1701 1703
1702 gfx::Rect RenderWidgetHostViewAura::ConvertRectToScreen( 1704 gfx::Rect RenderWidgetHostViewAura::ConvertRectToScreen(
1703 const gfx::Rect& rect) const { 1705 const gfx::Rect& rect) const {
1704 gfx::Point origin = rect.origin(); 1706 gfx::Point origin = rect.origin();
1705 gfx::Point end = gfx::Point(rect.right(), rect.bottom()); 1707 gfx::Point end = gfx::Point(rect.right(), rect.bottom());
1706 1708
1707 aura::Window* root_window = window_->GetRootWindow(); 1709 aura::Window* root_window = window_->GetRootWindow();
1708 if (!root_window) 1710 if (!root_window)
1709 return rect; 1711 return rect;
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after
3129 3131
3130 //////////////////////////////////////////////////////////////////////////////// 3132 ////////////////////////////////////////////////////////////////////////////////
3131 // RenderWidgetHostViewBase, public: 3133 // RenderWidgetHostViewBase, public:
3132 3134
3133 // static 3135 // static
3134 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 3136 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
3135 GetScreenInfoForWindow(results, NULL); 3137 GetScreenInfoForWindow(results, NULL);
3136 } 3138 }
3137 3139
3138 } // namespace content 3140 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698