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

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: Small Fixes. Created 4 years, 10 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 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 bool is_guest_view_hack) 454 bool is_guest_view_hack)
455 : host_(RenderWidgetHostImpl::From(host)), 455 : host_(RenderWidgetHostImpl::From(host)),
456 window_(nullptr), 456 window_(nullptr),
457 delegated_frame_host_(new DelegatedFrameHost(this)), 457 delegated_frame_host_(new DelegatedFrameHost(this)),
458 in_shutdown_(false), 458 in_shutdown_(false),
459 in_bounds_changed_(false), 459 in_bounds_changed_(false),
460 is_fullscreen_(false), 460 is_fullscreen_(false),
461 popup_parent_host_view_(NULL), 461 popup_parent_host_view_(NULL),
462 popup_child_host_view_(NULL), 462 popup_child_host_view_(NULL),
463 is_loading_(false), 463 is_loading_(false),
464 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
465 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
466 text_input_flags_(0),
467 can_compose_inline_(true),
468 has_composition_text_(false), 464 has_composition_text_(false),
469 accept_return_character_(false), 465 accept_return_character_(false),
470 last_swapped_software_frame_scale_factor_(1.f), 466 last_swapped_software_frame_scale_factor_(1.f),
471 paint_canvas_(NULL), 467 paint_canvas_(NULL),
472 synthetic_move_sent_(false), 468 synthetic_move_sent_(false),
473 cursor_visibility_state_in_renderer_(UNKNOWN), 469 cursor_visibility_state_in_renderer_(UNKNOWN),
474 #if defined(OS_WIN) 470 #if defined(OS_WIN)
475 legacy_render_widget_host_HWND_(NULL), 471 legacy_render_widget_host_HWND_(NULL),
476 legacy_window_destroyed_(false), 472 legacy_window_destroyed_(false),
477 showing_context_menu_(false), 473 showing_context_menu_(false),
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_); 996 gfx::Screen::GetScreen()->GetDisplayNearestWindow(window_);
1001 current_cursor_.SetDisplayInfo(display); 997 current_cursor_.SetDisplayInfo(display);
1002 UpdateCursorIfOverSelf(); 998 UpdateCursorIfOverSelf();
1003 } 999 }
1004 1000
1005 void RenderWidgetHostViewAura::SetIsLoading(bool is_loading) { 1001 void RenderWidgetHostViewAura::SetIsLoading(bool is_loading) {
1006 is_loading_ = is_loading; 1002 is_loading_ = is_loading;
1007 UpdateCursorIfOverSelf(); 1003 UpdateCursorIfOverSelf();
1008 } 1004 }
1009 1005
1010 void RenderWidgetHostViewAura::TextInputStateChanged( 1006 void RenderWidgetHostViewAura::UpdateTextInputState() {
1011 const ViewHostMsg_TextInputState_Params& params) { 1007 RenderWidgetHostViewBase::UpdateTextInputState();
1012 if (text_input_type_ != params.type || 1008
1013 text_input_mode_ != params.mode || 1009 if (!GetInputMethod())
1014 can_compose_inline_ != params.can_compose_inline || 1010 return;
1015 text_input_flags_ != params.flags) { 1011
1016 text_input_type_ = params.type; 1012 GetInputMethod()->OnTextInputTypeChanged(this);
Shu Chen 2016/03/04 02:30:29 The original logic notifies InputMethod only when
EhsanK 2016/03/04 09:31:49 I actually removed that part due to this comment:
Shu Chen 2016/03/04 09:57:45 The original logic is: if (anything changed) {
EhsanK 2016/03/08 05:21:03 Thanks for the detailed explanation. I realize the
1017 text_input_mode_ = params.mode; 1013
1018 can_compose_inline_ = params.can_compose_inline; 1014 const TextInputState* state = current_text_input_state();
1019 text_input_flags_ = params.flags; 1015 if (state->show_ime_if_needed && state->type != ui::TEXT_INPUT_TYPE_NONE)
1020 if (GetInputMethod()) 1016 GetInputMethod()->ShowImeIfNeeded();
1021 GetInputMethod()->OnTextInputTypeChanged(this);
1022 }
1023 if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) {
1024 if (GetInputMethod())
1025 GetInputMethod()->ShowImeIfNeeded();
1026 }
1027 } 1017 }
1028 1018
1029 void RenderWidgetHostViewAura::ImeCancelComposition() { 1019 void RenderWidgetHostViewAura::ImeCancelComposition() {
1030 if (GetInputMethod()) 1020 if (GetInputMethod())
1031 GetInputMethod()->CancelComposition(this); 1021 GetInputMethod()->CancelComposition(this);
1032 has_composition_text_ = false; 1022 has_composition_text_ = false;
1033 } 1023 }
1034 1024
1035 void RenderWidgetHostViewAura::ImeCompositionRangeChanged( 1025 void RenderWidgetHostViewAura::ImeCompositionRangeChanged(
1036 const gfx::Range& range, 1026 const gfx::Range& range,
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 has_composition_text_ = false; 1629 has_composition_text_ = false;
1640 } 1630 }
1641 1631
1642 void RenderWidgetHostViewAura::ClearCompositionText() { 1632 void RenderWidgetHostViewAura::ClearCompositionText() {
1643 if (host_ && has_composition_text_) 1633 if (host_ && has_composition_text_)
1644 host_->ImeCancelComposition(); 1634 host_->ImeCancelComposition();
1645 has_composition_text_ = false; 1635 has_composition_text_ = false;
1646 } 1636 }
1647 1637
1648 void RenderWidgetHostViewAura::InsertText(const base::string16& text) { 1638 void RenderWidgetHostViewAura::InsertText(const base::string16& text) {
1649 DCHECK(text_input_type_ != ui::TEXT_INPUT_TYPE_NONE); 1639 DCHECK(current_text_input_state()->type != ui::TEXT_INPUT_TYPE_NONE);
1650 if (host_) 1640 if (host_)
1651 host_->ImeConfirmComposition(text, gfx::Range::InvalidRange(), false); 1641 host_->ImeConfirmComposition(text, gfx::Range::InvalidRange(), false);
1652 has_composition_text_ = false; 1642 has_composition_text_ = false;
1653 } 1643 }
1654 1644
1655 void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) { 1645 void RenderWidgetHostViewAura::InsertChar(const ui::KeyEvent& event) {
1656 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { 1646 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) {
1657 popup_child_host_view_->InsertChar(event); 1647 popup_child_host_view_->InsertChar(event);
1658 return; 1648 return;
1659 } 1649 }
1660 1650
1661 // Ignore character messages for VKEY_RETURN sent on CTRL+M. crbug.com/315547 1651 // Ignore character messages for VKEY_RETURN sent on CTRL+M. crbug.com/315547
1662 if (host_ && 1652 if (host_ &&
1663 (accept_return_character_ || event.GetCharacter() != ui::VKEY_RETURN)) { 1653 (accept_return_character_ || event.GetCharacter() != ui::VKEY_RETURN)) {
1664 // Send a blink::WebInputEvent::Char event to |host_|. 1654 // Send a blink::WebInputEvent::Char event to |host_|.
1665 ForwardKeyboardEvent(NativeWebKeyboardEvent(event, event.GetCharacter())); 1655 ForwardKeyboardEvent(NativeWebKeyboardEvent(event, event.GetCharacter()));
1666 } 1656 }
1667 } 1657 }
1668 1658
1669 ui::TextInputType RenderWidgetHostViewAura::GetTextInputType() const { 1659 ui::TextInputType RenderWidgetHostViewAura::GetTextInputType() const {
1670 return text_input_type_; 1660 return current_text_input_state()->type;
1671 } 1661 }
1672 1662
1673 ui::TextInputMode RenderWidgetHostViewAura::GetTextInputMode() const { 1663 ui::TextInputMode RenderWidgetHostViewAura::GetTextInputMode() const {
1674 return text_input_mode_; 1664 return current_text_input_state()->mode;
1675 } 1665 }
1676 1666
1677 int RenderWidgetHostViewAura::GetTextInputFlags() const { 1667 int RenderWidgetHostViewAura::GetTextInputFlags() const {
1678 return text_input_flags_; 1668 return current_text_input_state()->flags;
1679 } 1669 }
1680 1670
1681 bool RenderWidgetHostViewAura::CanComposeInline() const { 1671 bool RenderWidgetHostViewAura::CanComposeInline() const {
1682 return can_compose_inline_; 1672 return current_text_input_state()->can_compose_inline;
1683 } 1673 }
1684 1674
1685 gfx::Rect RenderWidgetHostViewAura::ConvertRectToScreen( 1675 gfx::Rect RenderWidgetHostViewAura::ConvertRectToScreen(
1686 const gfx::Rect& rect) const { 1676 const gfx::Rect& rect) const {
1687 gfx::Point origin = rect.origin(); 1677 gfx::Point origin = rect.origin();
1688 gfx::Point end = gfx::Point(rect.right(), rect.bottom()); 1678 gfx::Point end = gfx::Point(rect.right(), rect.bottom());
1689 1679
1690 aura::Window* root_window = window_->GetRootWindow(); 1680 aura::Window* root_window = window_->GetRootWindow();
1691 if (!root_window) 1681 if (!root_window)
1692 return rect; 1682 return rect;
(...skipping 1379 matching lines...) Expand 10 before | Expand all | Expand 10 after
3072 3062
3073 //////////////////////////////////////////////////////////////////////////////// 3063 ////////////////////////////////////////////////////////////////////////////////
3074 // RenderWidgetHostViewBase, public: 3064 // RenderWidgetHostViewBase, public:
3075 3065
3076 // static 3066 // static
3077 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 3067 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
3078 GetScreenInfoForWindow(results, NULL); 3068 GetScreenInfoForWindow(results, NULL);
3079 } 3069 }
3080 3070
3081 } // namespace content 3071 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698