r72717 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72716‎ | r72717 | r72718 >
Date:13:08, 10 September 2010
Author:catrope
Status:ok (Comments)
Tags:
Comment:
(bug 25042) CSSJanus does not flip direction: rules outside of body { } selectors
Modified paths:
  • /trunk/phase3/includes/libs/CSSJanus.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/libs/CSSJanus.php
@@ -58,8 +58,8 @@
5959 'noflip_single' => null,
6060 'noflip_class' => null,
6161 'comment' => '/\/\*[^*]*\*+([^\/*][^*]*\*+)*\//',
62 - 'body_direction_ltr' => null,
63 - 'body_direction_rtl' => null,
 62+ 'direction_ltr' => null,
 63+ 'direction_rtl' => null,
6464 'left' => null,
6565 'right' => null,
6666 'left_in_url' => null,
@@ -97,8 +97,8 @@
9898 $patterns['lookahead_for_closing_paren'] = "(?={$patterns['url_chars']}?{$patterns['valid_after_uri_chars']}\))";
9999 $patterns['noflip_single'] = "/({$patterns['noflip_annotation']}{$patterns['lookahead_not_open_brace']}[^;}]+;?)/i";
100100 $patterns['noflip_class'] = "/({$patterns['noflip_annotation']}{$patterns['chars_within_selector']}})/i";
101 - $patterns['body_direction_ltr'] = "/({$patterns['body_selector']}{$patterns['chars_within_selector']}{$patterns['direction']})ltr/i";
102 - $patterns['body_direction_rtl'] = "/({$patterns['body_selector']}{$patterns['chars_within_selector']}{$patterns['direction']})rtl/i";
 101+ $patterns['direction_ltr'] = "/({$patterns['direction']})ltr/i";
 102+ $patterns['direction_rtl'] = "/({$patterns['direction']})rtl/i";
103103 $patterns['left'] = "/{$patterns['lookbehind_not_letter']}(left){$patterns['lookahead_not_closing_paren']}{$patterns['lookahead_not_open_brace']}/i";
104104 $patterns['right'] = "/{$patterns['lookbehind_not_letter']}(right){$patterns['lookahead_not_closing_paren']}{$patterns['lookahead_not_open_brace']}/i";
105105 $patterns['left_in_url'] = "/{$patterns['lookbehind_not_letter']}(left){$patterns['lookahead_for_closing_paren']}/i";
@@ -143,7 +143,7 @@
144144 $css = $comments->tokenize( $css );
145145
146146 // LTR->RTL fixes start here
147 - $css = self::fixBodyDirection( $css );
 147+ $css = self::fixDirection( $css );
148148 if ( $swapLtrRtlInURL ) {
149149 $css = self::fixLtrRtlInURL( $css );
150150 }
@@ -165,17 +165,19 @@
166166 }
167167
168168 /**
169 - * Replace direction: ltr; with direction: rtl; and vice versa, but *only*
170 - * those inside a body { .. } selector.
 169+ * Replace direction: ltr; with direction: rtl; and vice versa.
171170 *
172 - * Unlike the original implementation, this function doesn't suffer from
173 - * the bug causing "body\n{\ndirection: ltr;\n}" to be missed.
174 - * See http://code.google.com/p/cssjanus/issues/detail?id=15
 171+ * The original implementation only does this inside body selectors
 172+ * and misses "body\n{\ndirection:ltr;\n}". This function does not have
 173+ * these problems.
 174+ *
 175+ * See http://code.google.com/p/cssjanus/issues/detail?id=15 and
 176+ * TODO: URL
175177 */
176 - private static function fixBodyDirection( $css ) {
177 - $css = preg_replace( self::$patterns['body_direction_ltr'],
 178+ private static function fixDirection( $css ) {
 179+ $css = preg_replace( self::$patterns['direction_ltr'],
178180 '$1' . self::$patterns['tmpToken'], $css );
179 - $css = preg_replace( self::$patterns['body_direction_rtl'], '$1ltr', $css );
 181+ $css = preg_replace( self::$patterns['direction_rtl'], '$1ltr', $css );
180182 $css = str_replace( self::$patterns['tmpToken'], 'rtl', $css );
181183
182184 return $css;

Comments

#Comment by Trevor Parscal (WMF) (talk | contribs)   23:23, 24 September 2010

Did you pass this upstream?

#Comment by Catrope (talk | contribs)   12:11, 25 September 2010

I have a patch for the Python implementation, didn't get to passing it upstream yet.

Status & tagging log