Commit bc7231e3 authored by Richard Gibson's avatar Richard Gibson Committed by Dave Methvin

Apply a GibsonTransform(-55) to the #10877 fix. Closes gh-788.

parent d5e5ce5b
...@@ -112,7 +112,7 @@ jQuery.extend({ ...@@ -112,7 +112,7 @@ jQuery.extend({
// convert relative number strings (+= or -=) to relative numbers. #7345 // convert relative number strings (+= or -=) to relative numbers. #7345
if ( type === "string" && (ret = rrelNum.exec( value )) ) { if ( type === "string" && (ret = rrelNum.exec( value )) ) {
value = ( +( ret[1] + 1) * +ret[2] ) + parseFloat( jQuery.css( elem, name ) ); value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
// Fixes bug #9237 // Fixes bug #9237
type = "number"; type = "number";
} }
...@@ -147,8 +147,8 @@ jQuery.extend({ ...@@ -147,8 +147,8 @@ jQuery.extend({
} }
}, },
css: function( elem, name, extra ) { css: function( elem, name, numeric, extra ) {
var ret, hooks, var val, num, hooks,
origName = jQuery.camelCase( name ); origName = jQuery.camelCase( name );
// Make sure that we're working with the right name // Make sure that we're working with the right name
...@@ -164,13 +164,21 @@ jQuery.extend({ ...@@ -164,13 +164,21 @@ jQuery.extend({
} }
// If a hook was provided get the computed value from there // If a hook was provided get the computed value from there
if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) { if ( hooks && "get" in hooks ) {
return ret; val = hooks.get( elem, true, extra );
}
// Otherwise, if a way to get the computed value exists, use that // Otherwise, if a way to get the computed value exists, use that
} else { if ( val === undefined ) {
return curCSS( elem, name ); val = curCSS( elem, name );
} }
// Return, converting to number if forced or a qualifier was provided and val looks numeric
if ( numeric || extra ) {
num = parseFloat( val );
return numeric || jQuery.isNumeric( num ) ? num || 0 : val;
}
return val;
}, },
// A method for quickly swapping in/out CSS properties to get correct calculations // A method for quickly swapping in/out CSS properties to get correct calculations
...@@ -272,25 +280,28 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) { ...@@ -272,25 +280,28 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) {
function setPositiveNumber( elem, value, subtract ) { function setPositiveNumber( elem, value, subtract ) {
var matches = rnumsplit.exec( value ); var matches = rnumsplit.exec( value );
return matches ? return matches ?
Math.max( 0, +matches[ 1 ] - ( subtract || 0 ) ) + ( matches [ 2 ] || "px" ) Math.max( 0, matches[ 1 ] - ( subtract || 0 ) ) + ( matches[ 2 ] || "px" ) :
: value; value;
} }
function augmentWidthOrHeight( name, elem, extra, isBorderBox ) { function augmentWidthOrHeight( elem, name, extra, isBorderBox ) {
var val = 0, var i = extra === ( isBorderBox ? "border" : "content" ) ?
i = name === "width" ? 1 : 0; // If we already have the right measurement, avoid augmentation
4 :
// Otherwise initialize for horizontal or vertical properties
name === "width" ? 1 : 0,
val = 0;
// if the measurement we need is already represented by the measurement
// there's no need to augment further
if ( extra !== (isBorderBox ? "border" : "content") ) {
for ( ; i < 4; i += 2 ) { for ( ; i < 4; i += 2 ) {
// both box models exclude margin, so add it if we want it // both box models exclude margin, so add it if we want it
if ( extra === "margin" ) { if ( extra === "margin" ) {
// we use jQuery.css instead of curCSS here // we use jQuery.css instead of curCSS here
// because of the reliableMarginRight CSS hook! // because of the reliableMarginRight CSS hook!
val += parseFloat( jQuery.css( elem, extra + cssExpand[ i ] ) ) || 0; val += jQuery.css( elem, extra + cssExpand[ i ], true );
} }
// From this point on we use curCSS for maximum performance (relevant in animations)
if ( isBorderBox ) { if ( isBorderBox ) {
// border-box includes padding, so remove it if we want content // border-box includes padding, so remove it if we want content
if ( extra === "content" ) { if ( extra === "content" ) {
...@@ -311,7 +322,6 @@ function augmentWidthOrHeight( name, elem, extra, isBorderBox ) { ...@@ -311,7 +322,6 @@ function augmentWidthOrHeight( name, elem, extra, isBorderBox ) {
} }
} }
} }
}
return val; return val;
} }
...@@ -343,14 +353,15 @@ function getWidthOrHeight( elem, name, extra ) { ...@@ -343,14 +353,15 @@ function getWidthOrHeight( elem, name, extra ) {
val = parseFloat( val ) || 0; val = parseFloat( val ) || 0;
} }
// determine which box-sizing width we're supposed to be getting // use the active box-sizing model to add/subtract irrelevant styles
if ( !extra ) { return ( val +
extra = isBorderBox ? "border" : "content"; augmentWidthOrHeight(
} elem,
name,
val += augmentWidthOrHeight( name, elem, extra, valueIsBorderBox ); extra || ( isBorderBox ? "border" : "content" ),
valueIsBorderBox
return val + "px"; )
) + "px";
} }
jQuery.each([ "height", "width" ], function( i, name ) { jQuery.each([ "height", "width" ], function( i, name ) {
...@@ -370,8 +381,8 @@ jQuery.each([ "height", "width" ], function( i, name ) { ...@@ -370,8 +381,8 @@ jQuery.each([ "height", "width" ], function( i, name ) {
set: function( elem, value, extra ) { set: function( elem, value, extra ) {
return setPositiveNumber( elem, value, extra ? return setPositiveNumber( elem, value, extra ?
augmentWidthOrHeight( augmentWidthOrHeight(
name,
elem, elem,
name,
extra, extra,
jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box" jQuery.support.boxSizing && jQuery.css( elem, "boxSizing" ) === "border-box"
) : 0 ) : 0
......
(function( jQuery ) { (function( jQuery ) {
// Create width, height, innerHeight, innerWidth, outerHeight and outerWidth methods // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
// margin is only for outerHeight, outerWidth
jQuery.fn[ funcName ] = function( margin, value ) {
var clientProp = "client" + name, var clientProp = "client" + name,
scrollProp = "scroll" + name, scrollProp = "scroll" + name,
offsetProp = "offset" + name; offsetProp = "offset" + name,
chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
// height, width, innerHeight and innerWidth
jQuery.each( { padding: "inner" + name, content: type }, function( extra, funcName ) {
jQuery.fn[ funcName ] = function( value ) {
var args = [ type, extra ];
if ( arguments.length ) {
args.push( value );
}
return getDimension.apply( this, args );
};
});
// outerHeight and outerWidth
jQuery.fn[ "outer" + name ] = function( margin, value ) {
var args = [ type, ( margin === true || value === true ) ? "margin" : "border" ];
if ( arguments.length && typeof margin !== "boolean" ) {
args.push( margin );
}
return getDimension.apply( this, args );
};
function getDimension( type, extra, value ) {
return jQuery.access( this, function( elem, type, value ) { return jQuery.access( this, function( elem, type, value ) {
var doc, orig, ret; var doc;
if ( jQuery.isWindow( elem ) ) { if ( jQuery.isWindow( elem ) ) {
// As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there // As of 5/8/2012 this will yield incorrect results for Mobile Safari, but there
...@@ -56,17 +40,15 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { ...@@ -56,17 +40,15 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
); );
} }
// Get width or height on the element return value === undefined ?
if ( value === undefined ) { // Get width or height on the element, requesting but not forcing parseFloat
orig = jQuery.css( elem, type, extra ); jQuery.css( elem, type, value, extra ) :
ret = parseFloat( orig );
return jQuery.isNumeric( ret ) ? ret : orig;
}
// Set the width or height on the element // Set width or height on the element
jQuery.style( elem, type, value, extra ); jQuery.style( elem, type, value, extra );
}, type, value, arguments.length > 2, null ); }, type, chainable ? margin : undefined, chainable );
} };
});
}); });
})( jQuery ); })( jQuery );
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment