Commit 7da6a47d authored by fsamuel's avatar fsamuel Committed by Commit bot

GuestView: Use computed size if getBoundingClientRect() size is unavailable.

BUG=470230

Review URL: https://codereview.chromium.org/997153004

Cr-Commit-Position: refs/heads/master@{#322440}
parent 8e31f8da
......@@ -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;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment