( elem, dimension, box, isBorderBox, styles, computedVal )
| 37 | } |
| 38 | |
| 39 | function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) { |
| 40 | var i = dimension === "width" ? 1 : 0, |
| 41 | extra = 0, |
| 42 | delta = 0, |
| 43 | marginDelta = 0; |
| 44 | |
| 45 | // Adjustment may not be necessary |
| 46 | if ( box === ( isBorderBox ? "border" : "content" ) ) { |
| 47 | return 0; |
| 48 | } |
| 49 | |
| 50 | for ( ; i < 4; i += 2 ) { |
| 51 | |
| 52 | // Both box models exclude margin |
| 53 | // Count margin delta separately to only add it after scroll gutter adjustment. |
| 54 | // This is needed to make negative margins work with `outerHeight( true )` (gh-3982). |
| 55 | if ( box === "margin" ) { |
| 56 | marginDelta += jQuery.css( elem, box + cssExpand[ i ], true, styles ); |
| 57 | } |
| 58 | |
| 59 | // If we get here with a content-box, we're seeking "padding" or "border" or "margin" |
| 60 | if ( !isBorderBox ) { |
| 61 | |
| 62 | // Add padding |
| 63 | delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); |
| 64 | |
| 65 | // For "border" or "margin", add border |
| 66 | if ( box !== "padding" ) { |
| 67 | delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); |
| 68 | |
| 69 | // But still keep track of it otherwise |
| 70 | } else { |
| 71 | extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); |
| 72 | } |
| 73 | |
| 74 | // If we get here with a border-box (content + padding + border), we're seeking "content" or |
| 75 | // "padding" or "margin" |
| 76 | } else { |
| 77 | |
| 78 | // For "content", subtract padding |
| 79 | if ( box === "content" ) { |
| 80 | delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); |
| 81 | } |
| 82 | |
| 83 | // For "content" or "padding", subtract border |
| 84 | if ( box !== "margin" ) { |
| 85 | delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | // Account for positive content-box scroll gutter when requested by providing computedVal |
| 91 | if ( !isBorderBox && computedVal >= 0 ) { |
| 92 | |
| 93 | // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border |
| 94 | // Assuming integer scroll gutter, subtract the rest and round down |
| 95 | delta += Math.max( 0, Math.ceil( |
| 96 | elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - |
no outgoing calls
no test coverage detected