Use img instead of meta tags for SVGs

* replace meta tag with img tag
* remove js workaround for IE

Bug: T136709
Change-Id: Ifdd75ce51076b098af67a96b5dcb0fc0726d2b00
This commit is contained in:
Moritz Schubotz 2016-06-02 12:12:32 +02:00
parent 76fcd6e42c
commit 349d7cfc16
2 changed files with 6 additions and 14 deletions

View file

@ -385,9 +385,9 @@ class MathMathML extends MathRenderer {
* @return string XML the image html tag * @return string XML the image html tag
*/ */
private function getFallbackImage( $noRender = false, $classOverride = false ) { private function getFallbackImage( $noRender = false, $classOverride = false ) {
$url = $this->getFallbackImageUrl( $noRender ); $attribs = [
'src' => $this->getFallbackImageUrl( $noRender )
$attribs = []; ];
if ( $classOverride === false ) { // $class = '' suppresses class attribute if ( $classOverride === false ) { // $class = '' suppresses class attribute
$class = $this->getClassName( true ); $class = $this->getClassName( true );
} else { } else {
@ -396,18 +396,13 @@ class MathMathML extends MathRenderer {
if ( ! $this->mathoidStyle ) { if ( ! $this->mathoidStyle ) {
$this->correctSvgStyle( $this->mathoidStyle ); $this->correctSvgStyle( $this->mathoidStyle );
} }
// TODO: move the common styles to the global stylesheet!
$style = 'background-image: url(\''. $url .
'\'); background-repeat: no-repeat; background-size: 100% 100%; '.
$this->mathoidStyle;
if ( $class ) { if ( $class ) {
$attribs['class'] = $class; $attribs['class'] = $class;
} }
// Don't use an empty span, as that is going to be stripped by HTML tidy return Xml::element( 'img', $this->getAttributes( 'span', $attribs, [
// when enabled (which is true in production). 'aria-hidden' => 'true',
return Xml::element( 'meta', $this->getAttributes( 'style' => $this->mathoidStyle
'span', $attribs, [ 'aria-hidden' => 'true', 'style' => $style
] ) ); ] ) );
} }

View file

@ -31,8 +31,5 @@
// PNG fallback. See https://github.com/Modernizr/Modernizr/blob/master/feature-detects/svg/asimg.js // PNG fallback. See https://github.com/Modernizr/Modernizr/blob/master/feature-detects/svg/asimg.js
if ( !document.implementation.hasFeature( 'http://www.w3.org/TR/SVG11/feature#Image', '1.1' ) ) { if ( !document.implementation.hasFeature( 'http://www.w3.org/TR/SVG11/feature#Image', '1.1' ) ) {
insertImg( true ); insertImg( true );
} else if ( $.client.profile().name.match( /msie|edge/ ) ) {
// For all IE versions the meta tags are rendered blurry, while img tags are rendered fine.
insertImg( false );
} }
}( jQuery ) ); }( jQuery ) );