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

Unified Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 2208093004: Use focused RenderWidgetHostImpl instead of TextInputManager::GetActiveWidget() to obtain TextSelec… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a test Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/render_widget_host_view_aura.cc
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc
index 7286cec3fa775c32b472157008106267475c1b07..9636bb2a80b14ad354089297f608c5186b6dd58b 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura.cc
@@ -3023,11 +3023,26 @@ void RenderWidgetHostViewAura::OnTextSelectionChanged(
TextInputManager* text_input_manager,
RenderWidgetHostViewBase* updated_view) {
#if defined(USE_X11) && !defined(OS_CHROMEOS)
- if (!GetTextInputManager() || !GetTextInputManager()->GetActiveWidget())
+ if (!GetTextInputManager())
return;
- const TextInputManager::TextSelection* text_selection =
- GetTextInputManager()->GetTextSelection();
+ const TextInputManager::TextSelection* text_selection = nullptr;
+ if (is_guest_view_hack_) {
+ // We obtain the TextSelection from focused RWH which is obtained from the
+ // frame tree. BrowserPlugin-based guests' RWH is not part of the frame tree
+ // and the focused RWH will be that of the embedder which is incorrect. In
+ // this case we should use TextSelection for |this| since RWHV for guest
+ // forwards text selection information to its platform view.
+ text_selection = GetTextInputManager()->GetTextSelection(this);
+ } else {
+ RenderWidgetHostViewBase* focused =
+ host_->delegate()->GetFocusedRenderWidgetHost(host_)->GetView();
kenrb 2016/08/08 20:45:03 It looks like GetFocusedRenderWidgetHost can retur
EhsanK 2016/08/08 21:15:52 Acknowledged. And Done. Thanks for spotting this.
+ if (focused)
+ text_selection = GetTextInputManager()->GetTextSelection(focused);
+ }
+
+ if (!text_selection)
+ return;
if (text_selection->text.empty() || text_selection->range.is_empty())
return;

Powered by Google App Engine
This is Rietveld 408576698