New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaFX and MathML. #71

Closed
scientificware opened this Issue Apr 22, 2018 · 59 comments

Comments

Projects
None yet
5 participants
@scientificware
Contributor

scientificware commented Apr 22, 2018

The purpose of this issue is to repair MathML display in WebView.

When I discovered that JavaFX could manage MathML, I also discovered that it was buggy. Becauseof MathML is rendered with WebKit, I compared with other WebKit based web browsers. I also noticed that since 2016 that those web browser make good progress with MaltML display. First I thought that the differences were due to outdated WebKit version used by JavaFX but last releases, with an uptodate WebKit version, show that the problem is the same.

I contacted F. Wang from Igalia who worked to port or improve MathML support in FireFox and later in WebKit. He confirms that it was a bug in JavaFX not in WebKit witch displays MathML correctly.

As he suggested me, I wrote to the JavaFX mailing list and had a short discussion about this issue on OpenJDK.Java.net :

http://mail.openjdk.java.net/pipermail/openjfx-dev/2017-December/021112.html
https://bugs.openjdk.java.net/browse/JDK-8147476

So, as suggested by mainteners, I'm trying to find by myself what's wrong with MathML in javaFX HTMLEditor.

  • As far as I could read in javaFX java code,
    • I understand that HTMLEditor and WebView only manage and display a cached page.
    • I know that JavaFX use WebKit to display a webpage.
  • So I don't understand why,
    • when I tested webkit with Safari on OSX and IOS last versions, in an Apple Store and with my Ipod (with an oudated IOS 9), the display is pretty good :
      ipod_ios9_screencapture
    • And with JavaFX HTMLEditor the display is pretty bad (https://github.com/scientificware/javafxmathml) :
      screen_javafx_mathml

I tested all applications with Mozilla MathML Torture Test
(https://developer.mozilla.org/fr/docs/Mozilla/MathML_Project/MathML_Torture_Test)

Could someone help me ?

  • To find in which code level is the problem.
  • I don't think the problem is in the JavaFX java code, I read it several times.
  • I tried to find what wrong in the native code but, I don't know where to start !
  • So where I should start to work ?
@scientificware

This comment has been minimized.

Contributor

scientificware commented Apr 22, 2018

I think that the problem is related only with the vertical size of each element :
I notice that the size of the cursor is right outside the mathematics text but when we move it through the mathematics text, the cursor size is far much lower than text size.
All horizontal sizes seem good, by example a <mtext> followed by a <mrow> in a element :
screen_javafx_mathml_2

Which part of code deals with vertical size ?

@eugener eugener added the bug label Apr 22, 2018

@ararunprasad ararunprasad self-assigned this Apr 23, 2018

@ararunprasad

This comment has been minimized.

Contributor

ararunprasad commented Apr 23, 2018

Problem is current JavaFX font implementation for WebKit doesn't supports OpenMathData table.

Actually WebKit has it's own MathData table parser(OpenMathData.cpp) to extract MathML rendering parameters(like numeratorGap, denominatorGap,..etc), however it expects platform implementation(javafx) to return the OpenMathData table from OpenType font, which we don't support right now.

There is a fallback logic implemented when MathData is not available from platform implementation, however it seems to be buggy.

<math xmlns='http://www.w3.org/1998/Math/MathML'>
    <mrow>
    <mfrac>
        <mn>1</mn>
        <mn>2</mn>
    </mfrac>
    </mrow>
</math>

For e.g., to render the above simple mathml tocken, RenderMathMLFraction::fractionParameters(RenderMathMLFraction.cpp) method will be called to calculated the offsets. Since we don't support MathData table, the fallback logic to calculate the denominatorGapMin as follows,

        parameters.numeratorGapMin = display ? 3 * ruleThicknessFallback() : ruleThicknessFallback();
        parameters.denominatorGapMin = parameters.numeratorGapMin;

The above logic is not correct, because of that both numerator and denominator of a fraction is overlapping. Just adding a some offset to parameters.numeratorGapMin fixes the issue.

So the appropriate solution would be to implement a logic to extract a OpenMathData table from OpenType font table.

@scientificware

This comment has been minimized.

Contributor

scientificware commented Apr 23, 2018

Thank you very much for your help, and all these informations !
Thanks given me an entry point to investigate :-)

@scientificware

This comment has been minimized.

Contributor

scientificware commented Apr 25, 2018

First working comments :

  • In fact, what did I need to start was just the confirmation that the render logic for math is only the webkit logic.
  • Thanks to Arunprasad Rajkumar's comment, I'm a bit reassured.
  • The most important information that he gave, is that JavaFX doesn't have is own render implementation for webkit.
  • However, I not agree about the conclusion for the pointed code. In fraction rendering the openfont math table provides only gap value beetween numerator and denominator and the line thickness which separate numerator and denominator. I'm afraid the logic is good, because all these values are cumulative and positive, eventhough with a null gap between and denominator and a thickness to 0, both elements can't overlap : I use a similar method in Swing to implement a fraction View. May be the tickness default method ( ruleThicknessFallback() ) returns a negative value (must be verified) : this method seems to use the font current size to calculate the thickness.
  • The article "JavaFX WebView Overview" by Murali Billa.
  • Until, I verify some things, I maintain my first analysis : only one problem affects all math elements in the same time : somewhere in the code, logic looses font or children vertical size.
  • What I'm going to verify :
    • does ruleThicknessFallback() returns a negative value : this method seems to use the font current size to calculate the thickness. I'm sure not.
    • work with square root (only one children) :
      • how javafx transmits font vertical size to webkit.
      • how a children transfers its vertical size to its parent.
  • Before implement openFont math table, it would be important to repare fallback code.
    • OpenTypeMathData.cpp
    • Java and JavaFX use Harfbuzz, which can read OpenType Math Table. Why WebKit cannot access to these informations ?
@scientificware

This comment has been minimized.

Contributor

scientificware commented Apr 29, 2018

Configure my build and run environment to debug.
Mageia 6, all the required development packages

Mageia package name Description  
lib64alsa2-devel Development files for Advanced Linux Sound Architecture (ALSA)  
lib64mesagl1-devel Development files for Mesa (OpenGL compatible 3D lib)  
lib64gstreamer1.0-devel Libraries and include files for GStreamer streaming-media framework  
lib64gstreamer-plugins-base1.0-devel GStreamer Plugin Library Headers​  
lib64jpeg-devel Development tools for programs which will use the libjpeg library  
lib64png-devel Development tools for programs to manipulate PNG image format files  
lib64x11-devel Development files for libx11  
lib64xml2-devel Libraries, includes, etc. to develop XML and HTML applications  
lib64xslt-devel Libraries, includes, etc. to develop XML and HTML applications  
lib64xt-devel Development files for libxt  
lib64xxf86vm-devel Development files for libxxf86vm  
pkgconfig Pkgconfig helps make building packages easier  
x11-proto-devel Xorg X11 protocol specification headers  
lib64ffmpeg-static-devel Static library for the ffmpeg codec library  
mercurial A fast, lightweight distributed source control management system
lib64gtk+2.0-devel Development files for GTK+ (GIMP ToolKit) applications  
lib64gtk+3.0-devel Development files for GTK+ (GIMP ToolKit) applications
lib64xtst-devel Development files for libxtst  
lib64udev-devel udev library development files  
lib64ffmpeg-static-devel Static library for the ffmpeg codec library  
gcc-c++ C++ support for gcc  
.  
To build WebKit
bison A GNU general-purpose parser generator  
flex A tool for creating scanners (text pattern recognizers)  
gperf A perfect hash function generator  
ruby Object Oriented Script Language  
libstdc++-static-devel Static libraries for C++ development  

Ok

Try to run my application with a JavaFX patched WebCore :

  • What's wrong ?

java @run.args JavaFXMathML

  • run.args file :
#generated from tools/scripts/make_runargs.sh
--patch-module="javafx.base=/home/scientificware2016/Documents/jfx/rt/build/modular-sdk/modules/javafx.base"
--patch-module="javafx.graphics=/home/scientificware2016/Documents/jfx/rt/build/modular-sdk/modules/javafx.graphics"
--patch-module="javafx.swing=/home/scientificware2016/Documents/jfx/rt/build/modular-sdk/modules/javafx.swing"
--patch-module="javafx.controls=/home/scientificware2016/Documents/jfx/rt/build/modular-sdk/modules/javafx.controls"
--patch-module="javafx.fxml=/home/scientificware2016/Documents/jfx/rt/build/modular-sdk/modules/javafx.fxml"
--patch-module="javafx.media=/home/scientificware2016/Documents/jfx/rt/build/modular-sdk/modules/javafx.media"
--patch-module="javafx.web=/home/scientificware2016/Documents/jfx/rt/build/modular-sdk/modules/javafx.web"
-Djava.library.path="\
  /home/scientificware2016/Documents/jfx/rt/build/modular-sdk/modules_libs/javafx.base\
  :/home/scientificware2016/Documents/jfx/rt/build/modular-sdk/modules_libs/javafx.graphics\
  :/home/scientificware2016/Documents/jfx/rt/build/modular-sdk/modules_libs/javafx.media\
  :/home/scientificware2016/Documents/jfx/rt/build/modular-sdk/modules_libs/javafx.web"

Error message :

public class JavaFXMathML extends Application {
       ^
1 error
Exception in Application start method
java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:564)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:464)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:363)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:564)
        at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:941)
Caused by: java.lang.RuntimeException: Exception in Application start method
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:900)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:195)
        at java.base/java.lang.Thread.run(Thread.java:844)
Caused by: java.lang.IllegalAccessError: class com.sun.javafx.scene.control.Logging (in module javafx.controls) cannot access class com.sun.javafx.logging.PlatformLogger (in module javafx.base) because module javafx.base does not export com.sun.javafx.logging to module javafx.controls
        at javafx.controls/com.sun.javafx.scene.control.Logging.getControlsLogger(Logging.java:47)
        at javafx.controls/javafx.scene.control.Control$2.invalidated(Control.java:316)
        at javafx.base/javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:112)
        at javafx.base/javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:147)
        at javafx.graphics/javafx.css.StyleableObjectProperty.set(StyleableObjectProperty.java:82)
        at javafx.controls/javafx.scene.control.Control$2.set(Control.java:250)
        at javafx.controls/javafx.scene.control.Control$2.set(Control.java:233)
        at javafx.controls/javafx.scene.control.Control.loadSkinClass(Control.java:757)
        at javafx.controls/javafx.scene.control.Control$5.invalidated(Control.java:680)
        at javafx.base/javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:110)
        at javafx.base/javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:145)
        at javafx.graphics/javafx.css.StyleableStringProperty.set(StyleableStringProperty.java:83)
        at javafx.controls/javafx.scene.control.Control$5.set(Control.java:672)
        at javafx.graphics/javafx.css.StyleableStringProperty.applyStyle(StyleableStringProperty.java:69)
        at javafx.graphics/javafx.css.StyleableStringProperty.applyStyle(StyleableStringProperty.java:45)
        at javafx.web/javafx.scene.web.HTMLEditor.<init>(HTMLEditor.java:50)
        at JavaFXMathML.start(JavaFXMathML.java:26)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:846)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:451)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:424)
        at java.base/java.security.AccessController.doPrivileged(Native Method)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:423)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
        at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:277)
        ... 1 more
@kevinrushforth

This comment has been minimized.

Collaborator

kevinrushforth commented Apr 30, 2018

Not sure why you are using make_runargs.sh -- that script is usually meant for taking your own build of JavaFX done on one machine and copying it to another where the path to the FX modules is different (since run.args has absolute paths).

In any case, the problem seems to be that the exports from buildSrc/addExports is not being included in the generated run.args as it should be, which is a bug in make_runargs.sh. You can append the needed exports from that file to your generated run.args, or just not use it in the first place and take the build/run.args from your JavaFX build and manually adjust the paths as needed.

@scientificware

This comment has been minimized.

Contributor

scientificware commented May 1, 2018

Thanks a lot and sorry. You're right, I made three big mistakes :

  • working too late,
  • be impatient, I wanted to try before going to sleep,
  • and not use "The file build/run.args and build/compile.args created during the FX build process" as you suggest in the Wiki.

It works well with build/run.args from my JavaFX build.

@scientificware

This comment has been minimized.

Contributor

scientificware commented May 1, 2018

If you want to build WebKit :

Before to run gradle, edit the file in gradle.properties.template in rt/ and save it as "rt/gradle.properties" :

# These properties give developers the chance to skip building WebKit and/or
# GStreamer. WebKit takes a fair amount of time to build (more than 50% of the
# overall full build time is taken by WebKit), so allowing a developer to
# selectively enable building of WebKit is important. To build WebKit or
# GStreamer, uncomment the appropriate lines below.

COMPILE_WEBKIT = true
@scientificware

This comment has been minimized.

Contributor

scientificware commented May 5, 2018

  • Just a problem with a "lstdc++ missing" in my configuration
    • To do : modify the required development package list for Mageia 6 :
      • libstdc++6 - GNU C++ library​
      • libstdc++-static-devel - Static libraries for C++ development​
      • libstdc++-devel - Header files and libraries for C++ development​
  • The build with webkit is now OK (2h30min, AMD Athlon(tm) II X2 245 Processor).
  • Running JavaFX with custom RenderMathMLFraction.cpp where I inflated the fraction line. That doesn't resolve the bug : just an exercice to be familiar with the code.
    screenshot_javafxmathml_20180505_100542
@scientificware

This comment has been minimized.

Contributor

scientificware commented May 5, 2018

  • The numerator and denominator vertical sizes are equal to 1,
  • The numerator and denominator horizontal sizes are correct.
  • That's confirms my analysis : the problem is in one super class : May be RenderBox.
  • RenderMathMLFraction logic is correct.
  • Another picture to confirm my analysis. As Suggest by Arunprasad Rajkumar,
    • I fixed some values in RenderMathMLFraction.cpp :
      • the numerator and denominator sizes rather the gap size : because our analysis differ about the origin of the bug.
      • fallback logic is based on default OpenMathData table values. So the layout, could be done without reading OpenType font table.
    • The result is pretty good, compare with the first picture, I sent.
    • beware, that's not solve the bug !
      screenshot_javafxmathml_20180505_124605
  • I think the bug is pretty simple, I hope the priority of this bug may changed. Support MathML, should be a great opportunity to extend developpers interest for JavaFX especially those who developp serious games. I can continue alone but it will take a long :
    • look at style().logicalMaxHeight(), which sets the maximum vertical children's sizes.
    • style().fontMetrics().height() ?
    • Length.h, Length.cpp
@scientificware

This comment has been minimized.

Contributor

scientificware commented May 6, 2018

  • Can't determine what is the numerator and denominator styles, which set the horizontal and vertical sizes.
  • Looking for styles sets in the MathML elements class.
@scientificware

This comment has been minimized.

Contributor

scientificware commented May 7, 2018

  • https://trac.webkit.org/browser
  • RenderMathMLMath::layoutBlock
  • Have a look at RenderMathMLBlock and RenderMathMLRow to confirm that child vertical sizes are equal to 0 or 1 far less than expected values (layoutBlock and layoutItems).
    • confirmed : RenderMathMLBlock: layoutItems : child Height()1
  • It seems that webkit can build a MathML factory for each platform, javaFX included :
    • DerivedSourcesJava.pri (the logic)
    • MathMLElementFactory (the result).
  • Have a look at mathvariant.
  • Why WebCore ChangeLog stucks at ChangeLog-2014-10-07 ?
@scientificware

This comment has been minimized.

Contributor

scientificware commented May 10, 2018

Change c++ option : -fno-rtti

Where is the best place to change this option ?
rt/…les/javafx.web/src/main/native/Source/cmake/WebKitCompilerFlags.cmake :
WEBKIT_APPEND_GLOBAL_CXX_FLAGS(-std=c++14)

  • -fno-rtti :

    Disable generation of information about every class with virtual functions for use by the C++ run-time type identification features (dynamic_cast and typeid). If you don’t use those parts of the language, you can save some space by using this flag. Note that exception handling uses the same information, but G++ generates it as needed. The dynamic_cast operator can still be used for casts that do not require run-time type information, i.e. casts to void * or to unambiguous base classes.

@ararunprasad

This comment has been minimized.

Contributor

ararunprasad commented May 10, 2018

Do you want to remove the C++ RTTI? Then you can modify the same from WebKitCompilerFlags.cmake#line105. BTW, why do you want to remove that?

To explore the chagelog of a WebKit, please refer this. Current JavaFXWebView is based on GTK WebKit 2.18 branch.

@scientificware

This comment has been minimized.

Contributor

scientificware commented May 10, 2018

Hi,
Thank you very much,

  • I'd already "post-it" these links in previous comment three days ago.
  • And I already made the changes you mentioned in WebKitCompilerFlags.cmake.
  • I've also read changelogs, 2.20.2 branch included. May be I missed some informations.

Yes, I want to remove -fno-rtti, in order to use typeid to identify child in RenderMathMLBlock::layoutItems and understand why height is set to 1.

Have you got a specific configuration (Netbeans or others) to debug JavaFX/WebKit ?

Best regards.


Read the Wiki ! Using an IDE
Of course ! This is the second time I forget that basic advice

  • This section assumes that you have already succeeded in Building OpenJFX.
  • IDE Pre-Requirements :
    • Get a build of the JDK8 (8u40 or later)
    • Get an IDE that supports JDK8
      • NetBeans
      • IntelliJ
      • Eclipse
    • Delete jfxrt.jar (or move it to a different directory)
  • Using NetBeans
    • Edit netbeans.conf
    • Invoke NetBeans
    • Add the JDK8 Platform
    • Import NetBeans projects
    • Rebuild
    • Run sample code
    • Run sample code with grade built shared libraries
@scientificware

This comment has been minimized.

Contributor

scientificware commented May 10, 2018

The child of a RenderMathMLBlock is an RenderBlockFlow.

@scientificware

This comment has been minimized.

Contributor

scientificware commented May 12, 2018

I think that I gone a bit farther. The problem only affects MathML elements :
RenderBox, RenderBlockFlow, RenderBlock, ... work fine for all element types other than MathML elements.
I'm Trying something rather simple this morning.

@scientificware

This comment has been minimized.

Contributor

scientificware commented May 12, 2018

I think that MathML Renders are cast in an inappropiate objects.

  • Update TargetJava.pri
    • missing MathML enable
    • or deleted removed cpp files like RenderMathMLSquareRoot.cpp or MathMLTextElement.cpp
      • In the new Webkit version SquareRoot is rendering by RenderMathMLRoot.
contains(DEFINES, ENABLE_MATHML=1) {
    SOURCES += \
        css/CSSDefaultStyleSheets.cpp \
        accessibility/AXObjectCache.cpp \
        accessibility/AccessibilityNodeObject.cpp \
        accessibility/AccessibilityObject.cpp \
        accessibility/AccessibilityRenderObject.cpp \
        dom/Document.cpp \
        mathml/MathMLInlineContainerElement.cpp \
        mathml/MathMLAnnotationElement.cpp\
        mathml/MathMLElement.cpp \
        mathml/MathMLFractionElement.cpp \
        mathml/MathMLMathElement.cpp \
        mathml/MathMLMencloseElement.cpp \
        mathml/MathMLOperatorDictionary.cpp \
        mathml/MathMLOperatorElement.cpp \
        mathml/MathMLPaddedElement.cpp \
        mathml/MathMLPresentationElement.cpp \
        mathml/MathMLRowElement.cpp \
        mathml/MathMLScriptsElement.cpp \
        mathml/MathMLSelectElement.cpp \
        mathml/MathMLSpaceElement.cpp \
        mathml/MathMLTokenElement.cpp \
        mathml/MathMLUnderOverElement.cpp \
        rendering/RenderBox.cpp \
        rendering/RenderTreeAsText.cpp \
        rendering/RenderObject.h \
        rendering/RenderTableCell.cpp \
        rendering/mathml/MathMLStyle.cpp \
        rendering/mathml/MathOperator.cpp \
        rendering/mathml/RenderMathMLBlock.cpp \
        rendering/mathml/RenderMathMLFenced.cpp \
        rendering/mathml/RenderMathMLFencedOperator.cpp
        rendering/mathml/RenderMathMLFraction.cpp \
        rendering/mathml/RenderMathMLMath.cpp \
	    rendering/mathml/RenderMathMLMenclose.cpp \
        rendering/mathml/RenderMathMLOperator.cpp \
        rendering/mathml/RenderMathMLPadded.cpp
        rendering/mathml/RenderMathMLRoot.cpp \
        rendering/mathml/RenderMathMLRow.cpp \
        rendering/mathml/RenderMathMLScripts.cpp \
        rendering/mathml/RenderMathMLSpace.cpp \
	    rendering/mathml/RenderMathMLToken.cpp \
        rendering/mathml/RenderMathMLUnderOver.cpp
}
@scientificware

This comment has been minimized.

Contributor

scientificware commented May 12, 2018

Qt [Wiki]

Qt Documentation :

@scientificware

This comment has been minimized.

Contributor

scientificware commented May 12, 2018

Do not add these files which are already added in SOURCES

# css/CSSDefaultStyleSheets.cpp \
# accessibility/AXObjectCache.cpp \
# accessibility/AccessibilityNodeObject.cpp \
# accessibility/AccessibilityObject.cpp \
# accessibility/AccessibilityRenderObject.cpp \
# dom/Document.cpp \

Do not add this file which has been renamed to MathMLPresentationElement

# mathml/MathMLInlineContainerElement.cpp \
@scientificware

This comment has been minimized.

Contributor

scientificware commented May 12, 2018

  • Which part of WebKit use JSMathMLElementWrapperFactory ?
  • To do : have a look at mathMLStyleSheet in CSSDefaultStyleSheets.cpp
  • In RenderMathMLToken : : layoutBlock it seems that mathVariantGlyph doesn't return right glyph informations.
  • mathVariant see Improvements in MathML Rendering
  • Which part of JavaFX can interfer with WebKit build ?
@scientificware

This comment has been minimized.

Contributor

scientificware commented May 19, 2018

I'm looking for what is the function of WTFMove.
WTF : Web Template Framework
WTFMove is a macro defined in StdLibExtras.h :
#define WTFMove(value) std::move<WTF::CheckMoveParameter>(value)

Bug 152601 - Use of WTF::move prevents clang's move diagnostics from warning about several classes of mistakes

@scientificware

This comment has been minimized.

Contributor

scientificware commented May 26, 2018

  • Is there an specific implementation of fontCascade witch returns wrong text height value ?

    • See in /modules/javafx.web/src/main/native/Source/WebCore/platform/graphics/java
      (FontCascade, FontCascadeJava).
    • MathML implementation uses fontCascade informations(RenderMathMLToken::layoutBlock), does java implementation returns at least defaults MathML informations ?
  • Try to understand this comment in /modules/javafx.web/src/main/native/Source/WebCore/platform/graphics/java/FontJava.cpp

FloatRect Font::platformBoundsForGlyph(Glyph) const
{
    return FloatRect(); //That is OK! platformWidthForGlyph impl is enough.
}
@scientificware

This comment has been minimized.

Contributor

scientificware commented May 27, 2018

  • OpenTypeMathData is not defined becauseof HARFBUZZ and OPENTYPE_MATH not enabled.
  • Setting Child size to font height partially solve the problem :
    • But the container size is still 0 height.
    • The problem seems to be in the container too ?
void RenderMathMLToken::layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight)
{
    ASSERT(needsLayout());

    if (!relayoutChildren && simplifiedLayout())
        return;

    GlyphData mathVariantGlyph;
    if (m_mathVariantCodePoint)
        mathVariantGlyph = style().fontCascade().glyphDataForCharacter(m_mathVariantCodePoint.value(), m_mathVariantIsMirrored);

    if (!mathVariantGlyph.font) {
        RenderMathMLBlock::layoutBlock(relayoutChildren, pageLogicalHeight);
        return;
    }

    for (auto* child = firstChildBox(); child; child = child->nextSiblingBox())
        child->layoutIfNeeded();

    setLogicalWidth(mathVariantGlyph.font->widthForGlyph(mathVariantGlyph.glyph));
    
    setLogicalHeight(mathVariantGlyph.font->boundsForGlyph(mathVariantGlyph.glyph).height());
    clearNeedsLayout();
}
  • Why the following part of code is exectued ? Without math support mathVariantGlyph can't return a valid value.
    for (auto* child = firstChildBox(); child; child = child->nextSiblingBox())
        child->layoutIfNeeded();

    setLogicalWidth(mathVariantGlyph.font->widthForGlyph(mathVariantGlyph.glyph));
    
    setLogicalHeight(mathVariantGlyph.font->boundsForGlyph(mathVariantGlyph.glyph).height());
    clearNeedsLayout();
@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 6, 2018

Read previous comments above :
For Java platform FontJava.cpp platformBoundsForGlyph doesn't return the bounds of the glyph but a (0,0,0,0) rectangle.
May be that one who wrote this comment :

//That is OK! platformWidthForGlyph impl is enough.

Doesn't take in account that height values are used in MathML Rendering ?

So Font.h boundsForGlyph returns 0 for the height.

Try to explore that, this weekend.

@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 9, 2018

Abossolo Foh Guy - NB
I already signed the OCA.

@kevinrushforth

This comment has been minimized.

Collaborator

kevinrushforth commented Jun 9, 2018

Yes, I see you on the list of OCA signatories. Thanks.

@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 11, 2018

I don't understand why everybody adopts this approch of stretchy characters ! Implement a METAFONT like language would had be more efficient and simple. It's really a shame that the WebCore part was not written en Java. Java Swing text package seems to have been written for D. Knuth.

Stretchy Characters UTF-16 Code :

Name Char. Sy. Top Char. Extension Char. Bottom Char. Middle Char.
left parenthesis 0x28 ( 0x239b 0x239c 0x239d 0x0
right parenthesis 0x29 ) 0x239e 0x239f 0x23a0 0x0
left square bracket 0x5b [ 0x23a1 0x23a2 0x23a3 0x0
right square bracket 0x5d ] 0x23a4 0x23a5 0x23a6 0x0
left curly bracket 0x7b { 0x23a7 ⎧ 0x23aa ⎪ 0x23a9 ⎩ 0x23a8 ⎨
right curly bracket 0x7d } 0x23ab ⎫ 0x23aa ⎪ 0x23ad ⎭ 0x23ac ⎬
left ceiling 0x2308 0x23a1 0x23a2 0x23a2 0x0
right ceiling 0x2309 0x23a4 0x23a5 0x23a5 0x0
left floor 0x230a 0x23a2 0x23a2 0x23a3 0x0
right floor 0x230b 0x23a5 0x23a5 0x23a6 0x0
vertical bar 0x7c | 0x7c 0x7c 0x7c 0x0
double vertical line 0x2016 0x2016 0x2016 0x2016 0x0
parallel to 0x2225 0x2225 0x2225 0x2225 0x0
integral sign 0x222b 0x2320 0x23ae 0x2321 0x0
@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 11, 2018

Yes !

With this small correction matrix delimiters are well displayed !

WCFontImpl.java

        bb[1]= -getCapHeight();
        bb[3]= getDescent()-bb[1];

In fact, I don't understand exactly what getGlyphBoundingBox should return ! ?

  • GetAscent() or getCapHeight();
  • So, radical and other delemiters don't display correctly. It's really a shame.

TeX on the left and JavaFX / OpenJFX on the right.

screenshot_20180611_201434

screenshot_20180612_032744

@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 12, 2018

  • The remaining problems:

    • I'm afraid that without mathtable informations, glyphs assembly for stretchy glyphs couldn't be better and may vary from one font to another. Radical signe is a good example, in "Latin Modern Math" Font the top of the sign is based on the descent line of the font. In "STIX" font the top of the sign is over the ascent line.
      • A quite simple solution would be to provide a font substitution file with theses glyphes, with an right glyph position.
      • But since I started to work in math display implementation, I prefer draw theses specific signe by my self.
    • Big operators, like sum and integral signs, are too small.
      • May be a prism font map fix could solve this ?
    • No horizontal brackets.
  • Next step, provide a test to prevent another JDK-8147476 bug.

  • I saw several changes in the next WebKit version. It's worth to wait and see, if some of the problems listed above will be fixed.

screenshot_20180612_052032

@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 12, 2018

Ok, I've just understand what's wrong !

  • JavaFX used the bad code for glyph in latin modern.
  • But I don't know how to reach them :
    • These Glyphs are not in the Unicode range :
Name Char. Sy. Top Char. Extension Char. Bottom Char. Middle Char.
left curly bracket 0x7b { ? ⎧ ? ⎪ ? ⎩ ? ⎨
right curly bracket ? } ? ⎫ ? ⎪ ? ⎭ ? ⎬
left ceiling ? ? ? ? ?
right ceiling ? ? ? ? ?
left floor ? ? ? ? ?
right floor ? ? ? ? ?
vertical bar ? | ? ? ? ?
double vertical line ? ? ? ? ?
parallel to ? ? ? ? ?
integral sign ? ? ? ? ?
radical sign ?

Well have got all pieces of this puzzle !
All that's left to do, try to build something resilient.

The picture has been obtained after change order in the list of font in mathml.css.

screenshot_20180612_180253

@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 13, 2018

The relative test :

  • Return an error message without the patch.
  • an Ok message after with the patch.
  • it's simply test the height of some MathML element. I choosed but we can test any others elements.
/*
 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.web.HTMLEditor;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

/**
 * @test
 * @bug JDK-8147476 Rendering issues with MathML token elements
 * @bug JDK-8089878 HTMLEditor messes up MathML markup press
 */
public class OpenJFXMathMLRenderingIssueTest extends Application {

    final HTMLEditor htmlEditor = new HTMLEditor();
    final StackPane root = new StackPane();
    final WebView webView = (WebView) htmlEditor.lookup(".web-view");

    public void init() {
        htmlEditor.setHtmlText(content);
        root.getChildren().add(htmlEditor);
        htmlEditor.setPrefWidth(400);
        htmlEditor.setPrefHeight(150);
    }

    @Override
    public void start(Stage primaryStage) {

        webView.focusedProperty().addListener((observable, oldValue, newValue) -> {

            if (newValue) {

                WebEngine we = webView.getEngine();
                int height = (int) we.executeScript(
                        "elements = document.getElementsByTagName('mo');"
                        + "element = elements[0].clientHeight;"
                );

                if (height < 2) {
                    Platform.exit();
                    throw new RuntimeException(" : MathML rendering issues see JDK-8089878 and JDK-8147476.\n");
                }

                System.out.println("[Ok]\n");
                Platform.exit();
            }
        });

        primaryStage.setTitle("OpenJFX MathML Rendering Issue Test");
        primaryStage.setScene(new Scene(root));
        primaryStage.show();

    }

    String BodyContent
            = "<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>";

    String content = "<!doctype html>"
            + "<html>"
            + "   <head>"
            + "      <meta charset=\"UTF-8\">"
            + "      <title>OpenJFX and MathML</title>"
            + "   </head>"
            + "   <body>"
            + "      <p>"
            + BodyContent
            + "      </p>"
            + "   </body>"
            + "</html>";

}
@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 13, 2018

Exactly what I need and what I has been waiting since few years !
Hope, I could use it in my projects soon.

screenshot_20180613_123931

Hi !
screenshot_20180613_125304

The code of this page.

      <p>
	Here is an example of Presentation MathML:
	<math>
	  <mrow>
	    <mfenced>
	      <mtable>
		<mtr><mtd><mi> a </mi></mtd> <mtd><mi> b </mi></mtd></mtr>
		<mtr><mtd><mi> c </mi></mtd> <mtd><mi> d </mi></mtd></mtr>
	      </mtable>
	    </mfenced>
	    <mo> &#x2062;<!--INVISIBLE TIMES--> </mo>
	    <mfenced>
	      <mtable>
		<mtr><mtd><mi> x </mi></mtd></mtr>
		<mtr><mtd><mi> y </mi></mtd></mtr>
	      </mtable>
	    </mfenced>
	  </mrow>
	  <mo> = </mo>
	  <mfenced>
	    <mtable>
	      <mtr><mtd><mi> e </mi></mtd></mtr>
	      <mtr><mtd><mi> f </mi></mtd></mtr>
	    </mtable>
	  </mfenced>
	</math>
        and another:
        <math>
         <mfenced open="{" close="">
          <mtable>
           <mtr><mtd>
             <mrow>
              <mrow><mi>a</mi><mo>&#x2062;</mo><mi>x</mi></mrow>
              <mo>+</mo>
              <mrow><mi>b</mi><mo>&#x2062;</mo><mi>y</mi></mrow>
             </mrow>
             <mo> = </mo>
             <mi> e </mi>
           </mtd></mtr>
           <mtr><mtd>
             <mrow>
              <mrow><mi>c</mi><mo>&#x2062;</mo><mi>x</mi></mrow>
              <mo>+</mo>
              <mrow><mi>d</mi><mo>&#x2062;</mo><mi>y</mi></mrow>
             </mrow>
             <mo> = </mo>
             <mi> f </mi>
           </mtd></mtr>
          </mtable>
         </mfenced>
        </math>
      </p>

screenshot_20180613_130720

@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 13, 2018

The web browser I used to test the patch over the net.

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.web.HTMLEditor;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

public class NavigateurTest extends Application {

    final HTMLEditor htmlEditor = new HTMLEditor();
    final StackPane root = new StackPane();
    final WebView webView = (WebView) htmlEditor.lookup(".web-view");

    public void init() {
        htmlEditor.setHtmlText("");
        root.getChildren().add(htmlEditor);
        htmlEditor.setPrefWidth(800);
        htmlEditor.setPrefHeight(600);
    }

    @Override
    public void start(Stage primaryStage) {
    
        webView.getEngine().load("https://duckduckgo.com");

        primaryStage.setTitle("OpenJFX MathML Rendering Issue WebBrowser Test");
        primaryStage.setScene(new Scene(root));
        primaryStage.show();

    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
    
}

@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 14, 2018

JDK-8147476 Rendering issues with MathML token elements.
JDK-8165520 Several mathml/ DRT tests fail
JDK-8089878 HTMLEditor messes up MathML markup.
JDK-8090887 Support MathML

@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 16, 2018

Another question was not resolved :

Why WebCore authors didn't used the same logic in normal text and mathml text ?
They call bounding box height dimension rather than sum the text ascent and descent.
One who wrapped webkit in JavaFX must have been thinking that it was the same logic.

My response : In fact the problem with mathematical glyphs is that they go upper and lower than ascent or the descent. Only the bounding box height gives this right measure of the glyph.

JavaFX prism and WebCore Text Bounding Box implementation are different.

  • in WebCore as shown in the patch :
    • y contains the ascent position on the y axis (oriented from up to down). Thus It's a negative value when a part of the glyph is over the baseline.
    • height contains the height of the glyph. it's always a positive value.
  • JavaFX ?
    • y contains ?
    • height contains ?

Use of getAscent() and getDescent() is quite a good interim solution while I'm looking for what's wrong with JavaFX text bounding box informations.

@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 17, 2018

To do :

  • : Find why cursor disappears when enter in and becomes visible in tokens.
@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 19, 2018

PrismFontFile

Try to understand this :

createGlyphBoundingBox

    @Override
    protected synchronized int[] createGlyphBoundingBox](int gc) {
        int flags = OSFreetype.FT_LOAD_NO_SCALE;
        OSFreetype.FT_Load_Glyph(face, gc, flags);
        int[] bbox = new int[4];
        FT_GlyphSlotRec glyphRec = OSFreetype.getGlyphSlot(face);
        if (glyphRec != null && glyphRec.metrics != null) {
            FT_Glyph_Metrics gm = glyphRec.metrics;
            bbox[0] = (int)gm.horiBearingX;
            bbox[1] = (int)(gm.horiBearingY - gm.height);
            bbox[2] = (int)(gm.horiBearingX + gm.width);
            bbox[3] = (int)gm.horiBearingY;
        }
        return bbox;
}

It can explain what kind of informations is returned by getBoundingBox in FontResource.

Explanations :

Freetype definitions :

Picture giving all the JavaFX metric details for horizontal layout
horizontal_layout_metrics

Picture giving all the JavaFX metric details for vertical layout
vertical_layout_metrics

Picture giving all the WebCore metric details for horizontal layout
webcore_glyph_metrics

So I understand why when using GlyphBoundingBox, I didn't succeed to perfrom right alignment. Then I used getAscent() and getDescent() which work well for usual glyphs but not for mathematical glyphs as explains in the previous comment.

The rectangle definition are in different order :

  • JavaFX box[1] contains Glyph descent position on the y axis (oriented from down to up) but WebCore box[1] contains the ascent position on the y axis (oriented from up to down). Thus It's a negative value when a part of the glyph is over the baseline.
  • JavaFX box[3] contains Glyph ascent position on the y axis (oriented from down to up) but WebCore box[3] contains the height of the glyph. it's always a positive value.

Finally no more need of getAscent() and getDescent(), I used, pending best JavaFX metrics understanding.
Modify getGlyphBoundingBox

in WCFontImpl.java

Reorder values and compute height :

@Override public float[] getGlyphBoundingBox(int glyph) {
        float[] bb = new float[4];
        bb = getFontStrike().getFontResource().getGlyphBoundingBox(glyph, font.getSize(), bb);
        //bb[1]= -getAscent();
        //bb[3]= getDescent();
        return new float[]{bb[0],-bb[3],bb[2],bb[3]-bb[1]};
    }

Great ... adopted !

screenshot_20180619_191413

@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 20, 2018

OpenJFX unit tests

Building OpenJFX and testing

The junit test is ready to be tested

gradle -PFULL_TEST=true :systemTests:test --tests MathMLRenderTest

Test Succeeded !

  • WebCore with the patch.

screenshot_20180621_010700

  • WebCore without the patch.
    screenshot_20180621_005400
/*
 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.  Oracle designates this
 * particular file as subject to the "Classpath" exception as provided
 * by Oracle in the LICENSE file that accompanied this code.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */

import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import javafx.application.Application;
import javafx.application.Platform;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.web.HTMLEditor;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.Assert;

import static junit.framework.TestCase.fail;

import static test.util.Util.TIMEOUT;

public class MathMLRenderTest {

    private static final CountDownLatch launchLatch = new CountDownLatch(1);

    // Document test
    static String BodyContent
            = "<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>";

    static String content = "<!doctype html>"
            + "<html>"
            + "   <head>"
            + "      <meta charset=\"UTF-8\">"
            + "      <title>OpenJFX and MathML</title>"
            + "   </head>"
            + "   <body>"
            + "      <p>"
            + BodyContent
            + "      </p>"
            + "   </body>"
            + "</html>";

    // Application instance
    static TestApp testApp;

    public static class TestApp extends Application {

        final HTMLEditor htmlEditor = new HTMLEditor();
        final StackPane root = new StackPane();
        final WebView webView = (WebView) htmlEditor.lookup(".web-view");

        public void init() {
            MathMLRenderTest.testApp = this;
            htmlEditor.setHtmlText(content);
            root.getChildren().add(htmlEditor);
            htmlEditor.setPrefWidth(400);
            htmlEditor.setPrefHeight(150);
        }

        @Override
        public void start(Stage primaryStage) {
            primaryStage.setTitle("OpenJFX MathML Rendering Issue Test");
            primaryStage.setScene(new Scene(root));
            primaryStage.show();
            launchLatch.countDown();
        }

        // Get height of the first token element <mo>
        public int getTokenHeight(){
            WebEngine we = webView.getEngine();
            int height = (int) we.executeScript(
                "elements = document.getElementsByTagName('mo');"
                + "element = elements[0].clientHeight;"
            );
            return height;
        }
    }

    @BeforeClass
    public static void setupOnce() {

        // Start the Test Application
        new Thread(() -> Application.launch(TestApp.class,
            (String[]) null)).start();

        try {
            if (!launchLatch.await(TIMEOUT, TimeUnit.MILLISECONDS)) {
                fail("Timeout waiting for FX runtime to start");
            }
        } catch (InterruptedException exception) {
            fail("Unexpected exception: " + exception);
        }    
    }

    @AfterClass
    public static void tearDownOnce() {
        Platform.exit();
    }

    /**
     * @test
     * @bug JDK-8147476 Rendering issues with MathML token elements
     */
    @Test
    public void testgetTokenHeight() throws Exception {

        final CountDownLatch editorStateLatch = new CountDownLatch(1);
        final AtomicBoolean rightRender = new AtomicBoolean(false);
        final AtomicInteger tokenHeight = new AtomicInteger(0);
        Platform.runLater(() -> {
            tokenHeight.set(testApp.getTokenHeight());
            rightRender.set(!(tokenHeight.get()<2));
            editorStateLatch.countDown();
        });

        try {
            editorStateLatch.await(TIMEOUT, TimeUnit.MILLISECONDS);
        } catch (InterruptedException ex) {
            throw new AssertionError(ex);
        } finally {
            Assert.assertTrue("Check MathML token height : " + tokenHeight.get() + " is much smaller than the expected size." , rightRender.get());
        }
    }
}
@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 23, 2018

Close Buzilla Webkit Report.

ogimage

https://bugs.webkit.org/show_bug.cgi?id=185417

@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 27, 2018

Bug report related to this bug :

@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 28, 2018

Problems with Windows CR when editing files.

  • Really too hard to work with Windows.
  • Don't understand the logic of core.autocrlf !
  • Missing .getAttributes in GitHub repository to force with LF rather than CRLF.

Definitively stays on linux when working on GitHub OpenJFX project.

  • When not at home install Linux Mageia in a VirtualBox.
  • Install git.
  • Don't forget to set the core editor with kwrite : git config --global core.editor kwrite (kwrite allows to choose between LF or CRLF or ...

vbox_logo2_gradient

@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 28, 2018

Kevin comment

For ease of review, to address Arun's concern, can you please squash your commits into a single commit ?
You should do this on your existing branch (meaning you will need to use git push --force after you squash it), so that you don't need a new PR.
If you are worried about losing information, you can create a new local branch to save all of your commits.

Presuming you have an upstream remote pointing to javafxports/openjdk-jfx called 'upstream" the basic recipe is :

git fetch upstream
// this will put you into an editor where you can select which commits are squashed
git rebase -i upstream/develop

and then change the pick to squash in your editor for all commits except the first one (leaving that first commit as 'pick') like this :

But I prefered to use rewrote and fixup.

  • rewrote opens my editor (kwrite) and allowed me to change de commit message that resumes all next following commits :
    • Bug JDK-8147476, commit of the following :
      FontJava.cpp :
      • Completes the implementation of the platformBoundsForGlyph(Glyph c) function in FontJava.cpp.
      • Previous implementation simply returned a (0,0,0,0) rectangle, which explains the bad rendering height of MathML elements.
      • This affects only MathML elements due to specific mathematic glyphs behavior : WebCore MathML rendering can't use the font ascents and descents which causes gap into assembled glyphs. So getAscent(), getDescent() ... font methods are not appropriate.
      • WebCore uses bearY and heights informations from the glyph bounding box.
        ...
reword 78bf9df Bug JDK-8147476, commit of the following:
fixup 47d9135 Update FontJava.cpp
fixup 91023c1 Update FontJava.cpp
fixup 2c89846 Update FontJava.cpp
...

Alternatively, if you use a GUI front-end to git there will be options to allow you to squash the commits into a single commit.

@kevinrushforth

This comment has been minimized.

Collaborator

kevinrushforth commented Jun 29, 2018

As long as the end result is the same, you can use any method you like. My suggestion was just an example of one way to do it.

@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 29, 2018

Thank you very much Kevin.
Sure I would never succed without this and would be still stuck with Git :-)
I feel better this morning.
That was exactly what I needed.
I'm writing a "How to" and a notes for me. So I post here all helps and suggestions that you and your team gave. And of course all you teached me. With comments for future. I'll hope it will be helpfull for someone else.

@scientificware

This comment has been minimized.

Contributor

scientificware commented Jun 30, 2018

To execute all web test
gradle :web:test

To render only MathMLRenderTest
gradle :web:test --tests MathMLRenderTest gives :

  • with the patch :
    screenshot_20180630_083600

...

@scientificware

This comment has been minimized.

Contributor

scientificware commented Jul 2, 2018

@scientificware

This comment has been minimized.

Contributor

scientificware commented Jul 2, 2018

Can't build WebCore with WebKit 606.1.
And a problem with gradle : can't clean ?
May be because I disable java 9 ?

Resolved : In fact a problem with ant.

  • Build master (without MathML patch).

===================================================================
 WebKit is now built (1h:09m:04s). 
 To run FXLauncher with this newly-built code, use the
 "../../src/main/native/Tools/Scripts/run-minibrowser" script.
====================================================================

> Task :web:compileJavaDOMBindingLinux
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

> Task :fxml:compileJava
Note: /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.fxml/src/main/java/javafx/fxml/FXMLLoader.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

> Task :swing:compileJava
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

BUILD SUCCESSFUL in 1h 13m 38s
124 actionable tasks: 124 executed
  • Build branch with MathML patch.
====================================================================
 WebKit is now built (02m:58s). 
 To run FXLauncher with this newly-built code, use the
 "../../src/main/native/Tools/Scripts/run-minibrowser" script.
====================================================================

> Task :web:compileJavaDOMBindingLinux
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

BUILD SUCCESSFUL in 3m 37s
124 actionable tasks: 22 executed, 102 up-to-date
@kevinrushforth

This comment has been minimized.

Collaborator

kevinrushforth commented Aug 6, 2018

This was fixed some time ago by PR #117

@scientificware

This comment has been minimized.

Contributor

scientificware commented Sep 5, 2018

@kevinrushforth For a better MathML experience, a mathml.css comment suggests that at least one of these fonts must be installed (in order of preference).

  • Latin Modern Math

  • STIX Two Math

  • XITS Math

  • STIX Math

  • Libertinus Math

  • TeX Gyre Termes Math

  • TeX Gyre Bonum Math

  • TeX Gyre Schola

  • DejaVu Math TeX Gyre

  • TeX Gyre Pagella Math

  • Asana Math

  • Cambria Math

  • Lucida Bright Math

  • Minion Math

  • Times New Roman

Is it possible to indicate that to users somewhere in the documentation or elsewhere.

Before Latin Modern Math install :
screenshot_20180830_235258

After Latin Modern Math install : the greek small letter PI is well rendered, better than with the default font.
screenshot_20180831_013116

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment