Author: hsaputra
Date: Tue Oct 12 21:02:38 2010
New Revision: 1021919

URL: http://svn.apache.org/viewvc?rev=1021919&view=rev
Log:
SHINDIG-1421 | Patch from Mat Mannion | dynamic-height feature overestimates 
the height of gadgets that have elements with clipped overflow in Webkit

Codereview: http://codereview.appspot.com/2120042

Thanks for the patch Mat.


Modified:
    
shindig/trunk/features/src/main/javascript/features/dynamic-height/dynamic-height.js

Modified: 
shindig/trunk/features/src/main/javascript/features/dynamic-height/dynamic-height.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/dynamic-height/dynamic-height.js?rev=1021919&r1=1021918&r2=1021919&view=diff
==============================================================================
--- 
shindig/trunk/features/src/main/javascript/features/dynamic-height/dynamic-height.js
 (original)
+++ 
shindig/trunk/features/src/main/javascript/features/dynamic-height/dynamic-height.js
 Tue Oct 12 21:02:38 2010
@@ -69,12 +69,43 @@ gadgets.window = gadgets.window || {};
       var elem = queue.shift();
       var children = elem.childNodes;
 
+      /*
+       * Here, we are checking if we are a container that clips its overflow 
wit h
+       * a specific height, because if so, we should ignore children
+       */
+
+      // check that elem is actually an element, could be a text node otherwise
+      if (typeof elem.style !== 'undefined') {
+        // Get the overflowY value, looking in the computed style if necessary
+        var overflowY = elem.style['overflowY'];
+        if (!overflowY) {
+          var css = document.defaultView.getComputedStyle(elem, null);
+          overflowY = css ? css['overflowY'] : null;
+        }
+
+        // The only non-clipping values of overflow is 'visible'. We assume 
that 'inherit'
+        // is also non-clipping at the moment, but should we check this?
+        if (overflowY != 'visible' && overflowY != 'inherit') {
+          // Make sure this element explicitly specifies a height
+          var height = elem.style['height'];
+          if (!height) {
+            var css = document.defaultView.getComputedStyle(elem, null);
+            height = css ? css['height'] : '';
+          }
+          if (height.length > 0 && height != 'auto') {
+            // We can safely ignore the children of this element,
+            // so move onto the next in the queue
+            continue;
+          }
+        }
+      }
+
       for (var i = 0; i < children.length; i++) {
         var child = children[i];
         if (typeof child.offsetTop !== 'undefined' &&
-            typeof child.scrollHeight !== 'undefined') {
-          // scrollHeight already accounts for border-bottom, padding-bottom.
-          var bottom = child.offsetTop + child.scrollHeight +
+            typeof child.offsetHeight  !== 'undefined') {
+          // offsetHeight already accounts for border-bottom, padding-bottom.
+          var bottom = child.offsetTop + child.offsetHeight +
               parseIntFromElemPxAttribute(child, 'margin-bottom');
           result = Math.max(result, bottom);
         }


Reply via email to