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