Questions ad JavaScript in JavaFX' WebEngine

Rony G. Flatscher Rony.Flatscher at wu.ac.at
Wed May 20 14:13:52 UTC 2020


Hi Mike,

thank you for your pointers!

On 14.05.2020 14:21, Mike Hearn wrote:
> The WebKit binding code is some of the more complex code in JavaFX. Rather than try to extend the
> script tag you could instead look at the code for the <object> tag and the old support for
> Netscape-style plugins. 
>
> https://github.com/openjdk/jfx/tree/master/modules/javafx.web/src/main/native/Source/WebCore/plugins
>
> I've looked at this in the past to investigate embedding of arbitrary JavaFX nodes into a web
> page. It doesn't look particularly unfeasible as there's still a lot of old code lying around that
> used to do exactly that, it's just not used much anymore. However wiring it up to the Java level
> would require a fairly adventurous programmer with good knowledge of C++, rendering engines and
> JavaFX internals.

In the meantime I had some time to peek around that location which is quite interesting!

What I would be interested in is a possibility to get callbacks into Java while the DOM tree gets
built, such that one could run scripts and define script callbacks for plain HTML text.

The idea would be to think about possibilities to enable all of the Java script languages to become
usable as script languages for HTML, i.e. for WebView applications.

As it stands now it should be possible with the help of WebEngine to process the DOM tree after
loading concluded and process and set up event attribute scripts, if necessary. (Again, this is a
very coarse idea at the moment.)

---rony


>
> On Mon, May 11, 2020 at 14:17:07, Rony G. Flatscher <Rony.Flatscher at wu.ac.at
> <mailto:Rony.Flatscher at wu.ac.at>> wrote:
>
>     On 09.05.2020 17:23, Kevin Rushforth wrote:
>
>         WebEngine uses WebKit's JavaScriptCore as its JavaScript engine. The sources are in the
>         jfx repo, along with the JavaFX-specific classes that implement the two-way Java <-->
>         JavaScript bridge. Other than the public API docs for WebEngine, which you referred to in
>         your message, there isn't any documentation of the interface.
>
>     OK, thank you very much, this is reassuring! :)
>
>         What sort of information are you looking for?
>
>     Well, as event handlers and script tags in HTML have a type attribute that allows to denote
>     script languages other than JavaScript, I am interested in evaluating what WebEngine/WebView
>     allows for to support this with any of the Java script engines.
>
>     ---rony
>
>         On 5/8/2020 7:01 AM, Rony G. Flatscher wrote:
>
>             Wondering which JavaScript engine gets referred to in WebEngine [1].
>
>             In case it is currently (JavaFX 14) Nashorn [2], what happens after Nashorn gets
>             removed from the next [3] version? In case it is WebKit's JavaScriptCore [4] where can
>             one study the interface from WebEngine to it?
>
>             ---rony
>
>             [1] WebEngine:
>             <https://openjfx.io/javadoc/14/javafx.web/javafx/scene/web/class-use/WebEngine.html
>             <https://openjfx.io/javadoc/14/javafx.web/javafx/scene/web/class-use/WebEngine.html>>
>             [2] Nashorn: <https://openjdk.java.net/projects/nashorn/
>             <https://openjdk.java.net/projects/nashorn/>>
>             [3] Nashorn removal from JDK 15: <https://openjdk.java.net/jeps/372
>             <https://openjdk.java.net/jeps/372>>
>             [4] JavaScriptCore: <https://trac.webkit.org/wiki/JavaScriptCore
>             <https://trac.webkit.org/wiki/JavaScriptCore>>
>
>


More information about the openjfx-dev mailing list