Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/sheen/adpat cef 120 #432

Merged
merged 7 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 24 additions & 15 deletions cmake/CefViewCoreConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,33 @@ include(FetchContent)
FetchContent_Declare(
CefViewCore
GIT_REPOSITORY https://github.com/CefView/CefViewCore.git
GIT_TAG 8443548ddba2474e53304c0e602c23b988a16496
GIT_TAG 3d61b7956b14ebd879eb6c5ff7f2ab85d9f780c3
)

# set CEF version to be used
# "89.0.12+g2b76680+chromium-89.0.4389.90" # GOOD
# "91.1.23+g04c8d56+chromium-91.0.4472.164" # GOOD
# "95.7.12+g99c4ac0+chromium-95.0.4638.54" # GOOD
# "99.2.15+g71e9523+chromium-99.0.4844.84" # GOOD
# "102.0.10+gf249b2e+chromium-102.0.5005.115" # GOOD
# "104.4.18+g2587cf2+chromium-104.0.5112.81" # BAD # crash on macOS - debug mode
# "104.4.26+g4180781+chromium-104.0.5112.102" # BAD # crash on macOS - debug mode
# "105.3.25+g0ca6a9e+chromium-105.0.5195.54" # BAD # debugbreak - debug mode
# "105.3.28+g002805e+chromium-105.0.5195.54" # BAD # debugbreak - debug mode
# "107.1.9+g1f0a21a+chromium-107.0.5304.110" # BAD # debugbreak - debug mode
# "110.0.26+g732747f+chromium-110.0.5481.97" # BAD # TO-BE-FIXED
# "113.3.1+g525fa10+chromium-113.0.5672.128" # So far so good - doesn't support Xcode 15
# "119.4.7+g55e15c8+chromium-119.0.6045.199"
set(CEF_SDK_VERSION "119.4.7+g55e15c8+chromium-119.0.6045.199")
# set(CEF_SDK_VERSION "89.0.12+g2b76680+chromium-89.0.4389.90") # GOOD
# set(CEF_SDK_VERSION "91.1.23+g04c8d56+chromium-91.0.4472.164") # GOOD
# set(CEF_SDK_VERSION "95.7.12+g99c4ac0+chromium-95.0.4638.54") # GOOD
# set(CEF_SDK_VERSION "99.2.15+g71e9523+chromium-99.0.4844.84") # GOOD
# set(CEF_SDK_VERSION "102.0.10+gf249b2e+chromium-102.0.5005.115") # GOOD
# set(CEF_SDK_VERSION "104.4.18+g2587cf2+chromium-104.0.5112.81") # BAD # crash on macOS - debug mode
# set(CEF_SDK_VERSION "104.4.26+g4180781+chromium-104.0.5112.102") # BAD # crash on macOS - debug mode
# set(CEF_SDK_VERSION "105.3.25+g0ca6a9e+chromium-105.0.5195.54") # BAD # debugbreak - debug mode
# set(CEF_SDK_VERSION "105.3.28+g002805e+chromium-105.0.5195.54") # BAD # debugbreak - debug mode
# set(CEF_SDK_VERSION "107.1.9+g1f0a21a+chromium-107.0.5304.110") # BAD # debugbreak - debug mode
# set(CEF_SDK_VERSION "110.0.26+g732747f+chromium-110.0.5481.97") # BAD # TO-BE-FIXED
# set(CEF_SDK_VERSION "113.3.1+g525fa10+chromium-113.0.5672.128") # So far so good - doesn't support Xcode 15
# set(CEF_SDK_VERSION "119.4.7+g55e15c8+chromium-119.0.6045.199") # GOOD
# set(CEF_SDK_VERSION "120.1.6+gf08b1fd+chromium-120.0.6099.71") # GOOD
# set(CEF_SDK_VERSION "121.3.15+g4d3b0b4+chromium-121.0.6167.184") # GOOD
# set(CEF_SDK_VERSION "122.1.13+gde5b724+chromium-122.0.6261.130") # GOOD
# set(CEF_SDK_VERSION "123.0.13+gfc703fb+chromium-123.0.6312.124") # NOT-TEST
# set(CEF_SDK_VERSION "124.3.9+g9bd638f+chromium-124.0.6367.207") # NOT-TEST
# set(CEF_SDK_VERSION "125.0.22+gc410c95+chromium-125.0.6422.142") # NOT-TEST
# set(CEF_SDK_VERSION "126.2.18+g3647d39+chromium-126.0.6478.183") # NOT-TEST
set(CEF_SDK_VERSION "127.3.5+g114ea2a+chromium-127.0.6533.120") # GOOD

# set(CEF_SDK_VERSION "128.4.9+g9840ad9+chromium-128.0.6613.120") # BAD # debugbreak - debug mode

# populate CefViewCore project
FetchContent_MakeAvailable(CefViewCore)
Expand Down
6 changes: 3 additions & 3 deletions example/QCefViewTest/CefViewWidget.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "CefViewWidget.h"
#include "CefViewWidget.h"

#if defined(Q_OS_WIN)
#include <windows.h>
Expand All @@ -20,7 +20,7 @@ CefViewWidget::CefViewWidget(const QString url, const QCefSetting* setting, QWid
: QCefView(url, setting, parent)
{
setStyleSheet("background: blue;");

connect(this, &CefViewWidget::draggableRegionChanged, this, &CefViewWidget::onDraggableRegionChanged);
connect(this, &CefViewWidget::nativeBrowserCreated, this, &CefViewWidget::onNativeBrowserWindowCreated);
}
Expand Down Expand Up @@ -56,7 +56,7 @@ CefViewWidget::onDraggableRegionChanged(const QRegion& draggableRegion, const QR
}

bool
CefViewWidget::onNewPopup(qint64 sourceFrameId,
CefViewWidget::onNewPopup(const QCefFrameId& sourceFrameId,
const QString& targetUrl,
QString& targetFrameName,
QCefView::CefWindowOpenDisposition targetDisposition,
Expand Down
2 changes: 1 addition & 1 deletion example/QCefViewTest/CefViewWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected slots:
void onDraggableRegionChanged(const QRegion& draggableRegion, const QRegion& nonDraggableRegion);

protected:
bool onNewPopup(qint64 sourceFrameId,
bool onNewPopup(const QCefFrameId& sourceFrameId,
const QString& targetUrl,
QString& targetFrameName,
QCefView::CefWindowOpenDisposition targetDisposition,
Expand Down
25 changes: 17 additions & 8 deletions example/QCefViewTest/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,10 @@ MainWindow::createRightCefView()
}

void
MainWindow::onInvokeMethod(int browserId, int64_t frameId, const QString& method, const QVariantList& arguments)
MainWindow::onInvokeMethod(const QCefBrowserId& browserId,
const QCefFrameId& frameId,
const QString& method,
const QVariantList& arguments)
{
// extract the arguments and dispatch the invocation to corresponding handler
if (0 == method.compare("TestMethod")) {
Expand Down Expand Up @@ -160,7 +163,7 @@ MainWindow::onInvokeMethod(int browserId, int64_t frameId, const QString& method
}

void
MainWindow::onQCefQueryRequest(int browserId, int64_t frameId, const QCefQuery& query)
MainWindow::onQCefQueryRequest(const QCefBrowserId& browserId, const QCefFrameId& frameId, const QCefQuery& query)
{
QString title("QCef Query Request");
QString text = QString("Current Thread: QT_UI\r\n"
Expand All @@ -175,7 +178,10 @@ MainWindow::onQCefQueryRequest(int browserId, int64_t frameId, const QCefQuery&
}

void
MainWindow::onJavascriptResult(int browserId, int64_t frameId, const QString& context, const QVariant& result)
MainWindow::onJavascriptResult(const QCefBrowserId& browserId,
const QCefFrameId& frameId,
const QString& context,
const QVariant& result)
{
auto jsonValue = QJsonDocument::fromVariant(result);
auto jsonString = QString(jsonValue.toJson());
Expand All @@ -187,29 +193,32 @@ MainWindow::onJavascriptResult(int browserId, int64_t frameId, const QString& co
}

void
MainWindow::onLoadingStateChanged(int browserId, bool isLoading, bool canGoBack, bool canGoForward)
MainWindow::onLoadingStateChanged(const QCefBrowserId& browserId, bool isLoading, bool canGoBack, bool canGoForward)
{
qDebug() << "onLoadingStateChanged, browserId:" << browserId << ", isLoading:" << isLoading
<< ", canGoBack:" << canGoBack << ", canGoForward:" << canGoForward;
}

void
MainWindow::onLoadStart(int browserId, qint64 frameId, bool isMainFrame, int transitionType)
MainWindow::onLoadStart(const QCefBrowserId& browserId,
const QCefFrameId& frameId,
bool isMainFrame,
int transitionType)
{
qDebug() << "onLoadStart, browserId:" << browserId << ", frameId:" << frameId << ", isMainFrame:" << isMainFrame
<< ", transitionType:" << transitionType;
}

void
MainWindow::onLoadEnd(int browserId, qint64 frameId, bool isMainFrame, int httpStatusCode)
MainWindow::onLoadEnd(const QCefBrowserId& browserId, const QCefFrameId& frameId, bool isMainFrame, int httpStatusCode)
{
qDebug() << "onLoadEnd, browserId:" << browserId << ", frameId:" << frameId << ", isMainFrame:" << isMainFrame
<< ", httpStatusCode:" << httpStatusCode;
}

void
MainWindow::onLoadError(int browserId,
qint64 frameId,
MainWindow::onLoadError(const QCefBrowserId& browserId,
const QCefFrameId& frameId,
bool isMainFrame,
int errorCode,
const QString& errorMsg,
Expand Down
22 changes: 14 additions & 8 deletions example/QCefViewTest/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,26 @@ class MainWindow : public QMainWindow
// QCefView slots
protected slots:

void onInvokeMethod(int browserId, int64_t frameId, const QString& method, const QVariantList& arguments);
void onInvokeMethod(const QCefBrowserId& browserId,
const QCefFrameId& frameId,
const QString& method,
const QVariantList& arguments);

void onQCefQueryRequest(int browserId, int64_t frameId, const QCefQuery& query);
void onQCefQueryRequest(const QCefBrowserId& browserId, const QCefFrameId& frameId, const QCefQuery& query);

void onJavascriptResult(int browserId, int64_t frameId, const QString& context, const QVariant& result);
void onJavascriptResult(const QCefBrowserId& browserId,
const QCefFrameId& frameId,
const QString& context,
const QVariant& result);

void onLoadingStateChanged(int browserId, bool isLoading, bool canGoBack, bool canGoForward);
void onLoadingStateChanged(const QCefBrowserId& browserId, bool isLoading, bool canGoBack, bool canGoForward);

void onLoadStart(int browserId, qint64 frameId, bool isMainFrame, int transitionType);
void onLoadStart(const QCefBrowserId& browserId, const QCefFrameId& frameId, bool isMainFrame, int transitionType);

void onLoadEnd(int browserId, qint64 frameId, bool isMainFrame, int httpStatusCode);
void onLoadEnd(const QCefBrowserId& browserId, const QCefFrameId& frameId, bool isMainFrame, int httpStatusCode);

void onLoadError(int browserId,
qint64 frameId,
void onLoadError(const QCefBrowserId& browserId,
const QCefFrameId& frameId,
bool isMainFrame,
int errorCode,
const QString& errorMsg,
Expand Down
4 changes: 3 additions & 1 deletion include/QCefConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class QCEFVIEW_EXPORT QCefConfig
/// <summary>
/// Sets the acceptable language list
/// </summary>
/// <param name="languages">Comma delimited ordered list of language codes without any whitespace
/// <param name="languages">Comma delimited ordered list of language codes without any whitespace
/// that will be used in the "Accept-Language" HTTP header.</param>
void setAcceptLanguageList(const QString& languages);

Expand All @@ -271,6 +271,7 @@ class QCEFVIEW_EXPORT QCefConfig
/// </summary>
const QVariant persistSessionCookies() const;

#if CEF_VERSION_MAJOR < 128
/// <summary>
/// Sets whether to persist user preferences
/// </summary>
Expand All @@ -281,6 +282,7 @@ class QCEFVIEW_EXPORT QCefConfig
/// Gets whether to persist user preferences
/// </summary>
const QVariant persistUserPreferences() const;
#endif

/// <summary>
/// Sets the remote debugging port
Expand Down
60 changes: 43 additions & 17 deletions include/QCefView.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,23 @@
#include <QCefQuery.h>
#include <QCefSetting.h>

/// <summary>
/// Type alias for CEF browser id
/// </summary>
#define QCefBrowserId int

/// <summary>
/// Type alias for CEF frame id
/// </summary>
#if CEF_VERSION_MAJOR < 122
#define QCefFrameId qint64
#else
#define QCefFrameId QString
#endif

/// <summary>
/// Private implementation
/// </summary>
class QCefViewPrivate;

/// <summary>
Expand All @@ -39,10 +56,10 @@ class QCEFVIEW_EXPORT QCefView : public QWidget
/// <summary>
/// The main frame identity
/// </summary>
static const qint64 MainFrameID = 0;
static const QCefFrameId MainFrameID;

/// <summary>
/// Represents the CEF popup windows open disposition
/// Represents the CEF pop-up windows open disposition
/// </summary>
enum CefWindowOpenDisposition
{
Expand Down Expand Up @@ -105,7 +122,7 @@ class QCEFVIEW_EXPORT QCefView : public QWidget
/// Gets the browser id
/// </summary>
/// <returns>The browser id</returns>
int browserId();
QCefBrowserId browserId();

/// <summary>
/// Navigates to the content.
Expand Down Expand Up @@ -170,7 +187,7 @@ class QCEFVIEW_EXPORT QCefView : public QWidget
/// <param name="event">The <see cref="QCefEvent"/> instance</param>
/// <param name="frameId">The frame id</param>
/// <returns>True on successful; otherwise false</returns>
bool triggerEvent(const QCefEvent& event, qint64 frameId);
bool triggerEvent(const QCefEvent& event, const QCefFrameId& frameId);

/// <summary>
/// Broad cast the event for all frames
Expand All @@ -197,7 +214,7 @@ class QCEFVIEW_EXPORT QCefView : public QWidget
/// the source of the error
/// </param>
/// <returns>True on successful; otherwise false</returns>
bool executeJavascript(qint64 frameId, const QString& code, const QString& url);
bool executeJavascript(const QCefFrameId& frameId, const QString& code, const QString& url);

/// <summary>
/// Executes javascript code in specified frame and the result will be reported through <see
Expand All @@ -211,7 +228,10 @@ class QCEFVIEW_EXPORT QCefView : public QWidget
/// </param>
/// <param name="context">The context used to identify the one execution</param>
/// <returns>True on successful; otherwise false</returns>
bool executeJavascriptWithResult(qint64 frameId, const QString& code, const QString& url, const QString& context);
bool executeJavascriptWithResult(const QCefFrameId& frameId,
const QString& code,
const QString& url,
const QString& context);

/// <summary>
/// Sets the preference for this browser
Expand Down Expand Up @@ -277,7 +297,7 @@ class QCEFVIEW_EXPORT QCefView : public QWidget
/// <param name="isLoading">Indicates the browser is loading</param>
/// <param name="canGoBack">Indicates the browser can go back</param>
/// <param name="canGoForward">Indicates the browser can go forward</param>
void loadingStateChanged(int browserId, bool isLoading, bool canGoBack, bool canGoForward);
void loadingStateChanged(const QCefBrowserId& browserId, bool isLoading, bool canGoBack, bool canGoForward);

/// <summary>
/// Gets called on loading starts
Expand All @@ -286,7 +306,7 @@ class QCEFVIEW_EXPORT QCefView : public QWidget
/// <param name="frameId">Indicates the frame id</param>
/// <param name="isMainFrame">Indicates the whether this is the main frame</param>
/// <param name="transitionType">transition type</param>
void loadStart(int browserId, qint64 frameId, bool isMainFrame, int transitionType);
void loadStart(const QCefBrowserId& browserId, const QCefFrameId& frameId, bool isMainFrame, int transitionType);

/// <summary>
/// Gets called on loading ends
Expand All @@ -295,7 +315,7 @@ class QCEFVIEW_EXPORT QCefView : public QWidget
/// <param name="frameId">Indicates the frame id</param>
/// <param name="isMainFrame">Indicates the whether this is the main frame</param>
/// <param name="httpStatusCode">The HTTP status code</param>
void loadEnd(int browserId, qint64 frameId, bool isMainFrame, int httpStatusCode);
void loadEnd(const QCefBrowserId& browserId, const QCefFrameId& frameId, bool isMainFrame, int httpStatusCode);

/// <summary>
/// Gets called on loading failed due to error
Expand All @@ -306,8 +326,8 @@ class QCEFVIEW_EXPORT QCefView : public QWidget
/// <param name="errorCode">The error code</param>
/// <param name="errorMsg">The error message</param>
/// <param name="failedUrl">The url caused the failure</param>
void loadError(int browserId,
qint64 frameId,
void loadError(const QCefBrowserId& browserId,
const QCefFrameId& frameId,
bool isMainFrame,
int errorCode,
const QString& errorMsg,
Expand All @@ -325,7 +345,7 @@ class QCEFVIEW_EXPORT QCefView : public QWidget
/// </summary>
/// <param name="frameId">The frame id</param>
/// <param name="url">The address</param>
void addressChanged(qint64 frameId, const QString& url);
void addressChanged(const QCefFrameId& frameId, const QString& url);

/// <summary>
/// Gets called on title changed
Expand Down Expand Up @@ -370,7 +390,7 @@ class QCEFVIEW_EXPORT QCefView : public QWidget
/// <param name="browserId">The browser id</param>
/// <param name="frameId">The frame id</param>
/// <param name="query">The query request</param>
void cefQueryRequest(int browserId, qint64 frameId, const QCefQuery& query);
void cefQueryRequest(const QCefBrowserId& browserId, const QCefFrameId& frameId, const QCefQuery& query);

/// <summary>
/// Gets called on invoking method request from web content(Javascript)
Expand All @@ -379,7 +399,10 @@ class QCEFVIEW_EXPORT QCefView : public QWidget
/// <param name="frameId">The frame id</param>
/// <param name="method">The method name</param>
/// <param name="arguments">The arguments list</param>
void invokeMethod(int browserId, qint64 frameId, const QString& method, const QVariantList& arguments);
void invokeMethod(const QCefBrowserId& browserId,
const QCefFrameId& frameId,
const QString& method,
const QVariantList& arguments);

/// <summary>
/// Gets called on the result of the javascript executed with <see cref="executeJavascriptWithResult"/> returned
Expand All @@ -388,7 +411,10 @@ class QCEFVIEW_EXPORT QCefView : public QWidget
/// <param name="frameId">The frame id</param>
/// <param name="context">The context</param>
/// <param name="result">The result</param>
void reportJavascriptResult(int browserId, qint64 frameId, const QString& context, const QVariant& result);
void reportJavascriptResult(const QCefBrowserId& browserId,
const QCefFrameId& frameId,
const QString& context,
const QVariant& result);

/// <summary>
/// Gets called after the native browser window created. This slot does not work for OSR mode.
Expand All @@ -408,7 +434,7 @@ class QCEFVIEW_EXPORT QCefView : public QWidget
/// <param name="settings">Settings to be used for the popup</param>
/// <returns>True to cancel the popup; false to allow</returns>
/// <returns></returns>
virtual QCefView* onNewBrowser(qint64 sourceFrameId,
virtual QCefView* onNewBrowser(const QCefFrameId& sourceFrameId,
const QString& url,
const QString& name,
QCefView::CefWindowOpenDisposition targetDisposition,
Expand All @@ -425,7 +451,7 @@ class QCEFVIEW_EXPORT QCefView : public QWidget
/// <param name="rect">Rect to be used for the popup</param>
/// <param name="settings">Settings to be used for the popup</param>
/// <returns>True to cancel the popup; false to allow</returns>
virtual bool onNewPopup(qint64 frameId,
virtual bool onNewPopup(const QCefFrameId& frameId,
const QString& targetUrl,
QString& targetFrameName,
QCefView::CefWindowOpenDisposition targetDisposition,
Expand Down
Loading
Loading