if ( $flip === 'flip' && $this->getLanguage()->isRTL() ) {
# If wanted, and the interface is right-to-left, flip the CSS
$style_css = CSSJanus::transform( $style_css, true, false );
+ } else {
+ $style_css = CSSJanus::nullTransform( $style_css );
}
$this->mInlineStyles .= Html::inlineStyle( $style_css ) . "\n";
}
$previewedCSS = $this->getRequest()->getText( 'wpTextbox1' );
if ( $this->getLanguage()->getDir() !== $wgContLang->getDir() ) {
$previewedCSS = CSSJanus::transform( $previewedCSS, true, false );
+ } else {
+ $previewedCSS = CSSJanus::nullTransform( $previewedCSS );
}
$otherTags .= Html::inlineStyle( $previewedCSS ) . "\n";
} else {
$css = $noFlipClass->detokenize( $css );
$css = $noFlipSingle->detokenize( $css );
+ // Remove remaining /* @noflip */ annotations, they won't be needed anymore
+ // and can interfere with other code (bug 69698).
+ $css = self::nullTransform( $css );
+
+ return $css;
+ }
+
+ /**
+ * Remove @noflip annotations, but don't do any other transforms.
+ * @param string $css stylesheet to transform
+ * @return string Transformed stylesheet
+ */
+ public static function nullTransform( $css ) {
+ $patt = self::$patterns['noflip_annotation'];
+ $css = preg_replace( "/($patt)\\s*/i", '', $css );
+
return $css;
}
if ( $flip ) {
$style = CSSJanus::transform( $style, true, false );
+ } else {
+ $style = CSSJanus::nullTransform( $style );
}
$localDir = dirname( $localPath );
$remoteDir = dirname( $remotePath );
$style = implode( "\n", $rules );
if ( $this->getFlip( $context ) ) {
$style = CSSJanus::transform( $style, true, false );
+ } else {
+ $style = CSSJanus::nullTransform( $style );
}
return array( 'all' => $style );
}
}
if ( $this->getFlip( $context ) ) {
$style = CSSJanus::transform( $style, true, false );
+ } else {
+ $style = CSSJanus::nullTransform( $style );
}
$style = CSSMin::remap( $style, false, $this->getConfig()->get( 'ScriptPath' ), true );
if ( !isset( $styles[$media] ) ) {
.selector { /*@embed*/ background-image: url(simple-ltr.gif); }
-/* Doesn't work! */
-/*.selector { /*@noflip* / /*@embed* / background-image: url(simple-ltr.gif); }*/
+.selector { /*@embed*/ background-image: url(simple-ltr.gif); }
.selector { /*@embed*/ background-image: url(simple-ltr.gif); }
/*@noflip*/ .selector { background-image: /*@embed*/ url(simple-ltr.gif); }
-/* Doesn't work! */
-/*.selector { /*@noflip* / /*@embed* / background-image: url(simple-ltr.gif); }*/
+.selector { /*@noflip*/ /*@embed*/ background-image: url(simple-ltr.gif); }
.selector { /*@embed*/ /*@noflip*/ background-image: url(simple-ltr.gif); }
-/* @noflip */
.unit-tests {
color: green;
border: 2px solid #eeeeee;
if ( $cssB ) {
$transformedA = CSSJanus::transform( $cssA );
- $this->assertEquals( $transformedA, $cssB, 'Test A-B transformation' );
+ $this->assertEquals(
+ $transformedA,
+ str_replace( '/* @noflip */ ', '', $cssB ),
+ 'Test A-B transformation'
+ );
$transformedB = CSSJanus::transform( $cssB );
- $this->assertEquals( $transformedB, $cssA, 'Test B-A transformation' );
+ $this->assertEquals(
+ $transformedB,
+ str_replace( '/* @noflip */ ', '', $cssA ),
+ 'Test B-A transformation'
+ );
} else {
// If no B version is provided, it means
- // the output should equal the input.
+ // the output should equal the input (modulo @noflip annotations).
$transformedA = CSSJanus::transform( $cssA );
- $this->assertEquals( $transformedA, $cssA, 'Nothing was flipped' );
+ $this->assertEquals(
+ $transformedA,
+ str_replace( '/* @noflip */ ', '', $cssA ),
+ 'Nothing was flipped'
+ );
}
}
$this->assertEquals(
$expectedModule->getStyles( $contextLtr ),
- str_replace( '/*@noflip*/ ', '', $testModule->getStyles( $contextLtr ) ),
+ $testModule->getStyles( $contextLtr ),
"/*@noflip*/ with /*@embed*/ gives correct results in LTR mode"
);
$this->assertEquals(
$expectedModule->getStyles( $contextLtr ),
- str_replace( '/*@noflip*/ ', '', $testModule->getStyles( $contextRtl ) ),
+ $testModule->getStyles( $contextRtl ),
"/*@noflip*/ with /*@embed*/ gives correct results in RTL mode"
);
}