<commit_before>/*
==================================================================================================
  Lowland - JavaScript low level functions
  Copyright (C) 2012 <NAME>
==================================================================================================
*/

core.Module("lowland.bom.Element", {
  
  getContentWidth : function(element) {
    if ((core.Env.getValue("engine") == "gecko") && (element.getBoundingClientRect)) {
      // see https://bugzilla.mozilla.org/show_bug.cgi?id=450422
      var rect = element.getBoundingClientRect();
      return Math.round(rect.right) - Math.round(rect.left);
    } else {
      return element.offsetWidth;
    }
  },
  
  getContentHeight : function(element) {
    if ((core.Env.getValue("engine") == "gecko") && (element.getBoundingClientRect)) {
      // see https://bugzilla.mozilla.org/show_bug.cgi?id=450422
      var rect = element.getBoundingClientRect();
      return Math.round(rect.bottom) - Math.round(rect.top);
    } else {
      return element.offsetHeight;
    }
  },
  
  getContentSize : function(element) {
    if ((core.Env.getValue("engine") == "gecko") && (element.getBoundingClientRect)) {
      // see https://bugzilla.mozilla.org/show_bug.cgi?id=450422
      var rect = element.getBoundingClientRect();
      return  {
        width: Math.round(rect.right) - Math.round(rect.left),
        height: Math.round(rect.bottom) - Math.round(rect.top)
      };
    } else {
      return {
        width: element.offsetWidth,
        height: element.offsetHeight
      };
    }
  }
  
});<commit_msg>Add getLocation in Element<commit_after>/*
==================================================================================================
  Lowland - JavaScript low level functions
  Copyright (C) 2012 <NAME>
==================================================================================================
*/

(function(global){
  
  /*var computeBodyLocation = function() {
  };
  
  var computeOffset = function() {
  };
  
  var computeScroll = function() {
  };*/
  
  var getLocation = ("getBoundingClientRect" in document.documentElement) ? 
    function(element) {
      if ( !element || !element.ownerDocument ) {
        return null;
      }
  
      if ( element === element.ownerDocument.body ) {
        //return jQuery.offset.bodyOffset( elem );
        return null;
      }
  
      try {
        box = element.getBoundingClientRect();
      } catch(e) {}
  
      var doc = element.ownerDocument,
        docElem = doc.documentElement;
  
      // Make sure we're not dealing with a disconnected DOM node
      if ( !box /*|| !jQuery.contains( docElem, elem )*/ ) {
        return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
      }
  
  
      var body = doc.body,
        win = global.window, //getWindow(doc),
        clientTop  = docElem.clientTop  || body.clientTop  || 0,
        clientLeft = docElem.clientLeft || body.clientLeft || 0,
        scrollTop  = win.pageYOffset || true /*jQuery.support.boxModel*/ && docElem.scrollTop  || body.scrollTop,
        scrollLeft = win.pageXOffset || true /*jQuery.support.boxModel*/ && docElem.scrollLeft || body.scrollLeft,
        top  = box.top  + scrollTop  - clientTop,
        left = box.left + scrollLeft - clientLeft;
  
      return { top: top, left: left };
    } : function(element) {
      return null;
    };
  
  core.Module("lowland.bom.Element", {
    
    getContentWidth : function(element) {
      if ((core.Env.getValue("engine") == "gecko") && (element.getBoundingClientRect)) {
        // see https://bugzilla.mozilla.org/show_bug.cgi?id=450422
        var rect = element.getBoundingClientRect();
        return Math.round(rect.right) - Math.round(rect.left);
      } else {
        return element.offsetWidth;
      }
    },
    
    getContentHeight : function(element) {
      if ((core.Env.getValue("engine") == "gecko") && (element.getBoundingClientRect)) {
        // see https://bugzilla.mozilla.org/show_bug.cgi?id=450422
        var rect = element.getBoundingClientRect();
        return Math.round(rect.bottom) - Math.round(rect.top);
      } else {
        return element.offsetHeight;
      }
    },
    
    getContentSize : function(element) {
      if ((core.Env.getValue("engine") == "gecko") && (element.getBoundingClientRect)) {
        // see https://bugzilla.mozilla.org/show_bug.cgi?id=450422
        var rect = element.getBoundingClientRect();
        return  {
          width: Math.round(rect.right) - Math.round(rect.left),
          height: Math.round(rect.bottom) - Math.round(rect.top)
        };
      } else {
        return {
          width: element.offsetWidth,
          height: element.offsetHeight
        };
      }
    },
    
    getLocation : getLocation
    
  });

})(this);
{'fraction_non_alphanumeric': 0.212668743509865, 'fraction_numerical': 0.009968847352024923, 'mean_word_length': 2.7160493827160495, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1259664', 'n_tokens_mistral': 1454, 'n_tokens_neox': 1369, 'n_words': 249}