Skip to content

Commit b488d89

Browse files
committed
Merge remote-tracking branch 'upstream-bitbucket/master'
2 parents bc06f6e + 4bb479a commit b488d89

113 files changed

Lines changed: 2026 additions & 1975 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

AUTHORS.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# This file is an addendum to the Chromium Embedded Framework AUTHORS file.
2-
# Names should be added to this file like so:
3-
# Name or Organization <email address>
1+
# This file is an addendum to the Chromium Embedded Framework AUTHORS file. It
2+
# lists authors through March 18, 2015 when Git was introduced for source code
3+
# management. A list of additional authors added after that date can be found
4+
# by executing this command on a local Git checkout:
5+
# git log --all --format="%aN <%aE>" | sort -u
46

57
Marshall Greenblatt <magreenblatt@gmail.com>
68
Kai Klimke, censhare AG <kkl@censhare.com>

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ set_property(GLOBAL PROPERTY OS_FOLDERS ON)
121121

122122
# Specify the CEF distribution version.
123123
if(NOT DEFINED CEF_VERSION)
124-
set(CEF_VERSION "78.2.7+g9cd8bac+chromium-78.0.3904.70")
124+
set(CEF_VERSION "83.4.0+gfd6631b+chromium-83.0.4103.106")
125125
endif()
126126

127127
# Determine the platform.
@@ -177,6 +177,8 @@ if(NOT PYTHON_EXECUTABLE)
177177
endif()
178178
endif()
179179

180+
message(STATUS "Using Python: ${PYTHON_EXECUTABLE}")
181+
180182

181183
#
182184
# Java configuration.

build.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
<target name="compile">
2626
<mkdir dir="${out.path}"/>
2727
<javac encoding="UTF8" nowarn="on" deprecation="off" debug="on" includeantruntime="false" destdir="${out.path}"
28-
executable="/usr/bin/javac" fork="true" memoryinitialsize="32m" memorymaximumsize="128m" includeJavaRuntime="yes">
28+
executable="/usr/bin/javac" fork="true" memoryinitialsize="32m" memorymaximumsize="128m" includeJavaRuntime="yes"
29+
target="1.8" source="1.8">
2930
<compilerarg value="-XDignore.symbol.file"/>
3031
<classpath location="${jdk7.path}/jre/lib/rt.jar" />
3132
<classpath refid="class.path"/>

java/org/cef/CefApp.java

Lines changed: 58 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@
44

55
package org.cef;
66

7+
import org.cef.callback.CefSchemeHandlerFactory;
8+
import org.cef.handler.CefAppHandler;
9+
import org.cef.handler.CefAppHandlerAdapter;
10+
711
import java.awt.event.ActionEvent;
812
import java.awt.event.ActionListener;
913
import java.io.File;
1014
import java.io.FilenameFilter;
1115
import java.nio.file.Path;
1216
import java.nio.file.Paths;
1317
import java.util.HashSet;
18+
1419
import javax.swing.SwingUtilities;
1520
import javax.swing.Timer;
1621

17-
import org.cef.callback.CefSchemeHandlerFactory;
18-
import org.cef.handler.CefAppHandler;
19-
import org.cef.handler.CefAppHandlerAdapter;
20-
2122
/**
2223
* Exposes static methods for managing the global CEF context.
2324
*/
@@ -51,8 +52,8 @@ private CefVersion(int jcefCommitNo, int cefMajor, int cefMinor, int cefPatch,
5152
}
5253

5354
public String getJcefVersion() {
54-
return CEF_VERSION_MAJOR + "." + CEF_VERSION_MINOR + "." + CEF_VERSION_PATCH
55-
+ "." + JCEF_COMMIT_NUMBER;
55+
return CEF_VERSION_MAJOR + "." + CEF_VERSION_MINOR + "." + CEF_VERSION_PATCH + "."
56+
+ JCEF_COMMIT_NUMBER;
5657
}
5758

5859
public String getCefVersion() {
@@ -140,14 +141,14 @@ private CefApp(String[] args, CefSettings settings) throws UnsatisfiedLinkError
140141
super(args);
141142
if (settings != null) settings_ = settings.clone();
142143
if (OS.isWindows()) {
143-
System.loadLibrary("jawt");
144-
System.loadLibrary("chrome_elf");
145-
System.loadLibrary("libcef");
144+
SystemBootstrap.loadLibrary("jawt");
145+
SystemBootstrap.loadLibrary("chrome_elf");
146+
SystemBootstrap.loadLibrary("libcef");
146147

147148
// Other platforms load this library in CefApp.startup().
148-
System.loadLibrary("jcef");
149+
SystemBootstrap.loadLibrary("jcef");
149150
} else if (OS.isLinux()) {
150-
System.loadLibrary("cef");
151+
SystemBootstrap.loadLibrary("cef");
151152
}
152153
if (appHandler_ == null) {
153154
appHandler_ = this;
@@ -312,7 +313,7 @@ public synchronized CefClient createClient() {
312313
case NEW:
313314
setState(CefAppState.INITIALIZING);
314315
initialize();
315-
// FALL THRU
316+
// FALL THRU
316317

317318
case INITIALIZING:
318319
case INITIALIZED:
@@ -401,19 +402,29 @@ public void run() {
401402
}
402403
} else if (OS.isWindows()) {
403404
if (settings.browser_subprocess_path == null) {
404-
settings.browser_subprocess_path = library_path + "\\jcef_helper.exe";
405+
Path path = Paths.get(library_path, "jcef_helper.exe");
406+
settings.browser_subprocess_path =
407+
path.normalize().toAbsolutePath().toString();
405408
}
406409
} else if (OS.isLinux()) {
407-
if (settings.browser_subprocess_path == null)
408-
settings.browser_subprocess_path = library_path + "/jcef_helper";
409-
if (settings.resources_dir_path == null)
410-
settings.resources_dir_path = library_path;
411-
if (settings.locales_dir_path == null)
412-
settings.locales_dir_path = library_path + "/locales";
410+
if (settings.browser_subprocess_path == null) {
411+
Path path = Paths.get(library_path, "jcef_helper");
412+
settings.browser_subprocess_path =
413+
path.normalize().toAbsolutePath().toString();
414+
}
415+
if (settings.resources_dir_path == null) {
416+
Path path = Paths.get(library_path);
417+
settings.resources_dir_path =
418+
path.normalize().toAbsolutePath().toString();
419+
}
420+
if (settings.locales_dir_path == null) {
421+
Path path = Paths.get(library_path, "locales");
422+
settings.locales_dir_path =
423+
path.normalize().toAbsolutePath().toString();
424+
}
413425
}
414426

415-
if (N_Initialize(library_path, appHandler_, settings))
416-
setState(CefAppState.INITIALIZED);
427+
if (N_Initialize(appHandler_, settings)) setState(CefAppState.INITIALIZED);
417428
}
418429
};
419430
if (SwingUtilities.isEventDispatchThread())
@@ -517,11 +528,13 @@ public void actionPerformed(ActionEvent evt) {
517528
* This method must be called at the beginning of the main() method to perform platform-
518529
* specific startup initialization. On Linux this initializes Xlib multithreading and on
519530
* macOS this dynamically loads the CEF framework.
531+
* @param args Command-line arguments massed to main().
532+
* @return True on successful startup.
520533
*/
521-
public static final boolean startup() {
534+
public static final boolean startup(String[] args) {
522535
if (OS.isLinux() || OS.isMacintosh()) {
523-
System.loadLibrary("jcef");
524-
return N_Startup();
536+
SystemBootstrap.loadLibrary("jcef");
537+
return N_Startup(OS.isMacintosh() ? getCefFrameworkPath(args) : null);
525538
}
526539
return true;
527540
}
@@ -530,7 +543,7 @@ public static final boolean startup() {
530543
* Get the path which contains the jcef library
531544
* @return The path to the jcef library
532545
*/
533-
private final String getJcefLibPath() {
546+
private static final String getJcefLibPath() {
534547
String library_path = System.getProperty("java.library.path");
535548
String[] paths = library_path.split(System.getProperty("path.separator"));
536549
for (String path : paths) {
@@ -548,10 +561,27 @@ public boolean accept(File dir, String name) {
548561
return library_path;
549562
}
550563

551-
private final static native boolean N_Startup();
564+
/**
565+
* Get the path that contains the CEF Framework on macOS.
566+
* @return The path to the CEF Framework.
567+
*/
568+
private static final String getCefFrameworkPath(String[] args) {
569+
// Check for the path on the command-line.
570+
String switchPrefix = "--framework-dir-path=";
571+
for (String arg : args) {
572+
if (arg.startsWith(switchPrefix)) {
573+
return new File(arg.substring(switchPrefix.length())).getAbsolutePath();
574+
}
575+
}
576+
577+
// Determine the path relative to the JCEF lib location in the app bundle.
578+
return new File(getJcefLibPath() + "/../Frameworks/Chromium Embedded Framework.framework")
579+
.getAbsolutePath();
580+
}
581+
582+
private final static native boolean N_Startup(String pathToCefFramework);
552583
private final native boolean N_PreInitialize();
553-
private final native boolean N_Initialize(
554-
String pathToJavaDLL, CefAppHandler appHandler, CefSettings settings);
584+
private final native boolean N_Initialize(CefAppHandler appHandler, CefSettings settings);
555585
private final native void N_Shutdown();
556586
private final native void N_DoMessageLoopWork();
557587
private final native CefVersion N_GetVersion();

java/org/cef/SystemBootstrap.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) 2020 The Chromium Embedded Framework Authors. All rights
2+
// reserved. Use of this source code is governed by a BSD-style license that
3+
// can be found in the LICENSE file.
4+
package org.cef;
5+
6+
/**
7+
* To allow customization of System.load() calls by supplying a different
8+
* implementation. You'll want to call <code>setLoader</code> with your custom
9+
* implementation before calling into any other CEF classes which then in turn
10+
* will start triggering libraries to be loaded at runtime.
11+
*/
12+
public class SystemBootstrap {
13+
/**
14+
* Simple interface for how a library by name should be loaded.
15+
*/
16+
static public interface Loader { public void loadLibrary(String libname); }
17+
18+
/**
19+
* Default implementation is to call System.loadLibrary
20+
*/
21+
static private Loader loader_ = new Loader() {
22+
@Override
23+
public void loadLibrary(String libname) {
24+
System.loadLibrary(libname);
25+
}
26+
};
27+
28+
static public void setLoader(Loader loader) {
29+
if (loader == null) {
30+
throw new NullPointerException("Loader cannot be null");
31+
}
32+
loader_ = loader;
33+
}
34+
35+
static public void loadLibrary(String libname) {
36+
loader_.loadLibrary(libname);
37+
}
38+
}

java/org/cef/browser/CefBrowserOsr.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.jogamp.nativewindow.NativeSurface;
88
import com.jogamp.opengl.GLAutoDrawable;
99
import com.jogamp.opengl.GLCapabilities;
10+
import com.jogamp.opengl.GLContext;
1011
import com.jogamp.opengl.GLEventListener;
1112
import com.jogamp.opengl.GLProfile;
1213
import com.jogamp.opengl.awt.GLCanvas;
@@ -108,6 +109,8 @@ public void paint(Graphics g) {
108109
}
109110
};
110111

112+
// The GLContext will be re-initialized when changing displays, resulting in calls to
113+
// dispose/init/reshape.
111114
canvas_.addGLEventListener(new GLEventListener() {
112115
@Override
113116
public void reshape(
@@ -243,9 +246,20 @@ public void onPopupSize(CefBrowser browser, Rectangle size) {
243246
@Override
244247
public void onPaint(CefBrowser browser, boolean popup, Rectangle[] dirtyRects,
245248
ByteBuffer buffer, int width, int height) {
246-
canvas_.getContext().makeCurrent();
249+
// if window is closing, canvas_ or opengl context could be null
250+
final GLContext context = canvas_ != null ? canvas_.getContext() : null;
251+
252+
if (context == null) {
253+
return;
254+
}
255+
256+
// This result can occur due to GLContext re-initialization when changing displays.
257+
if (context.makeCurrent() == GLContext.CONTEXT_NOT_CURRENT) {
258+
return;
259+
}
260+
247261
renderer_.onPaint(canvas_.getGL().getGL2(), popup, dirtyRects, buffer, width, height);
248-
canvas_.getContext().release();
262+
context.release();
249263
SwingUtilities.invokeLater(new Runnable() {
250264
public void run() {
251265
canvas_.display();

java/org/cef/browser/CefBrowserWr.java

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,18 @@
44

55
package org.cef.browser;
66

7+
import org.cef.CefClient;
8+
import org.cef.OS;
9+
import org.cef.handler.CefWindowHandler;
10+
import org.cef.handler.CefWindowHandlerAdapter;
11+
712
import java.awt.BorderLayout;
813
import java.awt.Canvas;
914
import java.awt.Component;
1015
import java.awt.Container;
1116
import java.awt.Dimension;
1217
import java.awt.Graphics;
18+
import java.awt.Graphics2D;
1319
import java.awt.MouseInfo;
1420
import java.awt.Point;
1521
import java.awt.Rectangle;
@@ -33,11 +39,6 @@
3339
import javax.swing.Timer;
3440
import javax.swing.ToolTipManager;
3541

36-
import org.cef.CefClient;
37-
import org.cef.OS;
38-
import org.cef.handler.CefWindowHandler;
39-
import org.cef.handler.CefWindowHandlerAdapter;
40-
4142
/**
4243
* This class represents a windowed rendered browser.
4344
* The visibility of this class is "package". To create a new
@@ -49,14 +50,14 @@ class CefBrowserWr extends CefBrowser_N {
4950
private Rectangle content_rect_ = new Rectangle(0, 0, 0, 0);
5051
private long window_handle_ = 0;
5152
private boolean justCreated_ = false;
53+
private double scaleFactor_ = 1.0;
5254
private Timer delayedUpdate_ = new Timer(100, new ActionListener() {
5355
@Override
5456
public void actionPerformed(ActionEvent e) {
5557
SwingUtilities.invokeLater(new Runnable() {
5658
@Override
5759
public void run() {
58-
if (isClosed())
59-
return;
60+
if (isClosed()) return;
6061

6162
boolean hasCreatedUI = createBrowserIfRequired(true);
6263

@@ -149,7 +150,7 @@ public int getClickCount(int event, int button) {
149150
if (currTime > nextClick[idx]) {
150151
nextClick[idx] = currTime
151152
+ (Integer) Toolkit.getDefaultToolkit().getDesktopProperty(
152-
"awt.multiClickInterval");
153+
"awt.multiClickInterval");
153154
clickCnt[idx] = 1;
154155
} else {
155156
clickCnt[idx]++;
@@ -186,7 +187,7 @@ private CefBrowserWr(CefClient client, String url, CefRequestContext context,
186187
@Override
187188
public void setBounds(int x, int y, int width, int height) {
188189
super.setBounds(x, y, width, height);
189-
wasResized(width, height);
190+
wasResized((int) (width * scaleFactor_), (int) (height * scaleFactor_));
190191
}
191192

192193
@Override
@@ -197,7 +198,7 @@ public void setBounds(Rectangle r) {
197198
@Override
198199
public void setSize(int width, int height) {
199200
super.setSize(width, height);
200-
wasResized(width, height);
201+
wasResized((int) (width * scaleFactor_), (int) (height * scaleFactor_));
201202
}
202203

203204
@Override
@@ -215,6 +216,9 @@ public void paint(Graphics g) {
215216
// we're setting up a delayedUpdate timer which is reset each time
216217
// paint is called. This prevents the us of sending the UI update too
217218
// often.
219+
if (g instanceof Graphics2D) {
220+
scaleFactor_ = ((Graphics2D) g).getTransform().getScaleX();
221+
}
218222
doUpdate();
219223
delayedUpdate_.restart();
220224
}
@@ -344,7 +348,10 @@ private static long getWindowHandle(Component component) {
344348
private void doUpdate() {
345349
if (isClosed()) return;
346350

347-
Rectangle clipping = ((JPanel) component_).getVisibleRect();
351+
Rectangle vr = ((JPanel) component_).getVisibleRect();
352+
Rectangle clipping = new Rectangle((int) (vr.getX() * scaleFactor_),
353+
(int) (vr.getY() * scaleFactor_), (int) (vr.getWidth() * scaleFactor_),
354+
(int) (vr.getHeight() * scaleFactor_));
348355

349356
if (OS.isMacintosh()) {
350357
Container parent = component_.getParent();
@@ -369,7 +376,11 @@ private void doUpdate() {
369376
}
370377
} else {
371378
synchronized (content_rect_) {
372-
content_rect_ = component_.getBounds();
379+
Rectangle bounds = component_.getBounds();
380+
content_rect_ = new Rectangle((int) (bounds.getX() * scaleFactor_),
381+
(int) (bounds.getY() * scaleFactor_),
382+
(int) (bounds.getWidth() * scaleFactor_),
383+
(int) (bounds.getHeight() * scaleFactor_));
373384
updateUI(clipping, content_rect_);
374385
}
375386
}

0 commit comments

Comments
 (0)