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

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

Issue 11231086: Remove width and height property from <webview> tag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments + Sync <browser> to <webview> renaming. 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/web_view/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 <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 WEB_VIEW_ATTRIBUTES = ['src', 'width', 'height']; 10 var WEB_VIEW_ATTRIBUTES = ['src'];
11 11
12 var WEB_VIEW_READONLY_ATTRIBUTES = ['contentWindow']; 12 var WEB_VIEW_READONLY_ATTRIBUTES = ['contentWindow'];
13 13
14 // All exposed api methods for <webview>, these are forwarded to the browser 14 // All exposed api methods for <webview>, these are forwarded to the browser
15 // plugin. 15 // plugin.
16 var WEB_VIEW_API_METHODS = [ 16 var WEB_VIEW_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 WebView(node) { 53 function WebView(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 WEB_VIEW_ATTRIBUTES.forEach(this.copyAttribute_, this); 62 WEB_VIEW_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 WEB_VIEW_API_METHODS.forEach(function(apiMethod) { 68 WEB_VIEW_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 11 matching lines...) Expand all
80 // Expose getters and setters for the attributes. 83 // Expose getters and setters for the attributes.
81 WEB_VIEW_ATTRIBUTES.forEach(function(attributeName) { 84 WEB_VIEW_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 return node.getAttribute(attributeName);
91 var numericValue = parseInt(value, 10);
92 return isNaN(numericValue) ? value : numericValue;
93 }, 94 },
94 set: function(value) { 95 set: function(value) {
95 node.setAttribute(attributeName, value); 96 node.setAttribute(attributeName, value);
96 }, 97 },
97 enumerable: true 98 enumerable: true
98 }); 99 });
99 }, this); 100 }, this);
100 101
101 // We cannot use {writable: true} property descriptor because we want dynamic 102 // We cannot use {writable: true} property descriptor because we want dynamic
102 // getter value. 103 // getter value.
(...skipping 27 matching lines...) Expand all
130 } 131 }
131 }; 132 };
132 133
133 /** 134 /**
134 * @private 135 * @private
135 */ 136 */
136 WebView.prototype.copyAttribute_ = function(attributeName) { 137 WebView.prototype.copyAttribute_ = function(attributeName) {
137 this.objectNode_.setAttribute( 138 this.objectNode_.setAttribute(
138 attributeName, this.node_.getAttribute(attributeName)); 139 attributeName, this.node_.getAttribute(attributeName));
139 }; 140 };
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/platform_apps/web_view/main.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698