jenkins-bot has submitted this change and it was merged.
Change subject: SVG images should not be loaded when MathML is used
......................................................................
SVG images should not be loaded when MathML is used
- Use span with a background-image instead of <img> for the fallback SVG so
that they don't load in Gecko.
- Make the image fallback a span inline-block so that it can have a dimension.
Bug: 71929
Change-Id: I7f820cd5766db1fece452ebfc72915a55e42c82e
---
M MathMathML.php
M modules/ext.math.css
M modules/ext.math.js
3 files changed, 6 insertions(+), 5 deletions(-)
Approvals:
Physikerwelt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/MathMathML.php b/MathMathML.php
index 789bc2e..d5c2cf0 100644
--- a/MathMathML.php
+++ b/MathMathML.php
@@ -379,12 +379,12 @@
$class = $classOverride;
}
- $style = '';
+ $style = 'background-image: url(\''. $url. '\');
background-repeat: no-repeat; background-size: contain;';
$this->correctSvgStyle( $this->getSvg(), $style );
if ( $class ) { $attribs['class'] = $class; }
if ( $style ) { $attribs['style'] = $style; }
// an alternative for svg might be an object with
type="image/svg+xml"
- return Xml::element( 'img', $this->getAttributes( 'img',
$attribs , array( 'src' => $url, 'aria-hidden' => 'true' ) ) );
+ return Xml::element( 'span', $this->getAttributes( 'span',
$attribs , array( 'aria-hidden' => 'true' ) ) );
}
diff --git a/modules/ext.math.css b/modules/ext.math.css
index b5b8b0e..66e31c8 100644
--- a/modules/ext.math.css
+++ b/modules/ext.math.css
@@ -36,7 +36,7 @@
/* Default style for the image fallback. */
/* Note: We had to use !important rules because of conflicts with the style
generated by Mathoid. See https://gerrit.wikimedia.org/r/#/c/166213/ */
-.mwe-math-fallback-image-inline { display: inline; vertical-align: middle; }
+.mwe-math-fallback-image-inline { display: inline-block; vertical-align:
middle; }
.mwe-math-fallback-image-display { display: block; margin-left: auto
!important; margin-right: auto !important; }
/* Default style for the source fallback. */
diff --git a/modules/ext.math.js b/modules/ext.math.js
index 07f8f19..815a8f1 100644
--- a/modules/ext.math.js
+++ b/modules/ext.math.js
@@ -1,7 +1,7 @@
( function ( $ ) {
'use strict';
// The MW_MATH_PNG and MW_MATH_MATHML constants are taken from Math.php
- var MW_MATH_PNG = 0, MW_MATH_MATHML = 5, img;
+ var MW_MATH_PNG = 0, MW_MATH_MATHML = 5, img, url;
// If MathPlayer is installed we show the MathML rendering.
if (navigator.userAgent.indexOf('MathPlayer') > -1) {
@@ -16,7 +16,8 @@
$( '.mwe-math-fallback-image-inline,
.mwe-math-fallback-image-display' ).each(function() {
// Create a new PNG image to use as the fallback.
img = document.createElement('img');
- img.setAttribute( 'src', this.src.replace('mode=' +
MW_MATH_MATHML, 'mode=' + MW_MATH_PNG) );
+ url =
this.style.backgroundImage.match(/url\('?([^']*)'?\)/)[1];
+ img.setAttribute( 'src', url.replace('mode=' +
MW_MATH_MATHML, 'mode=' + MW_MATH_PNG) );
img.setAttribute( 'class', 'tex
mwe-math-fallback-image-' + ($( this
).hasClass('mwe-math-fallback-image-inline') ? 'inline' : 'display') );
img.setAttribute( 'aria-hidden', 'true' );
this.parentNode.insertBefore( img, this );
--
To view, visit https://gerrit.wikimedia.org/r/166179
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7f820cd5766db1fece452ebfc72915a55e42c82e
Gerrit-PatchSet: 8
Gerrit-Project: mediawiki/extensions/Math
Gerrit-Branch: master
Gerrit-Owner: Frédéric Wang <[email protected]>
Gerrit-Reviewer: Frédéric Wang <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: Physikerwelt <[email protected]>
Gerrit-Reviewer: TheDJ <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits