Open scientificware opened 6 years ago
New issue, new tool to debug.
JavaFXMathML was used for JDK-8147476 but for HTMLEditor and MathML. w3c/mathml#118, it's important to see DOM skeleton.
So FXMath is borned !
<mi>
, <mo>
, ... MathML token insert at the beginning or the end, yes. In this case, caret position is rigth, no more work just reached the first parent <mrow>
.
Otherwise, no !
<mn>
only digit and decimal separator enter, beginning and ending excepted.
<mfrac>
if loads
<mrow>
<mo> ( </mo>
<mfrac>
<mi> a </mi>
<mi> b </mi>
</mfrac>
<mo> ) </mo>
</mrow>
Has to use :
<mrow>
<mo> ( </mo>
<mfrac>
<mrow><mi> a </mi></mrow>
<mrow><mi> b </mi></mrow>
</mfrac>
<mo> ) </mo>
</mrow>
Saves simplyfied content where <mrow>
could be remove, if it contains only one element.
Using Fluent Mathematic Style Writing, all mathematic editing uses only these keyboard keys.
Writing a new application for mobile testers. The goal is obtain daily choice validations from selectionned testers. So have to use a common communication application like chat.
Show formula given in LaTeX or its MathML-conversion in javafx-label
<div contenteditable="true">
<p contenteditable="true">
...
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebView;
public class TestRM extends Application {
private Stage window;
private Scene scene;
private WebView webView = new WebView();
String javaversion = System.getProperty("java.runtime.version");
String javafxversion = System.getProperty("javafx.runtime.version");
String osinfo = System.getProperty("os.name");
String osarch = System.getProperty("os.arch");
String agent = webView.getEngine().getUserAgent();
private String string2 = new String("""
<html>
<head>
<title>TestRM</title>
</head>
<body contenteditable=\"true\">
<p>
<math xmlns=\"http://www.w3.or/1998/Math/MathML\" display=\"block\">
<semantics>
<mfrac>
<mrow>
<mo>-</mo>
<mi>b</mi>
<mo>±</mo>
<msqrt>
<mrow>
<msup>
<mi>b</mi>
<mn>2</mn>
</msup>
<mo>-</mo>
<mn>4</mn>
<mi>a</mi>
<mi>c</mi>
</mrow>
</msqrt>
</mrow>
<mrow>
<mn>2</mn>
<mi>a</mi>
</mrow>
</mfrac>
<annotation encoding=\"SnuggleTeX\">$$ \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a} $$</annotation>
</semantics>
</math>
</p>
<p>Version de Java . : %s</p>
<p>Version de JavaFX : %s</p>
<p>OS .............. : %s</p>
<p>CPU ............. : %s</p>
<p>User Agent ...... : %s</p>
</body>
</html>
""".formatted(javaversion, javafxversion, osinfo, osarch, agent);
VBox vbox = new VBox(webView);
public static void main(String[] args) {
launch(args);
}
public void start(Stage primaryStage) {
webView.getEngine().loadContent(string2);
window = primaryStage;
scene = new Scene(vbox, 400, 300);
window.setScene(scene);
window.show();
}
}
Presently, the patch for JDK-8147476 solves MathML display issues in WebView. Consequently, it solves MathML display in HTMLEditor too.
The MathML rendering is pretty good and equivalent to MathML Rendering with Safari. I think that JDK-8089878, which describe only rendering issues, is also solved.
Set HTMLEditor content with the following code displays the quadratic formula as expected in JDK-8089878.
<math display="block">
<mrow>
<mi>x</mi>
<mo>=</mo>
<mfrac>
<mrow>
<mo>−</mo>
<mi>b </mi>
<mo>±</mo>
<msqrt>
<mrow>
<msup>
<mi>b</mi>
<mn>2</mn>
</msup>
<mo>−</mo>
<mn>4</mn>
<mi>a</mi>
<mi>c</mi>
</mrow>
</msqrt>
</mrow>
<mrow>
<mn>2</mn>
<mi>a</mi>
</mrow>
</mfrac>
</mrow>
</math>
The remaining problems are related to editing capabilities.
Bugs : -Trying to modify a formula will occurate some trouble in your document. For example, try to modifiy the previous formula, by removing 2a from the fraction, this will break your formula.
Enhancements : A common user can not easily and directly use MathML to insert a mathematic formula in HTMLEditor.
Each test could be made with the previous MathML code.
Cursor deplacements : EditorClientJava
See exchanges with ebraminio and khaledhosny. SVG font: extract SVG per character #1192
https://github.com/harfbuzz/harfbuzz/pull/2016#issuecomment-572034118
Writing a new application for mobile testers. The goal is obtain daily choice validations from selectionned testers. So have to use a common communication application like chat.
In progress
WebKit source code : trac.webkit.org
Webcore Rendering (WebKit Blog) :
WebKit bug database : bugs.webkit.org Bug 13820 - Height of cursor should be same as height of text, not line-height
Rendering MathML (Folder): RenderMathMLBlock extends RenderBlock
Rendering (Folder) : RenderBlock extends RenderBox localCaretRect RenderBox extends RenderBoxModelObject localCaretRect RenderText Base implementation localCaretRect RootInlineBox extends InlineFlowBox computeCaretRect InlineFlowBox Base implementation TextLayout.java getCaretShape RenderInline extends RenderBoxModelObject0 LocalCaretRect RenderBoxModelObject extends RenderLayerModelObject RenderLayerModelObject extends RenderElement RenderElement Base implementation RenderObject Base implementation localCaretRect Internals absoluteCaretBounds Editing.cpp localCaretRectInRendererForCaretPainting
Tokens and elements :
Token | Element |
---|---|
annotation | MathMLAnnotationElement |
annotation-xml | MathMLAnnotationElement |
maction | MathMLSelectElement |
math | |
mfrac | MathMLFractionElement |
mfenced | MathMLRowElement |
msubsup | MathMLScriptsElement |
merror | MathMLRowElement |
mpadded | MathMLPaddedElement |
mphantom | MathMLRowElement |
mrow | MathMLRowElement |
mstyle | MathMLRowElement |
mover | MathMLUnderOverElement |
munder | MathMLUnderOverElement |
munderover | MathMLUnderOverElement |
msqrt | MathMLRootElement |
mroot | MathMLRootElement |
mi | MathMLTokenElement |
mn | MathMLTokenElement |
mo | MathMLOperatorElement |
mtext | MathMLTokenElement |
ms | MathMLTokenElement |
mspace | MathMLSpaceElement |
msub | MathMLScriptsElement |
msup | MathMLScriptsElement |
mtable | MathMLPresentationElement |
mtr | MathMLPresentationElement |
mtd | MathMLPresentationElement |
mmultiscripts | MathMLScriptsElement |
mprescripts | MathMLPresentationElement |
menclose | MathMLMencloseElement |
none | MathMLPresentationElement |
semantics | MathMLSelectElement |
maligngroup | MathMLPresentationElement |
malignmark | MathMLPresentationElement |
mglyph | MathMLPresentationElement |
mlabeledtr | MathMLPresentationElement |
mlongdiv | MathMLPresentationElement |
mscarries | MathMLPresentationElement |
mscarry | MathMLPresentationElement |
msgroup | MathMLPresentationElement |
msline | MathMLPresentationElement |
msrow | MathMLPresentationElement |
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<style type="text/css">
</style>
<body>
<h1>Fraction</h1>
<p>This is an empty fraction.
<math>
<mfrac>
<mrow></mrow>
<mrow></mrow>
</mfrac>
</math>
</p>
<h1>Fraction</h1>
<p>This is a normal fraction :
<math>
<mfrac>
<mrow><mn>7</mn></mrow>
<mrow><mn>3</mn></mrow>
</mfrac>
</math>
</p>
</body>
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<p>
<math>
<mi>A</mi>
<mo>=</mo>
<mi>y</mi>
<mo>×</mo>
<mi>sin</mi>
<mfenced>
<mrow>
<mi mathvariant="monospace">x</mi>
<mo>×</mo>
<mi mathvariant="bold">π</mi>
</mrow>
</mfenced>
</math>
</p>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
Enchaînement des appels de méthodes :
RenderBlock
extends RenderBox
and defines :
paint
method (protected)
paintObject
methodpaintObject
method (protected)
RenderBox::paintBoxDecorations
method (public)paintContents
methodpaintSelection
methodpaintFloats
methodpaintOutline
methodpaintCaret
methodpaintContents
method (private)
According this render implementation none paint should be made after a call to the renderBlock paint method. MathML implementation doesn't respect this and paint or paintChildren method are overided and paint proceed direct painting.
L'écriture mathématique implique que certaines chaines soient en italique par exemple le nom d'une variable. Mais ce n'est pas le cas pour le nom d'une fonction. Pour simplifer, l'implémentation actuelle considère que les variables d'un seul caractère sont bien des variables et elles sont affichées en italique par exemple <mi>i</mi>
sera bien affiché i. Mais <mi>in</mi>
ne sera pas affiché en italique.
https://github.com/w3c/mathml : TeX2MathML converter implementation guidelines :
The purpose of this issue is to make mathematic editing as simple as possible.
This is referenced in Java Bug Database as
This is tracked in JBS as
Situation
Presently, the patch for JDK-8147476 (javafxports/openjdk-jfx Rendering issues with MathML token elements. w3c/mathml#117) allows to display MathML formula in
WebView
. Consequently we can also work with MathML inHTMLEditor
, the MathML rendering is pretty good.Justification
HTMLEditor
. To insert this simple quadratic formula : You need to insert the following code :Conclusions and Roadmap.
HTMLEditor
and underlyingWebView
i.e. embeddedWebKit
implementation are clearly not ready yet for formula editing. It still needs some work to solve issues.Details
HTMLEditor
doesn't create a new line when one presses Enter.<mi>
token when the identifier name has only one character. If the name of the identifier is longer than 1 character, the cursor appears normaly. Note : in W3C<mi>
description, The default font style should (typically) be "normal" (non-slanted) unless the content is a single character, in which case it should be "italic". This not occurs in<mn>
and<mo>
. It's a WebCore issue, then transfered in my WebKit Repository Issue#1.<mo>
, the caret disappears too but only with the minus sign. Related to Hyphen. It's also a WebCore issue, then transfered in my WebKit Repository Issue#2.<row>
or<math>
height (that's why, it is important to correct MathML code when loads a file or paste, see below about these<row>
add and remove corrections). In the following example, move from the left to the right, you can see that the caret height is good outside the formula and too small inside :The caret height should be the same on the two pictures. Its height should be its height just after the word 'test'. That's the usual behavior. So, its size before '+' is wrong. May be a WebCore problem too so transfered to Issue#4
<mi>
token.<mi>
with only one character, css attributes are not apply. It's a WebCore issue too, then transfered in my WebKit Repository Issue#3.Enhancement Mathematic edition needs to be improved (simply using keyboard)
Roadmap :
Use materials I developed in my own products and follow W3C recommendations about editing. Impove the minimal parser. Work In Progress.
Port the language register selection method : daily french and english, AsciiMath, OpenOffice Math and LaTex languages.
[ ] Work in progress. Presently, only daily French, German, Spanish, English languages are supported.
Port the Fluent Mathematic Writing logic.
[ ] Work In Progress.
Related to HTMLEditor and MathML w3c/mathml#118