Skip to content

Commit

Permalink
fix: fix compiling error when version < 119
Browse files Browse the repository at this point in the history
  • Loading branch information
tishion committed Jan 9, 2025
1 parent ca26251 commit d072b57
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ if(NOT CEF_SDK_VERSION)
# set(DEFAULT_CEF_SDK_VERSION "111.2.7+gebf5d6a+chromium-111.0.5563.148") # GOOD
# set(DEFAULT_CEF_SDK_VERSION "112.3.0+gb09c4ca+chromium-112.0.5615.165") # GOOD
# set(DEFAULT_CEF_SDK_VERSION "113.3.1+g525fa10+chromium-113.0.5672.128") # GOOD
# set(DEFAULT_CEF_SDK_VERSION "114.2.13+g6792e13+chromium-114.0.5735.200")
# set(DEFAULT_CEF_SDK_VERSION "115.3.15+g21130e0+chromium-115.0.5790.173")
# set(DEFAULT_CEF_SDK_VERSION "116.0.27+gd8c85ac+chromium-116.0.5845.190")
# set(DEFAULT_CEF_SDK_VERSION "117.2.5+gda4c36a+chromium-117.0.5938.152")
# set(DEFAULT_CEF_SDK_VERSION "118.7.1+g99817d2+chromium-118.0.5993.119")
# set(DEFAULT_CEF_SDK_VERSION "119.4.7+g55e15c8+chromium-119.0.6045.199") # GOOD
# set(DEFAULT_CEF_SDK_VERSION "120.1.6+gf08b1fd+chromium-120.0.6099.71") # GOOD
# set(DEFAULT_CEF_SDK_VERSION "121.3.15+g4d3b0b4+chromium-121.0.6167.184") # GOOD
Expand Down
13 changes: 13 additions & 0 deletions src/CefWing/Bridge/CefViewBridgeObject.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#include "CefViewBridgeObject.h"

#include <include/cef_version.h>

#include <Common/CefViewCoreLog.h>

#include <CefViewCoreProtocol.h>


#if CEF_VERSION_MAJOR >= 119
class CefViewArrayBuffer : public CefV8ArrayBufferReleaseCallback
{
IMPLEMENT_REFCOUNTING(CefViewArrayBuffer);
Expand Down Expand Up @@ -72,6 +76,7 @@ class CefViewArrayBuffer : public CefV8ArrayBufferReleaseCallback
size_t m_size;
std::unique_ptr<uint8_t[]> m_buffer;
};
#endif

CefViewBridgeObject::V8Handler::V8Handler(CefViewBridgeObject* object)
: object_(object)
Expand Down Expand Up @@ -279,9 +284,13 @@ CefViewBridgeObject::CefValueToV8Value(CefValue* cefValue)
v8Value = CefV8Value::CreateString(v);
} break;
case CefValueType::VTYPE_BINARY: {
#if CEF_VERSION_MAJOR >= 119
auto v = cefValue->GetBinary();
auto arryBuffer = new CefViewArrayBuffer(v.get());
v8Value = CefV8Value::CreateArrayBuffer(arryBuffer->GetBuffer(), arryBuffer->GetSize(), arryBuffer);
#else
// currently not supported
#endif
} break;
case CefValueType::VTYPE_DICTIONARY: {
auto cDict = cefValue->GetDictionary();
Expand Down Expand Up @@ -358,9 +367,13 @@ CefViewBridgeObject::V8ValueToCefValue(CefV8Value* v8Value)
else if (v8Value->IsString())
cefValue->SetString(v8Value->GetStringValue());
else if (v8Value->IsArrayBuffer()) {
#if CEF_VERSION_MAJOR >= 119
auto size = v8Value->GetArrayBufferByteLength();
auto data = v8Value->GetArrayBufferData();
cefValue->SetBinary(CefBinaryValue::Create(data, size));
#else
// currently not supported
#endif
} else if (v8Value->IsArray()) {
auto s = v8Value->GetArrayLength();
auto cefList = CefListValue::Create();
Expand Down

0 comments on commit d072b57

Please sign in to comment.