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

Unified Diff: ui/views/controls/webview/webview.cc

Issue 173803002: Redesigns the text input focus handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments. Created 6 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/controls/webview/webview.cc
diff --git a/ui/views/controls/webview/webview.cc b/ui/views/controls/webview/webview.cc
index 4669c3ede4ac7a7827438711ee68e7c71d9de163..f836161fb58638a390716707b7d4b3b2eea1c9c6 100644
--- a/ui/views/controls/webview/webview.cc
+++ b/ui/views/controls/webview/webview.cc
@@ -14,6 +14,7 @@
#include "ipc/ipc_message.h"
#include "ui/accessibility/ax_enums.h"
#include "ui/accessibility/ax_view_state.h"
+#include "ui/base/ui_base_switches_util.h"
#include "ui/events/event.h"
#include "ui/views/accessibility/native_view_accessibility.h"
#include "ui/views/controls/native/native_view_host.h"
@@ -110,6 +111,17 @@ const char* WebView::GetClassName() const {
return kViewClassName;
}
+ui::TextInputClient* WebView::GetTextInputClient() {
+ if (switches::IsTextInputFocusManagerEnabled() &&
+ web_contents() && !web_contents()->IsBeingDestroyed()) {
+ content::RenderWidgetHostView* host_view =
+ web_contents()->GetRenderWidgetHostView();
msw 2014/03/11 23:24:39 Should this ever use web_contents()->GetFullscreen
Yuki 2014/03/12 09:13:15 Very good catch. Updated.
+ if (host_view)
+ return host_view->GetTextInputClient();
+ }
+ return NULL;
+}
+
void WebView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
wcv_holder_->SetSize(bounds().size());
}
@@ -194,6 +206,16 @@ bool WebView::EmbedsFullscreenWidget() const {
////////////////////////////////////////////////////////////////////////////////
// WebView, content::WebContentsObserver implementation:
+void WebView::RenderViewDeleted(content::RenderViewHost* render_view_host) {
+ // WebView::GetTextInputClient() delegates the text input handling to the
+ // underlying content::RenderWidgetHostView. So when the underlying RWHV is
+ // destroyed, we have to notify the FocusManager that the focused
+ // TextInputClient needs to be updated.
+ FocusManager* const focus_manager = GetFocusManager();
+ if (focus_manager)
+ focus_manager->OnTextInputClientChanged(this);
+}
+
void WebView::RenderViewHostChanged(content::RenderViewHost* old_host,
content::RenderViewHost* new_host) {
FocusManager* const focus_manager = GetFocusManager();

Powered by Google App Engine
This is Rietveld 408576698