diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2019-02-11 16:38:47 +0100 |
---|---|---|
committer | Peter Varga <pvarga@inf.u-szeged.hu> | 2019-02-25 07:14:32 +0000 |
commit | 837347e1901086a9757b5aca7e5bbee7b0d8e20e (patch) | |
tree | e0bf0ed4ae2523f87e96e65b57858c5e5f3405d7 /src/core/favicon_manager.cpp | |
parent | 598bfc652edffb047948e01c3c76eb9e0cb7db4e (diff) |
Fix handling of touch icons when it is disabled
Store the icon type in a bitfield because the same icon URL might be
used for various types on same page. This way webengine won't ignore to
download a default icon what is also set as a touch icon when touch
icons are disabled.
Moreover, do not store the icon types from the previous page because
a subsequent page might use the same icon URL but with different type.
With this change the type of the cached icons are updated after each
page load.
Fixes: QTBUG-70081
Change-Id: I8031a740b07b0c6a8e5759a994f386b13ce87be2
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src/core/favicon_manager.cpp')
-rw-r--r-- | src/core/favicon_manager.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/core/favicon_manager.cpp b/src/core/favicon_manager.cpp index de6a0f183..f7ba858c1 100644 --- a/src/core/favicon_manager.cpp +++ b/src/core/favicon_manager.cpp @@ -253,7 +253,7 @@ void FaviconManager::update(const QList<FaviconInfo> &candidates) const QList<FaviconInfo> &faviconInfoList = getFaviconInfoList(true /* candidates only */); for (auto it = faviconInfoList.cbegin(), end = faviconInfoList.cend(); it != end; ++it) { - if (!touchIconsEnabled && it->type != FaviconInfo::Favicon) + if (!touchIconsEnabled && !(it->type & FaviconInfo::Favicon)) continue; if (it->isValid()) @@ -272,6 +272,14 @@ void FaviconManager::update(const QList<FaviconInfo> &candidates) void FaviconManager::updateCandidates(const QList<FaviconInfo> &candidates) { + // Invalidate types of the already stored candidate icons because it might differ + // among pages. + for (FaviconInfo candidateFaviconInfo : candidates) { + const QUrl &candidateUrl = candidateFaviconInfo.url; + if (m_faviconInfoMap.contains(candidateUrl)) + m_faviconInfoMap[candidateUrl].type = FaviconInfo::InvalidIcon; + } + m_candidateCount = candidates.count(); for (FaviconInfo candidateFaviconInfo : candidates) { const QUrl &candidateUrl = candidateFaviconInfo.url; @@ -279,8 +287,8 @@ void FaviconManager::updateCandidates(const QList<FaviconInfo> &candidates) if (!m_faviconInfoMap.contains(candidateUrl)) m_faviconInfoMap.insert(candidateUrl, candidateFaviconInfo); else { - // The same icon can be used for more than one page with different types. - m_faviconInfoMap[candidateUrl].type = candidateFaviconInfo.type; + // The same icon URL can be used for different types. + m_faviconInfoMap[candidateUrl].type |= candidateFaviconInfo.type; } m_faviconInfoMap[candidateUrl].candidate = true; @@ -311,7 +319,7 @@ QUrl FaviconManager::candidateIconUrl(bool touchIconsEnabled) const unsigned bestArea = 0; for (auto it = faviconInfoList.cbegin(), end = faviconInfoList.cend(); it != end; ++it) { - if (!touchIconsEnabled && it->type != FaviconInfo::Favicon) + if (!touchIconsEnabled && !(it->type & FaviconInfo::Favicon)) continue; if (it->isValid() && bestArea < area(it->size)) { @@ -331,7 +339,7 @@ void FaviconManager::generateCandidateIcon(bool touchIconsEnabled) const QList<FaviconInfo> &faviconInfoList = getFaviconInfoList(true /* candidates only */); for (auto it = faviconInfoList.cbegin(), end = faviconInfoList.cend(); it != end; ++it) { - if (!touchIconsEnabled && it->type != FaviconInfo::Favicon) + if (!touchIconsEnabled && !(it->type & FaviconInfo::Favicon)) continue; if (!it->isValid() || !it->isDownloaded()) @@ -373,7 +381,7 @@ FaviconInfo::FaviconInfo(const FaviconInfo &other) { } -FaviconInfo::FaviconInfo(const QUrl &url, FaviconInfo::FaviconType type) +FaviconInfo::FaviconInfo(const QUrl &url, FaviconInfo::FaviconTypeFlags type) : url(url) , type(type) , size(QSize(0, 0)) |