Commit af9d14ce authored by cblu's avatar cblu
Browse files

- don't set nil data on the web file db

	- store absolute URLs in the db, not base URL/path combination URLs
	- support for multiple hosts with the same built-in icon

        * Misc.subproj/WebIconDatabase.m:
        (-[WebIconDatabase init]): renamed some dictionaries
        (-[WebIconDatabase iconForSiteURL:withSize:]): call _builtInIconsForHost
        (-[WebIconDatabase _updateFileDatabase]): check for nil
        (-[WebIconDatabase _hasIconForSiteURL:]): call _pathForBuiltInIconForHost
        (-[WebIconDatabase _pathForBuiltInIconForHost:]): new
        (-[WebIconDatabase _builtInIconsForHost:]): call _pathForBuiltInIconForHost
        * Misc.subproj/WebIconDatabasePrivate.h:
        * WebView.subproj/WebDataSourcePrivate.m:
        (-[WebDataSource _loadIcon]): use absolute URL


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1964 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b0badeac
2002-09-04 Chris Blumenberg <cblu@apple.com>
- don't set nil data on the web file db
- store absolute URLs in the db, not base URL/path combination URLs
- support for multiple hosts with the same built-in icon
* Misc.subproj/WebIconDatabase.m:
(-[WebIconDatabase init]): renamed some dictionaries
(-[WebIconDatabase iconForSiteURL:withSize:]): call _builtInIconsForHost
(-[WebIconDatabase _updateFileDatabase]): check for nil
(-[WebIconDatabase _hasIconForSiteURL:]): call _pathForBuiltInIconForHost
(-[WebIconDatabase _pathForBuiltInIconForHost:]): new
(-[WebIconDatabase _builtInIconsForHost:]): call _pathForBuiltInIconForHost
* Misc.subproj/WebIconDatabasePrivate.h:
* WebView.subproj/WebDataSourcePrivate.m:
(-[WebDataSource _loadIcon]): use absolute URL
2002-09-04 Chris Blumenberg <cblu@apple.com>
Made the icon DB take a a path for built-in icons so that we only load them when necessary.
......
2002-09-04 Chris Blumenberg <cblu@apple.com>
- don't set nil data on the web file db
- store absolute URLs in the db, not base URL/path combination URLs
- support for multiple hosts with the same built-in icon
* Misc.subproj/WebIconDatabase.m:
(-[WebIconDatabase init]): renamed some dictionaries
(-[WebIconDatabase iconForSiteURL:withSize:]): call _builtInIconsForHost
(-[WebIconDatabase _updateFileDatabase]): check for nil
(-[WebIconDatabase _hasIconForSiteURL:]): call _pathForBuiltInIconForHost
(-[WebIconDatabase _pathForBuiltInIconForHost:]): new
(-[WebIconDatabase _builtInIconsForHost:]): call _pathForBuiltInIconForHost
* Misc.subproj/WebIconDatabasePrivate.h:
* WebView.subproj/WebDataSourcePrivate.m:
(-[WebDataSource _loadIcon]): use absolute URL
2002-09-04 Chris Blumenberg <cblu@apple.com>
Made the icon DB take a a path for built-in icons so that we only load them when necessary.
......
......@@ -34,6 +34,7 @@ - (void)_loadIconDictionaries;
- (void)_updateFileDatabase;
- (NSMutableArray *)_iconsForIconURL:(NSURL *)iconURL;
- (NSImage *)_iconForFileURL:(NSURL *)fileURL withSize:(NSSize)size;
- (NSString *)_pathForBuiltInIconForHost:(NSString *)host;
- (NSMutableArray *)_builtInIconsForHost:(NSString *)host;
- (void)_retainIconForIconURL:(NSURL *)iconURL;
- (void)_releaseIconForIconURL:(NSURL *)iconURL;
......@@ -74,7 +75,7 @@ + (WebIconDatabase *)sharedIconDatabase
_private->iconURLToIcons = [[NSMutableDictionary dictionary] retain];
_private->iconURLToRetainCount = [[NSMutableDictionary dictionary] retain];
_private->futureSiteURLToRetainCount = [[NSMutableDictionary dictionary] retain];
_private->hostToBuiltInIcons = [[NSMutableDictionary dictionary] retain];
_private->pathToBuiltInIcons = [[NSMutableDictionary dictionary] retain];
_private->hostToBuiltInIconPath = [[NSMutableDictionary dictionary] retain];
_private->iconsToEraseWithURLs = [[NSMutableSet set] retain];
......@@ -95,7 +96,6 @@ + (WebIconDatabase *)sharedIconDatabase
- (NSImage *)iconForSiteURL:(NSURL *)siteURL withSize:(NSSize)size
{
if(!siteURL){
return [self defaultIconWithSize:size];
}
......@@ -310,8 +310,10 @@ - (void)_updateFileDatabase
while ((iconURL = [enumerator nextObject]) != nil) {
//NSLog(@"writing %@", iconURL);
iconData = [[self _iconForIconURL:iconURL] TIFFRepresentation];
[fileDB setObject:iconData forKey:iconURL];
[_private->iconsOnDiskWithURLs addObject:iconURL];
if(iconData){
[fileDB setObject:iconData forKey:iconURL];
[_private->iconsOnDiskWithURLs addObject:iconURL];
}
}
[_private->iconsToEraseWithURLs removeAllObjects];
......@@ -328,7 +330,7 @@ - (BOOL)_hasIconForSiteURL:(NSURL *)siteURL
{
if([siteURL isFileURL]){
return YES;
}else if([_private->hostToBuiltInIconPath objectForKey:[siteURL host]]){
}else if([self _pathForBuiltInIconForHost:[siteURL host]]){
return YES;
}else if([_private->siteURLToIconURL objectForKey:siteURL]){
return YES;
......@@ -396,15 +398,13 @@ - (NSImage *)_iconForFileURL:(NSURL *)fileURL withSize:(NSSize)size
}
}
- (NSMutableArray *)_builtInIconsForHost:(NSString *)host
- (NSString *)_pathForBuiltInIconForHost:(NSString *)host
{
NSArray *hostParts = [host componentsSeparatedByString:@"."];
NSMutableString *truncatedHost = [NSMutableString string];
NSString *hostPart, *path;
NSMutableArray *icons;
BOOL firstPart = YES;
NSImage *icon;
NSEnumerator *enumerator = [hostParts reverseObjectEnumerator];
while ((hostPart = [enumerator nextObject]) != nil) {
if(firstPart){
......@@ -414,18 +414,7 @@ - (NSMutableArray *)_builtInIconsForHost:(NSString *)host
[truncatedHost insertString:[NSString stringWithFormat:@"%@.", hostPart] atIndex:0];
path = [_private->hostToBuiltInIconPath objectForKey:truncatedHost];
if(path){
icons = [_private->hostToBuiltInIcons objectForKey:truncatedHost];
if(!icons){
icon = [[NSImage alloc] initWithContentsOfFile:path];
if(icon){
icons = [NSMutableArray arrayWithObject:icon];
[_private->hostToBuiltInIcons setObject:icons forKey:host];
[icon release];
}
}
if(icons){
return icons;
}
return path;
}
}
}
......@@ -433,6 +422,26 @@ - (NSMutableArray *)_builtInIconsForHost:(NSString *)host
return nil;
}
- (NSMutableArray *)_builtInIconsForHost:(NSString *)host
{
NSString *path = [self _pathForBuiltInIconForHost:host];
NSMutableArray *icons = nil;
if(path){
icons = [_private->pathToBuiltInIcons objectForKey:path];
if(!icons){
NSImage *icon = [[NSImage alloc] initWithContentsOfFile:path];
if(icon){
icons = [NSMutableArray arrayWithObject:icon];
[_private->pathToBuiltInIcons setObject:icons forKey:path];
[icon release];
}
}
}
return icons;
}
- (void)_setIcon:(NSImage *)icon forIconURL:(NSURL *)iconURL
{
if(!icon || !iconURL){
......
......@@ -22,7 +22,7 @@
NSMutableDictionary *siteURLToIconURL;
NSMutableDictionary *futureSiteURLToRetainCount;
NSMutableDictionary *hostToSiteURLs;
NSMutableDictionary *hostToBuiltInIcons;
NSMutableDictionary *pathToBuiltInIcons;
NSMutableDictionary *hostToBuiltInIconPath;
NSMutableSet *iconsOnDiskWithURLs;
......
......@@ -462,7 +462,7 @@ - (void)_loadIcon
if(!_private->iconURL){
// No icon URL from the LINK tag so try the server's root
_private->iconURL = [[NSURL _web_URLWithString:@"/favicon.ico" relativeToURL:dataSourceURL] retain];
_private->iconURL = [[[NSURL _web_URLWithString:@"/favicon.ico" relativeToURL:dataSourceURL] absoluteURL] retain];
}
if(_private->iconURL != nil){
......
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