cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / chrome / browser / resources / chromeos / chromevox / host / interface / abstract_mathjax.js
blobce19c05618d505927a7e706ac32f9e2f166733c2
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 /**
6 * @fileoverview Implentation of ChromeVox's bridge to MathJax.
8 */
10 goog.provide('cvox.AbstractMathJax');
12 goog.require('cvox.MathJaxInterface');
15 /**
16 * Creates a new instance.
17 * @constructor
18 * @implements {cvox.MathJaxInterface}
20 cvox.AbstractMathJax = function() {
24 /**
25 * @override
27 cvox.AbstractMathJax.prototype.isMathjaxActive = goog.abstractMethod;
30 /**
31 * @override
33 cvox.AbstractMathJax.prototype.getAllJax = goog.abstractMethod;
36 /**
37 * @override
39 cvox.AbstractMathJax.prototype.registerSignal = goog.abstractMethod;
42 /**
43 * @override
45 cvox.AbstractMathJax.prototype.getTex = goog.abstractMethod;
48 /**
49 * @override
51 cvox.AbstractMathJax.prototype.getAsciiMath = goog.abstractMethod;
54 /**
55 * @override
57 cvox.AbstractMathJax.prototype.injectScripts = goog.abstractMethod;
60 /**
61 * @override
63 cvox.AbstractMathJax.prototype.configMediaWiki = goog.abstractMethod;
66 /**
67 * Get MathML represententations for all images that have latex alt text.
68 * @param {function(Node, string)} callback A function taking a MathML node and
69 * an id string.
71 cvox.AbstractMathJax.prototype.getAllTexs = function(callback) {
72 var allTexs = document.
73 querySelectorAll(cvox.DomUtil.altMathQuerySelector('tex'));
74 for (var i = 0, tex; tex = allTexs[i]; i++) {
75 this.getTex(callback, tex);
80 /**
81 * Get MathML represententations for all images that have asciimath alt text.
82 * @param {function(Node, string)} callback A function taking a MathML node and
83 * an id string.
85 cvox.AbstractMathJax.prototype.getAllAsciiMaths = function(callback) {
86 var allAsciiMaths = document.
87 querySelectorAll(cvox.DomUtil.altMathQuerySelector('asciimath'));
88 for (var i = 0, tex; tex = allAsciiMaths[i]; i++) {
89 this.getAsciiMath(callback, tex);
94 /**
95 * Converts a XML markup string to a DOM node and applies a callback function.
96 * The function is generally used in the context of retrieving a MathJax
97 * element's MathML representation and converting it from a string. The callback
98 * is therefore use by MathJax internally in case the requested MathML
99 * representation is not ready yet.
100 * @param {function(Node, string)} callback A function taking a node and an id
101 * string.
102 * @param {string} mml The MathML string.
103 * @param {string} id The Mathjax node id.
105 cvox.AbstractMathJax.prototype.convertMarkupToDom = function(
106 callback, mml, id) {
107 if (mml) {
108 var dp = new DOMParser;
109 var cleanMml = mml.replace(/>\s+</g, '><');
110 callback(dp.parseFromString(cleanMml, 'text/xml').firstChild, id);