JDK-8210970 : MathML editing issues in HTMLEditor
  • Type: Bug
  • Component: javafx
  • Sub-Component: web
  • Affected Version: 8,9,10,openjfx11
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: x86_64
  • Submitted: 2018-09-11
  • Updated: 2022-08-12
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
This occurs with Windows 10 and Linux, running Java 8 b192 or Java 11 EA + JavaFX 11 EA.

A DESCRIPTION OF THE PROBLEM :
This report concerns the issues and enhancements related to HTMLEditor editing capabilities.

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 describes 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>

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.
- MathML content is not updated after an insertion. This only occurs when MathML Token are in a table like in the Mozilla MathML Torture Test.
- Cursor disappears in <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. This not occurs in <mn> and <mo>.
- In <mo>, cursor disappears too.
- Bad selection logic. Some parts of the formula disappear and selection should be only one rectangle not many rectangles.


Enhancements : A common user can not easily and directly use MathML to insert a mathematic formula in HTMLEditor.
-  MathML language is too verbose, an interface like AsciiMath for editing would be appreciate.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Each test could be made with the previous MathML code.


---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.VBox;
import javafx.scene.web.HTMLEditor;
import javafx.stage.Stage;

/**
 * A sample that demonstrates the HTML Editor. You can make changes to the
 * example text, and the resulting generated HTML is displayed.
 *
 * @related controls/text/SimpleLabel
 * @see javafx.scene.web.HTMLEditor
 */
public class HTMLEditorApp extends Application {

    private HTMLEditor htmlEditor = null;
    private final String INITIAL_TEXT = ""
            + "<html>"
            + "<body>"
            + "<p>A quadratic formula "
            + "<math>"
            + "   <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>"
            + " displayed in a presentation text."
            + "</p>"
            + "</body>"
            + "</html>";

    private void init(Stage primaryStage) {
        Group root = new Group();
        primaryStage.setScene(new Scene(root));
        VBox vRoot = new VBox();

        vRoot.setPadding(new Insets(8, 8, 8, 8));
        vRoot.setSpacing(5);

        htmlEditor = new HTMLEditor();
        htmlEditor.setPrefSize(500, 245);
        htmlEditor.setHtmlText(INITIAL_TEXT);
        vRoot.getChildren().add(htmlEditor);

        final Label htmlLabel = new Label();
        htmlLabel.setMaxWidth(500);
        htmlLabel.setWrapText(true);

        ScrollPane scrollPane = new ScrollPane();
        scrollPane.getStyleClass().add("noborder-scroll-pane");
        scrollPane.setContent(htmlLabel);
        scrollPane.setFitToWidth(true);
        scrollPane.setPrefHeight(180);

        Button showHTMLButton = new Button("Show the HTML below");
        vRoot.setAlignment(Pos.CENTER);
        showHTMLButton.setOnAction(new EventHandler<ActionEvent>() {

            @Override
            public void handle(ActionEvent arg0) {
                htmlLabel.setText(htmlEditor.getHtmlText());
            }
        });

        vRoot.getChildren().addAll(showHTMLButton, scrollPane);
        root.getChildren().addAll(vRoot);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        init(primaryStage);
        primaryStage.show();
    }

    /**
     * The main() method is ignored in correctly deployed JavaFX application.
     * main() serves only as fallback in case the application can not be
     * launched through deployment artifacts, e.g., in IDEs with limited FX
     * support. NetBeans ignores main().
     *
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
}
---------- END SOURCE ----------

FREQUENCY : always



Comments
Additional information from same submitter: ============================ Most of the problem I described in this report are due to the MathML rendering implementation in the WebKit /WebCore. Authors bypassed some WebCore's Rendering Logic because they cibled only rendering and not editing. I'm in the process to push things to their right place and hope submit a patch to the WebKit repository in a few months.
12-08-2022

Issue is reproducible. PFA screenshot of ran test case provided in description using latest Openjfx. Not able to select characters or place cursor properly between formula. when deleted some character, rendering of formula became more poor.
20-09-2018