Diff
Modified: trunk/Source/WebKit/win/ChangeLog (162811 => 162812)
--- trunk/Source/WebKit/win/ChangeLog 2014-01-26 22:39:31 UTC (rev 162811)
+++ trunk/Source/WebKit/win/ChangeLog 2014-01-26 22:41:13 UTC (rev 162812)
@@ -1,5 +1,23 @@
2014-01-26 Anders Carlsson <[email protected]>
+ Remove more history gunk.
+
+ * WebHistory.cpp:
+ (WebHistory::orderedLastVisitedDays):
+ (WebHistory::addItem):
+ (WebHistory::visitedURL):
+ (WebHistory::removeItemForURLString):
+ * WebHistory.h:
+ * WebHistoryItem.cpp:
+ (WebHistoryItem::initFromDictionaryRepresentation):
+ (WebHistoryItem::dictionaryRepresentation):
+ (WebHistoryItem::mergeAutoCompleteHints):
+ (WebHistoryItem::setLastVisitedTimeInterval):
+ (WebHistoryItem::initWithURLString):
+ (WebHistoryItem::lastVisitedTimeInterval):
+
+2014-01-26 Anders Carlsson <[email protected]>
+
Build fix.
* WebHistoryItem.cpp:
Modified: trunk/Source/WebKit/win/WebHistory.cpp (162811 => 162812)
--- trunk/Source/WebKit/win/WebHistory.cpp 2014-01-26 22:39:31 UTC (rev 162811)
+++ trunk/Source/WebKit/win/WebHistory.cpp 2014-01-26 22:41:13 UTC (rev 162812)
@@ -331,34 +331,12 @@
return postNotification(kWebHistoryAllItemsRemovedNotification, userInfo.get());
}
+// FIXME: This function should be removed from the IWebHistory interface.
HRESULT STDMETHODCALLTYPE WebHistory::orderedLastVisitedDays(
/* [out][in] */ int* count,
/* [in] */ DATE* calendarDates)
{
- int dateCount = m_entriesByDate.size();
- if (!calendarDates) {
- *count = dateCount;
- return S_OK;
- }
-
- if (*count < dateCount) {
- *count = dateCount;
- return E_FAIL;
- }
-
- *count = dateCount;
- if (!m_orderedLastVisitedDays) {
- m_orderedLastVisitedDays = std::make_unique<DATE[]>(dateCount);
- DateToEntriesMap::const_iterator::Keys end = m_entriesByDate.end().keys();
- int i = 0;
- for (DateToEntriesMap::const_iterator::Keys it = m_entriesByDate.begin().keys(); it != end; ++it, ++i)
- m_orderedLastVisitedDays[i] = *it / secondsPerDay;
- // Use std::greater to sort the days in descending order (i.e., most-recent first).
- sort(m_orderedLastVisitedDays.get(), m_orderedLastVisitedDays.get() + dateCount, greater<DATE>());
- }
-
- memcpy(calendarDates, m_orderedLastVisitedDays.get(), dateCount * sizeof(DATE));
- return S_OK;
+ return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE WebHistory::orderedItemsLastVisitedOnDay(
@@ -529,10 +507,6 @@
}
}
- hr = addItemToDateCaches(entry);
- if (FAILED(hr))
- return hr;
-
m_entriesByURL.set(urlString, entry);
COMPtr<IPropertyBag> userInfo = createUserInfoFromHistoryItem(
@@ -548,16 +522,7 @@
void WebHistory::visitedURL(const URL& url, const String& title, const String& httpMethod, bool wasFailure, bool increaseVisitCount)
{
IWebHistoryItem* entry = m_entriesByURL.get(url.string()).get();
- if (entry) {
- COMPtr<IWebHistoryItemPrivate> entryPrivate(Query, entry);
- if (!entryPrivate)
- return;
-
- // Remove the item from date caches before changing its last visited date. Otherwise we might get duplicate entries
- // as seen in <rdar://problem/6570573>.
- removeItemFromDateCaches(entry);
- entryPrivate->visitedWithTitle(BString(title), increaseVisitCount);
- } else {
+ if (!entry) {
COMPtr<WebHistoryItem> item(AdoptCOM, WebHistoryItem::createInstance());
if (!item)
return;
@@ -573,13 +538,9 @@
if (FAILED(entry->initWithURLString(BString(url.string()), BString(title), lastVisited)))
return;
- item->recordInitialVisit();
-
m_entriesByURL.set(url.string(), entry);
}
- addItemToDateCaches(entry);
-
COMPtr<IWebHistoryItemPrivate> entryPrivate(Query, entry);
if (!entryPrivate)
return;
@@ -614,9 +575,6 @@
if (it == m_entriesByURL.end())
return E_FAIL;
- HRESULT hr = removeItemFromDateCaches(it->value.get());
- m_entriesByURL.remove(it);
-
if (!m_entriesByURL.size())
PageGroup::removeAllVisitedLinks();
@@ -630,96 +588,6 @@
return m_entriesByURL.get(urlString);
}
-HRESULT WebHistory::removeItemFromDateCaches(IWebHistoryItem* entry)
-{
- DATE lastVisitedTime;
- entry->lastVisitedTimeInterval(&lastVisitedTime);
-
- auto found = m_entriesByDate.find(dateKey(lastVisitedTime));
- if (found == m_entriesByDate.end())
- return S_OK;
-
- auto& entriesForDate = found->value;
- int count = entriesForDate.size();
-
- for (int i = count - 1; i >= 0; --i) {
- if (entriesForDate[i] == entry)
- entriesForDate.remove(i);
- }
-
- // remove this date entirely if there are no other entries on it
- if (entriesForDate.isEmpty()) {
- m_entriesByDate.remove(found);
- // Clear m_orderedLastVisitedDays so it will be regenerated when next requested.
- m_orderedLastVisitedDays = nullptr;
- }
-
- return S_OK;
-}
-
-HRESULT WebHistory::addItemToDateCaches(IWebHistoryItem* entry)
-{
- ASSERT_ARG(entry, entry);
-
- DATE lastVisitedTime;
- entry->lastVisitedTimeInterval(&lastVisitedTime);
-
- DateKey key = dateKey(lastVisitedTime);
- auto found = m_entriesByDate.find(key);
- if (found == m_entriesByDate.end()) {
- Vector<COMPtr<IWebHistoryItem>> entries;
- entries.append(entry);
- m_entriesByDate.set(key, entries);
- // Clear m_orderedLastVisitedDays so it will be regenerated when next requested.
- m_orderedLastVisitedDays = nullptr;
- return S_OK;
- }
-
- auto& entriesForDate = found->value;
- size_t count = entriesForDate.size();
-
- // The entries for each day are stored in a sorted array with the most recent entry first
- // Check for the common cases of the entry being newer than all existing entries or the first entry of the day
- bool isNewerThanAllEntries = false;
- if (count) {
- DATE itemTime;
- isNewerThanAllEntries = SUCCEEDED(entriesForDate.first()->lastVisitedTimeInterval(&itemTime)) && itemTime < lastVisitedTime;
- }
- if (!count || isNewerThanAllEntries) {
- entriesForDate.insert(0, entry);
- return S_OK;
- }
-
- // .. or older than all existing entries
- bool isOlderThanAllEntries = false;
- if (count > 0) {
- DATE itemTime;
- isOlderThanAllEntries = SUCCEEDED(entriesForDate.last()->lastVisitedTimeInterval(&itemTime)) && itemTime >= lastVisitedTime;
- }
- if (isOlderThanAllEntries) {
- entriesForDate.append(entry);
- return S_OK;
- }
-
- unsigned low = 0;
- unsigned high = count;
- while (low < high) {
- unsigned mid = low + (high - low) / 2;
- DATE itemTime;
- if (FAILED(entriesForDate[mid]->lastVisitedTimeInterval(&itemTime)))
- return E_FAIL;
-
- if (itemTime >= lastVisitedTime)
- low = mid + 1;
- else
- high = mid;
- }
-
- // low is now the index of the first entry that is older than entryDate
- entriesForDate.insert(low, entry);
- return S_OK;
-}
-
void WebHistory::addVisitedLinksToPageGroup(PageGroup& group)
{
for (auto it = m_entriesByURL.begin(); it != m_entriesByURL.end(); ++it) {
Modified: trunk/Source/WebKit/win/WebHistory.h (162811 => 162812)
--- trunk/Source/WebKit/win/WebHistory.h 2014-01-26 22:39:31 UTC (rev 162811)
+++ trunk/Source/WebKit/win/WebHistory.h 2014-01-26 22:41:13 UTC (rev 162812)
@@ -134,14 +134,10 @@
HRESULT removeItem(IWebHistoryItem* entry);
HRESULT addItem(IWebHistoryItem* entry, bool discardDuplicate, bool* added);
HRESULT removeItemForURLString(const WTF::String& urlString);
- HRESULT addItemToDateCaches(IWebHistoryItem* entry);
- HRESULT removeItemFromDateCaches(IWebHistoryItem* entry);
BSTR getNotificationString(NotificationType notifyType);
ULONG m_refCount;
URLToEntriesMap m_entriesByURL;
- DateToEntriesMap m_entriesByDate;
- std::unique_ptr<DATE[]> m_orderedLastVisitedDays;
COMPtr<WebPreferences> m_preferences;
};
Modified: trunk/Source/WebKit/win/WebHistoryItem.cpp (162811 => 162812)
--- trunk/Source/WebKit/win/WebHistoryItem.cpp 2014-01-26 22:39:31 UTC (rev 162811)
+++ trunk/Source/WebKit/win/WebHistoryItem.cpp 2014-01-26 22:41:13 UTC (rev 162812)
@@ -91,7 +91,6 @@
// IWebHistoryItemPrivate -----------------------------------------------------
static CFStringRef urlKey = CFSTR("");
-static CFStringRef lastVisitedDateKey = CFSTR("lastVisitedDate");
static CFStringRef titleKey = CFSTR("title");
static CFStringRef visitCountKey = CFSTR("visitCount");
static CFStringRef lastVisitWasFailureKey = CFSTR("lastVisitWasFailure");
@@ -107,11 +106,6 @@
if (urlStringRef && CFGetTypeID(urlStringRef) != CFStringGetTypeID())
return E_FAIL;
- CFStringRef lastVisitedRef = (CFStringRef) CFDictionaryGetValue(dictionaryRef, lastVisitedDateKey);
- if (!lastVisitedRef || CFGetTypeID(lastVisitedRef) != CFStringGetTypeID())
- return E_FAIL;
- CFAbsoluteTime lastVisitedTime = CFStringGetDoubleValue(lastVisitedRef);
-
CFStringRef titleRef = (CFStringRef) CFDictionaryGetValue(dictionaryRef, titleKey);
if (titleRef && CFGetTypeID(titleRef) != CFStringGetTypeID())
return E_FAIL;
@@ -174,7 +168,7 @@
}
historyItemWrappers().remove(m_historyItem.get());
- m_historyItem = HistoryItem::create(urlStringRef, titleRef, lastVisitedTime);
+ m_historyItem = HistoryItem::create(urlStringRef, titleRef);
historyItemWrappers().set(m_historyItem.get(), this);
m_historyItem->setVisitCount(visitedCount);
@@ -193,11 +187,6 @@
HRESULT STDMETHODCALLTYPE WebHistoryItem::dictionaryRepresentation(void** dictionary)
{
CFDictionaryRef* dictionaryRef = (CFDictionaryRef*) dictionary;
- static CFStringRef lastVisitedFormat = CFSTR("%.1lf");
- CFStringRef lastVisitedStringRef =
- CFStringCreateWithFormat(0, 0, lastVisitedFormat, m_historyItem->lastVisitedTime());
- if (!lastVisitedStringRef)
- return E_FAIL;
int keyCount = 0;
CFTypeRef keys[9];
@@ -296,24 +285,16 @@
return S_OK;
}
+// FIXME: This function should be removed from the IWebHistoryItem interface.
HRESULT STDMETHODCALLTYPE WebHistoryItem::mergeAutoCompleteHints(IWebHistoryItem* otherItem)
{
- if (!otherItem)
- return E_FAIL;
-
- COMPtr<WebHistoryItem> otherWebHistoryItem(Query, otherItem);
- if (!otherWebHistoryItem)
- return E_FAIL;
-
- m_historyItem->mergeAutoCompleteHints(otherWebHistoryItem->historyItem());
-
- return S_OK;
+ return E_NOTIMPL;
}
+// FIXME: This function should be removed from the IWebHistoryItem interface.
HRESULT STDMETHODCALLTYPE WebHistoryItem::setLastVisitedTimeInterval(DATE time)
{
- m_historyItem->setLastVisitedTime(MarshallingHelpers::DATEToCFAbsoluteTime(time));
- return S_OK;
+ return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE WebHistoryItem::setTitle(BSTR title)
@@ -539,7 +520,7 @@
/* [in] */ DATE lastVisited)
{
historyItemWrappers().remove(m_historyItem.get());
- m_historyItem = HistoryItem::create(String(urlString, SysStringLen(urlString)), String(title, SysStringLen(title)), MarshallingHelpers::DATEToCFAbsoluteTime(lastVisited));
+ m_historyItem = HistoryItem::create(String(urlString, SysStringLen(urlString)), String(title, SysStringLen(title)), 0);
historyItemWrappers().set(m_historyItem.get(), this);
return S_OK;
@@ -578,14 +559,11 @@
return S_OK;
}
+// FIXME: This function should be removed from the IWebHistoryItem interface.
HRESULT STDMETHODCALLTYPE WebHistoryItem::lastVisitedTimeInterval(
/* [retval][out] */ DATE* lastVisited)
{
- if (!lastVisited)
- return E_POINTER;
-
- *lastVisited = MarshallingHelpers::CFAbsoluteTimeToDATE(m_historyItem->lastVisitedTime());
- return S_OK;
+ return E_NOTIMPL;
}
HRESULT STDMETHODCALLTYPE WebHistoryItem::setAlternateTitle(