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

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

Issue 2171443003: In TextInputManager, reset input type to none before switching active widgets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix the failing test on ASAN bots Created 4 years, 5 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
« no previous file with comments | « chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/text_input_manager.h" 5 #include "content/browser/renderer_host/text_input_manager.h"
6 6
7 #include "content/browser/renderer_host/render_widget_host_impl.h" 7 #include "content/browser/renderer_host/render_widget_host_impl.h"
8 #include "content/browser/renderer_host/render_widget_host_view_base.h" 8 #include "content/browser/renderer_host/render_widget_host_view_base.h"
9 #include "content/common/view_messages.h" 9 #include "content/common/view_messages.h"
10 #include "ui/gfx/geometry/rect.h" 10 #include "ui/gfx/geometry/rect.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 const TextInputState& text_input_state) { 77 const TextInputState& text_input_state) {
78 DCHECK(IsRegistered(view)); 78 DCHECK(IsRegistered(view));
79 79
80 // Since |view| is registgered, we already have a previous value for its 80 // Since |view| is registgered, we already have a previous value for its
81 // TextInputState. 81 // TextInputState.
82 bool changed = AreDifferentTextInputStates(text_input_state_map_[view], 82 bool changed = AreDifferentTextInputStates(text_input_state_map_[view],
83 text_input_state); 83 text_input_state);
84 84
85 text_input_state_map_[view] = text_input_state; 85 text_input_state_map_[view] = text_input_state;
86 86
87 // |active_view_| is only updated when the state for |view| is not none. 87 // |active_view_| is only updated when the state for |view| is not none.
Charlie Reis 2016/07/21 23:48:18 Let's update this as well. Maybe that it "only ne
EhsanK 2016/07/25 21:09:57 Acknowledged.
88 if (text_input_state.type != ui::TEXT_INPUT_TYPE_NONE) 88 if (text_input_state.type != ui::TEXT_INPUT_TYPE_NONE &&
89 active_view_ != view) {
90 // |view| will become the new |active_view_|, which means the IPC to reset
91 // the TextInputState for |active_view_| has not arrived yet (and will be
92 // ignored later). So we should reset the TextInputState for |active_view_|
93 // manually.
94 if (active_view_)
95 UpdateTextInputState(active_view_, TextInputState());
Charlie Reis 2016/07/21 23:48:18 This has a small risk of becoming an infinite recu
EhsanK 2016/07/25 21:09:57 The only reason I used recursion like this was to
89 active_view_ = view; 96 active_view_ = view;
97 }
90 98
91 // If the state for |active_view_| is none, then we no longer have an 99 // If the state for |active_view_| is none, then we no longer have an
92 // |active_view_|. 100 // |active_view_|.
93 if (active_view_ == view && text_input_state.type == ui::TEXT_INPUT_TYPE_NONE) 101 if (active_view_ == view && text_input_state.type == ui::TEXT_INPUT_TYPE_NONE)
94 active_view_ = nullptr; 102 active_view_ = nullptr;
95 103
96 NotifyObserversAboutInputStateUpdate(view, changed); 104 NotifyObserversAboutInputStateUpdate(view, changed);
97 } 105 }
98 106
99 void TextInputManager::ImeCancelComposition(RenderWidgetHostViewBase* view) { 107 void TextInputManager::ImeCancelComposition(RenderWidgetHostViewBase* view) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 TextInputManager::SelectionRegion::SelectionRegion( 234 TextInputManager::SelectionRegion::SelectionRegion(
227 const SelectionRegion& other) = default; 235 const SelectionRegion& other) = default;
228 236
229 TextInputManager::CompositionRangeInfo::CompositionRangeInfo() {} 237 TextInputManager::CompositionRangeInfo::CompositionRangeInfo() {}
230 238
231 TextInputManager::CompositionRangeInfo::CompositionRangeInfo( 239 TextInputManager::CompositionRangeInfo::CompositionRangeInfo(
232 const CompositionRangeInfo& other) = default; 240 const CompositionRangeInfo& other) = default;
233 241
234 TextInputManager::CompositionRangeInfo::~CompositionRangeInfo() {} 242 TextInputManager::CompositionRangeInfo::~CompositionRangeInfo() {}
235 243
236 } // namespace content 244 } // namespace content
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/site_per_process_text_input_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698