| 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 watchForTag = require("tagWatcher").watchForTag; | 10 var watchForTag = require("tagWatcher").watchForTag; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 window.addEventListener('DOMContentLoaded', function() { | 38 window.addEventListener('DOMContentLoaded', function() { |
| 39 watchForTag('WEBVIEW', function(addedNode) { new WebView(addedNode); }); | 39 watchForTag('WEBVIEW', function(addedNode) { new WebView(addedNode); }); |
| 40 }); | 40 }); |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * @constructor | 43 * @constructor |
| 44 */ | 44 */ |
| 45 function WebView(node) { | 45 function WebView(node) { |
| 46 this.node_ = node; | 46 this.node_ = node; |
| 47 var shadowRoot = new WebKitShadowRoot(node); | 47 var shadowRoot = node.webkitCreateShadowRoot(); |
| 48 | 48 |
| 49 this.objectNode_ = document.createElement('object'); | 49 this.objectNode_ = document.createElement('object'); |
| 50 this.objectNode_.type = 'application/browser-plugin'; | 50 this.objectNode_.type = 'application/browser-plugin'; |
| 51 // The <object> node fills in the <browser> container. | 51 // The <object> node fills in the <browser> container. |
| 52 this.objectNode_.style.width = '100%'; | 52 this.objectNode_.style.width = '100%'; |
| 53 this.objectNode_.style.height = '100%'; | 53 this.objectNode_.style.height = '100%'; |
| 54 WEB_VIEW_ATTRIBUTES.forEach(function(attributeName) { | 54 WEB_VIEW_ATTRIBUTES.forEach(function(attributeName) { |
| 55 this.objectNode_.setAttribute( | 55 this.objectNode_.setAttribute( |
| 56 attributeName, this.node_.getAttribute(attributeName)); | 56 attributeName, this.node_.getAttribute(attributeName)); |
| 57 }, this); | 57 }, this); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 var node = this.node_; | 136 var node = this.node_; |
| 137 this.objectNode_.addEventListener('-internal-' + eventname, function(e) { | 137 this.objectNode_.addEventListener('-internal-' + eventname, function(e) { |
| 138 var evt = new Event(eventname); | 138 var evt = new Event(eventname); |
| 139 var detail = e.detail ? JSON.parse(e.detail) : {}; | 139 var detail = e.detail ? JSON.parse(e.detail) : {}; |
| 140 attribs.forEach(function(attribName) { | 140 attribs.forEach(function(attribName) { |
| 141 evt[attribName] = detail[attribName]; | 141 evt[attribName] = detail[attribName]; |
| 142 }); | 142 }); |
| 143 node.dispatchEvent(evt); | 143 node.dispatchEvent(evt); |
| 144 }); | 144 }); |
| 145 } | 145 } |
| OLD | NEW |