diff options
author | Jüri Valdmann <juri.valdmann@qt.io> | 2018-06-04 12:08:57 +0200 |
---|---|---|
committer | Jüri Valdmann <juri.valdmann@qt.io> | 2018-06-06 06:10:38 +0000 |
commit | 542c5b698cb9586aac48cc4dda66a6a2f98c905e (patch) | |
tree | edfdde1de98e132e6cb7bf4445638ed8f7ce8f3a /src/core | |
parent | 6cd3360c4d5283893eeb1efe43e329073709b48c (diff) |
Use range-based for instead of Q_FOREACH
Change-Id: Ibf016b795ff98fddfa29fb5dc63924a2d2159d71
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/api/qwebenginecookiestore.cpp | 2 | ||||
-rw-r--r-- | src/core/browser_context_adapter.cpp | 6 | ||||
-rw-r--r-- | src/core/clipboard_qt.cpp | 3 | ||||
-rw-r--r-- | src/core/content_client_qt.cpp | 5 | ||||
-rw-r--r-- | src/core/delegated_frame_node.cpp | 8 | ||||
-rw-r--r-- | src/core/download_manager_delegate_qt.cpp | 6 | ||||
-rw-r--r-- | src/core/file_picker_controller.cpp | 7 | ||||
-rw-r--r-- | src/core/location_provider_qt.cpp | 3 | ||||
-rw-r--r-- | src/core/permission_manager_qt.cpp | 2 | ||||
-rw-r--r-- | src/core/profile_io_data_qt.cpp | 6 | ||||
-rw-r--r-- | src/core/renderer/user_resource_controller.cpp | 6 | ||||
-rw-r--r-- | src/core/renderer_host/user_resource_controller_host.cpp | 13 | ||||
-rw-r--r-- | src/core/type_conversion.h | 2 | ||||
-rw-r--r-- | src/core/web_contents_adapter.cpp | 3 | ||||
-rw-r--r-- | src/core/web_engine_library_info.cpp | 4 | ||||
-rw-r--r-- | src/core/web_engine_settings.cpp | 4 |
16 files changed, 43 insertions, 37 deletions
diff --git a/src/core/api/qwebenginecookiestore.cpp b/src/core/api/qwebenginecookiestore.cpp index 5fcd46064..21610e334 100644 --- a/src/core/api/qwebenginecookiestore.cpp +++ b/src/core/api/qwebenginecookiestore.cpp @@ -94,7 +94,7 @@ void QWebEngineCookieStorePrivate::processPendingUserCookies() if (m_pendingUserCookies.isEmpty()) return; - Q_FOREACH (const auto &cookieData, m_pendingUserCookies) { + for (const CookieData &cookieData : qAsConst(m_pendingUserCookies)) { if (cookieData.callbackId == CallbackDirectory::DeleteCookieCallbackId) delegate->deleteCookie(cookieData.cookie, cookieData.origin); else diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp index 2aeb8c5bf..4715451f2 100644 --- a/src/core/browser_context_adapter.cpp +++ b/src/core/browser_context_adapter.cpp @@ -293,7 +293,7 @@ void BrowserContextAdapter::setHttpUserAgent(const QString &userAgent) m_httpUserAgent = userAgent.simplified(); std::vector<content::WebContentsImpl *> list = content::WebContentsImpl::GetAllWebContents(); - Q_FOREACH (content::WebContentsImpl *web_contents, list) + for (content::WebContentsImpl *web_contents : list) if (web_contents->GetBrowserContext() == m_browserContext.data()) web_contents->SetUserAgentOverride(m_httpUserAgent.toStdString()); @@ -466,7 +466,7 @@ QString BrowserContextAdapter::httpAcceptLanguageWithoutQualities() const { const QStringList list = m_httpAcceptLanguage.split(QLatin1Char(',')); QString out; - Q_FOREACH (const QString& str, list) { + for (const QString &str : list) { if (!out.isEmpty()) out.append(QLatin1Char(',')); out.append(str.split(QLatin1Char(';')).first()); @@ -486,7 +486,7 @@ void BrowserContextAdapter::setHttpAcceptLanguage(const QString &httpAcceptLangu m_httpAcceptLanguage = httpAcceptLanguage; std::vector<content::WebContentsImpl *> list = content::WebContentsImpl::GetAllWebContents(); - Q_FOREACH (content::WebContentsImpl *web_contents, list) { + for (content::WebContentsImpl *web_contents : list) { if (web_contents->GetBrowserContext() == m_browserContext.data()) { content::RendererPreferences* rendererPrefs = web_contents->GetMutableRendererPrefs(); rendererPrefs->accept_languages = httpAcceptLanguageWithoutQualities().toStdString(); diff --git a/src/core/clipboard_qt.cpp b/src/core/clipboard_qt.cpp index cff975e61..44756bdfe 100644 --- a/src/core/clipboard_qt.cpp +++ b/src/core/clipboard_qt.cpp @@ -296,7 +296,8 @@ void ClipboardQt::ReadAvailableTypes(ui::ClipboardType type, std::vector<base::s return; if (mimeData->hasImage() && !mimeData->formats().contains(QStringLiteral("image/png"))) types->push_back(toString16(QStringLiteral("image/png"))); - Q_FOREACH (const QString &mimeType, mimeData->formats()) + const QStringList formats = mimeData->formats(); + for (const QString &mimeType : formats) types->push_back(toString16(mimeType)); *contains_filenames = false; diff --git a/src/core/content_client_qt.cpp b/src/core/content_client_qt.cpp index 37b601bf8..584d6c0aa 100644 --- a/src/core/content_client_qt.cpp +++ b/src/core/content_client_qt.cpp @@ -165,7 +165,8 @@ void AddPepperFlashFromSystem(std::vector<content::PepperPluginInfo>* plugins) winDir = QString::fromLatin1("C:/Windows"); QDir pluginDir(winDir + "/System32/Macromed/Flash"); pluginDir.setFilter(QDir::Files); - Q_FOREACH (const QFileInfo &info, pluginDir.entryInfoList(QStringList("pepflashplayer*.dll"))) + const QFileInfoList infos = pluginDir.entryInfoList(QStringList("pepflashplayer*.dll")); + for (const QFileInfo &info : infos) pluginPaths << info.absoluteFilePath(); pluginPaths << ppapiPluginsPath() + QStringLiteral("/pepflashplayer.dll"); #endif @@ -248,7 +249,7 @@ void AddPepperWidevine(std::vector<content::PepperPluginInfo>* plugins) #endif } - Q_FOREACH (const QString &pluginPath, pluginPaths) { + for (const QString &pluginPath : qAsConst(pluginPaths)) { base::FilePath path = QtWebEngineCore::toFilePath(pluginPath); if (base::PathExists(path)) { content::PepperPluginInfo widevine_cdm; diff --git a/src/core/delegated_frame_node.cpp b/src/core/delegated_frame_node.cpp index eed407a09..d130fe33a 100644 --- a/src/core/delegated_frame_node.cpp +++ b/src/core/delegated_frame_node.cpp @@ -431,7 +431,7 @@ private: static inline QSharedPointer<QSGLayer> findRenderPassLayer(const int &id, const QVector<QPair<int, QSharedPointer<QSGLayer> > > &list) { typedef QPair<int, QSharedPointer<QSGLayer> > Pair; - Q_FOREACH (const Pair &pair, list) + for (const Pair &pair : list) if (pair.first == id) return pair.second; return QSharedPointer<QSGLayer>(); @@ -748,7 +748,7 @@ void DelegatedFrameNode::preprocess() // Then render any intermediate RenderPass in order. typedef QPair<int, QSharedPointer<QSGLayer> > Pair; - Q_FOREACH (const Pair &pair, m_sgObjects.renderPassLayers) { + for (const Pair &pair : qAsConst(m_sgObjects.renderPassLayers)) { // The layer is non-live, request a one-time update here. pair.second->scheduleUpdate(); // Proceed with the actual update. @@ -1270,7 +1270,7 @@ void DelegatedFrameNode::fetchAndSyncMailboxes(QList<MailboxTexture *> &mailboxe m_textureFences.swap(transferredFences); } - Q_FOREACH (gl::TransferableFence sync, transferredFences) { + for (gl::TransferableFence sync : qAsConst(transferredFences)) { // We need to wait on the fences on the Qt current context, and // can therefore not use GLFence routines that uses a different // concept of current context. @@ -1293,7 +1293,7 @@ void DelegatedFrameNode::fetchAndSyncMailboxes(QList<MailboxTexture *> &mailboxe GLuint fbo = 0; funcs->glGenFramebuffers(1, &fbo); - Q_FOREACH (MailboxTexture *mailboxTexture, mailboxesToFetch) { + for (MailboxTexture *mailboxTexture : qAsConst(mailboxesToFetch)) { // Read texture into QImage from shared context. // Switch to shared context. sharedContext->makeCurrent(m_offsurface.data()); diff --git a/src/core/download_manager_delegate_qt.cpp b/src/core/download_manager_delegate_qt.cpp index 5a5e5b79d..b8ef9c56d 100644 --- a/src/core/download_manager_delegate_qt.cpp +++ b/src/core/download_manager_delegate_qt.cpp @@ -184,7 +184,7 @@ bool DownloadManagerDelegateQt::DetermineDownloadTarget(content::DownloadItem* i item->GetLastReason() }; - Q_FOREACH (BrowserContextAdapterClient *client, clients) { + for (BrowserContextAdapterClient *client : qAsConst(clients)) { client->downloadRequested(info); if (info.accepted) break; @@ -279,7 +279,7 @@ void DownloadManagerDelegateQt::ChooseSavePath(content::WebContents *web_content BrowserContextAdapterClient::NoReason }; - Q_FOREACH (BrowserContextAdapterClient *client, clients) { + for (BrowserContextAdapterClient *client : qAsConst(clients)) { client->downloadRequested(info); if (info.accepted) break; @@ -339,7 +339,7 @@ void DownloadManagerDelegateQt::OnDownloadUpdated(content::DownloadItem *downloa download->GetLastReason() }; - Q_FOREACH (BrowserContextAdapterClient *client, clients) { + for (BrowserContextAdapterClient *client : qAsConst(clients)) { client->downloadUpdated(info); } } diff --git a/src/core/file_picker_controller.cpp b/src/core/file_picker_controller.cpp index 158ff7f67..3ded5ec41 100644 --- a/src/core/file_picker_controller.cpp +++ b/src/core/file_picker_controller.cpp @@ -70,7 +70,8 @@ void FilePickerController::accepted(const QVariant &files) if (files.canConvert(QVariant::StringList)) { stringList = files.toStringList(); } else if (files.canConvert<QList<QUrl> >()) { - Q_FOREACH (const QUrl &url, files.value<QList<QUrl> >()) + const QList<QUrl> urls = files.value<QList<QUrl>>(); + for (const QUrl &url : urls) stringList.append(url.toLocalFile()); } else { qWarning("An unhandled type '%s' was provided in FilePickerController::accepted(QVariant)", files.typeName()); @@ -87,8 +88,8 @@ void FilePickerController::rejected() static QStringList listRecursively(const QDir &dir) { QStringList ret; - QFileInfoList infoList(dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden)); - Q_FOREACH (const QFileInfo &fileInfo, infoList) { + const QFileInfoList infoList(dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot | QDir::Hidden)); + for (const QFileInfo &fileInfo : infoList) { if (fileInfo.isDir()) { ret.append(fileInfo.absolutePath() + QStringLiteral("/.")); // Match chromium's behavior. See chrome/browser/file_select_helper.cc ret.append(listRecursively(QDir(fileInfo.absoluteFilePath()))); diff --git a/src/core/location_provider_qt.cpp b/src/core/location_provider_qt.cpp index d0b783b20..6cae63463 100644 --- a/src/core/location_provider_qt.cpp +++ b/src/core/location_provider_qt.cpp @@ -116,7 +116,8 @@ void QtPositioningHelper::start(bool highAccuracy) // Find high accuracy source if the default source is not already one. if (highAccuracy && !isHighAccuracySource(m_positionInfoSource)) { - Q_FOREACH (const QString &name, QGeoPositionInfoSource::availableSources()) { + const QStringList availableSources = QGeoPositionInfoSource::availableSources(); + for (const QString &name : availableSources) { if (name == m_positionInfoSource->sourceName()) continue; QGeoPositionInfoSource *source = QGeoPositionInfoSource::createSource(name, this); diff --git a/src/core/permission_manager_qt.cpp b/src/core/permission_manager_qt.cpp index c65da34af..bc714881b 100644 --- a/src/core/permission_manager_qt.cpp +++ b/src/core/permission_manager_qt.cpp @@ -101,7 +101,7 @@ void PermissionManagerQt::permissionRequestReply(const QUrl &origin, BrowserCont ++it; } } - Q_FOREACH (const RequestOrSubscription &subscriber, m_subscribers) { + for (const RequestOrSubscription &subscriber : qAsConst(m_subscribers)) { if (subscriber.origin == origin && subscriber.type == type) subscriber.callback.Run(status); } diff --git a/src/core/profile_io_data_qt.cpp b/src/core/profile_io_data_qt.cpp index cf13559bc..2cdd7aab1 100644 --- a/src/core/profile_io_data_qt.cpp +++ b/src/core/profile_io_data_qt.cpp @@ -478,7 +478,7 @@ void ProfileIODataQt::generateJobFactory() net::FtpProtocolHandler::Create(m_urlRequestContext->host_resolver())); m_installedCustomSchemes = m_customUrlSchemes; - Q_FOREACH (const QByteArray &scheme, m_installedCustomSchemes) { + for (const QByteArray &scheme : qAsConst(m_installedCustomSchemes)) { jobFactory->SetProtocolHandler(scheme.toStdString(), std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>( new CustomProtocolHandler(m_browserContextAdapter))); @@ -519,12 +519,12 @@ void ProfileIODataQt::regenerateJobFactory() if (m_customUrlSchemes == m_installedCustomSchemes) return; - Q_FOREACH (const QByteArray &scheme, m_installedCustomSchemes) { + for (const QByteArray &scheme : qAsConst(m_installedCustomSchemes)) { m_baseJobFactory->SetProtocolHandler(scheme.toStdString(), nullptr); } m_installedCustomSchemes = m_customUrlSchemes; - Q_FOREACH (const QByteArray &scheme, m_installedCustomSchemes) { + for (const QByteArray &scheme : qAsConst(m_installedCustomSchemes)) { m_baseJobFactory->SetProtocolHandler(scheme.toStdString(), std::unique_ptr<net::URLRequestJobFactory::ProtocolHandler>( new CustomProtocolHandler(m_browserContextAdapter))); diff --git a/src/core/renderer/user_resource_controller.cpp b/src/core/renderer/user_resource_controller.cpp index 2b8fc714a..6e28564f8 100644 --- a/src/core/renderer/user_resource_controller.cpp +++ b/src/core/renderer/user_resource_controller.cpp @@ -200,7 +200,7 @@ void UserResourceController::runScripts(UserScriptData::InjectionPoint p, blink: QList<uint64_t> scriptsToRun = m_viewUserScriptMap.value(0).toList(); scriptsToRun.append(m_viewUserScriptMap.value(renderView).toList()); - Q_FOREACH (uint64_t id, scriptsToRun) { + for (uint64_t id : qAsConst(scriptsToRun)) { const UserScriptData &script = m_scripts.value(id); if (script.injectionPoint != p || (!script.injectForSubframes && !isMainFrame)) @@ -365,7 +365,7 @@ void UserResourceController::renderViewDestroyed(content::RenderView *renderView ViewUserScriptMap::iterator it = m_viewUserScriptMap.find(renderView); if (it == m_viewUserScriptMap.end()) // ASSERT maybe? return; - Q_FOREACH (uint64_t id, it.value()) { + for (uint64_t id : qAsConst(it.value())) { m_scripts.remove(id); } m_viewUserScriptMap.remove(renderView); @@ -396,7 +396,7 @@ void UserResourceController::clearScriptsForView(content::RenderView *view) ViewUserScriptMap::iterator it = m_viewUserScriptMap.find(view); if (it == m_viewUserScriptMap.end()) return; - Q_FOREACH (uint64_t id, it.value()) + for (uint64_t id : qAsConst(it.value())) m_scripts.remove(id); m_viewUserScriptMap.remove(view); diff --git a/src/core/renderer_host/user_resource_controller_host.cpp b/src/core/renderer_host/user_resource_controller_host.cpp index d889915a6..ed4d736f2 100644 --- a/src/core/renderer_host/user_resource_controller_host.cpp +++ b/src/core/renderer_host/user_resource_controller_host.cpp @@ -75,7 +75,8 @@ void UserResourceControllerHost::WebContentsObserverHelper::RenderFrameCreated( content::RenderFrameHost *renderFrameHost) { content::WebContents *contents = web_contents(); - Q_FOREACH (const UserScript &script, m_controllerHost->m_perContentsScripts.value(contents)) + const QList<UserScript> scripts = m_controllerHost->m_perContentsScripts.value(contents); + for (const UserScript &script : scripts) renderFrameHost->Send(new RenderFrameObserverHelper_AddScript( renderFrameHost->GetRoutingID(), script.data())); } @@ -122,7 +123,7 @@ void UserResourceControllerHost::addUserScript(const UserScript &script, WebCont if (isProfileWideScript) { if (!m_profileWideScripts.contains(script)) { m_profileWideScripts.append(script); - Q_FOREACH (content::RenderProcessHost *renderer, m_observedProcesses) + for (content::RenderProcessHost *renderer : qAsConst(m_observedProcesses)) renderer->Send(new UserResourceController_AddScript(script.data())); } } else { @@ -168,7 +169,7 @@ bool UserResourceControllerHost::removeUserScript(const UserScript &script, WebC = std::find(m_profileWideScripts.begin(), m_profileWideScripts.end(), script); if (it == m_profileWideScripts.end()) return false; - Q_FOREACH (content::RenderProcessHost *renderer, m_observedProcesses) + for (content::RenderProcessHost *renderer : qAsConst(m_observedProcesses)) renderer->Send(new UserResourceController_RemoveScript((*it).data())); m_profileWideScripts.erase(it); } else { @@ -193,7 +194,7 @@ void UserResourceControllerHost::clearAllScripts(WebContentsAdapter *adapter) const bool isProfileWideScript = !adapter; if (isProfileWideScript) { m_profileWideScripts.clear(); - Q_FOREACH (content::RenderProcessHost *renderer, m_observedProcesses) + for (content::RenderProcessHost *renderer : qAsConst(m_observedProcesses)) renderer->Send(new UserResourceController_ClearScripts); } else { content::WebContents *contents = adapter->webContents(); @@ -229,7 +230,7 @@ void UserResourceControllerHost::renderProcessStartedWithHost(content::RenderPro m_renderProcessObserver.reset(new RenderProcessObserverHelper(this)); renderer->AddObserver(m_renderProcessObserver.data()); m_observedProcesses.insert(renderer); - Q_FOREACH (const UserScript &script, m_profileWideScripts) + for (const UserScript &script : qAsConst(m_profileWideScripts)) renderer->Send(new UserResourceController_AddScript(script.data())); } @@ -244,7 +245,7 @@ UserResourceControllerHost::UserResourceControllerHost() UserResourceControllerHost::~UserResourceControllerHost() { - Q_FOREACH (content::RenderProcessHost *renderer, m_observedProcesses) + for (content::RenderProcessHost *renderer : qAsConst(m_observedProcesses)) renderer->RemoveObserver(m_renderProcessObserver.data()); } diff --git a/src/core/type_conversion.h b/src/core/type_conversion.h index 023bed21e..5181bc23d 100644 --- a/src/core/type_conversion.h +++ b/src/core/type_conversion.h @@ -265,7 +265,7 @@ inline std::vector<T> toVector(const QStringList &fileList) { std::vector<T> selectedFiles; selectedFiles.reserve(fileList.size()); - Q_FOREACH (const QString &file, fileList) + for (const QString &file : fileList) selectedFiles.push_back(fileListingHelper<T>(file)); return selectedFiles; } diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index 9a544cb0a..fc1bbd044 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -1415,7 +1415,8 @@ bool WebContentsAdapter::handleDropDataFileContents(const content::DropData &dro static void fillDropDataFromMimeData(content::DropData *dropData, const QMimeData *mimeData) { Q_ASSERT(dropData->filenames.empty()); - Q_FOREACH (const QUrl &url, mimeData->urls()) { + const QList<QUrl> urls = mimeData->urls(); + for (const QUrl &url : urls) { if (url.isLocalFile()) { ui::FileInfo uifi; uifi.path = toFilePath(url.toLocalFile()); diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp index 515f763d2..950be89b9 100644 --- a/src/core/web_engine_library_info.cpp +++ b/src/core/web_engine_library_info.cpp @@ -168,7 +168,7 @@ QString subProcessPath() % QLatin1Char('/') % processBinary; } - Q_FOREACH (const QString &candidate, candidatePaths) { + for (const QString &candidate : qAsConst(candidatePaths)) { if (QFileInfo::exists(candidate)) { processPath = candidate; break; @@ -244,7 +244,7 @@ QString dictionariesPath() candidatePaths << libraryDictionariesPath; } - Q_FOREACH (const QString &candidate, candidatePaths) { + for (const QString &candidate : qAsConst(candidatePaths)) { if (QFileInfo::exists(candidate)) { potentialDictionariesPath = candidate; break; diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp index 4cd4b6452..7bad96a09 100644 --- a/src/core/web_engine_settings.cpp +++ b/src/core/web_engine_settings.cpp @@ -126,7 +126,7 @@ WebEngineSettings::~WebEngineSettings() if (parentSettings) parentSettings->childSettings.remove(this); // In QML the profile and its settings may be garbage collected before the page and its settings. - Q_FOREACH (WebEngineSettings *settings, childSettings) { + for (WebEngineSettings *settings : qAsConst(childSettings)) { settings->parentSettings = 0; } } @@ -426,7 +426,7 @@ bool WebEngineSettings::applySettingsToRendererPreferences(content::RendererPref void WebEngineSettings::scheduleApplyRecursively() { scheduleApply(); - Q_FOREACH (WebEngineSettings *settings, childSettings) { + for (WebEngineSettings *settings : qAsConst(childSettings)) { settings->scheduleApply(); } } |