From: Shahyar Date: Wed, 30 Jul 2014 22:50:17 +0000 (-0400) Subject: Correct shadow flipping in CSSJanus X-Git-Tag: 1.31.0-rc.0~14652^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=923ad97b3aba45d0bce1aa821d65baa1a1f65073 Correct shadow flipping in CSSJanus Was incorrectly assuming values between -1 and 1 were 0 Fixes an issue with mw-ui-input class in RTL mode which makes use of box shadow. Change-Id: I13e52467721bc2534e0a7c5245e3380ac43736ef --- diff --git a/includes/libs/CSSJanus.php b/includes/libs/CSSJanus.php index 4f0651d939..30b92c72ff 100644 --- a/includes/libs/CSSJanus.php +++ b/includes/libs/CSSJanus.php @@ -301,7 +301,7 @@ class CSSJanus { // (We can't just negate the value with unary minus due to the units.) $flipSign = function ( $cssValue ) { // Don't mangle zeroes - if ( intval( $cssValue ) === 0 ) { + if ( floatval( $cssValue ) === 0.0 ) { return $cssValue; } elseif ( $cssValue[0] === '-' ) { return substr( $cssValue, 1 ); diff --git a/tests/phpunit/includes/libs/CSSJanusTest.php b/tests/phpunit/includes/libs/CSSJanusTest.php index c8b20d2a8b..407f11a64c 100644 --- a/tests/phpunit/includes/libs/CSSJanusTest.php +++ b/tests/phpunit/includes/libs/CSSJanusTest.php @@ -221,6 +221,11 @@ class CSSJanusTest extends MediaWikiTestCase { // Don't mangle zeroes '.foo { text-shadow: orange 0 2px; }' ), + array( + // Make sure floats are not considered zero + '.foo { box-shadow: inset .5em 0 0 white; }', + '.foo { box-shadow: inset -.5em 0 0 white; }', + ), // Direction // Note: This differs from the Python implementation,