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

Side by Side Diff: chrome/renderer/resources/extensions/browser_tag.js

Issue 11231086: Remove width and height property from <webview> tag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update the tests, less timeouts. Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/browser_tag/main.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <browser> tag via Mutation Observers. 5 // Shim that simulates a <browser> 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 BROWSER_TAG_ATTRIBUTES = ['src', 'width', 'height']; 10 var BROWSER_TAG_ATTRIBUTES = ['src'];
11 11
12 var BROWSER_TAG_READONLY_ATTRIBUTES = ['contentWindow']; 12 var BROWSER_TAG_READONLY_ATTRIBUTES = ['contentWindow'];
13 13
14 // All exposed api methods for <browser>, these are forwarded to the browser 14 // All exposed api methods for <browser>, these are forwarded to the browser
15 // plugin. 15 // plugin.
16 var BROWSER_TAG_API_METHODS = [ 16 var BROWSER_TAG_API_METHODS = [
17 'addEventListener', 17 'addEventListener',
18 'back', 18 'back',
19 'canGoBack', 19 'canGoBack',
20 'canGoForward', 20 'canGoForward',
(...skipping 28 matching lines...) Expand all
49 49
50 /** 50 /**
51 * @constructor 51 * @constructor
52 */ 52 */
53 function BrowserTag(node) { 53 function BrowserTag(node) {
54 this.node_ = node; 54 this.node_ = node;
55 var shadowRoot = new WebKitShadowRoot(node); 55 var shadowRoot = new WebKitShadowRoot(node);
56 56
57 this.objectNode_ = document.createElement('object'); 57 this.objectNode_ = document.createElement('object');
58 this.objectNode_.type = 'application/browser-plugin'; 58 this.objectNode_.type = 'application/browser-plugin';
59 // The <object> node fills in the <browser> container.
60 this.objectNode_.style.width = '100%';
61 this.objectNode_.style.height = '100%';
59 BROWSER_TAG_ATTRIBUTES.forEach(this.copyAttribute_, this); 62 BROWSER_TAG_ATTRIBUTES.forEach(this.copyAttribute_, this);
60 63
61 shadowRoot.appendChild(this.objectNode_); 64 shadowRoot.appendChild(this.objectNode_);
62 65
63 // this.objectNode_[apiMethod] are defined after the shadow object is appended 66 // this.objectNode_[apiMethod] are defined after the shadow object is appended
64 // to the shadow root. 67 // to the shadow root.
65 BROWSER_TAG_API_METHODS.forEach(function(apiMethod) { 68 BROWSER_TAG_API_METHODS.forEach(function(apiMethod) {
66 node[apiMethod] = this.objectNode_[apiMethod].bind(this.objectNode_); 69 node[apiMethod] = this.objectNode_[apiMethod].bind(this.objectNode_);
67 }, this); 70 }, this);
68 71
(...skipping 12 matching lines...) Expand all
81 BROWSER_TAG_ATTRIBUTES.forEach(function(attributeName) { 84 BROWSER_TAG_ATTRIBUTES.forEach(function(attributeName) {
82 Object.defineProperty(this.node_, attributeName, { 85 Object.defineProperty(this.node_, attributeName, {
83 get: function() { 86 get: function() {
84 if (attributeName == 'src') { 87 if (attributeName == 'src') {
85 // Always read src attribute from the plugin <object> since: a) It can 88 // Always read src attribute from the plugin <object> since: a) It can
86 // have different value when empty src is set. b) BrowserPlugin 89 // have different value when empty src is set. b) BrowserPlugin
87 // updates its src attribute on guest-initiated navigations. 90 // updates its src attribute on guest-initiated navigations.
88 return objectNode.src; 91 return objectNode.src;
89 } 92 }
90 var value = node.getAttribute(attributeName); 93 var value = node.getAttribute(attributeName);
91 var numericValue = parseInt(value, 10); 94 var numericValue = parseInt(value, 10);
Mihai Parparita -not on Chrome 2012/10/24 17:16:54 You can now remove this.
lazyboy 2012/10/24 18:29:44 Thanks, Done.
92 return isNaN(numericValue) ? value : numericValue; 95 return isNaN(numericValue) ? value : numericValue;
93 }, 96 },
94 set: function(value) { 97 set: function(value) {
95 node.setAttribute(attributeName, value); 98 node.setAttribute(attributeName, value);
96 }, 99 },
97 enumerable: true 100 enumerable: true
98 }); 101 });
99 }, this); 102 }, this);
100 103
101 // We cannot use {writable: true} property descriptor because we want dynamic 104 // We cannot use {writable: true} property descriptor because we want dynamic
(...skipping 28 matching lines...) Expand all
130 } 133 }
131 }; 134 };
132 135
133 /** 136 /**
134 * @private 137 * @private
135 */ 138 */
136 BrowserTag.prototype.copyAttribute_ = function(attributeName) { 139 BrowserTag.prototype.copyAttribute_ = function(attributeName) {
137 this.objectNode_.setAttribute( 140 this.objectNode_.setAttribute(
138 attributeName, this.node_.getAttribute(attributeName)); 141 attributeName, this.node_.getAttribute(attributeName));
139 }; 142 };
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/browser_tag/main.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698