Skip to content

Commit

Permalink
feat: replace static member with macro to remove runtime depends on C…
Browse files Browse the repository at this point in the history
…EF during initialization
  • Loading branch information
tishion committed Oct 30, 2024
1 parent 1cc9a2a commit 0aa55c8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
20 changes: 9 additions & 11 deletions include/CefViewBrowserClient.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//
//
// CefViewBrowserClient.h
// CefViewCore
//
Expand All @@ -18,6 +18,14 @@
#include <CefViewBrowserApp.h>
#include <CefViewBrowserClientDelegate.h>

#if CEF_VERSION_MAJOR < 122
#define CEFVIEW_MAIN_FRAME (0)
#define CEFVIEW_ALL_FRAMES (-1)
#else
#define CEFVIEW_MAIN_FRAME ("0")
#define CEFVIEW_ALL_FRAMES ("-1")
#endif

/// <summary>
/// Forward declaration
/// </summary>
Expand Down Expand Up @@ -73,16 +81,6 @@ class CefViewBrowserClient
std::unordered_map<int, CefRefPtr<CefBrowser>> browser_map_;

public:
/// <summary>
///
/// </summary>
const static CefFrameId MAIN_FRAME;

/// <summary>
///
/// </summary>
const static CefFrameId ALL_FRAMES;

/// <summary>
///
/// </summary>
Expand Down
14 changes: 3 additions & 11 deletions src/CefView/CefBrowserApp/CefViewBrowserClient.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <CefViewBrowserClient.h>
#include <CefViewBrowserClient.h>

#pragma region stl_headers
#include <sstream>
Expand All @@ -12,14 +12,6 @@

#include "CefViewQueryHandler/CefViewQueryHandler.h"

#if CEF_VERSION_MAJOR < 122
const CefFrameId CefViewBrowserClient::MAIN_FRAME = 0;
const CefFrameId CefViewBrowserClient::ALL_FRAMES = -1;
#else
const CefFrameId CefViewBrowserClient::MAIN_FRAME = "0";
const CefFrameId CefViewBrowserClient::ALL_FRAMES = "-1";
#endif

CefViewBrowserClient::CefViewBrowserClient(CefRefPtr<CefViewBrowserApp> app,
CefViewBrowserClientDelegateInterface::RefPtr delegate)
: app_(app)
Expand Down Expand Up @@ -96,9 +88,9 @@ CefViewBrowserClient::TriggerEvent(CefRefPtr<CefBrowser> browser,

if (browser) {
std::vector<CefFrameId> frameIds;
if (MAIN_FRAME == frame_id) {
if (frame_id == CEFVIEW_MAIN_FRAME) {
frameIds.push_back(browser->GetMainFrame()->GetIdentifier());
} else if (ALL_FRAMES == frame_id) {
} else if (frame_id == CEFVIEW_ALL_FRAMES) {
browser->GetFrameIdentifiers(frameIds);
} else {
frameIds.push_back(frame_id);
Expand Down

0 comments on commit 0aa55c8

Please sign in to comment.