Skip to content

Commit 8089a0c

Browse files
committed
Fix compile errors due to CEF API changes
1 parent 8cafb58 commit 8089a0c

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

MTA10/core/CWebView.cpp

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "CAjaxResourceHandler.h"
1313
#include <cef3/include/cef_parser.h>
1414
#include <cef3/include/cef_task.h>
15-
#include <cef3/include/cef_runnable.h>
1615
#include "CWebDevTools.h"
1716

1817
CWebView::CWebView ( unsigned int uiWidth, unsigned int uiHeight, bool bIsLocal, CWebBrowserItem* pWebBrowserRenderItem, bool bTransparent )
@@ -67,7 +66,7 @@ void CWebView::Initialise ()
6766

6867
CefWindowInfo windowInfo;
6968
windowInfo.SetAsWindowless ( g_pCore->GetHookedWindow (), m_bIsTransparent );
70-
69+
7170
CefBrowserHost::CreateBrowser ( windowInfo, this, "", browserSettings, nullptr );
7271
}
7372

@@ -125,7 +124,7 @@ bool CWebView::LoadURL ( const SString& strURL, bool bFilterEnabled, const SStri
125124
request->SetPostData ( postData );
126125
pFrame->LoadRequest ( request );
127126
}
128-
127+
129128
return true;
130129
}
131130

@@ -196,7 +195,7 @@ bool CWebView::SetProperty ( const SString& strKey, const SString& strValue )
196195
{
197196
if ( strKey == "mobile" && ( strValue == "0" || strValue == "1" ) )
198197
{
199-
198+
200199
}
201200
else
202201
return false;
@@ -219,7 +218,7 @@ void CWebView::InjectMouseMove ( int iPosX, int iPosY )
219218
{
220219
if ( !m_pWebView )
221220
return;
222-
221+
223222
CefMouseEvent mouseEvent;
224223
mouseEvent.x = iPosX;
225224
mouseEvent.y = iPosY;
@@ -242,7 +241,7 @@ void CWebView::InjectMouseDown ( eWebBrowserMouseButton mouseButton )
242241
{
243242
if ( !m_pWebView )
244243
return;
245-
244+
246245
CefMouseEvent mouseEvent;
247246
mouseEvent.x = m_vecMousePosition.x;
248247
mouseEvent.y = m_vecMousePosition.y;
@@ -549,7 +548,7 @@ void CWebView::OnPaint ( CefRefPtr<CefBrowser> browser, CefRenderHandler::PaintE
549548
auto sourceData = (const int*)buffer;
550549
auto pitch = LockedRect.Pitch;
551550
552-
for (auto& rect : dirtyRects)
551+
for (auto& rect : dirtyRects)
553552
{
554553
for (int y = rect.y; y < rect.y+rect.height; ++y)
555554
{
@@ -655,7 +654,7 @@ void CWebView::OnLoadEnd ( CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> fr
655654
void CWebView::OnLoadError ( CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefLoadHandler::ErrorCode errorCode, const CefString& errorText, const CefString& failedURL )
656655
{
657656
SString strURL = UTF16ToMbUTF8 ( frame->GetURL () );
658-
657+
659658
// Queue event to run on the main thread
660659
auto func = std::bind ( &CWebBrowserEventsInterface::Events_OnLoadingFailed, m_pEventsInterface, strURL, errorCode, SString ( errorText ) );
661660
g_pCore->GetWebCore ()->AddEventToEventQueue ( func, this, "OnLoadError" );
@@ -673,13 +672,13 @@ bool CWebView::OnBeforeBrowse ( CefRefPtr<CefBrowser> browser, CefRefPtr<CefFram
673672
From documentation:
674673
The |request| object cannot be modified in this callback.
675674
CefLoadHandler::OnLoadingStateChange will be called twice in all cases. If the navigation is allowed CefLoadHandler::OnLoadStart and CefLoadHandler::OnLoadEnd will be called.
676-
If the navigation is canceled CefLoadHandler::OnLoadError will be called with an |errorCode| value of ERR_ABORTED.
675+
If the navigation is canceled CefLoadHandler::OnLoadError will be called with an |errorCode| value of ERR_ABORTED.
677676
*/
678677

679678
CefURLParts urlParts;
680679
if ( !CefParseURL ( request->GetURL(), urlParts ) )
681680
return true; // Cancel if invalid URL (this line will normally not be executed)
682-
681+
683682
bool bResult;
684683
WString scheme = urlParts.scheme.str;
685684
if ( scheme == L"http" || scheme == L"https" )
@@ -797,7 +796,7 @@ void CWebView::OnBeforeClose ( CefRefPtr<CefBrowser> browser )
797796
NotifyPaint ();
798797

799798
m_pWebView = nullptr;
800-
799+
801800
// Remove focused web view reference
802801
if ( g_pCore->GetWebCore ()->GetFocusedWebView () == this )
803802
g_pCore->GetWebCore ()->SetFocusedWebView ( nullptr );
@@ -812,11 +811,11 @@ void CWebView::OnBeforeClose ( CefRefPtr<CefBrowser> browser )
812811
bool CWebView::OnBeforePopup ( CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& target_url, const CefString& target_frame_name, CefLifeSpanHandler::WindowOpenDisposition target_disposition, bool user_gesture, const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, CefRefPtr<CefClient>& client, CefBrowserSettings& settings, bool* no_javascript_access )
813812
{
814813
// ATTENTION: This method is called on the IO thread
815-
814+
816815
// Trigger the popup/new tab event
817816
SString strTagetURL = UTF16ToMbUTF8 ( target_url );
818817
SString strOpenerURL = UTF16ToMbUTF8 ( frame->GetURL () );
819-
818+
820819
// Queue event to run on the main thread
821820
auto func = std::bind ( &CWebBrowserEventsInterface::Events_OnPopup, m_pEventsInterface, strTagetURL, strOpenerURL );
822821
g_pCore->GetWebCore ()->AddEventToEventQueue ( func, this, "OnBeforePopup" );
@@ -848,7 +847,7 @@ void CWebView::OnAfterCreated ( CefRefPtr<CefBrowser> browser )
848847
// http://magpcss.org/ceforum/apidocs3/projects/(default)/CefJSDialogHandler.html#OnJSDialog(CefRefPtr%3CCefBrowser%3E,constCefString&,constCefString&,JSDialogType,constCefString&,constCefString&,CefRefPtr%3CCefJSDialogCallback%3E,bool&) //
849848
// //
850849
////////////////////////////////////////////////////////////////////
851-
bool CWebView::OnJSDialog ( CefRefPtr<CefBrowser> browser, const CefString& origin_url, const CefString& accept_lang, CefJSDialogHandler::JSDialogType dialog_type, const CefString& message_text, const CefString& default_prompt_text, CefRefPtr< CefJSDialogCallback > callback, bool& suppress_message )
850+
bool CWebView::OnJSDialog ( CefRefPtr<CefBrowser> browser, const CefString& origin_url, CefJSDialogHandler::JSDialogType dialog_type, const CefString& message_text, const CefString& default_prompt_text, CefRefPtr<CefJSDialogCallback> callback, bool& suppress_message )
852851
{
853852
// TODO: Provide a way to influence Javascript dialogs via Lua
854853
// e.g. addEventHandler("onClientBrowserDialog", browser, function(message, defaultText) continueBrowserDialog("My input") end)
@@ -892,7 +891,7 @@ bool CWebView::OnTooltip ( CefRefPtr<CefBrowser> browser, CefString& title )
892891
// Queue event to run on the main thread
893892
auto func = std::bind ( &CWebBrowserEventsInterface::Events_OnTooltip, m_pEventsInterface, UTF16ToMbUTF8 ( title ) );
894893
g_pCore->GetWebCore ()->AddEventToEventQueue ( func, this, "OnTooltip" );
895-
894+
896895
return true;
897896
}
898897

@@ -907,10 +906,10 @@ bool CWebView::OnConsoleMessage ( CefRefPtr<CefBrowser> browser, const CefString
907906
// Redirect console message to debug window (if development mode is enabled)
908907
if ( g_pCore->GetWebCore ()->IsTestModeEnabled () )
909908
{
910-
g_pCore->GetWebCore ()->AddEventToEventQueue ( [message, source]() {
911-
g_pCore->DebugPrintfColor ( "[BROWSER] Console: %s (%s)", 255, 0, 0, UTF16ToMbUTF8 ( message ).c_str (), UTF16ToMbUTF8 ( source ).c_str () );
909+
g_pCore->GetWebCore ()->AddEventToEventQueue ( [message, source]() {
910+
g_pCore->DebugPrintfColor ( "[BROWSER] Console: %s (%s)", 255, 0, 0, UTF16ToMbUTF8 ( message ).c_str (), UTF16ToMbUTF8 ( source ).c_str () );
912911
}, this, "OnConsoleMessage" );
913-
912+
914913
}
915914

916915
return true;

MTA10/core/CWebView.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class CWebView : public CWebViewInterface, private CefClient, private CefRenderH
5959

6060
bool SetProperty ( const SString& strKey, const SString& strValue );
6161
bool GetProperty ( const SString& strKey, SString& outProperty );
62-
62+
6363
void InjectMouseMove ( int iPosX, int iPosY );
6464
void InjectMouseDown ( eWebBrowserMouseButton mouseButton );
6565
void InjectMouseUp ( eWebBrowserMouseButton mouseButton );
@@ -75,7 +75,7 @@ class CWebView : public CWebViewInterface, private CefClient, private CefRenderH
7575

7676
bool GetFullPathFromLocal ( SString& strPath );
7777
bool VerifyFile ( const SString& strPath );
78-
78+
7979
virtual bool RegisterAjaxHandler ( const SString& strURL ) override;
8080
virtual bool UnregisterAjaxHandler ( const SString& strURL ) override;
8181
virtual bool HasAjaxHandler ( const SString& strURL );
@@ -109,7 +109,7 @@ class CWebView : public CWebViewInterface, private CefClient, private CefRenderH
109109
virtual void OnLoadStart ( CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame ) override;
110110
virtual void OnLoadEnd ( CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, int httpStatusCode ) override;
111111
virtual void OnLoadError ( CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefLoadHandler::ErrorCode errorCode, const CefString& errorText, const CefString& failedURL ) override;
112-
112+
113113
// CefRequestHandler methods
114114
virtual bool OnBeforeBrowse ( CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, bool isRedirect ) override;
115115
virtual CefRequestHandler::ReturnValue OnBeforeResourceLoad ( CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, CefRefPtr<CefRequestCallback> callback ) override;
@@ -120,7 +120,7 @@ class CWebView : public CWebViewInterface, private CefClient, private CefRenderH
120120
virtual void OnAfterCreated ( CefRefPtr<CefBrowser> browser) override;
121121

122122
// CefJSDialogHandler methods
123-
virtual bool OnJSDialog ( CefRefPtr<CefBrowser> browser, const CefString& origin_url, const CefString& accept_lang, CefJSDialogHandler::JSDialogType dialog_type, const CefString& message_text, const CefString& default_prompt_text, CefRefPtr< CefJSDialogCallback > callback, bool& suppress_message ) override;
123+
virtual bool OnJSDialog ( CefRefPtr<CefBrowser> browser, const CefString& origin_url, CefJSDialogHandler::JSDialogType dialog_type, const CefString& message_text, const CefString& default_prompt_text, CefRefPtr<CefJSDialogCallback> callback, bool& suppress_message ) override;
124124

125125
// CefDialogHandler methods
126126
virtual bool OnFileDialog ( CefRefPtr<CefBrowser> browser, CefDialogHandler::FileDialogMode mode, const CefString& title, const CefString& default_file_name, const std::vector< CefString >& accept_types, int selected_accept_filter, CefRefPtr< CefFileDialogCallback > callback ) override;
@@ -129,7 +129,7 @@ class CWebView : public CWebViewInterface, private CefClient, private CefRenderH
129129
virtual void OnTitleChange ( CefRefPtr<CefBrowser> browser, const CefString& title ) override;
130130
virtual bool OnTooltip ( CefRefPtr<CefBrowser> browser, CefString& text ) override;
131131
virtual bool OnConsoleMessage ( CefRefPtr<CefBrowser> browser, const CefString& message, const CefString& source, int line ) override;
132-
132+
133133
private:
134134
CefRefPtr<CefBrowser> m_pWebView;
135135
CWebBrowserItem* m_pWebBrowserRenderItem;

0 commit comments

Comments
 (0)