Commit cd430f3e authored by cblu's avatar cblu
Browse files

WebKit:

	- Moved the default icon method to WebIconDatabase
	- Removed "icon URL" from the location change handler API

        * History.subproj/WebHistoryItem.m:
        (-[WebHistoryItem icon]): don't worry about iconForSiteURL:withSize: returning nil
        * Misc.subproj/WebIconDatabase.h:
        * Misc.subproj/WebIconDatabase.m:
        (-[WebIconDatabase iconForSiteURL:withSize:]): return defaultIconWithSize if none found
        (-[WebIconDatabase defaultIconWithSize:]): added, loads, caches default icon
        (-[WebIconDatabase _hasIconForSiteURL:]): added, called by webdatasource to determine if icon is necessary
        * Misc.subproj/WebIconDatabasePrivate.h: added _hasIconForSiteURL
        * Misc.subproj/WebIconLoader.h: removed default icon method
        * Misc.subproj/WebIconLoader.m: removed default icon method
        * Resources/url_icon.tiff: resized to 32 x 32
        * WebKit.exp: export symbol for a dictionary key
        * WebKit.pbproj/project.pbxproj:
        * WebView.subproj/WebDataSourcePrivate.m:
        (-[WebDataSource _loadIcon]): call _hasIconForSiteURL
        * WebView.subproj/WebHTMLView.m:
        (-[WebHTMLView mouseDragged:]): call defaultIconWithSize
        * WebView.subproj/WebLocationChangeHandler.h:
        * WebView.subproj/WebLocationChangeHandler.m:
        (-[WebLocationChangeHandler receivedPageIcon:forDataSource:]): renamed

WebBrowser:

	- Moved the default icon method to WebIconDatabase
	- Removed "icon URL" from the location change handler API

        * ABHomePagesController.m:
        (-[ABHomePagesController tableView:willDisplayCell:forTableColumn:row:]): call defaultIconWithSize
        * BrowserWindowController.m:
        (-[BrowserWindowController frameLoadCommitted:]): call defaultIconWithSize
        (-[BrowserWindowController setUpFavoritesBar]): call defaultIconWithSize
        * LocationChangeHandler.m:
        (-[LocationChangeHandler receivedPageIcon:forDataSource:]): renamed, don't use icon URL anymore
        * LocationTextField.m:
        (-[LocationTextField setDisplayAttributes]): call defaultIconWithSize
        (-[LocationTextField textDidChange:]): call defaultIconWithSize
        * RendezvousController.m:
        (-[RendezvousController _iconForServiceDictionary:]): call defaultIconWithSize
        * TitleBarButton.m:
        (-[TitleBarButton initWithFrame:]): call defaultIconWithSize
        * WebBrowser.pbproj/project.pbxproj:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1953 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent aa873226
2002-09-03 Chris Blumenberg <cblu@apple.com>
- Moved the default icon method to WebIconDatabase
- Removed "icon URL" from the location change handler API
* History.subproj/WebHistoryItem.m:
(-[WebHistoryItem icon]): don't worry about iconForSiteURL:withSize: returning nil
* Misc.subproj/WebIconDatabase.h:
* Misc.subproj/WebIconDatabase.m:
(-[WebIconDatabase iconForSiteURL:withSize:]): return defaultIconWithSize if none found
(-[WebIconDatabase defaultIconWithSize:]): added, loads, caches default icon
(-[WebIconDatabase _hasIconForSiteURL:]): added, called by webdatasource to determine if icon is necessary
* Misc.subproj/WebIconDatabasePrivate.h: added _hasIconForSiteURL
* Misc.subproj/WebIconLoader.h: removed default icon method
* Misc.subproj/WebIconLoader.m: removed default icon method
* Resources/url_icon.tiff: resized to 32 x 32
* WebKit.exp: export symbol for a dictionary key
* WebKit.pbproj/project.pbxproj:
* WebView.subproj/WebDataSourcePrivate.m:
(-[WebDataSource _loadIcon]): call _hasIconForSiteURL
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView mouseDragged:]): call defaultIconWithSize
* WebView.subproj/WebLocationChangeHandler.h:
* WebView.subproj/WebLocationChangeHandler.m:
(-[WebLocationChangeHandler receivedPageIcon:forDataSource:]): renamed
2002-09-03 Ken Kocienda <kocienda@apple.com>
Modify calls into WebFoundation to use the new WebResourceRequest class,
......
2002-09-03 Chris Blumenberg <cblu@apple.com>
- Moved the default icon method to WebIconDatabase
- Removed "icon URL" from the location change handler API
* History.subproj/WebHistoryItem.m:
(-[WebHistoryItem icon]): don't worry about iconForSiteURL:withSize: returning nil
* Misc.subproj/WebIconDatabase.h:
* Misc.subproj/WebIconDatabase.m:
(-[WebIconDatabase iconForSiteURL:withSize:]): return defaultIconWithSize if none found
(-[WebIconDatabase defaultIconWithSize:]): added, loads, caches default icon
(-[WebIconDatabase _hasIconForSiteURL:]): added, called by webdatasource to determine if icon is necessary
* Misc.subproj/WebIconDatabasePrivate.h: added _hasIconForSiteURL
* Misc.subproj/WebIconLoader.h: removed default icon method
* Misc.subproj/WebIconLoader.m: removed default icon method
* Resources/url_icon.tiff: resized to 32 x 32
* WebKit.exp: export symbol for a dictionary key
* WebKit.pbproj/project.pbxproj:
* WebView.subproj/WebDataSourcePrivate.m:
(-[WebDataSource _loadIcon]): call _hasIconForSiteURL
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView mouseDragged:]): call defaultIconWithSize
* WebView.subproj/WebLocationChangeHandler.h:
* WebView.subproj/WebLocationChangeHandler.m:
(-[WebLocationChangeHandler receivedPageIcon:forDataSource:]): renamed
2002-09-03 Ken Kocienda <kocienda@apple.com>
Modify calls into WebFoundation to use the new WebResourceRequest class,
......
......@@ -114,18 +114,12 @@ -(void)_setIcon:(NSImage *)newIcon
-(NSImage *)icon
{
if (!_loadedIcon) {
NSImage *newIcon;
if (_URL != nil) {
newIcon = [[WebIconDatabase sharedIconDatabase] iconForSiteURL:_URL withSize:WebIconSmallSize];
}else{
newIcon = nil;
}
NSImage *newIcon = [[WebIconDatabase sharedIconDatabase] iconForSiteURL:_URL withSize:WebIconSmallSize];
[self _setIcon:newIcon];
_loadedIcon = YES;
}
return _icon ? _icon : [WebIconLoader defaultIcon];
return _icon;
}
......
......@@ -24,8 +24,8 @@
*/
// Sent whenever a site icon has changed. The object of the notification is the icon database.
// Upon receiving this notification the receiver should call doesNotificationUserInfo: matchSiteURL:
// to determine if the site URL in question has an updated icon.
// The userInfo contains the site URL who's icon has changed.
// It can be accessed with the key WebIconNotificationUserInfoSiteURLKey.
extern NSString *WebIconDidChangeNotification;
extern NSString *WebIconNotificationUserInfoSiteURLKey;
......@@ -50,6 +50,8 @@ extern NSSize WebIconMediumSize; // 32 x 32
// Also usually called by the observer of WebIconChangedNotification after the notification is sent.
- (NSImage *)iconForSiteURL:(NSURL *)siteURL withSize:(NSSize)size;
- (NSImage *)defaultIconWithSize:(NSSize)size;
// Customize the site icon for all web sites with the given host name.
- (void)setIcon:(NSImage *)icon forHost:(NSString *)host;
......
......@@ -93,6 +93,11 @@ + (WebIconDatabase *)sharedIconDatabase
- (NSImage *)iconForSiteURL:(NSURL *)siteURL withSize:(NSSize)size
{
if(!siteURL){
return [self defaultIconWithSize:size];
}
if([siteURL isFileURL]){
return [self _iconForFileURL:siteURL withSize:size];
}
......@@ -105,14 +110,14 @@ - (NSImage *)iconForSiteURL:(NSURL *)siteURL withSize:(NSSize)size
if(!iconURL){
// Don't have it
//NSLog(@"iconForSiteURL no iconURL for siteURL: %@", siteURL);
return nil;
return [self defaultIconWithSize:size];
}
icons = [self _iconsForIconURL:iconURL];
if(!icons){
// This should not happen
//NSLog(@"iconForSiteURL no icon for iconURL: %@", iconURL);
return nil;
return [self defaultIconWithSize:size];
}
}
......@@ -124,6 +129,19 @@ - (NSImage *)iconForSiteURL:(NSURL *)siteURL withSize:(NSSize)size
}
}
- (NSImage *)defaultIconWithSize:(NSSize)size
{
if (!_private->defaultIcons) {
NSString *pathForDefaultImage = [[NSBundle bundleForClass:[self class]] pathForResource:@"url_icon" ofType:@"tiff"];
if (pathForDefaultImage != nil) {
NSImage *icon = [[NSImage alloc] initByReferencingFile: pathForDefaultImage];
_private->defaultIcons = [[NSMutableArray arrayWithObject:icon] retain];
}
}
return [self _cachedIconFromArray:_private->defaultIcons withSize:size];
}
- (void)setIcon:(NSImage *)icon forSiteURL:(NSURL *)siteURL
{
if(!icon || !siteURL){
......@@ -303,6 +321,19 @@ - (void)_updateFileDatabase
[fileDB setObject:_private->hostToSiteURLs forKey:WebHostToSiteURLsKey];
}
- (BOOL)_hasIconForSiteURL:(NSURL *)siteURL
{
if([siteURL isFileURL]){
return YES;
}else if([_private->hostToBuiltItIcons objectForKey:[siteURL host]]){
return YES;
}else if([_private->siteURLToIconURL objectForKey:siteURL]){
return YES;
}else{
return NO;
}
}
- (NSImage *)_iconForIconURL:(NSURL *)iconURL
{
// The first item in the icon array is the original non-resized icon
......
......@@ -34,6 +34,7 @@
BOOL waitingToCleanup;
NSMutableArray *htmlIcons;
NSMutableArray *defaultIcons;
}
@end
......@@ -51,4 +52,6 @@
- (void)_setBuiltInIcon:(NSImage *)icon forHost:(NSString *)host;
- (BOOL)_hasIconForSiteURL:(NSURL *)siteURL;
@end
\ No newline at end of file
......@@ -8,22 +8,14 @@
#import <Cocoa/Cocoa.h>
@class WebDataSource;
@class WebResourceHandle;
@class WebIconLoaderPrivate;
@protocol WebResourceClient;
#define IconWidth 16
#define IconHeight 16
@interface WebIconLoader : NSObject <WebResourceClient>
{
WebIconLoaderPrivate *_private;
}
+ (NSImage *)defaultIcon;
+ (NSImage *)iconForFileAtPath:(NSString *)path;
+ iconLoaderWithURL:(NSURL *)URL;
- initWithURL:(NSURL *)URL;
- (NSURL *)URL;
......
......@@ -40,51 +40,6 @@ - (void)dealloc
@implementation WebIconLoader
+ (void)_resizeImage:(NSImage *)image
{
[image setScalesWhenResized:YES];
[image setSize:NSMakeSize(IconWidth,IconHeight)];
}
+ (NSImage *)defaultIcon
{
static NSImage *defaultIcon = nil;
static BOOL loadedDefaultImage = NO;
// Attempt to load default image only once, to avoid performance penalty of repeatedly
// trying and failing to find it.
if (!loadedDefaultImage) {
NSString *pathForDefaultImage =
[[NSBundle bundleForClass:[self class]] pathForResource:@"url_icon" ofType:@"tiff"];
if (pathForDefaultImage != nil) {
defaultIcon = [[NSImage alloc] initByReferencingFile: pathForDefaultImage];
[[self class] _resizeImage:defaultIcon];
}
loadedDefaultImage = YES;
}
return defaultIcon;
}
+ (NSImage *)iconForFileAtPath:(NSString *)path
{
static NSImage *htmlIcon = nil;
NSImage *icon;
if([[path pathExtension] rangeOfString:@"htm"].length != 0){
if(!htmlIcon){
htmlIcon = [[[NSWorkspace sharedWorkspace] iconForFileType:@"html"] retain];
[[self class] _resizeImage:htmlIcon];
}
icon = htmlIcon;
}else{
icon = [[NSWorkspace sharedWorkspace] iconForFile:path];
[[self class] _resizeImage:icon];
}
return icon;
}
+ iconLoaderWithURL:(NSURL *)URL
{
return [[[self alloc] initWithURL:URL] autorelease];
......
WebKit/Resources/url_icon.tiff

1.19 KB | W: | H:

WebKit/Resources/url_icon.tiff

1.62 KB | W: | H:

WebKit/Resources/url_icon.tiff
WebKit/Resources/url_icon.tiff
WebKit/Resources/url_icon.tiff
WebKit/Resources/url_icon.tiff
  • 2-up
  • Swipe
  • Onion skin
......@@ -33,4 +33,6 @@ _WebHistoryEntriesChangedNotification
_WebIconDidChangeNotification
_WebIconSmallSize
_WebIconMediumSize
_WebIconNotificationUserInfoSiteURLKey
......@@ -72,7 +72,6 @@
F58C8A07025BD3BC018635CA,
F531DDFF02F0C36F018635CA,
);
hasScannedForEncodings = 1;
isa = PBXProject;
knownRegions = (
English,
......
......@@ -452,7 +452,7 @@ -(void)_receivedData:(NSData *)data
- (void)iconLoader:(WebIconLoader *)iconLoader receivedPageIcon:(NSImage *)icon;
{
[[WebIconDatabase sharedIconDatabase] _setIconURL:[iconLoader URL] forSiteURL:[self URL]];
[[_private->controller locationChangeHandler] receivedPageIcon:icon fromURL:[iconLoader URL] forDataSource:self];
[[_private->controller locationChangeHandler] receivedPageIcon:icon forDataSource:self];
}
- (void)_loadIcon
......@@ -462,12 +462,12 @@ - (void)_loadIcon
if([self isMainDocument] && !_private->mainDocumentError){
NSURL *dataSourceURL = [self URL];
NSImage *icon = [[WebIconDatabase sharedIconDatabase] iconForSiteURL:dataSourceURL withSize:NSMakeSize(0,0)];
if(icon){
WebIconDatabase *iconDB = [WebIconDatabase sharedIconDatabase];
if([iconDB _hasIconForSiteURL:dataSourceURL]){
// Return the icon immediately if the db already has it
[[_private->controller locationChangeHandler] receivedPageIcon:icon fromURL:nil forDataSource:self];
NSImage *icon = [iconDB iconForSiteURL:dataSourceURL withSize:NSMakeSize(0,0)];
[[_private->controller locationChangeHandler] receivedPageIcon:icon forDataSource:self];
}else{
if(!_private->iconURL){
......
......@@ -42,7 +42,7 @@
- (void)locationChangeDone:(WebError *)error forDataSource:(WebDataSource *)dataSource;
- (void)receivedPageTitle:(NSString *)title forDataSource:(WebDataSource *)dataSource;
- (void)receivedPageIcon:(NSImage *)image fromURL:(NSURL *)iconURL forDataSource:(WebDataSource *)dataSource;
- (void)receivedPageIcon:(NSImage *)image forDataSource:(WebDataSource *)dataSource;
- (void)serverRedirectTo:(NSURL *)URL forDataSource:(WebDataSource *)dataSource;
......
......@@ -13,6 +13,7 @@
#import <WebKit/WebException.h>
#import <WebKit/WebFrame.h>
#import <WebKit/WebHTMLViewPrivate.h>
#import <WebKit/WebIconDatabase.h>
#import <WebKit/WebIconLoader.h>
#import <WebKit/WebKitDebug.h>
#import <WebKit/WebNSViewExtras.h>
......@@ -446,7 +447,7 @@ - (void)mouseDragged:(NSEvent *)event
[pasteboard declareTypes:[NSArray arrayWithObject:NSURLPboardType] owner:nil];
[_private->draggedURL writeToPasteboard: pasteboard];
[self dragImage:[WebIconLoader defaultIcon]
[self dragImage:[[WebIconDatabase sharedIconDatabase] defaultIconWithSize:WebIconSmallSize]
at:[self convertPoint:[event locationInWindow] fromView:nil]
offset:NSMakeSize(0.0,0.0)
event:event
......
......@@ -42,7 +42,7 @@
- (void)locationChangeDone:(WebError *)error forDataSource:(WebDataSource *)dataSource;
- (void)receivedPageTitle:(NSString *)title forDataSource:(WebDataSource *)dataSource;
- (void)receivedPageIcon:(NSImage *)image fromURL:(NSURL *)iconURL forDataSource:(WebDataSource *)dataSource;
- (void)receivedPageIcon:(NSImage *)image forDataSource:(WebDataSource *)dataSource;
- (void)serverRedirectTo:(NSURL *)URL forDataSource:(WebDataSource *)dataSource;
......
......@@ -12,7 +12,7 @@ - (void)locationChangeCommittedForDataSource:(WebDataSource *)dataSource { }
- (void)locationChangeDone:(WebError *)error forDataSource:(WebDataSource *)dataSource { }
- (void)receivedPageTitle:(NSString *)title forDataSource:(WebDataSource *)dataSource { }
- (void)receivedPageIcon:(NSImage *)image fromURL:(NSURL *)iconURL forDataSource:(WebDataSource *)dataSource { }
- (void)receivedPageIcon:(NSImage *)image forDataSource:(WebDataSource *)dataSource { }
- (void)serverRedirectTo:(NSURL *)URL forDataSource:(WebDataSource *)dataSource { }
......
......@@ -42,7 +42,7 @@
- (void)locationChangeDone:(WebError *)error forDataSource:(WebDataSource *)dataSource;
- (void)receivedPageTitle:(NSString *)title forDataSource:(WebDataSource *)dataSource;
- (void)receivedPageIcon:(NSImage *)image fromURL:(NSURL *)iconURL forDataSource:(WebDataSource *)dataSource;
- (void)receivedPageIcon:(NSImage *)image forDataSource:(WebDataSource *)dataSource;
- (void)serverRedirectTo:(NSURL *)URL forDataSource:(WebDataSource *)dataSource;
......
......@@ -12,7 +12,7 @@ - (void)locationChangeCommittedForDataSource:(WebDataSource *)dataSource { }
- (void)locationChangeDone:(WebError *)error forDataSource:(WebDataSource *)dataSource { }
- (void)receivedPageTitle:(NSString *)title forDataSource:(WebDataSource *)dataSource { }
- (void)receivedPageIcon:(NSImage *)image fromURL:(NSURL *)iconURL forDataSource:(WebDataSource *)dataSource { }
- (void)receivedPageIcon:(NSImage *)image forDataSource:(WebDataSource *)dataSource { }
- (void)serverRedirectTo:(NSURL *)URL forDataSource:(WebDataSource *)dataSource { }
......
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