Reviewers: shindig.remailer_gmail.com,
Description:
Interested in comments on these changes.
1. Only perform auto-detection of height when document.body and
document.documentElement exist, preventing size calculation of 0 when
API is called before this occurs.
2. Do not resize when size auto-detection yields value of 0.
The idea is to prevent gadgets from squeezing themselves to 0 height
under various circumstances.
While both changes are in this patch, they may be separated.
Please review this at http://codereview.appspot.com/88160
Affected files:
features/src/main/javascript/features/dynamic-height/dynamic-height.js
Index:
features/src/main/javascript/features/dynamic-height/dynamic-height.js
===================================================================
--- features/src/main/javascript/features/dynamic-height/dynamic-height.js
(revision 793777)
+++ features/src/main/javascript/features/dynamic-height/dynamic-height.js
(working copy)
@@ -109,7 +109,10 @@
*/
gadgets.window.adjustHeight = function(opt_height) {
var newHeight = parseInt(opt_height, 10);
+ var heightAutoCalculated = false;
if (isNaN(newHeight)) {
+ heightAutoCalculated = true;
+
// Resize the gadget to fit its content.
// Calculating inner content height is hard and different between
@@ -142,7 +145,7 @@
// (ie: made smaller). These properties also do not account margin
and
// padding size of an element.
newHeight = getHeightForWebkit();
- } else {
+ } else if (body && docEl) {
// In Quirks mode:
// documentElement.clientHeight is equal to
documentElement.offsetHeight
// except in IE. In most browsers, document.documentElement can
be used
@@ -172,7 +175,9 @@
}
// Only make the IFPC call if height has changed
- if (newHeight !== oldHeight) {
+ if (newHeight !== oldHeight &&
+ !isNaN(newHeight) &&
+ !(heightAutoCalculated && newHeight === 0)) {
oldHeight = newHeight;
gadgets.rpc.call(null, "resize_iframe", null, newHeight);
}