summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/cf
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-05-27 21:51:42 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-05-27 21:51:42 +0200
commitbe01689f43cf6882cf670d33df49ead1f570c53a (patch)
tree4bb2161d8983b38e3e7ed37b4a50303bfd5e2e85 /Source/WebKit2/UIProcess/cf
parenta89b2ebb8e192c5e8cea21079bda2ee2c0c7dddd (diff)
downloadqtwebkit-be01689f43cf6882cf670d33df49ead1f570c53a.tar.gz
Imported WebKit commit 8d6c5efc74f0222dfc7bcce8d845d4a2707ed9e6 (http://svn.webkit.org/repository/webkit/trunk@118629)
Diffstat (limited to 'Source/WebKit2/UIProcess/cf')
-rw-r--r--Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp21
1 files changed, 10 insertions, 11 deletions
diff --git a/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp b/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp
index f5ec6a312..b4885220f 100644
--- a/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp
+++ b/Source/WebKit2/UIProcess/cf/WebBackForwardListCF.cpp
@@ -53,12 +53,12 @@ DEFINE_STATIC_GETTER(CFStringRef, SessionHistoryEntryDataKey, (CFSTR("SessionHis
CFDictionaryRef WebBackForwardList::createCFDictionaryRepresentation(WebPageProxy::WebPageProxySessionStateFilterCallback filter, void* context) const
{
- ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size());
+ ASSERT(!m_hasCurrentIndex || m_currentIndex < m_entries.size());
RetainPtr<CFMutableArrayRef> entries(AdoptCF, CFArrayCreateMutable(0, m_entries.size(), &kCFTypeArrayCallBacks));
// We may need to update the current index to account for entries that are filtered by the callback.
- CFIndex currentIndex = m_current;
+ CFIndex currentIndex = m_currentIndex;
for (size_t i = 0; i < m_entries.size(); ++i) {
// If we somehow ended up with a null entry then we should consider the data invalid and not save session history at all.
@@ -67,7 +67,7 @@ CFDictionaryRef WebBackForwardList::createCFDictionaryRepresentation(WebPageProx
return 0;
if (filter && !filter(toAPI(m_page), WKPageGetSessionHistoryURLValueType(), toURLRef(m_entries[i]->originalURL().impl()), context)) {
- if (i <= static_cast<size_t>(m_current))
+ if (i <= static_cast<size_t>(m_currentIndex))
currentIndex--;
continue;
}
@@ -89,12 +89,12 @@ CFDictionaryRef WebBackForwardList::createCFDictionaryRepresentation(WebPageProx
// If all items before and including the current item were filtered then currentIndex will be -1.
// Assuming we didn't start out with NoCurrentItemIndex, we should store "current" to point at the first item.
- if (currentIndex == -1 && m_current != NoCurrentItemIndex && CFArrayGetCount(entries.get()))
+ if (currentIndex == -1 && m_hasCurrentIndex && CFArrayGetCount(entries.get()))
currentIndex = 0;
// FIXME: We're relying on currentIndex == -1 to mean the exact same thing as NoCurrentItemIndex (UINT_MAX) in unsigned form.
// That seems implicit and fragile and we should find a better way of representing the NoCurrentItemIndex case.
- if (m_current == NoCurrentItemIndex || !CFArrayGetCount(entries.get()))
+ if (!m_hasCurrentIndex || !CFArrayGetCount(entries.get()))
currentIndex = -1;
RetainPtr<CFNumberRef> currentIndexNumber(AdoptCF, CFNumberCreate(0, kCFNumberCFIndexType, &currentIndex));
@@ -138,9 +138,10 @@ bool WebBackForwardList::restoreFromCFDictionaryRepresentation(CFDictionaryRef d
// FIXME: We're relying on currentIndex == -1 to mean the exact same thing as NoCurrentItemIndex (UINT_MAX) in unsigned form.
// That seems implicit and fragile and we should find a better way of representing the NoCurrentItemIndex case.
- uint32_t currentIndex = currentCFIndex == -1 ? NoCurrentItemIndex : static_cast<uint32_t>(currentCFIndex);
+ bool hasCurrentIndex = currentCFIndex > -1;
+ unsigned currentIndex = hasCurrentIndex ? static_cast<unsigned>(currentCFIndex) : 0;
- if (currentIndex == NoCurrentItemIndex && size) {
+ if (!hasCurrentIndex && size) {
LOG(SessionState, "WebBackForwardList dictionary representation says there is no current item index, but there is a list of %ld entries - this is bogus", size);
return false;
}
@@ -182,10 +183,8 @@ bool WebBackForwardList::restoreFromCFDictionaryRepresentation(CFDictionaryRef d
}
m_entries = newEntries;
- m_current = currentIndex;
- // Perform a sanity check: in case we're out of range, we reset.
- if (m_current != NoCurrentItemIndex && m_current >= newEntries.size())
- m_current = NoCurrentItemIndex;
+ m_hasCurrentIndex = hasCurrentIndex;
+ m_currentIndex = currentIndex;
return true;
}