( elem, dimension, box, isBorderBox, styles, computedVal )
| 5974 | } |
| 5975 | |
| 5976 | function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) { |
| 5977 | var i = dimension === "width" ? 1 : 0, |
| 5978 | extra = 0, |
| 5979 | delta = 0, |
| 5980 | marginDelta = 0; |
| 5981 | |
| 5982 | // Adjustment may not be necessary |
| 5983 | if ( box === ( isBorderBox ? "border" : "content" ) ) { |
| 5984 | return 0; |
| 5985 | } |
| 5986 | |
| 5987 | for ( ; i < 4; i += 2 ) { |
| 5988 | |
| 5989 | // Both box models exclude margin |
| 5990 | // Count margin delta separately to only add it after scroll gutter adjustment. |
| 5991 | // This is needed to make negative margins work with `outerHeight( true )` (gh-3982). |
| 5992 | if ( box === "margin" ) { |
| 5993 | marginDelta += jQuery.css( elem, box + cssExpand[ i ], true, styles ); |
| 5994 | } |
| 5995 | |
| 5996 | // If we get here with a content-box, we're seeking "padding" or "border" or "margin" |
| 5997 | if ( !isBorderBox ) { |
| 5998 | |
| 5999 | // Add padding |
| 6000 | delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); |
| 6001 | |
| 6002 | // For "border" or "margin", add border |
| 6003 | if ( box !== "padding" ) { |
| 6004 | delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); |
| 6005 | |
| 6006 | // But still keep track of it otherwise |
| 6007 | } else { |
| 6008 | extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); |
| 6009 | } |
| 6010 | |
| 6011 | // If we get here with a border-box (content + padding + border), we're seeking "content" or |
| 6012 | // "padding" or "margin" |
| 6013 | } else { |
| 6014 | |
| 6015 | // For "content", subtract padding |
| 6016 | if ( box === "content" ) { |
| 6017 | delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); |
| 6018 | } |
| 6019 | |
| 6020 | // For "content" or "padding", subtract border |
| 6021 | if ( box !== "margin" ) { |
| 6022 | delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); |
| 6023 | } |
| 6024 | } |
| 6025 | } |
| 6026 | |
| 6027 | // Account for positive content-box scroll gutter when requested by providing computedVal |
| 6028 | if ( !isBorderBox && computedVal >= 0 ) { |
| 6029 | |
| 6030 | // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border |
| 6031 | // Assuming integer scroll gutter, subtract the rest and round down |
| 6032 | delta += Math.max( 0, Math.ceil( |
| 6033 | elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] - |
no outgoing calls
no test coverage detected