From d9022f63880ce039446fba8364f68e656b7bf4cb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 3 May 2012 13:01:35 +0200 Subject: Update to MediaWiki 1.19.0 --- includes/libs/CSSJanus.php | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'includes/libs/CSSJanus.php') diff --git a/includes/libs/CSSJanus.php b/includes/libs/CSSJanus.php index aa04bc49..c8fc296b 100644 --- a/includes/libs/CSSJanus.php +++ b/includes/libs/CSSJanus.php @@ -22,7 +22,9 @@ * written for LTR to RTL. * * The original Python version of CSSJanus is Copyright 2008 by Google Inc. and - * is distributed under the Apache license. + * is distributed under the Apache license. This PHP port is Copyright 2010 by + * Roan Kattouw and is dual-licensed under the GPL (as in the comment above) and + * the Apache (as in the original code) licenses. * * Original code: http://code.google.com/p/cssjanus/source/browse/trunk/cssjanus.py * License of original code: http://code.google.com/p/cssjanus/source/browse/trunk/LICENSE @@ -111,8 +113,8 @@ class CSSJanus { $patterns['four_notation_color'] = "/(-color\s*:\s*){$patterns['color']}(\s+){$patterns['color']}(\s+){$patterns['color']}(\s+){$patterns['color']}/i"; // The two regexes below are parenthesized differently then in the original implementation to make the // callback's job more straightforward - $patterns['bg_horizontal_percentage'] = "/(background(?:-position)?\s*:\s*[^%]*?)({$patterns['num']})(%\s*(?:{$patterns['quantity']}|{$patterns['ident']}))/"; - $patterns['bg_horizontal_percentage_x'] = "/(background-position-x\s*:\s*)({$patterns['num']})(%)/"; + $patterns['bg_horizontal_percentage'] = "/(background(?:-position)?\s*:\s*[^%]*?)(-?{$patterns['num']})(%\s*(?:{$patterns['quantity']}|{$patterns['ident']}))/"; + $patterns['bg_horizontal_percentage_x'] = "/(background-position-x\s*:\s*)(-?{$patterns['num']})(%)/"; } /** @@ -173,6 +175,8 @@ class CSSJanus { * * See http://code.google.com/p/cssjanus/issues/detail?id=15 and * TODO: URL + * @param $css string + * @return string */ private static function fixDirection( $css ) { $css = preg_replace( self::$patterns['direction_ltr'], @@ -185,6 +189,8 @@ class CSSJanus { /** * Replace 'ltr' with 'rtl' and vice versa in background URLs + * @param $css string + * @return string */ private static function fixLtrRtlInURL( $css ) { $css = preg_replace( self::$patterns['ltr_in_url'], self::$patterns['tmpToken'], $css ); @@ -196,6 +202,8 @@ class CSSJanus { /** * Replace 'left' with 'right' and vice versa in background URLs + * @param $css string + * @return string */ private static function fixLeftRightInURL( $css ) { $css = preg_replace( self::$patterns['left_in_url'], self::$patterns['tmpToken'], $css ); @@ -207,6 +215,8 @@ class CSSJanus { /** * Flip rules like left: , padding-right: , etc. + * @param $css string + * @return string */ private static function fixLeftAndRight( $css ) { $css = preg_replace( self::$patterns['left'], self::$patterns['tmpToken'], $css ); @@ -218,6 +228,8 @@ class CSSJanus { /** * Flip East and West in rules like cursor: nw-resize; + * @param $css string + * @return string */ private static function fixCursorProperties( $css ) { $css = preg_replace( self::$patterns['cursor_east'], @@ -237,6 +249,8 @@ class CSSJanus { * and four-part color rules with multiple whitespace characters between * colors are not recognized. * See http://code.google.com/p/cssjanus/issues/detail?id=16 + * @param $css string + * @return string */ private static function fixFourPartNotation( $css ) { $css = preg_replace( self::$patterns['four_notation_quantity'], '$1$2$7$4$5$6$3', $css ); @@ -247,6 +261,8 @@ class CSSJanus { /** * Flip horizontal background percentages. + * @param $css string + * @return string */ private static function fixBackgroundPosition( $css ) { $css = preg_replace_callback( self::$patterns['bg_horizontal_percentage'], @@ -259,6 +275,8 @@ class CSSJanus { /** * Callback for calculateNewBackgroundPosition() + * @param $matches array + * @return string */ private static function calculateNewBackgroundPosition( $matches ) { return $matches[1] . ( 100 - $matches[2] ) . $matches[3]; @@ -295,6 +313,10 @@ class CSSJanus_Tokenizer { return preg_replace_callback( $this->regex, array( $this, 'tokenizeCallback' ), $str ); } + /** + * @param $matches array + * @return string + */ private function tokenizeCallback( $matches ) { $this->originals[] = $matches[0]; return $this->token; @@ -314,6 +336,10 @@ class CSSJanus_Tokenizer { array( $this, 'detokenizeCallback' ), $str ); } + /** + * @param $matches + * @return mixed + */ private function detokenizeCallback( $matches ) { $retval = current( $this->originals ); next( $this->originals ); -- cgit v1.2.3-54-g00ecf