From da0e6cab16fde6d885ec125a3ac17f541a465f8f Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Wed, 12 Nov 2014 18:46:46 +0000 Subject: [PATCH] Fix rendering issues in MathML mode Force display:none on a hidden MathML rendering to avoid generating focusable node highlights. Move adding of class to setup to ensure it persists after render. Bug: T87007 Change-Id: I5fc21afa61ccc07e9d2126846cf29ee898182a7c --- Math.php | 1 + modules/VisualEditor/ve.ce.MWMathNode.css | 11 +++++++++++ modules/VisualEditor/ve.ce.MWMathNode.js | 16 +++++++++++----- modules/VisualEditor/ve.dm.MWMathNode.js | 2 +- 4 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 modules/VisualEditor/ve.ce.MWMathNode.css diff --git a/Math.php b/Math.php index 7ca7884..4dca145 100644 --- a/Math.php +++ b/Math.php @@ -513,6 +513,7 @@ $wgResourceModules['ext.math.visualEditor'] = array( 'VisualEditor/ve.ui.MWMathInspectorTool.js', ), 'styles' => array( + 'VisualEditor/ve.ce.MWMathNode.css', 'VisualEditor/ve.ui.MWMathIcons.css', 'VisualEditor/ve.ui.MWMathInspector.css', ), diff --git a/modules/VisualEditor/ve.ce.MWMathNode.css b/modules/VisualEditor/ve.ce.MWMathNode.css new file mode 100644 index 0000000..a08375a --- /dev/null +++ b/modules/VisualEditor/ve.ce.MWMathNode.css @@ -0,0 +1,11 @@ +/** + * Hide math tag completely to avoid extra bounding boxes for Chrome, Safari, Android... + * Browser-specific hacks are bad but let's use that for now... + * See http://browserhacks.com + */ +@media screen and (-webkit-min-device-pixel-ratio:0) { + .ve-ce-mwMathNode .mwe-math-mathml-a11y { + display: none !important; + } +} + diff --git a/modules/VisualEditor/ve.ce.MWMathNode.js b/modules/VisualEditor/ve.ce.MWMathNode.js index 9aaf694..91dee82 100644 --- a/modules/VisualEditor/ve.ce.MWMathNode.js +++ b/modules/VisualEditor/ve.ce.MWMathNode.js @@ -17,12 +17,9 @@ * @param {ve.dm.MWMathNode} model Model to observe * @param {Object} [config] Configuration options */ -ve.ce.MWMathNode = function VeCeMWMathNode( model, config ) { +ve.ce.MWMathNode = function VeCeMWMathNode() { // Parent constructor - ve.ce.MWInlineExtensionNode.call( this, model, config ); - - // DOM changes - this.$element.addClass( 've-ce-mwMathNode' ); + ve.ce.MWMathNode.super.apply( this, arguments ); }; /* Inheritance */ @@ -37,6 +34,15 @@ ve.ce.MWMathNode.static.primaryCommandName = 'math'; /* Methods */ +/** */ +ve.ce.MWMathNode.prototype.onSetup = function () { + // Parent method + ve.ce.MWMathNode.super.prototype.onSetup.call( this ); + + // DOM changes + this.$element.addClass( 've-ce-mwMathNode' ); +}; + /** */ ve.ce.MWMathNode.prototype.onParseSuccess = function ( deferred, response ) { var data = response.visualeditor, contentNodes = this.$( data.content ).get(); diff --git a/modules/VisualEditor/ve.dm.MWMathNode.js b/modules/VisualEditor/ve.dm.MWMathNode.js index ed024e3..116efe6 100644 --- a/modules/VisualEditor/ve.dm.MWMathNode.js +++ b/modules/VisualEditor/ve.dm.MWMathNode.js @@ -18,7 +18,7 @@ */ ve.dm.MWMathNode = function VeDmMWMathNode() { // Parent constructor - ve.dm.MWInlineExtensionNode.apply( this, arguments ); + ve.dm.MWMathNode.super.apply( this, arguments ); }; /* Inheritance */