OLD | NEW |
---|---|
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 // Shim that simulates a <webview> tag via Mutation Observers. | 5 // Shim that simulates a <webview> tag via Mutation Observers. |
6 // | 6 // |
7 // The actual tag is implemented via the browser plugin. The internals of this | 7 // The actual tag is implemented via the browser plugin. The internals of this |
8 // are hidden via Shadow DOM. | 8 // are hidden via Shadow DOM. |
9 | 9 |
10 var chrome = requireNative('chrome').GetChrome(); | 10 var chrome = requireNative('chrome').GetChrome(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 this.objectNode_.style.height = '100%'; | 56 this.objectNode_.style.height = '100%'; |
57 forEach(WEB_VIEW_ATTRIBUTES, function(i, attributeName) { | 57 forEach(WEB_VIEW_ATTRIBUTES, function(i, attributeName) { |
58 // Only copy attributes that have been assigned values, rather than copying | 58 // Only copy attributes that have been assigned values, rather than copying |
59 // a series of undefined attributes to BrowserPlugin. | 59 // a series of undefined attributes to BrowserPlugin. |
60 if (this.node_.hasAttribute(attributeName)) { | 60 if (this.node_.hasAttribute(attributeName)) { |
61 this.objectNode_.setAttribute( | 61 this.objectNode_.setAttribute( |
62 attributeName, this.node_.getAttribute(attributeName)); | 62 attributeName, this.node_.getAttribute(attributeName)); |
63 } | 63 } |
64 }, this); | 64 }, this); |
65 | 65 |
66 if (!this.node_.hasAttribute('tabIndex')) { | |
67 // <webview> needs a tabIndex in order to respond to keyboard focus. | |
68 // TODO(fsamuel): Maybe we should fix this so that it's not required. | |
69 this.node_.setAttribute('tabIndex', 0); | |
lazyboy
2013/04/15 21:46:58
This feels too hacky though, and would trigger inc
Fady Samuel
2013/04/15 22:15:28
Unfortunately, that didn't work. I've added a bug
| |
70 } | |
71 var self = this; | |
72 this.node_.addEventListener('focus', function(e) { | |
73 // Focus the BrowserPlugin when the <webview> takes focus. | |
74 self.objectNode_.focus(); | |
75 }); | |
76 this.node_.addEventListener('blur', function(e) { | |
77 // Blur the BrowserPlugin when the <webview> loses focus. | |
78 self.objectNode_.blur(); | |
79 }); | |
80 | |
66 shadowRoot.appendChild(this.objectNode_); | 81 shadowRoot.appendChild(this.objectNode_); |
67 | 82 |
68 // this.objectNode_[apiMethod] are not necessarily defined immediately after | 83 // this.objectNode_[apiMethod] are not necessarily defined immediately after |
69 // the shadow object is appended to the shadow root. | 84 // the shadow object is appended to the shadow root. |
70 var self = this; | |
71 forEach(WEB_VIEW_API_METHODS, function(i, apiMethod) { | 85 forEach(WEB_VIEW_API_METHODS, function(i, apiMethod) { |
72 node[apiMethod] = function(var_args) { | 86 node[apiMethod] = function(var_args) { |
73 return self.objectNode_[apiMethod].apply(self.objectNode_, arguments); | 87 return self.objectNode_[apiMethod].apply(self.objectNode_, arguments); |
74 }; | 88 }; |
75 }, this); | 89 }, this); |
76 | 90 |
77 // Map attribute modifications on the <webview> tag to property changes in | 91 // Map attribute modifications on the <webview> tag to property changes in |
78 // the underlying <object> node. | 92 // the underlying <object> node. |
79 var handleMutation = function(i, mutation) { | 93 var handleMutation = function(i, mutation) { |
80 this.handleMutation_(mutation); | 94 this.handleMutation_(mutation); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 */ | 213 */ |
200 WebView.prototype.maybeSetupPermissionEvent_ = function() {}; | 214 WebView.prototype.maybeSetupPermissionEvent_ = function() {}; |
201 | 215 |
202 /** | 216 /** |
203 * Implemented when experimental permission is available. | 217 * Implemented when experimental permission is available. |
204 * @private | 218 * @private |
205 */ | 219 */ |
206 WebView.prototype.maybeSetupExecuteScript_ = function() {}; | 220 WebView.prototype.maybeSetupExecuteScript_ = function() {}; |
207 | 221 |
208 exports.WebView = WebView; | 222 exports.WebView = WebView; |
OLD | NEW |