From 134cd72310b081340fd9eadbc353d2950651b51e Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 29 Aug 2023 23:18:06 +0200 Subject: [PATCH] Use C++11 keywords in wxWebView CEF backend Use "override" and "nullptr". --- include/wx/webview_chromium.h | 94 ++++++++++++++++----------------- src/common/webview_chromium.cpp | 68 ++++++++++++------------ 2 files changed, 81 insertions(+), 81 deletions(-) diff --git a/include/wx/webview_chromium.h b/include/wx/webview_chromium.h index 7d6c9b9371..48f419d879 100644 --- a/include/wx/webview_chromium.h +++ b/include/wx/webview_chromium.h @@ -49,75 +49,75 @@ public: const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, - const wxString& name = wxWebViewNameStr) wxOVERRIDE; + const wxString& name = wxWebViewNameStr) override; - virtual void LoadURL(const wxString& url) wxOVERRIDE; - virtual void LoadHistoryItem(wxSharedPtr item) wxOVERRIDE; - virtual wxVector > GetBackwardHistory() wxOVERRIDE; - virtual wxVector > GetForwardHistory() wxOVERRIDE; + virtual void LoadURL(const wxString& url) override; + virtual void LoadHistoryItem(wxSharedPtr item) override; + virtual wxVector > GetBackwardHistory() override; + virtual wxVector > GetForwardHistory() override; - virtual bool CanGoForward() const wxOVERRIDE; - virtual bool CanGoBack() const wxOVERRIDE; - virtual void GoBack() wxOVERRIDE; - virtual void GoForward() wxOVERRIDE; - virtual void ClearHistory() wxOVERRIDE; - virtual void EnableHistory(bool enable = true) wxOVERRIDE; - virtual void Stop() wxOVERRIDE; - virtual void Reload(wxWebViewReloadFlags flags = wxWEBVIEW_RELOAD_DEFAULT) wxOVERRIDE; + virtual bool CanGoForward() const override; + virtual bool CanGoBack() const override; + virtual void GoBack() override; + virtual void GoForward() override; + virtual void ClearHistory() override; + virtual void EnableHistory(bool enable = true) override; + virtual void Stop() override; + virtual void Reload(wxWebViewReloadFlags flags = wxWEBVIEW_RELOAD_DEFAULT) override; - virtual wxString GetPageSource() const wxOVERRIDE; - virtual wxString GetPageText() const wxOVERRIDE; + virtual wxString GetPageSource() const override; + virtual wxString GetPageText() const override; - virtual bool IsBusy() const wxOVERRIDE; - virtual wxString GetCurrentURL() const wxOVERRIDE; - virtual wxString GetCurrentTitle() const wxOVERRIDE; + virtual bool IsBusy() const override; + virtual wxString GetCurrentURL() const override; + virtual wxString GetCurrentTitle() const override; - virtual void SetZoomType(wxWebViewZoomType type) wxOVERRIDE; - virtual wxWebViewZoomType GetZoomType() const wxOVERRIDE; - virtual bool CanSetZoomType(wxWebViewZoomType type) const wxOVERRIDE; + virtual void SetZoomType(wxWebViewZoomType type) override; + virtual wxWebViewZoomType GetZoomType() const override; + virtual bool CanSetZoomType(wxWebViewZoomType type) const override; - virtual void Print() wxOVERRIDE; + virtual void Print() override; - virtual wxWebViewZoom GetZoom() const wxOVERRIDE; - virtual void SetZoom(wxWebViewZoom zoom) wxOVERRIDE; + virtual wxWebViewZoom GetZoom() const override; + virtual void SetZoom(wxWebViewZoom zoom) override; - virtual void* GetNativeBackend() const wxOVERRIDE; + virtual void* GetNativeBackend() const override; - virtual long Find(const wxString& WXUNUSED(text), int WXUNUSED(flags) = wxWEBVIEW_FIND_DEFAULT) wxOVERRIDE { return wxNOT_FOUND; } + virtual long Find(const wxString& WXUNUSED(text), int WXUNUSED(flags) = wxWEBVIEW_FIND_DEFAULT) override { return wxNOT_FOUND; } //Clipboard functions - virtual bool CanCut() const wxOVERRIDE { return true; } - virtual bool CanCopy() const wxOVERRIDE { return true; } - virtual bool CanPaste() const wxOVERRIDE { return true; } - virtual void Cut() wxOVERRIDE; - virtual void Copy() wxOVERRIDE; - virtual void Paste() wxOVERRIDE; + virtual bool CanCut() const override { return true; } + virtual bool CanCopy() const override { return true; } + virtual bool CanPaste() const override { return true; } + virtual void Cut() override; + virtual void Copy() override; + virtual void Paste() override; //Undo / redo functionality - virtual bool CanUndo() const wxOVERRIDE { return true; } - virtual bool CanRedo() const wxOVERRIDE { return true; } - virtual void Undo() wxOVERRIDE; - virtual void Redo() wxOVERRIDE; + virtual bool CanUndo() const override { return true; } + virtual bool CanRedo() const override { return true; } + virtual void Undo() override; + virtual void Redo() override; //Editing functions - virtual void SetEditable(bool enable = true) wxOVERRIDE; - virtual bool IsEditable() const wxOVERRIDE { return false; } + virtual void SetEditable(bool enable = true) override; + virtual bool IsEditable() const override { return false; } //Selection - virtual void SelectAll() wxOVERRIDE; - virtual bool HasSelection() const wxOVERRIDE { return false; } - virtual void DeleteSelection() wxOVERRIDE; - virtual wxString GetSelectedText() const wxOVERRIDE { return ""; } - virtual wxString GetSelectedSource() const wxOVERRIDE { return ""; } - virtual void ClearSelection() wxOVERRIDE; + virtual void SelectAll() override; + virtual bool HasSelection() const override { return false; } + virtual void DeleteSelection() override; + virtual wxString GetSelectedText() const override { return ""; } + virtual wxString GetSelectedSource() const override { return ""; } + virtual void ClearSelection() override; - virtual bool RunScript(const wxString& javascript, wxString* output = NULL) wxOVERRIDE; + virtual bool RunScript(const wxString& javascript, wxString* output = nullptr) override; //Virtual Filesystem Support - virtual void RegisterHandler(wxSharedPtr handler) wxOVERRIDE; + virtual void RegisterHandler(wxSharedPtr handler) override; protected: - virtual void DoSetPage(const wxString& html, const wxString& baseUrl) wxOVERRIDE; + virtual void DoSetPage(const wxString& html, const wxString& baseUrl) override; private: //History related variables, we currently use our own implementation diff --git a/src/common/webview_chromium.cpp b/src/common/webview_chromium.cpp index e60bbb35d0..8df5b59457 100644 --- a/src/common/webview_chromium.cpp +++ b/src/common/webview_chromium.cpp @@ -69,38 +69,38 @@ public: ClientHandler() : m_loadErrorCode(-1) {} virtual ~ClientHandler() {} - virtual CefRefPtr GetContextMenuHandler() wxOVERRIDE { return this; } - virtual CefRefPtr GetLifeSpanHandler() wxOVERRIDE { return this; } - virtual CefRefPtr GetLoadHandler() wxOVERRIDE { return this; } - virtual CefRefPtr GetDisplayHandler() wxOVERRIDE { return this; } + virtual CefRefPtr GetContextMenuHandler() override { return this; } + virtual CefRefPtr GetLifeSpanHandler() override { return this; } + virtual CefRefPtr GetLoadHandler() override { return this; } + virtual CefRefPtr GetDisplayHandler() override { return this; } // CefDisplayHandler methods virtual void OnLoadingStateChange(CefRefPtr browser, bool isLoading, bool canGoBack, - bool canGoForward) wxOVERRIDE; + bool canGoForward) override; virtual void OnAddressChange(CefRefPtr browser, CefRefPtr frame, - const CefString& url) wxOVERRIDE; + const CefString& url) override; virtual void OnTitleChange(CefRefPtr browser, - const CefString& title) wxOVERRIDE; + const CefString& title) override; virtual bool OnConsoleMessage(CefRefPtr browser, cef_log_severity_t level, const CefString& message, const CefString& source, - int line) wxOVERRIDE; + int line) override; // CefContextMenuHandler methods virtual void OnBeforeContextMenu(CefRefPtr browser, CefRefPtr frame, CefRefPtr params, - CefRefPtr model) wxOVERRIDE; + CefRefPtr model) override; virtual bool OnContextMenuCommand(CefRefPtr browser, CefRefPtr frame, CefRefPtr params, int command_id, - CefContextMenuHandler::EventFlags event_flags) wxOVERRIDE; + CefContextMenuHandler::EventFlags event_flags) override; virtual void OnContextMenuDismissed(CefRefPtr browser, - CefRefPtr frame) wxOVERRIDE; + CefRefPtr frame) override; // CefLifeSpanHandler methods virtual bool OnBeforePopup(CefRefPtr browser, @@ -113,23 +113,23 @@ public: CefWindowInfo& windowInfo, CefRefPtr& client, CefBrowserSettings& settings, - bool* no_javascript_access) wxOVERRIDE; - virtual void OnAfterCreated(CefRefPtr browser) wxOVERRIDE; - virtual bool DoClose(CefRefPtr browser) wxOVERRIDE; - virtual void OnBeforeClose(CefRefPtr browser) wxOVERRIDE; + bool* no_javascript_access) override; + virtual void OnAfterCreated(CefRefPtr browser) override; + virtual bool DoClose(CefRefPtr browser) override; + virtual void OnBeforeClose(CefRefPtr browser) override; // CefLoadHandler methods virtual void OnLoadStart(CefRefPtr browser, CefRefPtr frame, - TransitionType transition_type) wxOVERRIDE; + TransitionType transition_type) override; virtual void OnLoadEnd(CefRefPtr browser, CefRefPtr frame, - int httpStatusCode) wxOVERRIDE; + int httpStatusCode) override; virtual void OnLoadError(CefRefPtr browser, CefRefPtr frame, ErrorCode errorCode, const CefString& errorText, - const CefString& failedUrl) wxOVERRIDE; + const CefString& failedUrl) override; CefRefPtr GetBrowser() { return m_browser; } @@ -152,15 +152,15 @@ public: // CefResourceHandler methods virtual bool ProcessRequest(CefRefPtr request, - CefRefPtr callback) wxOVERRIDE; + CefRefPtr callback) override; virtual void GetResponseHeaders(CefRefPtr response, int64& response_length, - CefString& redirectUrl) wxOVERRIDE; + CefString& redirectUrl) override; virtual bool ReadResponse(void* data_out, int bytes_to_read, int& bytes_read, - CefRefPtr callback) wxOVERRIDE; - virtual void Cancel() wxOVERRIDE {} + CefRefPtr callback) override; + virtual void Cancel() override {} private: wxSharedPtr m_handler; @@ -181,7 +181,7 @@ public: virtual CefRefPtr Create(CefRefPtr WXUNUSED(browser), CefRefPtr WXUNUSED(frame), const CefString& WXUNUSED(scheme_name), - CefRefPtr WXUNUSED(request)) wxOVERRIDE + CefRefPtr WXUNUSED(request)) override { return new SchemeHandler(m_handler); } @@ -201,7 +201,7 @@ public: }; wxStringVisitor(wxWebViewChromium* webview, StringType type) : m_type(type), m_webview(webview) {} - void Visit(const CefString& string) wxOVERRIDE + void Visit(const CefString& string) override { switch(m_type) { @@ -263,12 +263,12 @@ bool wxWebViewChromium::Create(wxWindow* parent, #endif #ifdef __WXGTK__ - m_widget = gtk_scrolled_window_new( NULL, NULL ); + m_widget = gtk_scrolled_window_new( nullptr, nullptr ); g_object_ref( m_widget ); GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW( m_widget ); // Hide the scroll bar. gtk_scrolled_window_set_policy( scrolled_window, GTK_POLICY_NEVER, GTK_POLICY_NEVER); - GtkWidget* view_port = gtk_viewport_new( NULL, NULL ); + GtkWidget* view_port = gtk_viewport_new( nullptr, nullptr ); gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(scrolled_window), view_port ); // TODO: figure out correct parameters for Linux SetAsChild() call @@ -286,7 +286,7 @@ bool wxWebViewChromium::Create(wxWindow* parent, #endif CefBrowserHost::CreateBrowser(info, static_cast >(m_clientHandler), - url.ToStdString(), browsersettings, NULL); + url.ToStdString(), browsersettings, nullptr); this->Bind(wxEVT_SIZE, &wxWebViewChromium::OnSize, this); @@ -308,7 +308,7 @@ wxWebViewChromium::~wxWebViewChromium() if (m_clientHandler) { m_clientHandler->Release(); - m_clientHandler = NULL; + m_clientHandler = nullptr; } } @@ -343,7 +343,7 @@ bool wxWebViewChromium::InitCEF() wxAppConsole* app = wxApp::GetInstance(); CefMainArgs args(app->argc, app->argv); #endif - if (CefInitialize(args, settings, NULL, NULL)) + if (CefInitialize(args, settings, nullptr, nullptr)) { ms_cefInitialized = true; return true; @@ -383,7 +383,7 @@ void wxWebViewChromium::OnSize(wxSizeEvent& event) if ( handle ) { HDWP hdwp = BeginDeferWindowPos(1); - hdwp = DeferWindowPos(hdwp, handle, NULL, 0, 0, + hdwp = DeferWindowPos(hdwp, handle, nullptr, 0, 0, size.GetWidth(), size.GetHeight(), SWP_NOZORDER); EndDeferWindowPos(hdwp); } @@ -772,7 +772,7 @@ void ClientHandler::OnBeforeClose(CefRefPtr browser) { if ( browser->GetIdentifier() == m_browserId ) { - m_browser = NULL; + m_browser = nullptr; } } @@ -995,7 +995,7 @@ class wxWebViewChromiumModule : public wxModule { public: wxWebViewChromiumModule() { } - virtual bool OnInit() wxOVERRIDE + virtual bool OnInit() override { m_isHelperProcess = false; #ifdef __WXMSW__ @@ -1005,7 +1005,7 @@ public: CefMainArgs args(app->argc, app->argv); #endif // If there is no subprocess then we need to execute on this process - int code = CefExecuteProcess(args, NULL, NULL); + int code = CefExecuteProcess(args, nullptr, nullptr); if (code >= 0) { m_isHelperProcess = true; @@ -1022,7 +1022,7 @@ public: #endif return true; }; - virtual void OnExit() wxOVERRIDE + virtual void OnExit() override { if (m_isHelperProcess) return;