12
12
#include " CAjaxResourceHandler.h"
13
13
#include < cef3/include/cef_parser.h>
14
14
#include < cef3/include/cef_task.h>
15
+ #include < cef3/include/cef_runnable.h>
15
16
#include " CWebDevTools.h"
16
17
17
18
CWebView::CWebView ( unsigned int uiWidth, unsigned int uiHeight, bool bIsLocal, CWebBrowserItem* pWebBrowserRenderItem, bool bTransparent )
@@ -66,7 +67,7 @@ void CWebView::Initialise ()
66
67
67
68
CefWindowInfo windowInfo;
68
69
windowInfo.SetAsWindowless ( g_pCore->GetHookedWindow (), m_bIsTransparent );
69
-
70
+
70
71
CefBrowserHost::CreateBrowser ( windowInfo, this , " " , browserSettings, nullptr );
71
72
}
72
73
@@ -124,7 +125,7 @@ bool CWebView::LoadURL ( const SString& strURL, bool bFilterEnabled, const SStri
124
125
request->SetPostData ( postData );
125
126
pFrame->LoadRequest ( request );
126
127
}
127
-
128
+
128
129
return true ;
129
130
}
130
131
@@ -195,7 +196,7 @@ bool CWebView::SetProperty ( const SString& strKey, const SString& strValue )
195
196
{
196
197
if ( strKey == " mobile" && ( strValue == " 0" || strValue == " 1" ) )
197
198
{
198
-
199
+
199
200
}
200
201
else
201
202
return false ;
@@ -218,7 +219,7 @@ void CWebView::InjectMouseMove ( int iPosX, int iPosY )
218
219
{
219
220
if ( !m_pWebView )
220
221
return ;
221
-
222
+
222
223
CefMouseEvent mouseEvent;
223
224
mouseEvent.x = iPosX;
224
225
mouseEvent.y = iPosY;
@@ -241,7 +242,7 @@ void CWebView::InjectMouseDown ( eWebBrowserMouseButton mouseButton )
241
242
{
242
243
if ( !m_pWebView )
243
244
return ;
244
-
245
+
245
246
CefMouseEvent mouseEvent;
246
247
mouseEvent.x = m_vecMousePosition.x ;
247
248
mouseEvent.y = m_vecMousePosition.y ;
@@ -548,7 +549,7 @@ void CWebView::OnPaint ( CefRefPtr<CefBrowser> browser, CefRenderHandler::PaintE
548
549
auto sourceData = (const int*)buffer;
549
550
auto pitch = LockedRect.Pitch;
550
551
551
- for (auto& rect : dirtyRects)
552
+ for (auto& rect : dirtyRects)
552
553
{
553
554
for (int y = rect.y; y < rect.y+rect.height; ++y)
554
555
{
@@ -654,7 +655,7 @@ void CWebView::OnLoadEnd ( CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> fr
654
655
void CWebView::OnLoadError ( CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefLoadHandler::ErrorCode errorCode, const CefString& errorText, const CefString& failedURL )
655
656
{
656
657
SString strURL = UTF16ToMbUTF8 ( frame->GetURL () );
657
-
658
+
658
659
// Queue event to run on the main thread
659
660
auto func = std::bind ( &CWebBrowserEventsInterface::Events_OnLoadingFailed, m_pEventsInterface, strURL, errorCode, SString ( errorText ) );
660
661
g_pCore->GetWebCore ()->AddEventToEventQueue ( func, this , " OnLoadError" );
@@ -672,13 +673,13 @@ bool CWebView::OnBeforeBrowse ( CefRefPtr<CefBrowser> browser, CefRefPtr<CefFram
672
673
From documentation:
673
674
The |request| object cannot be modified in this callback.
674
675
CefLoadHandler::OnLoadingStateChange will be called twice in all cases. If the navigation is allowed CefLoadHandler::OnLoadStart and CefLoadHandler::OnLoadEnd will be called.
675
- If the navigation is canceled CefLoadHandler::OnLoadError will be called with an |errorCode| value of ERR_ABORTED.
676
+ If the navigation is canceled CefLoadHandler::OnLoadError will be called with an |errorCode| value of ERR_ABORTED.
676
677
*/
677
678
678
679
CefURLParts urlParts;
679
680
if ( !CefParseURL ( request->GetURL (), urlParts ) )
680
681
return true ; // Cancel if invalid URL (this line will normally not be executed)
681
-
682
+
682
683
bool bResult;
683
684
WString scheme = urlParts.scheme .str ;
684
685
if ( scheme == L" http" || scheme == L" https" )
@@ -796,7 +797,7 @@ void CWebView::OnBeforeClose ( CefRefPtr<CefBrowser> browser )
796
797
NotifyPaint ();
797
798
798
799
m_pWebView = nullptr ;
799
-
800
+
800
801
// Remove focused web view reference
801
802
if ( g_pCore->GetWebCore ()->GetFocusedWebView () == this )
802
803
g_pCore->GetWebCore ()->SetFocusedWebView ( nullptr );
@@ -811,11 +812,11 @@ void CWebView::OnBeforeClose ( CefRefPtr<CefBrowser> browser )
811
812
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 )
812
813
{
813
814
// ATTENTION: This method is called on the IO thread
814
-
815
+
815
816
// Trigger the popup/new tab event
816
817
SString strTagetURL = UTF16ToMbUTF8 ( target_url );
817
818
SString strOpenerURL = UTF16ToMbUTF8 ( frame->GetURL () );
818
-
819
+
819
820
// Queue event to run on the main thread
820
821
auto func = std::bind ( &CWebBrowserEventsInterface::Events_OnPopup, m_pEventsInterface, strTagetURL, strOpenerURL );
821
822
g_pCore->GetWebCore ()->AddEventToEventQueue ( func, this , " OnBeforePopup" );
@@ -847,7 +848,7 @@ void CWebView::OnAfterCreated ( CefRefPtr<CefBrowser> browser )
847
848
// http://magpcss.org/ceforum/apidocs3/projects/(default)/CefJSDialogHandler.html#OnJSDialog(CefRefPtr%3CCefBrowser%3E,constCefString&,constCefString&,JSDialogType,constCefString&,constCefString&,CefRefPtr%3CCefJSDialogCallback%3E,bool&) //
848
849
// //
849
850
// //////////////////////////////////////////////////////////////////
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 )
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 )
851
852
{
852
853
// TODO: Provide a way to influence Javascript dialogs via Lua
853
854
// e.g. addEventHandler("onClientBrowserDialog", browser, function(message, defaultText) continueBrowserDialog("My input") end)
@@ -891,7 +892,7 @@ bool CWebView::OnTooltip ( CefRefPtr<CefBrowser> browser, CefString& title )
891
892
// Queue event to run on the main thread
892
893
auto func = std::bind ( &CWebBrowserEventsInterface::Events_OnTooltip, m_pEventsInterface, UTF16ToMbUTF8 ( title ) );
893
894
g_pCore->GetWebCore ()->AddEventToEventQueue ( func, this , " OnTooltip" );
894
-
895
+
895
896
return true ;
896
897
}
897
898
@@ -906,10 +907,10 @@ bool CWebView::OnConsoleMessage ( CefRefPtr<CefBrowser> browser, const CefString
906
907
// Redirect console message to debug window (if development mode is enabled)
907
908
if ( g_pCore->GetWebCore ()->IsTestModeEnabled () )
908
909
{
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 () );
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 () );
911
912
}, this , " OnConsoleMessage" );
912
-
913
+
913
914
}
914
915
915
916
return true ;
0 commit comments