Skip to content

Commit

Permalink
feat: JCEF w/ CEF 122.1.10+gc902316+chromium-122.0.6261.112
Browse files Browse the repository at this point in the history
- Fixed merge issues
- Fixed macOS building
- Removal of tests (not required for our use-case)
- Fix JCEF CMAKE download
  • Loading branch information
1zun4 committed Mar 12, 2024
1 parent 5b2d278 commit 2d43af0
Show file tree
Hide file tree
Showing 49 changed files with 56 additions and 4,629 deletions.
36 changes: 34 additions & 2 deletions .github/workflows/build-jcef.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
matrix:
platform: [amd64, arm64]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install deps and build
run: |
sudo apt update
Expand Down Expand Up @@ -40,7 +40,7 @@ jobs:
matrix:
platform: [amd64, arm64]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: ilammy/msvc-dev-cmd@v1
- name: Build
run: |
Expand All @@ -61,3 +61,35 @@ jobs:
jcef_build/windows_${{ matrix.platform }}.tar.gz
jcef_build/windows_${{ matrix.platform }}.tar.gz.sha256
if-no-files-found: error

java-cef-macos:
runs-on: [macos-12]
strategy:
matrix:
platform: [amd64, arm64]
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.9'
- run: |
brew install ninja
brew install python
brew install coreutils
sudo xcode-select --switch /Applications/Xcode_13.1.app
mkdir jcef_build && cd jcef_build
cmake -G "Ninja" -DPROJECT_ARCH=${{ matrix.platform }} -DCMAKE_BUILD_TYPE=Release ..
ninja -j4
mv native/Release macos_${{ matrix.platform }}
tar -czf macos_${{ matrix.platform }}.tar.gz macos_${{ matrix.platform }}
sha256sum macos_${{ matrix.platform }}.tar.gz > macos_${{ matrix.platform }}.tar.gz.sha256
- uses: actions/upload-artifact@v3
if: ${{ github.ref == 'refs/heads/master' }}
with:
name: 'macos_${{ matrix.platform }}'
path: |
jcef_build/macos_${{ matrix.platform }}.tar.gz
jcef_build/macos_${{ matrix.platform }}.tar.gz.sha256
if-no-files-found: error
7 changes: 0 additions & 7 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
<compilerarg value="-XDignore.symbol.file"/>
<classpath location="${jdk7.path}/jre/lib/rt.jar" />
<classpath refid="class.path"/>
<src path="java/tests/"/>
<src path="java/org/cef/"/>
</javac>
<copy todir="${out.path}">
Expand All @@ -47,11 +46,6 @@
<include name="org/cef/**"/>
</fileset>
</jar>
<jar destfile="${out.path}/jcef-tests.jar" index="true" update="false">
<fileset dir="${out.path}">
<include name="tests/**"/>
</fileset>
</jar>
</target>

<target name="bundle" depends="jar">
Expand All @@ -64,7 +58,6 @@
icon="third_party/cef/res/CefIcon.icns">
<classpath dir="${out.path}">
<include name="jcef.jar"/>
<include name="jcef-tests.jar"/>
</classpath>
<classpath dir="third_party/jogamp/jar/">
<include name="gluegen-rt.jar"/>
Expand Down
12 changes: 6 additions & 6 deletions cmake/DownloadCEF.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Visit https://cef-builds.spotifycdn.com/index.html for the list of
# supported platforms and versions.

function(DownloadCEF platform branch version download_dir)
function(DownloadCEF platform version download_dir)
# Specify the binary distribution type and download directory.
set(CEF_DISTRIBUTION "cef_binary_${version}_${platform}")
set(CEF_DOWNLOAD_DIR "${download_dir}")
Expand All @@ -21,19 +21,19 @@ function(DownloadCEF platform branch version download_dir)
set(CEF_DOWNLOAD_FILENAME "${CEF_DISTRIBUTION}.tar.bz2")
set(CEF_DOWNLOAD_PATH "${CEF_DOWNLOAD_DIR}/${CEF_DOWNLOAD_FILENAME}")
if(NOT EXISTS "${CEF_DOWNLOAD_PATH}")
set(CEF_DOWNLOAD_URL "https://mcef-download.cinemamod.com/cef-builds/${branch}/${CEF_DOWNLOAD_FILENAME}")
set(CEF_DOWNLOAD_URL "https://cef-builds.spotifycdn.com/${CEF_DOWNLOAD_FILENAME}")
string(REPLACE "+" "%2B" CEF_DOWNLOAD_URL_ESCAPED ${CEF_DOWNLOAD_URL})

# Download the SHA1 hash for the binary distribution.
# message(STATUS "Downloading ${CEF_DOWNLOAD_PATH}.sha1 from ${CEF_DOWNLOAD_URL_ESCAPED}...")
# file(DOWNLOAD "${CEF_DOWNLOAD_URL_ESCAPED}.sha1" "${CEF_DOWNLOAD_PATH}.sha1")
# file(READ "${CEF_DOWNLOAD_PATH}.sha1" CEF_SHA1)
message(STATUS "Downloading ${CEF_DOWNLOAD_PATH}.sha1 from ${CEF_DOWNLOAD_URL_ESCAPED}...")
file(DOWNLOAD "${CEF_DOWNLOAD_URL_ESCAPED}.sha1" "${CEF_DOWNLOAD_PATH}.sha1")
file(READ "${CEF_DOWNLOAD_PATH}.sha1" CEF_SHA1)

# Download the binary distribution and verify the hash.
message(STATUS "Downloading ${CEF_DOWNLOAD_PATH}...")
file(
DOWNLOAD "${CEF_DOWNLOAD_URL_ESCAPED}" "${CEF_DOWNLOAD_PATH}"
# EXPECTED_HASH SHA1=${CEF_SHA1}
EXPECTED_HASH SHA1=${CEF_SHA1}
SHOW_PROGRESS
)
endif()
Expand Down
32 changes: 4 additions & 28 deletions java/org/cef/CefClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,22 @@

package org.cef;

import org.cef.browser.CefBrowser;
import org.cef.browser.CefBrowserFactory;
import org.cef.browser.CefFrame;
import org.cef.browser.CefMessageRouter;
import org.cef.browser.CefRequestContext;
import org.cef.callback.CefAuthCallback;
import org.cef.callback.CefBeforeDownloadCallback;
import org.cef.callback.CefCallback;
import org.cef.callback.CefContextMenuParams;
import org.cef.callback.CefDownloadItem;
import org.cef.callback.CefDownloadItemCallback;
import org.cef.callback.CefDragData;
import org.cef.callback.CefFileDialogCallback;
import org.cef.callback.CefJSDialogCallback;
import org.cef.callback.CefMenuModel;
import org.cef.callback.CefPrintDialogCallback;
import org.cef.callback.CefPrintJobCallback;
import org.cef.browser.*;
import org.cef.callback.*;
import org.cef.handler.*;
import org.cef.misc.BoolRef;
import org.cef.misc.CefAudioParameters;
import org.cef.misc.CefPrintSettings;
import org.cef.misc.StringRef;
import org.cef.network.CefRequest;
import org.cef.network.CefRequest.TransitionType;
import org.cef.network.CefResponse;
import org.cef.network.CefURLRequest;

import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;

import java.awt.*;
import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.HashMap;
import java.util.Vector;
import java.util.function.Consumer;

import javax.swing.SwingUtilities;

/**
* Client that owns a browser and renderer.
*/
Expand Down
4 changes: 1 addition & 3 deletions java/org/cef/browser/CefBrowserFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
public class CefBrowserFactory {
public static CefBrowser create(CefClient client, String url, boolean isOffscreenRendered,
boolean isTransparent, CefRequestContext context, CefBrowserSettings settings) {
if (isOffscreenRendered)
return new CefBrowserOsr(client, url, isTransparent, context, settings);
return new CefBrowserWr(client, url, context, settings);
return new CefBrowserOsr(client, url, isTransparent, context, settings);
}
}
12 changes: 4 additions & 8 deletions java/org/cef/browser/CefBrowserOsr.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

package org.cef.browser;

import org.cef.CefBrowserSettings;
import org.cef.CefClient;
import org.cef.callback.CefDragData;
import org.cef.handler.CefRenderHandler;
Expand All @@ -18,9 +19,6 @@
import java.nio.ByteBuffer;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;

/**
Expand All @@ -40,8 +38,8 @@ public class CefBrowserOsr extends CefBrowser_N implements CefRenderHandler {
private CopyOnWriteArrayList<Consumer<CefPaintEvent>> onPaintListeners =
new CopyOnWriteArrayList<>();

CefBrowserOsr(CefClient client, String url, boolean transparent, CefRequestContext context,
CefBrowserSettings settings) {
protected CefBrowserOsr(CefClient client, String url, boolean transparent, CefRequestContext context,
CefBrowserSettings settings) {
this(client, url, transparent, context, null, null, settings);
}

Expand All @@ -50,8 +48,6 @@ private CefBrowserOsr(CefClient client, String url, boolean transparent,
CefBrowserSettings settings) {
super(client, url, context, parent, inspectAt, settings);
isTransparent_ = transparent;
renderer_ = new CefRenderer(transparent);
createGLCanvas();
}

@Override
Expand Down Expand Up @@ -160,7 +156,7 @@ private void createBrowserIfRequired(boolean hasParent) {
getInspectAt());
} else {
createBrowser(getClient(), windowHandle, getUrl(), true, isTransparent_,
getRequestContext());
null, getRequestContext());
}
} else if (hasParent && justCreated_) {
notifyAfterParentChanged();
Expand Down
45 changes: 7 additions & 38 deletions java/org/cef/browser/CefBrowser_N.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@
import org.cef.CefBrowserSettings;
import org.cef.CefClient;
import org.cef.browser.CefDevToolsClient.DevToolsException;
import org.cef.browser.CefRequestContext;
import org.cef.callback.CefDragData;
import org.cef.callback.CefNativeAdapter;
import org.cef.callback.CefPdfPrintCallback;
import org.cef.callback.CefRunFileDialogCallback;
import org.cef.callback.CefStringVisitor;
import org.cef.callback.*;
import org.cef.event.CefKeyEvent;
import org.cef.event.CefMouseEvent;
import org.cef.event.CefMouseWheelEvent;
Expand All @@ -22,16 +17,10 @@
import org.cef.handler.CefWindowHandler;
import org.cef.misc.CefPdfPrintSettings;
import org.cef.network.CefRequest;
import java.util.concurrent.CompletableFuture;

import java.awt.Component;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Window;
import java.awt.event.WindowEvent;
import java.awt.*;
import java.util.Vector;

import javax.swing.SwingUtilities;
import java.util.concurrent.CompletableFuture;

/**
* This class represents all methods which are connected to the
Expand Down Expand Up @@ -209,7 +198,7 @@ protected final void createDevTools(CefBrowser_N parent, CefClientHandler client
if (getNativeRef("CefBrowser") == 0 && !isPending_) {
try {
isPending_ = N_CreateDevTools(
parent, clientHandler, windowHandle, osr, transparent, inspectAt);
parent, clientHandler, windowHandle, osr, transparent, null, inspectAt);
} catch (UnsatisfiedLinkError err) {
err.printStackTrace();
}
Expand Down Expand Up @@ -339,26 +328,6 @@ public CefFrame getFocusedFrame() {
}
}

@Override
public CefFrame getFrame(long identifier) {
try {
return N_GetFrame(identifier);
} catch (UnsatisfiedLinkError ule) {
ule.printStackTrace();
return null;
}
}

@Override
public CefFrame getFrame(String name) {
try {
return N_GetFrame2(name);
} catch (UnsatisfiedLinkError ule) {
ule.printStackTrace();
return null;
}
}

@Override
public CefFrame getFrameByIdentifier(String identifier) {
try {
Expand Down Expand Up @@ -871,9 +840,9 @@ private final native void N_Find(
private final native void N_ReplaceMisspelling(String word);
private final native void N_WasResized(int width, int height);
private final native void N_Invalidate();
private final native void N_SendKeyEvent(KeyEvent e);
private final native void N_SendMouseEvent(MouseEvent e);
private final native void N_SendMouseWheelEvent(MouseWheelEvent e);
private final native void N_SendKeyEvent(CefKeyEvent e);
private final native void N_SendMouseEvent(CefMouseEvent e);
private final native void N_SendMouseWheelEvent(CefMouseWheelEvent e);
private final native void N_DragTargetDragEnter(
CefDragData dragData, Point pos, int modifiers, int allowed_ops);
private final native void N_DragTargetDragOver(Point pos, int modifiers, int allowed_ops);
Expand Down
Loading

0 comments on commit 2d43af0

Please sign in to comment.