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

Unified Diff: chrome/renderer/resources/extensions/web_view.js

Issue 14272003: <webview>: Focusing <webview> should propagate to BrowserPlugin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved to web_view_interactive_browsertest.cc Created 7 years, 8 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: chrome/renderer/resources/extensions/web_view.js
diff --git a/chrome/renderer/resources/extensions/web_view.js b/chrome/renderer/resources/extensions/web_view.js
index dc91c248dd4ba12d1bbf21f474e5be5c715d0bbc..becb7a1138cbd9b9d783677c1e8910091a68c4f4 100644
--- a/chrome/renderer/resources/extensions/web_view.js
+++ b/chrome/renderer/resources/extensions/web_view.js
@@ -63,11 +63,27 @@ function WebView(node) {
}
}, this);
+ if (!this.node_.hasAttribute('tabIndex')) {
+ // <webview> needs a tabIndex in order to respond to keyboard focus.
+ // TODO(fsamuel): This introduces unexpected tab ordering. We need to find
+ // a way to take keyboard focus without messing with tab ordering.
+ // See http://crbug.com/231664.
+ this.node_.setAttribute('tabIndex', 0);
+ }
+ var self = this;
+ this.node_.addEventListener('focus', function(e) {
+ // Focus the BrowserPlugin when the <webview> takes focus.
+ self.objectNode_.focus();
+ });
+ this.node_.addEventListener('blur', function(e) {
+ // Blur the BrowserPlugin when the <webview> loses focus.
+ self.objectNode_.blur();
+ });
+
shadowRoot.appendChild(this.objectNode_);
// this.objectNode_[apiMethod] are not necessarily defined immediately after
// the shadow object is appended to the shadow root.
- var self = this;
forEach(WEB_VIEW_API_METHODS, function(i, apiMethod) {
node[apiMethod] = function(var_args) {
return self.objectNode_[apiMethod].apply(self.objectNode_, arguments);

Powered by Google App Engine
This is Rietveld 408576698