You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by hs...@apache.org on 2011/08/17 23:35:53 UTC

svn commit: r1158921 - /shindig/trunk/features/src/main/javascript/features/dynamic-height.height/dynamic-height-height.js

Author: hsaputra
Date: Wed Aug 17 21:35:52 2011
New Revision: 1158921

URL: http://svn.apache.org/viewvc?rev=1158921&view=rev
Log:
SHINDIG-1583  | Remove duplicate code in features/src/main/javascript/features/dynamic-height.height/dynamic-height-height.js | Patch from Dan Dumont

CR at : https://reviews.apache.org/r/1577



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

Modified: shindig/trunk/features/src/main/javascript/features/dynamic-height.height/dynamic-height-height.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/dynamic-height.height/dynamic-height-height.js?rev=1158921&r1=1158920&r2=1158921&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/dynamic-height.height/dynamic-height-height.js (original)
+++ shindig/trunk/features/src/main/javascript/features/dynamic-height.height/dynamic-height-height.js Wed Aug 17 21:35:52 2011
@@ -182,89 +182,4 @@ gadgets.window = gadgets.window || {};
       }
     }
   };
-
-  /**
-   * Parse out the value (specified in px) for a CSS attribute of an element.
-   *
-   * @param {Element} elem the element with the attribute to look for.
-   * @param {string} attr the CSS attribute name of interest.
-   * @return {number} the value of the px attr of the elem.
-   * @private
-   */
-  function parseIntFromElemPxAttribute(elem, attr) {
-    var style = window.getComputedStyle(elem, '');
-    var value = style.getPropertyValue(attr);
-    value.match(/^([0-9]+)/);
-    return parseInt(RegExp.$1, 10);
-  }
-
-  /**
-   * For Webkit-based browsers, calculate the height of the gadget iframe by
-   * iterating through all elements in the gadget, starting with the body tag.
-   * It is not sufficient to only account body children elements, because
-   * CSS style position "float" may place a child element outside of the
-   * containing parent element. Not counting "float" elements may lead to
-   * undercounting.
-   *
-   * @return {number} the height of the gadget.
-   * @private
-   */
-  function getHeightForWebkit() {
-    var result = 0;
-    var queue = [document.body];
-
-    while (queue.length > 0) {
-      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.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);
-        }
-        queue.push(child);
-      }
-    }
-
-    // Add border, padding and margin of the containing body.
-    return result +
-        parseIntFromElemPxAttribute(document.body, 'border-bottom') +
-        parseIntFromElemPxAttribute(document.body, 'margin-bottom') +
-        parseIntFromElemPxAttribute(document.body, 'padding-bottom');
-  }
 }());