From 2bff4b2d17037540b68e0c1336efeb136175a2a0 Mon Sep 17 00:00:00 2001 From: Kirill Burtsev Date: Tue, 30 Nov 2021 13:01:39 +0100 Subject: Cleanup code and clang build warnings Fix build noise as reported by clang for issues like api deprecation, unused variables, sign/unsigned mismatch and other non critical issues. Change-Id: I4fba25406eea8170e3283c42e908ae86bd512e3a Reviewed-by: Allan Sandfeld Jensen (cherry picked from commit 02d58a067fb5f0db32c254e783170f9f283aeb9d) Reviewed-by: Michal Klocek --- src/core/api/qwebenginehttprequest.cpp | 8 ++++---- src/core/api/qwebenginepage.cpp | 2 -- src/core/compositor/display_gl_output_surface.cpp | 2 +- src/core/content_browser_client_qt.cpp | 9 ++++----- src/core/content_client_qt.cpp | 4 ---- src/core/delegated_frame_host_client_qt.h | 2 +- ...lugin_response_interceptor_url_loader_throttle.cpp | 3 +-- .../plugin_response_interceptor_url_loader_throttle.h | 4 +--- .../net/proxying_restricted_cookie_manager_qt.cpp | 18 ++---------------- src/core/net/proxying_restricted_cookie_manager_qt.h | 14 +------------- .../render_widget_host_view_qt_delegate_client.cpp | 6 +++--- src/core/renderer/content_renderer_client_qt.cpp | 2 -- .../extensions/extensions_renderer_client_qt.cpp | 1 - src/core/tools/main.cpp | 1 - src/core/web_contents_adapter.cpp | 2 -- src/core/web_engine_error.cpp | 2 -- tests/auto/core/origins/tst_origins.cpp | 5 +++-- tests/auto/quick/qmltests/tst_qmltests.cpp | 19 +++++++------------ .../widgets/qwebenginescript/tst_qwebenginescript.cpp | 2 +- .../widgets/qwebengineview/tst_qwebengineview.cpp | 6 +++--- 20 files changed, 32 insertions(+), 80 deletions(-) diff --git a/src/core/api/qwebenginehttprequest.cpp b/src/core/api/qwebenginehttprequest.cpp index f5733cde4..d199bff1d 100644 --- a/src/core/api/qwebenginehttprequest.cpp +++ b/src/core/api/qwebenginehttprequest.cpp @@ -182,16 +182,16 @@ QWebEngineHttpRequest QWebEngineHttpRequest::postRequest(const QUrl &url, QWebEngineHttpRequest result(url); result.setMethod(QWebEngineHttpRequest::Post); - QString buffer; + QByteArray buffer; for (QMap::const_iterator it = postData.begin(); it != postData.end(); it++) { QByteArray key = QUrl::toPercentEncoding(it.key()); QByteArray value = QUrl::toPercentEncoding(it.value()); if (buffer.length() > 0) - buffer += QLatin1Char('&'); - buffer += key + QLatin1Char('=') + value; + buffer += '&'; + buffer.append(key).append('=').append(value); } - result.setPostData(buffer.toLatin1()); + result.setPostData(buffer); result.setHeader(QByteArrayLiteral("Content-Type"), QByteArrayLiteral("application/x-www-form-urlencoded")); diff --git a/src/core/api/qwebenginepage.cpp b/src/core/api/qwebenginepage.cpp index 758bf3905..8e03aea0d 100644 --- a/src/core/api/qwebenginepage.cpp +++ b/src/core/api/qwebenginepage.cpp @@ -456,8 +456,6 @@ void QWebEnginePagePrivate::didFetchDocumentInnerText(quint64 requestId, const Q void QWebEnginePagePrivate::didPrintPage(quint64 requestId, QSharedPointer result) { #if QT_CONFIG(webengine_printing_and_pdf) - Q_Q(QWebEnginePage); - // If no currentPrinter is set that means that were printing to PDF only. if (!currentPrinter) { if (!result.data()) diff --git a/src/core/compositor/display_gl_output_surface.cpp b/src/core/compositor/display_gl_output_surface.cpp index dfc3cb7c6..1a6e6cf72 100644 --- a/src/core/compositor/display_gl_output_surface.cpp +++ b/src/core/compositor/display_gl_output_surface.cpp @@ -231,7 +231,7 @@ void DisplayGLOutputSurface::swapBuffersOnVizThread() } const auto now = base::TimeTicks::Now(); - m_client->DidReceiveSwapBuffersAck(gfx::SwapTimings{now, now}); + m_client->DidReceiveSwapBuffersAck(gfx::SwapTimings{now, now, {}, {}}); m_client->DidReceivePresentationFeedback( gfx::PresentationFeedback(now, base::TimeDelta(), gfx::PresentationFeedback::Flags::kVSync)); diff --git a/src/core/content_browser_client_qt.cpp b/src/core/content_browser_client_qt.cpp index 9c6787340..9a7014c16 100644 --- a/src/core/content_browser_client_qt.cpp +++ b/src/core/content_browser_client_qt.cpp @@ -618,9 +618,9 @@ bool ContentBrowserClientQt::WillCreateRestrictedCookieManager(network::mojom::R content::BrowserContext *browser_context, const url::Origin & /*origin*/, const net::IsolationInfo & /*isolation_info*/, - bool is_service_worker, - int process_id, - int routing_id, + bool /*is_service_worker*/, + int /*process_id*/, + int /*routing_id*/, mojo::PendingReceiver *receiver) { mojo::PendingReceiver orig_receiver = std::move(*receiver); @@ -631,7 +631,6 @@ bool ContentBrowserClientQt::WillCreateRestrictedCookieManager(network::mojom::R ProxyingRestrictedCookieManagerQt::CreateAndBind( ProfileIODataQt::FromBrowserContext(browser_context), std::move(target_rcm_remote), - is_service_worker, process_id, routing_id, std::move(orig_receiver)); return false; // only made a proxy, still need the actual impl to be made. @@ -786,7 +785,7 @@ ContentBrowserClientQt::CreateURLLoaderThrottles( ProtocolHandlerRegistryFactory::GetForBrowserContext(browser_context))); #if BUILDFLAG(ENABLE_EXTENSIONS) result.push_back(std::make_unique( - browser_context, request.destination, frame_tree_node_id)); + request.destination, frame_tree_node_id)); #endif return result; } diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp index e06cde63d..1bd9edd27 100644 --- a/src/core/content_client_qt.cpp +++ b/src/core/content_client_qt.cpp @@ -134,10 +134,6 @@ static QString getProgramFilesDir(bool x86Dir = false) #include "content/public/common/pepper_plugin_info.h" #include "ppapi/shared_impl/ppapi_permissions.h" -namespace switches { -const char kPpapiWidevinePath[] = "ppapi-widevine-path"; -} - static QString ppapiPluginsPath() { // Look for plugins in /plugins/ppapi or application dir. diff --git a/src/core/delegated_frame_host_client_qt.h b/src/core/delegated_frame_host_client_qt.h index f9bc99d24..89cd3700c 100644 --- a/src/core/delegated_frame_host_client_qt.h +++ b/src/core/delegated_frame_host_client_qt.h @@ -40,7 +40,7 @@ #ifndef DELEGATED_FRAME_HOST_CLIENT_QT_H #define DELEGATED_FRAME_HOST_CLIENT_QT_H -#include "qtwebenginecoreglobal_p.h" +#include #include "content/browser/renderer_host/delegated_frame_host.h" #include "content/browser/renderer_host/render_widget_host_impl.h" diff --git a/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp b/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp index d66e69ef4..0fc518a9b 100644 --- a/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp +++ b/src/core/net/plugin_response_interceptor_url_loader_throttle.cpp @@ -68,10 +68,9 @@ namespace QtWebEngineCore { PluginResponseInterceptorURLLoaderThrottle::PluginResponseInterceptorURLLoaderThrottle( - content::BrowserContext *browser_context, network::mojom::RequestDestination request_destination, int frame_tree_node_id) - : m_browser_context(browser_context), m_request_destination(request_destination), m_frame_tree_node_id(frame_tree_node_id) + : m_request_destination(request_destination), m_frame_tree_node_id(frame_tree_node_id) {} void PluginResponseInterceptorURLLoaderThrottle::WillProcessResponse(const GURL &response_url, diff --git a/src/core/net/plugin_response_interceptor_url_loader_throttle.h b/src/core/net/plugin_response_interceptor_url_loader_throttle.h index 0e10b2124..d4ff87846 100644 --- a/src/core/net/plugin_response_interceptor_url_loader_throttle.h +++ b/src/core/net/plugin_response_interceptor_url_loader_throttle.h @@ -54,8 +54,7 @@ namespace QtWebEngineCore { class PluginResponseInterceptorURLLoaderThrottle : public blink::URLLoaderThrottle { public: - PluginResponseInterceptorURLLoaderThrottle(content::BrowserContext *browser_context, - network::mojom::RequestDestination request_destination, + PluginResponseInterceptorURLLoaderThrottle(network::mojom::RequestDestination request_destination, int frame_tree_node_id); ~PluginResponseInterceptorURLLoaderThrottle() override = default; @@ -67,7 +66,6 @@ private: // layer chance to initialize its browser side state. void ResumeLoad(); - content::BrowserContext *m_browser_context = nullptr; const network::mojom::RequestDestination m_request_destination; const int m_frame_tree_node_id; diff --git a/src/core/net/proxying_restricted_cookie_manager_qt.cpp b/src/core/net/proxying_restricted_cookie_manager_qt.cpp index f86c0e997..f66a4c1a7 100644 --- a/src/core/net/proxying_restricted_cookie_manager_qt.cpp +++ b/src/core/net/proxying_restricted_cookie_manager_qt.cpp @@ -61,9 +61,6 @@ namespace QtWebEngineCore { // static void ProxyingRestrictedCookieManagerQt::CreateAndBind(ProfileIODataQt *profileIoData, mojo::PendingRemote underlying_rcm, - bool is_service_worker, - int process_id, - int frame_id, mojo::PendingReceiver receiver) { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); @@ -72,7 +69,6 @@ void ProxyingRestrictedCookieManagerQt::CreateAndBind(ProfileIODataQt *profileIo base::BindOnce(&ProxyingRestrictedCookieManagerQt::CreateAndBindOnIoThread, profileIoData, std::move(underlying_rcm), - is_service_worker, process_id, frame_id, std::move(receiver))); } @@ -80,31 +76,21 @@ void ProxyingRestrictedCookieManagerQt::CreateAndBind(ProfileIODataQt *profileIo // static void ProxyingRestrictedCookieManagerQt::CreateAndBindOnIoThread(ProfileIODataQt *profileIoData, mojo::PendingRemote underlying_rcm, - bool is_service_worker, - int process_id, - int frame_id, mojo::PendingReceiver receiver) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); auto wrapper = base::WrapUnique(new ProxyingRestrictedCookieManagerQt( profileIoData->getWeakPtrOnIOThread(), - std::move(underlying_rcm), - is_service_worker, process_id, frame_id)); + std::move(underlying_rcm))); mojo::MakeSelfOwnedReceiver(std::move(wrapper), std::move(receiver)); } ProxyingRestrictedCookieManagerQt::ProxyingRestrictedCookieManagerQt( base::WeakPtr profileIoData, - mojo::PendingRemote underlyingRestrictedCookieManager, - bool is_service_worker, - int32_t process_id, - int32_t frame_id) + mojo::PendingRemote underlyingRestrictedCookieManager) : m_profileIoData(std::move(profileIoData)) , underlying_restricted_cookie_manager_(std::move(underlyingRestrictedCookieManager)) - , is_service_worker_(is_service_worker) - , process_id_(process_id) - , frame_id_(frame_id) , weak_factory_(this) { DCHECK_CURRENTLY_ON(content::BrowserThread::IO); diff --git a/src/core/net/proxying_restricted_cookie_manager_qt.h b/src/core/net/proxying_restricted_cookie_manager_qt.h index 3d4765b3b..37271dfd3 100644 --- a/src/core/net/proxying_restricted_cookie_manager_qt.h +++ b/src/core/net/proxying_restricted_cookie_manager_qt.h @@ -56,9 +56,6 @@ public: // Expects to be called on the UI thread. static void CreateAndBind(ProfileIODataQt *profileIoData, mojo::PendingRemote underlying_rcm, - bool is_service_worker, - int process_id, - int frame_id, mojo::PendingReceiver receiver); ~ProxyingRestrictedCookieManagerQt() override; @@ -98,24 +95,15 @@ public: private: ProxyingRestrictedCookieManagerQt(base::WeakPtr profileIoData, - mojo::PendingRemote underlying_rcm, - bool is_service_worker, - int32_t process_id, - int32_t frame_id); + mojo::PendingRemote underlying_rcm); static void CreateAndBindOnIoThread(ProfileIODataQt *profileIoData, mojo::PendingRemote underlying_rcm, - bool is_service_worker, - int process_id, - int frame_id, mojo::PendingReceiver receiver); base::WeakPtr m_profileIoData; mojo::Remote underlying_restricted_cookie_manager_; - bool is_service_worker_; - int process_id_; - int frame_id_; base::WeakPtrFactory weak_factory_; diff --git a/src/core/render_widget_host_view_qt_delegate_client.cpp b/src/core/render_widget_host_view_qt_delegate_client.cpp index d28e789ee..0a93a6082 100644 --- a/src/core/render_widget_host_view_qt_delegate_client.cpp +++ b/src/core/render_widget_host_view_qt_delegate_client.cpp @@ -589,13 +589,13 @@ void RenderWidgetHostViewQtDelegateClient::handleTouchEvent(QTouchEvent *event) // Check first if the touch event should be routed to the selectionController if (!touchPoints.isEmpty()) { switch (touchPoints[0].second.state()) { - case Qt::TouchPointPressed: + case QEventPoint::Pressed: action = ui::MotionEvent::Action::DOWN; break; - case Qt::TouchPointMoved: + case QEventPoint::Updated: action = ui::MotionEvent::Action::MOVE; break; - case Qt::TouchPointReleased: + case QEventPoint::Released: action = ui::MotionEvent::Action::UP; break; default: diff --git a/src/core/renderer/content_renderer_client_qt.cpp b/src/core/renderer/content_renderer_client_qt.cpp index f52c17dcf..18b07637e 100644 --- a/src/core/renderer/content_renderer_client_qt.cpp +++ b/src/core/renderer/content_renderer_client_qt.cpp @@ -120,8 +120,6 @@ namespace QtWebEngineCore { -static const char kHttpErrorDomain[] = "http"; - ContentRendererClientQt::ContentRendererClientQt() { #if BUILDFLAG(ENABLE_EXTENSIONS) diff --git a/src/core/renderer/extensions/extensions_renderer_client_qt.cpp b/src/core/renderer/extensions/extensions_renderer_client_qt.cpp index b1998e027..6bd0fd5ec 100644 --- a/src/core/renderer/extensions/extensions_renderer_client_qt.cpp +++ b/src/core/renderer/extensions/extensions_renderer_client_qt.cpp @@ -70,7 +70,6 @@ namespace chrome { const char kExtensionInvalidRequestURL[] = "chrome-extension://invalid/"; -const char kExtensionResourceInvalidRequestURL[] = "chrome-extension-resource://invalid/"; } namespace QtWebEngineCore { diff --git a/src/core/tools/main.cpp b/src/core/tools/main.cpp index a977fc22d..2a71943c8 100644 --- a/src/core/tools/main.cpp +++ b/src/core/tools/main.cpp @@ -194,7 +194,6 @@ int main(int argc, char *argv[]) } #endif // USE_ICU_FILE - base::AtExitManager exit_manager; base::i18n::InitializeICU(); base::FilePath file_in_path = toFilePath(argv[1]); diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 0a83b248f..5c79bf654 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -132,8 +132,6 @@ namespace QtWebEngineCore { return; \ } -static const int kTestWindowWidth = 800; -static const int kTestWindowHeight = 600; static const int kHistoryStreamVersion = 4; static QVariant fromJSValue(const base::Value *result) diff --git a/src/core/web_engine_error.cpp b/src/core/web_engine_error.cpp index 0d326473b..52a84494c 100644 --- a/src/core/web_engine_error.cpp +++ b/src/core/web_engine_error.cpp @@ -44,12 +44,10 @@ const int WebEngineError::UserAbortedError = net::ERR_ABORTED; namespace { const int noError = 0; -const int systemRelatedErrors = -1; const int connectionRelatedErrors = -100; const int certificateErrors = -200; const int httpErrors = -300; const int cacheErrors = -400; -const int internalErrors = -500; const int ftpErrors = -600; const int certificateManagerErrors = -700; const int dnsResolverErrors = -800; diff --git a/tests/auto/core/origins/tst_origins.cpp b/tests/auto/core/origins/tst_origins.cpp index 08f9d097f..478ca7ba9 100644 --- a/tests/auto/core/origins/tst_origins.cpp +++ b/tests/auto/core/origins/tst_origins.cpp @@ -200,8 +200,9 @@ private: if (url.path().startsWith("/qtwebchannel/")) pathPrefix = QSL(":"); QString pathSuffix = url.path(); - QFile *file = new QFile(pathPrefix + pathSuffix, job); + auto file = std::make_unique(pathPrefix + pathSuffix, job); if (!file->open(QIODevice::ReadOnly)) { + qWarning() << "Failed to read data for:" << url << file->errorString(); job->fail(QWebEngineUrlRequestJob::RequestFailed); return; } @@ -210,7 +211,7 @@ private: mimeType = QBAL("application/javascript"); else if (pathSuffix.endsWith(QSL(".css"))) mimeType = QBAL("text/css"); - job->reply(mimeType, file); + job->reply(mimeType, file.release()); } QList m_requests; diff --git a/tests/auto/quick/qmltests/tst_qmltests.cpp b/tests/auto/quick/qmltests/tst_qmltests.cpp index 78c167106..8bd7cedc8 100644 --- a/tests/auto/quick/qmltests/tst_qmltests.cpp +++ b/tests/auto/quick/qmltests/tst_qmltests.cpp @@ -251,22 +251,17 @@ int main(int argc, char **argv) sigaction(SIGSEGV, &sigAction, 0); #endif - QScopedPointer app; + QtWebEngineQuick::initialize(); // Force to use English language for testing due to error message checks QLocale::setDefault(QLocale("en")); static QByteArrayList params = {QByteArrayLiteral("--use-fake-device-for-media-stream")}; - QList w_argv(argc); \ - for (int i = 0; i < argc; ++i) \ - w_argv[i] = argv[i]; \ - for (int i = 0; i < params.size(); ++i) \ - w_argv.append(params[i].data()); \ - int w_argc = w_argv.size(); \ - - if (!QCoreApplication::instance()) { - app.reset(new Application(w_argc, const_cast(w_argv.data()))); - } - QtWebEngineQuick::initialize(); + QList w_argv(argc); + for (int i = 0; i < argc; ++i) w_argv[i] = argv[i]; + for (int i = 0; i < params.size(); ++i) w_argv.append(params[i].data()); + int w_argc = w_argv.size(); + Application app(w_argc, const_cast(w_argv.data())); + QQuickWebEngineProfile::defaultProfile()->setOffTheRecord(true); qmlRegisterType("Test.util", 1, 0, "TempDir"); qmlRegisterType("Test.util", 1, 0, "TestInputContext"); diff --git a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp index 5df9f035f..26ba71ae3 100644 --- a/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp +++ b/tests/auto/widgets/qwebenginescript/tst_qwebenginescript.cpp @@ -218,7 +218,7 @@ void tst_QWebEngineScript::loadEvents() // Using window.open from JS QVERIFY(profile.pages.size() == 1); page.load(QUrl("qrc:/resources/test_window_open.html")); - QTRY_COMPARE(profile.pages.size(), 2); + QTRY_COMPARE(profile.pages.size(), 2u); QTRY_COMPARE(profile.pages.front().spy.count(), 1); QTRY_COMPARE(profile.pages.back().spy.count(), 1); QVERIFY(verifyOrder(profile.pages.front().eval("window.log", QWebEngineScript::MainWorld).toStringList())); diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp index d589ba311..388cd3c96 100644 --- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp +++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp @@ -592,6 +592,7 @@ void tst_QWebEngineView::focusInputTypes() class KeyEventRecordingWidget : public QWidget { public: + ~KeyEventRecordingWidget() { qDeleteAll(pressEvents); qDeleteAll(releaseEvents); } QList pressEvents; QList releaseEvents; void keyPressEvent(QKeyEvent *e) override { pressEvents << e->clone(); } @@ -1676,11 +1677,10 @@ void tst_QWebEngineView::postData() void tst_QWebEngineView::inputFieldOverridesShortcuts() { + QWebEngineView view; bool actionTriggered = false; - QAction *action = new QAction; + QAction *action = new QAction(&view); connect(action, &QAction::triggered, [&actionTriggered] () { actionTriggered = true; }); - - QWebEngineView view; view.addAction(action); QSignalSpy loadFinishedSpy(&view, SIGNAL(loadFinished(bool))); -- cgit v1.2.3