Index: trunk/phase3/includes/libs/CSSJanus.php |
— | — | @@ -58,8 +58,8 @@ |
59 | 59 | 'noflip_single' => null, |
60 | 60 | 'noflip_class' => null, |
61 | 61 | 'comment' => '/\/\*[^*]*\*+([^\/*][^*]*\*+)*\//', |
62 | | - 'body_direction_ltr' => null, |
63 | | - 'body_direction_rtl' => null, |
| 62 | + 'direction_ltr' => null, |
| 63 | + 'direction_rtl' => null, |
64 | 64 | 'left' => null, |
65 | 65 | 'right' => null, |
66 | 66 | 'left_in_url' => null, |
— | — | @@ -97,8 +97,8 @@ |
98 | 98 | $patterns['lookahead_for_closing_paren'] = "(?={$patterns['url_chars']}?{$patterns['valid_after_uri_chars']}\))"; |
99 | 99 | $patterns['noflip_single'] = "/({$patterns['noflip_annotation']}{$patterns['lookahead_not_open_brace']}[^;}]+;?)/i"; |
100 | 100 | $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"; |
103 | 103 | $patterns['left'] = "/{$patterns['lookbehind_not_letter']}(left){$patterns['lookahead_not_closing_paren']}{$patterns['lookahead_not_open_brace']}/i"; |
104 | 104 | $patterns['right'] = "/{$patterns['lookbehind_not_letter']}(right){$patterns['lookahead_not_closing_paren']}{$patterns['lookahead_not_open_brace']}/i"; |
105 | 105 | $patterns['left_in_url'] = "/{$patterns['lookbehind_not_letter']}(left){$patterns['lookahead_for_closing_paren']}/i"; |
— | — | @@ -143,7 +143,7 @@ |
144 | 144 | $css = $comments->tokenize( $css ); |
145 | 145 | |
146 | 146 | // LTR->RTL fixes start here |
147 | | - $css = self::fixBodyDirection( $css ); |
| 147 | + $css = self::fixDirection( $css ); |
148 | 148 | if ( $swapLtrRtlInURL ) { |
149 | 149 | $css = self::fixLtrRtlInURL( $css ); |
150 | 150 | } |
— | — | @@ -165,17 +165,19 @@ |
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
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. |
171 | 170 | * |
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 |
175 | 177 | */ |
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'], |
178 | 180 | '$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 ); |
180 | 182 | $css = str_replace( self::$patterns['tmpToken'], 'rtl', $css ); |
181 | 183 | |
182 | 184 | return $css; |