/*
	Copyright (c) 2004-2016, The JS Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/

//>>built
define("dojo/dom-geometry",["./sniff","./_base/window","./dom","./dom-style"],function(l,n,m,k){function q(a,d,b,c,f,e){e=e||"px";a=a.style;isNaN(d)||(a.left=d+e);isNaN(b)||(a.top=b+e);0<=c&&(a.width=c+e);0<=f&&(a.height=f+e)}function r(a){return"button"==a.tagName.toLowerCase()||"input"==a.tagName.toLowerCase()&&"button"==(a.getAttribute("type")||"").toLowerCase()}function t(a){return"border-box"==g.boxModel||"table"==a.tagName.toLowerCase()||r(a)}function u(a){var d={x:0,y:0,width:0,height:0,top:0,
right:0,bottom:0,left:0};try{var b=a.getBoundingClientRect()}catch(c){return d}return"undefined"===typeof b.left?d:b}var g={boxModel:"content-box"};l("ie")&&(g.boxModel="BackCompat"==document.compatMode?"border-box":"content-box");g.getPadExtents=function(a,d){a=m.byId(a);var b=d||k.getComputedStyle(a),c=k.toPixelValue,f=c(a,b.paddingLeft),e=c(a,b.paddingTop),h=c(a,b.paddingRight);b=c(a,b.paddingBottom);return{l:f,t:e,r:h,b:b,w:f+h,h:e+b}};g.getBorderExtents=function(a,d){a=m.byId(a);var b=k.toPixelValue,
c=d||k.getComputedStyle(a),f="none"!=c.borderLeftStyle?b(a,c.borderLeftWidth):0,e="none"!=c.borderTopStyle?b(a,c.borderTopWidth):0,h="none"!=c.borderRightStyle?b(a,c.borderRightWidth):0;b="none"!=c.borderBottomStyle?b(a,c.borderBottomWidth):0;return{l:f,t:e,r:h,b:b,w:f+h,h:e+b}};g.getPadBorderExtents=function(a,d){a=m.byId(a);var b=d||k.getComputedStyle(a),c=g.getPadExtents(a,b);b=g.getBorderExtents(a,b);return{l:c.l+b.l,t:c.t+b.t,r:c.r+b.r,b:c.b+b.b,w:c.w+b.w,h:c.h+b.h}};g.getMarginExtents=function(a,
d){a=m.byId(a);var b=d||k.getComputedStyle(a),c=k.toPixelValue,f=c(a,b.marginLeft),e=c(a,b.marginTop),h=c(a,b.marginRight);b=c(a,b.marginBottom);return{l:f,t:e,r:h,b:b,w:f+h,h:e+b}};g.getMarginBox=function(a,d){a=m.byId(a);var b=d||k.getComputedStyle(a);b=g.getMarginExtents(a,b);var c=a.offsetLeft-b.l,f=a.offsetTop-b.t,e=a.parentNode,h=k.toPixelValue;8==l("ie")&&!l("quirks")&&e&&(e=k.getComputedStyle(e),c-="none"!=e.borderLeftStyle?h(a,e.borderLeftWidth):0,f-="none"!=e.borderTopStyle?h(a,e.borderTopWidth):
0);return{l:c,t:f,w:a.offsetWidth+b.w,h:a.offsetHeight+b.h}};g.getContentBox=function(a,d){a=m.byId(a);var b=d||k.getComputedStyle(a),c=a.clientWidth,f=g.getPadExtents(a,b);var e=g.getBorderExtents(a,b);b=a.offsetLeft+f.l+e.l;var h=a.offsetTop+f.t+e.t;c?e=a.clientHeight:(c=a.offsetWidth-e.w,e=a.offsetHeight-e.h);if(8==l("ie")&&!l("quirks")){var p=a.parentNode,v=k.toPixelValue;p&&(p=k.getComputedStyle(p),b-="none"!=p.borderLeftStyle?v(a,p.borderLeftWidth):0,h-="none"!=p.borderTopStyle?v(a,p.borderTopWidth):
0)}return{l:b,t:h,w:c-f.w,h:e-f.h}};g.setContentSize=function(a,d,b){a=m.byId(a);var c=d.w;d=d.h;t(a)&&(b=g.getPadBorderExtents(a,b),0<=c&&(c+=b.w),0<=d&&(d+=b.h));q(a,NaN,NaN,c,d)};var w={l:0,t:0,w:0,h:0};g.setMarginBox=function(a,d,b){a=m.byId(a);var c=b||k.getComputedStyle(a);b=d.w;var f=d.h,e=t(a)?w:g.getPadBorderExtents(a,c);c=g.getMarginExtents(a,c);if(l("webkit")&&r(a)){var h=a.style;0<=b&&!h.width&&(h.width="4px");0<=f&&!h.height&&(h.height="4px")}0<=b&&(b=Math.max(b-e.w-c.w,0));0<=f&&(f=
Math.max(f-e.h-c.h,0));q(a,d.l,d.t,b,f)};g.isBodyLtr=function(a){a=a||n.doc;return"ltr"==(n.body(a).dir||a.documentElement.dir||"ltr").toLowerCase()};g.docScroll=function(a){a=a||n.doc;var d=a.parentWindow||a.defaultView;return"pageXOffset"in d?{x:d.pageXOffset,y:d.pageYOffset}:(d=l("quirks")?n.body(a):a.documentElement)&&{x:g.fixIeBiDiScrollLeft(d.scrollLeft||0,a),y:d.scrollTop||0}};g.getIeDocumentElementOffset=function(a){return{x:0,y:0}};g.fixIeBiDiScrollLeft=function(a,d){d=d||n.doc;var b=l("ie");
if(b&&!g.isBodyLtr(d)){var c=l("quirks"),f=c?n.body(d):d.documentElement,e=n.global;6==b&&!c&&e.frameElement&&f.scrollHeight>f.clientHeight&&(a+=f.clientLeft);return 8>b||c?a+f.clientWidth-f.scrollWidth:-a}return a};g.position=function(a,d){a=m.byId(a);var b=n.body(a.ownerDocument),c=u(a);c={x:c.left,y:c.top,w:c.right-c.left,h:c.bottom-c.top};9>l("ie")&&(c.x-=l("quirks")?b.clientLeft+b.offsetLeft:0,c.y-=l("quirks")?b.clientTop+b.offsetTop:0);d&&(b=g.docScroll(a.ownerDocument),c.x+=b.x,c.y+=b.y);return c};
g.getMarginSize=function(a,d){a=m.byId(a);var b=g.getMarginExtents(a,d||k.getComputedStyle(a)),c=u(a);return{w:c.right-c.left+b.w,h:c.bottom-c.top+b.h}};g.normalizeEvent=function(a){"layerX"in a||(a.layerX=a.offsetX,a.layerY=a.offsetY);if(!("pageX"in a)){var d=a.target;d=d&&d.ownerDocument||document;var b=l("quirks")?d.body:d.documentElement;a.pageX=a.clientX+g.fixIeBiDiScrollLeft(b.scrollLeft||0,d);a.pageY=a.clientY+(b.scrollTop||0)}};return g});