Commit 0d9e16ff authored by beidson@apple.com's avatar beidson@apple.com

WebCore:

2008-11-04  Brady Eidson  <beidson@apple.com>

        Reviewed by John Sullivan

        Add a simple "visited" method to HistoryItem for use by global history

        * WebCore.base.exp:

        * history/HistoryItem.cpp:
        (WebCore::HistoryItem::visited):  Update the title on the item, set last visited time,
          and bump the visit count.  All things that should happen when a url is visited again!
        * history/HistoryItem.h:

WebKit/mac:

2008-11-04  Brady Eidson  <beidson@apple.com>

        Reviewed by John Sullivan

        Cleanup global history a tad.  

        Used to _addItemForURL always create a new item and merge it with a previous item if one existed.

        It is more efficient and less complicated to update the previous item if one exists.

        * History/WebHistory.mm:
        (-[WebHistoryPrivate visitedURL:withTitle:]):
        (-[WebHistory _visitedURL:withTitle:]):  Instead of calling the general purpose [WebHistoryPrivate addItem:]
          with a new history item, call the new special purposed visitedURL:withTitle:
        * History/WebHistoryInternal.h:

        * History/WebHistoryItem.mm:
        (-[WebHistoryItem _visitedWithTitle:]): Call "visited()" on the WebCore history item with the pertinent info.
        * History/WebHistoryItemInternal.h:

        * WebCoreSupport/WebFrameLoaderClient.mm:
        (WebFrameLoaderClient::updateGlobalHistory):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@38110 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 31293443
2008-11-04 Brady Eidson <beidson@apple.com>
Reviewed by John Sullivan
Add a simple "visited" method to HistoryItem for use by global history
* WebCore.base.exp:
* history/HistoryItem.cpp:
(WebCore::HistoryItem::visited): Update the title on the item, set last visited time,
and bump the visit count. All things that should happen when a url is visited again!
* history/HistoryItem.h:
2008-11-04 Jan Michael Alonzo <jmalonzo@webkit.org>
Build fix. Not reviewed.
......
......@@ -187,6 +187,7 @@ __ZN7WebCore11HistoryItem20setTransientPropertyERKNS_6StringEP11objc_object
__ZN7WebCore11HistoryItem22mergeAutoCompleteHintsEPS0_
__ZN7WebCore11HistoryItem23recurseToFindTargetItemEv
__ZN7WebCore11HistoryItem6setURLERKNS_4KURLE
__ZN7WebCore11HistoryItem7visitedERKNS_6StringEd
__ZN7WebCore11HistoryItem8formDataEv
__ZN7WebCore11HistoryItem8setTitleERKNS_6StringE
__ZN7WebCore11HistoryItem9setParentERKNS_6StringE
......@@ -273,8 +274,6 @@ __ZN7WebCore13TypingCommand39insertParagraphSeparatorInQuotedContentEPNS_8Docume
__ZN7WebCore13toDeviceSpaceERKNS_9FloatRectEP8NSWindow
__ZN7WebCore13toJSDOMWindowEPNS_5FrameE
__ZN7WebCore14CachedResource12removeClientEPNS_20CachedResourceClientE
__ZN7WebCore7Console21shouldPrintExceptionsEv
__ZN7WebCore7Console24setShouldPrintExceptionsEb
__ZN7WebCore14DocumentLoader13attachToFrameEv
__ZN7WebCore14DocumentLoader15detachFromFrameEv
__ZN7WebCore14DocumentLoader18addArchiveResourceEN3WTF10PassRefPtrINS_15ArchiveResourceEEE
......@@ -553,6 +552,8 @@ __ZN7WebCore6Widget9setParentEPNS_10ScrollViewE
__ZN7WebCore6WidgetC1EP6NSView
__ZN7WebCore6WidgetC2EP6NSView
__ZN7WebCore6WidgetD2Ev
__ZN7WebCore7Console21shouldPrintExceptionsEv
__ZN7WebCore7Console24setShouldPrintExceptionsEb
__ZN7WebCore7IntSizeC1ERK7_NSSize
__ZN7WebCore7nsColorERKNS_5ColorE
__ZN7WebCore8Document11createRangeEv
......
......@@ -236,6 +236,13 @@ void HistoryItem::setLastVisitedTime(double time)
}
}
void HistoryItem::visited(const String& title, double time)
{
m_title = title;
m_lastVisitedTime = time;
m_visitCount++;
}
int HistoryItem::visitCount() const
{
return m_visitCount;
......
......@@ -139,6 +139,7 @@ public:
// This should not be called directly for HistoryItems that are already included
// in GlobalHistory. The WebKit api for this is to use -[WebHistory setLastVisitedTimeInterval:forItem:] instead.
void setLastVisitedTime(double);
void visited(const String& title, double time);
bool isCurrentDocument(Document*) const;
......
2008-11-04 Brady Eidson <beidson@apple.com>
Reviewed by John Sullivan
Cleanup global history a tad.
Used to _addItemForURL always create a new item and merge it with a previous item if one existed.
It is more efficient and less complicated to update the previous item if one exists.
* History/WebHistory.mm:
(-[WebHistoryPrivate visitedURL:withTitle:]):
(-[WebHistory _visitedURL:withTitle:]): Instead of calling the general purpose [WebHistoryPrivate addItem:]
with a new history item, call the new special purposed visitedURL:withTitle:
* History/WebHistoryInternal.h:
* History/WebHistoryItem.mm:
(-[WebHistoryItem _visitedWithTitle:]): Call "visited()" on the WebCore history item with the pertinent info.
* History/WebHistoryItemInternal.h:
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::updateGlobalHistory):
2008-11-04 Anders Carlsson <andersca@apple.com>
Reviewed by Kevin Decker.
......
......@@ -71,6 +71,8 @@ NSString *DatesArrayKey = @"WebHistoryDates";
int ageInDaysLimit;
}
- (WebHistoryItem *)visitedURL:(NSURL *)url withTitle:(NSString *)title;
- (void)addItem:(WebHistoryItem *)entry;
- (void)addItems:(NSArray *)newEntries;
- (BOOL)removeItem:(WebHistoryItem *)entry;
......@@ -258,6 +260,30 @@ WebHistoryDateKey timeIntervalForBeginningOfDay(NSTimeInterval interval)
}
}
- (WebHistoryItem *)visitedURL:(NSURL *)url withTitle:(NSString *)title
{
ASSERT(url);
ASSERT(title);
NSString *URLString = [url _web_originalDataAsString];
WebHistoryItem *entry = [_entriesByURL objectForKey:URLString];
if (entry) {
LOG(History, "Updating global history entry %@", entry);
[entry _visitedWithTitle:title];
[self removeItemFromDateCaches:entry];
} else {
LOG(History, "Adding new global history entry for %@", url);
entry = [[WebHistoryItem alloc] initWithURLString:URLString title:title lastVisitedTimeInterval:[NSDate timeIntervalSinceReferenceDate]];
[_entriesByURL setObject:entry forKey:URLString];
[entry release];
}
[self addItemToDateCaches:entry];
return entry;
}
- (void)addItem:(WebHistoryItem *)entry
{
ASSERT_ARG(entry, entry);
......@@ -763,17 +789,12 @@ WebHistoryDateKey timeIntervalForBeginningOfDay(NSTimeInterval interval)
@implementation WebHistory (WebInternal)
- (void)_addItemForURL:(NSURL *)URL title:(NSString *)title
- (void)_visitedURL:(NSURL *)URL withTitle:(NSString *)title;
{
WebHistoryItem *entry = [[WebHistoryItem alloc] initWithURL:URL title:title];
[entry _setLastVisitedTimeInterval:[NSDate timeIntervalSinceReferenceDate]];
LOG(History, "adding %@", entry);
[_historyPrivate addItem:entry];
WebHistoryItem *entry = [_historyPrivate visitedURL:URL withTitle:title];
[self _sendNotification:WebHistoryItemsAddedNotification
entries:[NSArray arrayWithObject:entry]];
[entry release];
}
- (void)_addVisitedLinksToPageGroup:(WebCore::PageGroup&)group
......
......@@ -33,6 +33,6 @@ namespace WebCore {
}
@interface WebHistory (WebInternal)
- (void)_addItemForURL:(NSURL *)URL title:(NSString *)title;
- (void)_visitedURL:(NSURL *)URL withTitle:(NSString *)title;
- (void)_addVisitedLinksToPageGroup:(WebCore::PageGroup&)group;
@end
......@@ -368,6 +368,11 @@ static WebWindowWatcher *_windowWatcher = nil;
return core(_private)->scrollPoint();
}
- (void)_visitedWithTitle:(NSString *)title
{
core(_private)->visited(title, [NSDate timeIntervalSinceReferenceDate]);
}
@end
@implementation WebHistoryItem (WebPrivate)
......
......@@ -51,6 +51,7 @@ extern void WKNotifyHistoryItemChanged();
- (void)_mergeAutoCompleteHints:(WebHistoryItem *)otherItem;
- (void)setTitle:(NSString *)title;
- (void)_visitedWithTitle:(NSString *)title;
@end
......
......@@ -715,7 +715,7 @@ void WebFrameLoaderClient::updateGlobalHistory(const KURL& url)
{
NSURL *cocoaURL = url;
const String& pageTitle = core(m_webFrame.get())->loader()->documentLoader()->title();
[[WebHistory optionalSharedHistory] _addItemForURL:cocoaURL title:pageTitle];
[[WebHistory optionalSharedHistory] _visitedURL:cocoaURL withTitle:pageTitle];
}
bool WebFrameLoaderClient::shouldGoToHistoryItem(HistoryItem* item) const
......
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