Skip to content
This repository has been archived by the owner on Jun 24, 2021. It is now read-only.

JDK-8147476 : Rendering issues with MathML token elements. #117

Merged

Conversation

scientificware
Copy link
Contributor

@scientificware scientificware commented Jun 21, 2018

Hi !

This is tracked in JBS as

Issue #71 was submitted for this.

Please could you review this patch :
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.

MathMLRenderTest.java :

  • Adds a HeadLess proper unit test for this Bug JDK-8147476.
  • Tests the height of the first MathML mo token element in a quadratic formula.

WCFont.java :

  • Adds the abstract getGlyphBoundingBox() method.

WCFontPerfLogger.java :

  • Adds the getGlyphBoundingBox() method.

WCFontImpl.java :

  • Implements the getGlyphBoundingBox() method.
  • Uses and reorders (FontResource) getGlyphBoundingBox values to match perfectly with WebCore requirements.

All files :

  • Changes copyright date and removes white space tabulation.

With last small changes (comments #71) the rendering is far better than with my previous patch. Now WebView is not so far from Safari and FireFox versus MathML display. The remaining problems are due to the missing OpenMathData table support.
A quick solution would be :

  • to include a font file containing the right glyph alignment.
  • and modify the mathml.css file to force MathML renderer to use them first.

Best regards.

Copy link
Contributor

@arajkumar arajkumar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall changes looks good to me, there are few concerns which need to be addressed.

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Leave a space after comma.

e.g.
new float[] { bb[0], -bb[3], bb[2], bb[3] - bb[1] };

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@@ -160,6 +160,12 @@ private FontStrike getFontStrike()
return getFontStrike().getFontResource().getAdvance(glyph, font.getSize());
}

@Override public float[] getGlyphBoundingBox(int glyph) {
float[] bb = new float[4];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How often this method will be called from native? Is it too frequent? Too much of call to this function will leave a plenty of garbages. If it is too much, probably consider having static member similar like WCBufferedContext class.

Copy link
Contributor Author

@scientificware scientificware Jun 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, this method seems often used, I think that WebCore displays the mathematics words glyph by glyph due the nature of these words (frequently 1 or 2 characters) and over all because some of theses glyphs don't respect ascent and descent. But I made no test.

My purpose was simply to repair MathML rendering with a minimum of changes, not improve performances or memory usage. I think you are far more qualified than me to appreciate that. So I'm rely on you.

Do you means that, that all variables not directly used by others method of the class or not directly called could be declare private and static.
float[] bb in getGlyphBoundingBox(int glyph), for example ?
In this case, it should be interresting to test all methods ?
May be you already did that ?

Or I can not declare this variable and code like that :

return  new float[]{
getFontStrike().getFontResource().getGlyphBoundingBox(glyph, font.getSize())[0],
-getFontStrike().getFontResource().getGlyphBoundingBox(glyph, font.getSize())[3], 
getFontStrike().getFontResource().getGlyphBoundingBox(glyph, font.getSize())[2], 
getFontStrike().getFontResource().getGlyphBoundingBox(glyph, font.getSize())[3]
- getFontStrike().getFontResource().getGlyphBoundingBox(glyph, font.getSize())[1]};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

return FloatRect(); //That is OK! platformWidthForGlyph impl is enough.
FloatRect Font::platformBoundsForGlyph(Glyph c) const
{
//return FloatRect(); //That is OK! platformWidthForGlyph impl is enough.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this


jfloatArray boundingBox = (jfloatArray)env->CallObjectMethod(*jFont, getGlyphBoundingBox_mID, (jint)c);

jfloat *bBox = env->GetFloatArrayElements(boundingBox,0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You must release FloatArrayElements after reading it's contents using the following JNI function,

env->ReleaseFloatArrayElements(boundingBox, bBox, 0);

Copy link
Contributor Author

@scientificware scientificware Jun 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this advice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove env->ReleaseFloatArrayElements(boundingBox, bBox, 0);
Bad effects, I loose all BoundingBox values.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add ReleaseFloatArrayElements after reading the array elements.

jfloat *bBox = env->GetFloatArrayElements(boundingBox,0);
auto bb = FloatRect { bBox[0], bBox[1], bBox[2], bBox[3] };
env->ReleaseFloatArrayElements(boundingBox, bBox, 0);
return bb;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.


RefPtr<RQRef> jFont = m_platformData.nativeFontData();
if (!jFont) {
return FloatRect();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use c++11 braced-init-list returns.

e.g.

if (!jFont) {
    return { }
}


import static test.util.Util.TIMEOUT;

public class MathMLRenderTest {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider writing a headless test under modules/javafx.web/src/test/java/test/javafx/scene/web/.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean, I have to remove these lines ?

            + "   <head>"
            + "      <meta charset=\"UTF-8\">"
            + "      <title>OpenJFX and MathML</title>"
            + "   </head>"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't understand your request ?
This test works with all others tests when I use this command :
gradle -PFULL_TEST=true :systemTests:test

Copy link
Contributor Author

@scientificware scientificware Jun 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm really sorry,
I misread the message, but the place you suggest was the first place where I had put the test.
And Kevin said that I had to go into tests/system ...
I'm a bit confuse about what I have to do ?

kevin_suggestion

Copy link
Contributor Author

@scientificware scientificware Jun 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HeadLess Test

Under modules/javafx.web/src/test/java/test/javafx/scene/web/

  • Round 1 : Ok it works with patched WebCore

screenshot_20180623_005000

  • Round 2 : Ok it fails with no patched WebCore
    screenshot_20180623_010300

Game Over ?

Copy link
Contributor Author

@scientificware scientificware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add and remove :
env->ReleaseFloatArrayElements(boundingBox, bBox, 0);
Can't Release bBox because I use it to return dimensions.

Could you tell me

  • if I understant what you mean with static member in getGlyphBoundingBox method.
  • and headless test.

Copy link
Contributor Author

@scientificware scientificware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removes Head in the document test.
Declares array private and static in WCFontImpl
Thanks for your help and all suggestions.

Copy link
Contributor

@arajkumar arajkumar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While committing the changes, add relevant commit messages instead of generic messages like "Update FontJava.cpp".

package test.javafx.scene.web;

import org.junit.Assert;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:
Don't leave empty line between imports

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@@ -0,0 +1,87 @@
/*
* Copyright (c) 2018, 2018, Oracle and/or its affiliates. All rights reserved.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep a single copy right year,

Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

);

boolean rightRender = !(height < 2);
Assert.assertTrue("Check MathML token height : " + height + " is much smaller than the expected size." , rightRender);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too cryptic, I guess the following snippet is pretty clear about the expectation.

assertTrue("MathML token height must be greater than " + height, height > 2);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.


package test.javafx.scene.web;

import org.junit.Assert;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do static import of necessary methods,

import static org.junit.Assert.assertTrue;

This is how we do it for other tests, keep a consistent style.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

public class MathMLRenderTest extends TestBase {

// Document test
static String BodyContent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these test markups(BodyContent, content) are specific to testTokenHeight, move it as a local variable inside testTokenHeight method.

Also change the variable names to meaningful one, e.g. BodyContent => quadraticFormula, content => htmlBody.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@@ -160,6 +162,11 @@ private FontStrike getFontStrike()
return getFontStrike().getFontResource().getAdvance(glyph, font.getSize());
}

@Override public float[] getGlyphBoundingBox(int glyph) {
bb = getFontStrike().getFontResource().getGlyphBoundingBox(glyph, font.getSize(), bb);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of now you can stick with your old approach, probably after profiling we can decide whether to go with static member approach. Sorry for the confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

@@ -160,6 +162,11 @@ private FontStrike getFontStrike()
return getFontStrike().getFontResource().getAdvance(glyph, font.getSize());
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still you need to give a space between operands and operators, bb[3] - bb[1]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

+ " </body>"
+ "</html>";

@Test public void testgetTokenHeight() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename testgetTokenHeight => testTokenHeight

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.


env->ReleaseFloatArrayElements(boundingBox, bBox, 0);
CheckAndClearException(env);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the empty line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

jfloatArray boundingBox = (jfloatArray)env->CallObjectMethod(*jFont, getGlyphBoundingBox_mID, (jint)c);
jfloat *bBox = env->GetFloatArrayElements(boundingBox,0);
auto bb = FloatRect { bBox[0], bBox[1], bBox[2], bBox[3] };

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

Copy link
Contributor Author

@scientificware scientificware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I Made all requested changes.
Thanks again for all suggestions.

Copy link
Contributor Author

@scientificware scientificware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I corrected a mistake made in previous commit.

Copy link
Contributor

@arajkumar arajkumar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have few more concerns. Sorry for missing these in the earlier reviews.

@@ -0,0 +1,85 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test file's extension is missing. Did you run this?

It should be MathMLRenderTest.java right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the name is MathMLRenderTest.java
I ran the test but with my working copy and pasted the code directly online in the GitHub editor.
I forgot to add the extension when I enter the name.
Sorry, I have to change my way of working.

loadContent(htmlBody);

int height = (int) executeScript(
"elements = document.getElementsByTagName('mo');"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you are testing the height of the first mo tag which seems to be =.

Why can't use a very basic mathml markup which might be enough to test the problematic scenario? Something like below?

<body>
<math id='math'>
      <mfrac>
        <mn>1</mn>
        <mn>2</mn>
      </mfrac>
</math>
</body>

then,

final int EXPECTED_MINIUM_HEIGHT = 25;
int height = executeScript ("document.getElementById('html').clientHeight");
assertTrue("MathML token height is " + height, height > EXPECTED_MINIUM_HEIGHT);

Copy link
Contributor Author

@scientificware scientificware Jun 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could change but I will regret that :-( :-)

  • I used a basic element because the problem occured for any the element, text token element include.
    So the patch simply solves a character height bug, but it's difficult to see it only with a text element. In a text element the only sign was the cursor height.
  • Thus we don't need a formula to test it. I used this opportunity as an exercise and to show how to do to test for any others token elements.
  • The quadratic formula is a reference to the first bug report in 2015 : JDK-8089878 .
  • But, it's also because, if you test with complexe formula the height could be over 25 : when formula contains a fraction, the box size is not equal to 0, you must take in account the fraction line tickness. So if you've got fraction in a fraction ... the size grows up.

As I esplained in #71 the OpenJFX and WebCore are clean. I never had doubt about this.
One who wrote the code thought logically that the rendering of a simple MathML text like "Hello" is made exactly with the same logic used for same text in a html paragraph. Why it should be different ?

In fact WebCore and most of all others mathematic editor use a rendering way I hate. In their logic they can't used ascents and descents because of stretchy assembled glyphs like ( [ { ... : for example to construct a big { you need to assemble 3 characters (like bricks for a wall).
If you use the glyph ascent or descent , you'll see gap between characters, because it is the common ascent or descent for all glyph and not the ascent or descent of the glyph you're using.

I understood where was the problem when I read his comment "//That is OK! platformWidthForGlyph impl is enough." He tought that getAscent() and getDescent() was enough.

I aware of this problem because I'm building my own math editor. I prefer draw these stretchy glyphs by myself. I'm sure that is provided a better experience to users. The Swing API allows this but to use it, I'had been send several bug reports and build a patch. I sent the patch in 2012 and it has been accepted in 2017 when Sergey Bylokhov accepted to sponsor me.

You said that present WebKit version is 2.18. But I saw that some code are older. What is your project for the next WebKit version. There are many changes in MathML support, they improved RTL support and other things. Because of this PR work I haven't time to look further inside.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it is a headless test, I prefer to have the test case as simple as possible. Basically the test case should able to catch the future regressions. Even though you render the quadratic formula, you end up checking only the height of '='. Then why can't just have a simple element with only '=' (or anything which you wish).

(This is my only concern right now, I request @kevinrushforth to take a look)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All that work just for "=" :-D
As I said the quadric formula is a reference to the bug report Kevin treated in 2015 :-)
Of course we can.
Your are right a headless test doesn't need more.
I let you decide.

quadratic_formula

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According your request the test could be :
But I'm not at home and I can't test it before Friday.

/*
 * Copyright (c) 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.
 */

package test.javafx.scene.web;

import static org.junit.Assert.assertTrue;
import org.junit.Test;

public class MathMLRenderTest extends TestBase {

    @Test public void testTokenHeight() throws Exception {

        // Document test
        String htmlBody = "<!doctype html>"
            + "<html>"
            + "   <body>"
            + "      <p>"
            +  "        <math display=\"block\">"
            + "            <mrow>"
            + "               <mo>=</mo>"
            + "            </mrow>"
            + "         </math>";
            + "      </p>"
            + "   </body>"
            + "</html>";
            
        loadContent(htmlBody);

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

        assertTrue("MathML token height must be greater than " + height, height > 1);      
    }
}

Copy link
Contributor Author

@scientificware scientificware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the missing extension.

Copy link
Contributor Author

@scientificware scientificware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd forgotten to commit this change.

@arajkumar
Copy link
Contributor

Looks like this pull request is messed up with irrelevant file changes. Probably it might be due to rebasing the devlop instead of merging it. Could you please get rid of the irrelevant changes?

@scientificware
Copy link
Contributor Author

JFXWCMathMLRenderingPatch201806241013' into WebCorePatch2018062102_work

I don't understand, I don't remember having made a such request.
I certainly made a mistake in trying to clean my local repository.

@scientificware
Copy link
Contributor Author

I cleaned my master and reverted WebCorePatch2018062102_work branch to its previous state just before my dirty commit.

Copy link
Contributor Author

@scientificware scientificware left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How often this method will be called from native? Is it too frequent? Too much of call to this function will leave a plenty of garbages. If it is too much, probably consider having static member similar like WCBufferedContext class.

This have been already done ?

@kevinrushforth
Copy link
Collaborator

@scientificware 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
git rebase -i upstream/develop    // this will put you into an editor where you can select which commits are squashed

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:

pick 78bf9df Bug JDK-8147476, commit of the following:
squash 47d9135 Update FontJava.cpp
squash 91023c1 Update FontJava.cpp
squash 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
Copy link
Collaborator

Also, you have trailing white-space in two files. This will need to be eliminated.

modules/javafx.web/src/main/java/com/sun/webkit/perf/WCFontPerfLogger.java
modules/javafx.web/src/test/java/test/javafx/scene/web/MathMLRenderTest.java

@nlisker
Copy link

nlisker commented Jun 28, 2018

This PR is targeting several JBS issues. This means that either they are duplicates (or should be merged) or that this PR should be split to address each issue separately. These are:

  • JDK-8147476
  • JDK-8165520
  • JDK-8089878
  • JDK-8090887

@scientificware
Copy link
Contributor Author

Fails to build with : Update to 606.1 version of WebKit

[ 77%] Generating ../../DerivedSources/WebCore/WebCoreJSBuiltins.cpp, ../../DerivedSources/WebCore/WebCoreJSBuiltinInternals.cpp, ../../DerivedSources/WebCore/WebCoreJSBuiltins.h, ../../DerivedSources/WebCore/WebCoreJSBuiltinInternals.h
Scanning dependencies of target WebCore
[ 77%] Building CXX object Source/WebCore/CMakeFiles/WebCore.dir/html/track/AudioTrack.cpp.o
[ 77%] Building CXX object Source/WebCore/CMakeFiles/WebCore.dir/html/track/AudioTrackList.cpp.o
In file included from /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/build/linux/Release/DerivedSources/ForwardingHeaders/JavaScriptCore/Weak.h:1:0,
                 from /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/src/main/native/Source/WebCore/bindings/js/ScriptWrappable.h:34,
                 from /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/src/main/native/Source/WebCore/dom/EventTarget.h:36,
                 from /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/src/main/native/Source/WebCore/html/track/TrackListBase.h:31,
                 from /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/src/main/native/Source/WebCore/html/track/AudioTrackList.h:30,
                 from /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/src/main/native/Source/WebCore/html/track/AudioTrackList.cpp:30:
/home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/src/main/native/Source/JavaScriptCore/heap/Weak.h:28:28: erreur fatale : JSExportMacros.h : Aucun fichier ou dossier de ce type
compilation terminée.
Source/WebCore/CMakeFiles/WebCore.dir/build.make:829 : la recette pour la cible « Source/WebCore/CMakeFiles/WebCore.dir/html/track/AudioTrackList.cpp.o » a échouée
gmake[2]: *** [Source/WebCore/CMakeFiles/WebCore.dir/html/track/AudioTrackList.cpp.o] Erreur 1
gmake[2]: *** Attente des tâches non terminées....
In file included from /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/build/linux/Release/DerivedSources/ForwardingHeaders/JavaScriptCore/Weak.h:1:0,
                 from /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/src/main/native/Source/WebCore/bindings/js/ScriptWrappable.h:34,
                 from /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/src/main/native/Source/WebCore/dom/EventTarget.h:36,
                 from /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/src/main/native/Source/WebCore/dom/Node.h:27,
                 from /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/src/main/native/Source/WebCore/dom/ContainerNode.h:27,
                 from /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/src/main/native/Source/WebCore/dom/Document.h:31,
                 from /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/src/main/native/Source/WebCore/dom/Element.h:28,
                 from /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/src/main/native/Source/WebCore/dom/StyledElement.h:30,
                 from /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/src/main/native/Source/WebCore/html/HTMLElement.h:29,
                 from /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/src/main/native/Source/WebCore/html/HTMLMediaElement.h:35,
                 from /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/src/main/native/Source/WebCore/html/track/AudioTrack.cpp:37:
/home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/src/main/native/Source/JavaScriptCore/heap/Weak.h:28:28: erreur fatale : JSExportMacros.h : Aucun fichier ou dossier de ce type
compilation terminée.
Source/WebCore/CMakeFiles/WebCore.dir/build.make:805 : la recette pour la cible « Source/WebCore/CMakeFiles/WebCore.dir/html/track/AudioTrack.cpp.o » a échouée
gmake[2]: *** [Source/WebCore/CMakeFiles/WebCore.dir/html/track/AudioTrack.cpp.o] Erreur 1
CMakeFiles/Makefile2:519 : la recette pour la cible « Source/WebCore/CMakeFiles/WebCore.dir/all » a échouée
gmake[1]: *** [Source/WebCore/CMakeFiles/WebCore.dir/all] Erreur 2
Makefile:105 : la recette pour la cible « all » a échouée
gmake: *** [all] Erreur 2

> Task :web:compileNativeLinux FAILED

FAILURE: Build failed with an exception.

* Where:
Build file '/home/scientificware2016/Documents/openjdk-jfx-compile/build.gradle' line: 3732

* What went wrong:
Execution failed for task ':web:compileNativeLinux'.
> Process 'command 'perl'' finished with non-zero exit value 2

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 18m 12s

@scientificware
Copy link
Contributor Author

in built.make :
JavaScriptCoreForwardingHeaders: DerivedSources/ForwardingHeaders/JavaScriptCore/JSExportMacros.h
...

DerivedSources/ForwardingHeaders/JavaScriptCore/JSExportMacros.h: /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/src/main/native/Source/JavaScriptCore/runtime/JSExportMacros.h
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --blue --bold --progress-dir=/home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/build/linux/Release/CMakeFiles --progress-num=$(CMAKE_PROGRESS_398) "Generating ../../DerivedSources/ForwardingHeaders/JavaScriptCore/JSExportMacros.h"
	cd /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/build/linux/Release/Source/JavaScriptCore && /usr/bin/cmake -E copy /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/src/main/native/Source/JavaScriptCore/runtime/JSExportMacros.h /home/scientificware2016/Documents/openjdk-jfx-compile/modules/javafx.web/build/linux/Release/DerivedSources/ForwardingHeaders/JavaScriptCore/JSExportMacros.h

...
JavaScriptCoreForwardingHeaders: DerivedSources/ForwardingHeaders/JavaScriptCore/JSExportMacros.h

@kevinrushforth
Copy link
Collaborator

This PR is targeting several JBS issues. This means that either they are duplicates (or should be merged) or that this PR should be split to address each issue separately.

Yes, good catch. I recommend using one of the bug IDs -- probably JDK-8147476 since that is the issue currently linked to this bug -- and closing the other two open issues, JDK-8090887 and JDK-8089878 as duplicates after ensuring that JDK-8089878 is fixed by this patch. (I note that JDK-8165520 is closed already).

@kevinrushforth kevinrushforth added the bug Something isn't working label Jun 30, 2018
@scientificware
Copy link
Contributor Author

scientificware commented Jun 30, 2018

I knew JDK-8165520 report is closed but I added it in my list because it says that some tests are skipped until JDK-8165429 and JDK-8165527.

In fact, JDK-8165520 mentions JDK-8165429, JDK-8165556 and JDK-8165527, I can't find these reports. Some of them have restricted access.

8 out of 9 test needs platform specific /platform/java/mathml/<below 8 test >-expected.txt. These will be skipped along with JDK-8165429 untill JDK-8165527 (Enhancement).
mathml/mathml-in-dashboard.html
mathml/opentype/horizontal-munderover.html
mathml/opentype/horizontal.html
mathml/opentype/large-operators.html
mathml/opentype/opentype-stretchy-horizontal.html
mathml/opentype/opentype-stretchy.html
mathml/opentype/vertical.html
mathml/presentation/foreign-element-in-token.html
mathml/presentation/stretchy-depth-height.html -> JDK-8165556

We should see, if some of them can be reactivated.

@scientificware
Copy link
Contributor Author

scientificware commented Jul 2, 2018

The MathML patch is compatible with WebKit 606.1.

I succeeded to build master and the branch with the patch (in fact a problem with ant)

  • The result with HTMLEditor.
    screenshot_20180702_123352

  • The result online with the Mozilla MathML Torture Test.

    • On the left, "As rendered by TeX", means that in this column, with can see pictures of TeX mathematic formulas rendering (the reference rendering engine of Donald Knuth).
    • On the right, "As rendered by your browser" means that in this column we can see a rendering by WebView of a MathML code that try to reache the same quality (they're not pictures !).
    • Some difference are due to the display style choosen in the MathML code. For example 2/3 uses two different display mode : "block" or "inline".
    • We can change the font choice to illustrates why "to include a font file containing the well aligned glyphs". Not all glyph but just a font with a few of glyphs.
      screenshot_20180702_130044
  • The result of the test.
    screenshot_20180702_124137

@scientificware
Copy link
Contributor Author

@kevinrushforth Do you think this patch could be backported to previous java releases ? Becauseof this bug I don't think someone has been using this functionnality but having it without code changing could be benefit and appreciated.

@kevinrushforth
Copy link
Collaborator

We have a general policy of backporting all change that touch native WebKit, so yes, this would be backported to FX 8u-dev after it is pushed to jfx-dev (for OpenJFX 11).

@scientificware
Copy link
Contributor Author

Great ! Thanks ...

@kevinrushforth
Copy link
Collaborator

I note that the branch referenced in this PR has not been rebased (or merged) with the latest WebKit changes from the WebKit 606.1 update. Can you please update the PR so the review can continue?

@scientificware
Copy link
Contributor Author

scientificware commented Jul 3, 2018

Yes, but I did it in another branch (WebCorePatch2018063010_work) waiting your instructions. I wrote a comment 3 days ago, to inform you I had get a problem with the build. But after ant install, it works.

@scientificware
Copy link
Contributor Author

Done.

@kevinrushforth kevinrushforth self-requested a review July 4, 2018 13:40
@kevinrushforth
Copy link
Collaborator

Thanks. The review can proceed now (likely next week). For bug tracking purposes I will close JDK-8090887 as a duplicate of JDK-8147476. As discussed with @ararunprasad yesterday, we will treat this as a bug fix, so it can go in after RDP1 of openjfx 11.

Arun can comment on the DRT issue.

As for the HTML issue, JDK-8089878, if that is still a bug, it can be left open, otherwise it can be closed as a duplicate.

@Test public void testTokenHeight() throws Exception {

// Document test
String mathmlContent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, we discussed to reduce the test mathml content. Is there any specific reason for going back to the bigger one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not going back to the bigger one.
I posted here the shorter version you asked.
As I was not at home I couldn't test it.
But it was deleted, so I thought the discussion was closed.

loadContent(htmlBody);

int height = (int) executeScript(
"elements = document.getElementsByTagName('mo');"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be simplified like executeScript("document.getElementsByTagName('mo')[0]. clientHeight");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

+ "element = elements[0].clientHeight;"
);

assertTrue("MathML token height must be greater than " + height, height > 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertTrue("MathML token height is lesser than expected " + height, height > 1);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

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 height informations from the glyph bounding box.

MathMLRenderTest.java :
 - Adds a HeadLess proper unit test for this Bug JDK-8147476.
 - Tests the height of the first MathML mo token element in a quadratic formula.

WCFont.java :
 - Adds the abstract getGlyphBoundingBox() method.

WCFontPerfLogger.java :
 - Adds the getGlyphBoundingBox() method.

WCFontImpl.java :
 - Implements the getGlyphBoundingBox() method.
 - Uses and reorders (FontResource) getGlyphBoundingBox values to match perfectly with WebCore requirements.

All files :
 - Changes copyright date and removes white space tabulation.
@scientificware
Copy link
Contributor Author

Done, I rewrote the test as you requested and posted two runs :

  • fails without the patch,
    screenshot_20180704_225234
  • succeeds with the patch.
    screenshot_20180704_225327

@arajkumar
Copy link
Contributor

lgtm

Copy link
Collaborator

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now.

@ararunprasad you can squash/merge this when you get a chance, and then integrate it to jfx-dev and 8u-dev.

@arajkumar
Copy link
Contributor

Thanks @kevinrushforth. I will do it ASAP.

@arajkumar arajkumar merged commit ad87b47 into javafxports:develop Jul 17, 2018
@arajkumar
Copy link
Contributor

arajkumar commented Jul 18, 2018

@scientificware I would like to know your email address in order to add your name to "Contributed-by" filed while committing your contribution to jfx-dev and 8u-dev.

Is it same as your jfx-dev mailing list email(guy.abossolo.foh@scientificware.com) ?

@scientificware
Copy link
Contributor Author

@ararunprasad
Yes it is the same :
guy.abossolo.foh@scientificware.com

Thanks.

@arajkumar
Copy link
Contributor

This fix is now available in both jfx-dev and 8u-dev.

@scientificware, Thanks for your efforts.

@scientificware
Copy link
Contributor Author

Thanks Kevin and Arunprasad for the your help, time, suggestions, reviews, and advices.

@scientificware scientificware deleted the WebCorePatch2018062102_work branch August 6, 2018 10:26
@kevinrushforth kevinrushforth mentioned this pull request Aug 6, 2018
@scientificware
Copy link
Contributor Author

@kevinrushforth JDK-8089878 is still in Open Status.

@kevinrushforth
Copy link
Collaborator

@kevinrushforth JDK-8089878 is still in Open Status.

Yes, it is still Open. JDK-8089878 should probably be linked with issue #118. Are you still having issues with HTMLEditor rendering MathML?

@scientificware
Copy link
Contributor Author

scientificware commented Aug 9, 2018

@kevinrushforth Yes I still having issue with HTMLEditor rendering MathML but (to be precise) none related with the problem described in the JDK-8089878, I'm afraid that linking it with #118 may produce confusions :
The following example, given in JDK-8089878, is presently well displayed by HTMLEditor/Webview with JDK 8.192.b4 and OpenJFX 11.

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

screenshot_20180809_120329

  • The only remaining problems, I know, are :
    • Horizontal delimiters. As you can see on the picture below, brackets should be bigger (left, Tex and right, HTMLEditor/WebView) but I don't think it's related to JDK-8089878. To confirm, I had to test MacOS/Safari with the mozilla torture test. The same display result would mean that the problem is in WebCore.
    • and few problems tracked and described in issue#118. I also think they are not related to JDK-8089878.
  • But due to limited time ressource, I prefered start to work only on mathematic editing. Issue JDK-8210970 : MathML editing issues in HTMLEditor #118 is firstly an enhancement request : One can insert math formula in HTMLEditor using JavaScript and MathML. But it's very tricky to directly use MathML. Common users can't deal with kind of above codes. I'm trying to build something like AsciiMath (http://asciimath.org). AsciiMath is just a JavaScript application that uses MathJax to render MathML code. In fact, I'm trying to write a similar script to do the same job but with HTMLEditor (and of course in all WebCore based components, with MathML enabled, too).
    screenshot_20180619_191413.

@kevinrushforth
Copy link
Collaborator

kevinrushforth commented Aug 9, 2018

In that case I suggest filing a new bug in JBS to describe the bug you wish to fix with as much detail as possible. You can also create a new issue in GitHub if you like. Then once you have a solution, you can create a PR.

@scientificware
Copy link
Contributor Author

scientificware commented Aug 24, 2018

Test with IOS 11.4
Confirm that horizontal bracket problem size is not related to this PR. The result is exactly the same with IOS 11.4 and JavaFX11 EA. On the following picture, TeX Rendering on the left, IOS/Safari on the right the same table for JavaFX is in the previous comment with the same order TeX on the left and JavaFX on the right.

28b26723-a150-46da-8ad8-7b754ffc4923 1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants