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

Side by Side Diff: extensions/renderer/resources/guest_view/guest_view_container.js

Issue 997153004: GuestView: Use computed size if getBoundingClientRect() size is unavailable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comment Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // This module implements the shared functionality for different guestview 5 // This module implements the shared functionality for different guestview
6 // containers, such as web_view, app_view, etc. 6 // containers, such as web_view, app_view, etc.
7 7
8 var DocumentNatives = requireNative('document_natives'); 8 var DocumentNatives = requireNative('document_natives');
9 var GuestView = require('guestView').GuestView; 9 var GuestView = require('guestView').GuestView;
10 var GuestViewInternalNatives = requireNative('guest_view_internal'); 10 var GuestViewInternalNatives = requireNative('guest_view_internal');
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 this.dispatchEvent(resizeEvent); 150 this.dispatchEvent(resizeEvent);
151 151
152 if (!this.guest.getId()) 152 if (!this.guest.getId())
153 return; 153 return;
154 this.guest.setSize({normal: {width: newWidth, height: newHeight}}); 154 this.guest.setSize({normal: {width: newWidth, height: newHeight}});
155 }; 155 };
156 156
157 GuestViewContainer.prototype.buildParams = function() { 157 GuestViewContainer.prototype.buildParams = function() {
158 var params = this.buildContainerParams(); 158 var params = this.buildContainerParams();
159 params['instanceId'] = this.viewInstanceId; 159 params['instanceId'] = this.viewInstanceId;
160 // When the GuestViewContainer is not participating in layout (display:none)
161 // then getBoundingClientRect() would report a width and height of 0.
162 // However, in the case where the GuestViewContainer has a fixed size we can
163 // use that value to initially size the guest so as to avoid a relayout of the
164 // on display:block.
165 var css = window.getComputedStyle(this.element, null);
160 var elementRect = this.element.getBoundingClientRect(); 166 var elementRect = this.element.getBoundingClientRect();
161 params['elementWidth'] = parseInt(elementRect.width); 167 params['elementWidth'] = parseInt(elementRect.width) ||
162 params['elementHeight'] = parseInt(elementRect.height); 168 parseInt(css.getPropertyValue('width'));
169 params['elementHeight'] = parseInt(elementRect.height) ||
170 parseInt(css.getPropertyValue('height'));
163 return params; 171 return params;
164 }; 172 };
165 173
166 GuestViewContainer.prototype.dispatchEvent = function(event) { 174 GuestViewContainer.prototype.dispatchEvent = function(event) {
167 return this.element.dispatchEvent(event); 175 return this.element.dispatchEvent(event);
168 } 176 }
169 177
170 // Implemented by the specific view type, if needed. 178 // Implemented by the specific view type, if needed.
171 GuestViewContainer.prototype.buildContainerParams = function() { return {}; }; 179 GuestViewContainer.prototype.buildContainerParams = function() { return {}; };
172 GuestViewContainer.prototype.onElementAttached = function() {}; 180 GuestViewContainer.prototype.onElementAttached = function() {};
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 // Delete the callbacks so developers cannot call them and produce unexpected 270 // Delete the callbacks so developers cannot call them and produce unexpected
263 // behavior. 271 // behavior.
264 delete proto.createdCallback; 272 delete proto.createdCallback;
265 delete proto.attachedCallback; 273 delete proto.attachedCallback;
266 delete proto.detachedCallback; 274 delete proto.detachedCallback;
267 delete proto.attributeChangedCallback; 275 delete proto.attributeChangedCallback;
268 } 276 }
269 277
270 // Exports. 278 // Exports.
271 exports.GuestViewContainer = GuestViewContainer; 279 exports.GuestViewContainer = GuestViewContainer;
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698