Commit 6a0bcb13 authored by mrowe@apple.com's avatar mrowe@apple.com

<rdar://problem/9251566> WebBackForwardList::createCFDictionaryRepresentation's current item index

doesn't account for items removed by filter callback.

Reviewed by Dan Bernstein.

* UIProcess/cf/WebBackForwardListCF.cpp:
(WebKit::WebBackForwardList::createCFDictionaryRepresentation): Update the current item index
when we omit an item due to the filter callback.

git-svn-id: svn://svn.chromium.org/blink/trunk@83206 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 85f0b276
2011-04-07 Mark Rowe <mrowe@apple.com>
Reviewed by Dan Bernstein.
<rdar://problem/9251566> WebBackForwardList::createCFDictionaryRepresentation's current item index
doesn't account for items removed by filter callback.
* UIProcess/cf/WebBackForwardListCF.cpp:
(WebKit::WebBackForwardList::createCFDictionaryRepresentation): Update the current item index
when we omit an item due to the filter callback.
2011-04-07 Alexey Proskuryakov <ap@apple.com> 2011-04-07 Alexey Proskuryakov <ap@apple.com>
Reviewed by Anders Carlsson. Reviewed by Anders Carlsson.
......
...@@ -54,18 +54,18 @@ CFDictionaryRef WebBackForwardList::createCFDictionaryRepresentation(WebPageProx ...@@ -54,18 +54,18 @@ CFDictionaryRef WebBackForwardList::createCFDictionaryRepresentation(WebPageProx
{ {
ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size()); ASSERT(m_current == NoCurrentItemIndex || m_current < m_entries.size());
RetainPtr<CFNumberRef> currentIndex(AdoptCF, CFNumberCreate(0, kCFNumberIntType, &m_current));
RetainPtr<CFMutableArrayRef> entries(AdoptCF, CFArrayCreateMutable(0, m_entries.size(), &kCFTypeArrayCallBacks)); RetainPtr<CFMutableArrayRef> entries(AdoptCF, CFArrayCreateMutable(0, m_entries.size(), &kCFTypeArrayCallBacks));
const void* keys[2] = { SessionHistoryCurrentIndexKey(), SessionHistoryEntriesKey() };
const void* values[2] = { currentIndex.get(), entries.get() };
RetainPtr<CFDictionaryRef> dictionary(AdoptCF, CFDictionaryCreate(0, keys, values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); // We may need to update the current index to account for entries that are filtered by the callback.
int currentIndex = m_current;
for (size_t i = 0; i < m_entries.size(); ++i) { for (size_t i = 0; i < m_entries.size(); ++i) {
RefPtr<WebURL> webURL = WebURL::create(m_entries[i]->url()); RefPtr<WebURL> webURL = WebURL::create(m_entries[i]->url());
if (filter && !filter(toAPI(m_page), WKPageGetSessionHistoryURLValueType(), toURLRef(m_entries[i]->originalURL().impl()), context)) if (filter && !filter(toAPI(m_page), WKPageGetSessionHistoryURLValueType(), toURLRef(m_entries[i]->originalURL().impl()), context)) {
if (i <= static_cast<size_t>(currentIndex))
currentIndex--;
continue; continue;
}
RetainPtr<CFStringRef> url(AdoptCF, m_entries[i]->url().createCFString()); RetainPtr<CFStringRef> url(AdoptCF, m_entries[i]->url().createCFString());
RetainPtr<CFStringRef> title(AdoptCF, m_entries[i]->title().createCFString()); RetainPtr<CFStringRef> title(AdoptCF, m_entries[i]->title().createCFString());
...@@ -78,8 +78,12 @@ CFDictionaryRef WebBackForwardList::createCFDictionaryRepresentation(WebPageProx ...@@ -78,8 +78,12 @@ CFDictionaryRef WebBackForwardList::createCFDictionaryRepresentation(WebPageProx
RetainPtr<CFDictionaryRef> entryDictionary(AdoptCF, CFDictionaryCreate(0, keys, values, 4, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks)); RetainPtr<CFDictionaryRef> entryDictionary(AdoptCF, CFDictionaryCreate(0, keys, values, 4, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
CFArrayAppendValue(entries.get(), entryDictionary.get()); CFArrayAppendValue(entries.get(), entryDictionary.get());
} }
RetainPtr<CFNumberRef> currentIndexNumber(AdoptCF, CFNumberCreate(0, kCFNumberIntType, &currentIndex));
return dictionary.leakRef();
const void* keys[2] = { SessionHistoryCurrentIndexKey(), SessionHistoryEntriesKey() };
const void* values[2] = { currentIndexNumber.get(), entries.get() };
return CFDictionaryCreate(0, keys, values, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
} }
bool WebBackForwardList::restoreFromCFDictionaryRepresentation(CFDictionaryRef dictionary) bool WebBackForwardList::restoreFromCFDictionaryRepresentation(CFDictionaryRef dictionary)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment