MCPcopy Create free account
hub / github.com/dtmilano/AndroidViewClient / boxModelAdjustment

Function boxModelAdjustment

docs/_static/jquery-3.6.0.js:6707–6773  ·  view source on GitHub ↗
( elem, dimension, box, isBorderBox, styles, computedVal )

Source from the content-addressed store, hash-verified

6705}
6706
6707function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
6708 var i = dimension === "width" ? 1 : 0,
6709 extra = 0,
6710 delta = 0;
6711
6712 // Adjustment may not be necessary
6713 if ( box === ( isBorderBox ? "border" : "content" ) ) {
6714 return 0;
6715 }
6716
6717 for ( ; i < 4; i += 2 ) {
6718
6719 // Both box models exclude margin
6720 if ( box === "margin" ) {
6721 delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
6722 }
6723
6724 // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
6725 if ( !isBorderBox ) {
6726
6727 // Add padding
6728 delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
6729
6730 // For "border" or "margin", add border
6731 if ( box !== "padding" ) {
6732 delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6733
6734 // But still keep track of it otherwise
6735 } else {
6736 extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6737 }
6738
6739 // If we get here with a border-box (content + padding + border), we're seeking "content" or
6740 // "padding" or "margin"
6741 } else {
6742
6743 // For "content", subtract padding
6744 if ( box === "content" ) {
6745 delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
6746 }
6747
6748 // For "content" or "padding", subtract border
6749 if ( box !== "margin" ) {
6750 delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
6751 }
6752 }
6753 }
6754
6755 // Account for positive content-box scroll gutter when requested by providing computedVal
6756 if ( !isBorderBox && computedVal >= 0 ) {
6757
6758 // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
6759 // Assuming integer scroll gutter, subtract the rest and round down
6760 delta += Math.max( 0, Math.ceil(
6761 elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
6762 computedVal -
6763 delta -
6764 extra -

Callers 2

getWidthOrHeightFunction · 0.85
jquery-3.6.0.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected