Skip to content

Commit

Permalink
Merge pull request #4953 from kwvanderlinde/bugfix/missing-html5-even…
Browse files Browse the repository at this point in the history
…ts-develop

Port missing 1.14 commits to develop
  • Loading branch information
cwisniew authored Sep 27, 2024
2 parents b65c884 + 4564cb4 commit 4c7ecc8
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 13 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ jobs:
# | |/ |/ // // / / // /_/ // /_/ /| |/ |/ /(__ )
# |__/|__//_//_/ /_/ \__,_/ \____/ |__/|__//____/
#
- name: Copy Windows Release Files
- name: Rename Windows Release Files
if: matrix.os == 'windows-latest'
run: |
cp releases/MapTool*.exe releases/MapTool-${{ github.event.release.tag_name }}.exe
cp releases/MapTool*.msi releases/MapTool-${{ github.event.release.tag_name }}.msi
mv releases/MapTool*.exe releases/MapTool-${{ github.event.release.tag_name }}.exe
mv releases/MapTool*.msi releases/MapTool-${{ github.event.release.tag_name }}.msi
continue-on-error: true
- name: Upload Windows EXE Release Asset
id: upload-release-asset-exe
Expand Down Expand Up @@ -113,12 +113,12 @@ jobs:
# / /___ / // / / // /_/ /_> <
# /_____//_//_/ /_/ \__,_//_/|_|
#
- name: Copy Linux Release Files
- name: Rename Linux Release Files
if: matrix.os == 'ubuntu-latest'
run: |
cp releases/maptool*.x86_64.rpm releases/maptool-${{ github.event.release.tag_name }}.x86_64.rpm
cp releases/maptool*_amd64.deb releases/maptool_${{ github.event.release.tag_name }}_amd64.deb
cp package/archlinux/maptool/maptool-*-x86_64.pkg.tar.zst releases/maptool-${{ github.event.release.tag_name }}-x86_64.pkg.tar.zst
mv -n releases/maptool*.x86_64.rpm releases/maptool-${{ github.event.release.tag_name }}.x86_64.rpm
mv -n releases/maptool*_amd64.deb releases/maptool_${{ github.event.release.tag_name }}_amd64.deb
mv -n package/archlinux/maptool/maptool-*-x86_64.pkg.tar.zst releases/maptool-${{ github.event.release.tag_name }}-x86_64.pkg.tar.zst
continue-on-error: true
- name: Upload Linux RPM Release Asset
id: upload-release-asset-rpm
Expand Down Expand Up @@ -159,11 +159,11 @@ jobs:
# / / / / / // /_/ // /__ / /_/ /___/ /
# /_/ /_/ /_/ \__,_/ \___/ \____//____/
#
- name: Copy Mac OS Release Files
- name: Rename Mac OS Release Files
if: matrix.os == 'macOS-13'
run: |
cp releases/MapTool*.dmg releases/MapTool-${{ github.event.release.tag_name }}.dmg
cp releases/MapTool*.pkg releases/MapTool-${{ github.event.release.tag_name }}.pkg
mv releases/MapTool*.dmg releases/MapTool-${{ github.event.release.tag_name }}.dmg
mv releases/MapTool*.pkg releases/MapTool-${{ github.event.release.tag_name }}.pkg
continue-on-error: true
- name: Upload Mac DMG Release Asset
id: upload-release-asset-dmg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.w3c.dom.*;
import org.w3c.dom.events.EventListener;
import org.w3c.dom.events.EventTarget;
import org.w3c.dom.html.*;

Expand Down Expand Up @@ -91,6 +92,10 @@ public class HTMLWebViewManager {
/** The bridge from Javascript to Java. */
private final JavaBridge bridge;

private EventListener listenerA = this::fixHref;

private EventListener listenerSubmit = this::getDataAndSubmit;

/** Represents a bridge from Javascript to Java. */
public class JavaBridge {

Expand Down Expand Up @@ -159,13 +164,50 @@ public void handleAddedNode(Object object) {
if (addedNode instanceof EventTarget) {
EventTarget target = (EventTarget) addedNode;
if (addedNode instanceof HTMLAnchorElement || addedNode instanceof HTMLAreaElement) {
target.addEventListener("click", HTMLWebViewManager.this::fixHref, true);
target.addEventListener("click", listenerA, true);
} else if (target instanceof HTMLFormElement) {
target.addEventListener("submit", HTMLWebViewManager.this::getDataAndSubmit, true);
target.addEventListener("submit", listenerSubmit, true);
} else if (target instanceof HTMLInputElement || target instanceof HTMLButtonElement) {
target.addEventListener("click", HTMLWebViewManager.this::getDataAndSubmit, true);
target.addEventListener("click", listenerSubmit, true);
}
}

// Add listeners to the node's descendant as they don't trigger mutation observer.
NodeList nodeList;

// Add event handlers for <a> hyperlinks.
nodeList = addedNode.getElementsByTagName("a");
for (int i = 0; i < nodeList.getLength(); i++) {
EventTarget node = (EventTarget) nodeList.item(i);
node.addEventListener("click", listenerA, true);
}

// Add event handlers for hyperlinks for maps.
nodeList = addedNode.getElementsByTagName("area");
for (int i = 0; i < nodeList.getLength(); i++) {
EventTarget node = (EventTarget) nodeList.item(i);
node.addEventListener("click", listenerA, true);
}

// Set the "submit" handler to get the data on submission not based on buttons
nodeList = addedNode.getElementsByTagName("form");
for (int i = 0; i < nodeList.getLength(); i++) {
EventTarget target = (EventTarget) nodeList.item(i);
target.addEventListener("submit", listenerSubmit, true);
}

// Set the "submit" handler to get the data on submission based on input
nodeList = addedNode.getElementsByTagName("input");
for (int i = 0; i < nodeList.getLength(); i++) {
EventTarget target = (EventTarget) nodeList.item(i);
target.addEventListener("click", listenerSubmit, true);
}
// Set the "submit" handler to get the data on submission based on button
nodeList = addedNode.getElementsByTagName("button");
for (int i = 0; i < nodeList.getLength(); i++) {
EventTarget target = (EventTarget) nodeList.item(i);
target.addEventListener("click", listenerSubmit, true);
}
}
}
}
Expand Down Expand Up @@ -269,6 +311,10 @@ public void flush() {
// Delete cookies
java.net.CookieHandler.setDefault(new java.net.CookieManager());

// This may look pointless, but we need new objects on JFX <22 to avoid peering issues.
listenerA = this::fixHref;
listenerSubmit = this::getDataAndSubmit;

isFlushed = true;
}

Expand Down

0 comments on commit 4c7ecc8

Please sign in to comment.