From 923ad97b3aba45d0bce1aa821d65baa1a1f65073 Mon Sep 17 00:00:00 2001 From: Shahyar Date: Wed, 30 Jul 2014 18:50:17 -0400 Subject: [PATCH] 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 --- includes/libs/CSSJanus.php | 2 +- tests/phpunit/includes/libs/CSSJanusTest.php | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) 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, -- 2.20.1