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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/renderer/resources/guest_view/guest_view_container.js
diff --git a/extensions/renderer/resources/guest_view/guest_view_container.js b/extensions/renderer/resources/guest_view/guest_view_container.js
index 35c6991039cec6152b94e483f75a1c3e0cc547fa..5b6a736758ffe04dbec929baf704ec9289618e24 100644
--- a/extensions/renderer/resources/guest_view/guest_view_container.js
+++ b/extensions/renderer/resources/guest_view/guest_view_container.js
@@ -157,9 +157,17 @@ GuestViewContainer.prototype.onElementResize = function(oldWidth, oldHeight,
GuestViewContainer.prototype.buildParams = function() {
var params = this.buildContainerParams();
params['instanceId'] = this.viewInstanceId;
+ // When the GuestViewContainer is not participating in layout (display:none)
+ // then getBoundingClientRect() would report a width and height of 0.
+ // However, in the case where the GuestViewContainer has a fixed size we can
+ // use that value to initially size the guest so as to avoid a relayout of the
+ // on display:block.
+ var css = window.getComputedStyle(this.element, null);
var elementRect = this.element.getBoundingClientRect();
- params['elementWidth'] = parseInt(elementRect.width);
- params['elementHeight'] = parseInt(elementRect.height);
+ params['elementWidth'] = parseInt(elementRect.width) ||
+ parseInt(css.getPropertyValue('width'));
+ params['elementHeight'] = parseInt(elementRect.height) ||
+ parseInt(css.getPropertyValue('height'));
return params;
};
« 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