Changeset 219695 in webkit


Ignore:
Timestamp:
Jul 20, 2017 11:07:30 AM (7 years ago)
Author:
beidson@apple.com
Message:

Deprecate WebIconDatabase in WebKitLegacy/mac.
https://bugs.webkit.org/show_bug.cgi?id=174607

Reviewed by Alex Christensen.

Source/WebKitLegacy/mac:

This patch:
1 - Formally deprecates WebIconDatabase (which was never API anyways)
2 - Guts the class to where it can only return the default icon at the small size
3 - Reworks other parts of WebKitLegacy that used it for anything to either

use something else or to not do anything.

This patch *could* go much farther. A future patch is what will remove WebCore/IconDatabase
and that patch will remove all of the last remnants of WebIconDatabase.

  • History/WebHistoryItem.mm:

(-[WebHistoryItem icon]):

  • Misc/WebIconDatabase.h:
  • Misc/WebIconDatabase.mm:

(-[WebIconDatabase init]):
(-[WebIconDatabase iconForURL:withSize:cache:]):
(-[WebIconDatabase iconForURL:withSize:]):
(-[WebIconDatabase defaultIconWithSize:]):
(-[WebIconDatabase defaultIconForURL:withSize:]):
(-[WebIconDatabase iconURLForURL:]):
(-[WebIconDatabase retainIconForURL:]):
(-[WebIconDatabase releaseIconForURL:]):
(+[WebIconDatabase delayDatabaseCleanup]):
(+[WebIconDatabase allowDatabaseCleanup]):
(-[WebIconDatabase setDelegate:]):
(-[WebIconDatabase delegate]):
(+[WebIconDatabase initialize]): Deleted.
(-[WebIconDatabase isEnabled]): Deleted.
(-[WebIconDatabase setEnabled:]): Deleted.
(-[WebIconDatabase removeAllIcons]): Deleted.
(+[WebIconDatabase _checkIntegrityBeforeOpening]): Deleted.
(-[WebIconDatabase _sendNotificationForURL:]): Deleted.
(-[WebIconDatabase _sendDidRemoveAllIconsNotification]): Deleted.
(-[WebIconDatabase _startUpIconDatabase]): Deleted.
(-[WebIconDatabase _shutDownIconDatabase]): Deleted.
(-[WebIconDatabase _applicationWillTerminate:]): Deleted.
(-[WebIconDatabase _iconForFileURL:withSize:]): Deleted.
(-[WebIconDatabase _resetCachedWebPreferences:]): Deleted.
(-[WebIconDatabase _largestIconFromDictionary:]): Deleted.
(-[WebIconDatabase _iconsBySplittingRepresentationsOfIcon:]): Deleted.
(-[WebIconDatabase _iconFromDictionary:forSize:cache:]): Deleted.
(-[WebIconDatabase _scaleIcon:toSize:]): Deleted.
(-[WebIconDatabase _databaseDirectory]): Deleted.
(webGetNSImage): Deleted.

  • Misc/WebIconDatabaseDelegate.h: Removed.
  • Misc/WebIconDatabaseInternal.h: Removed.
  • Misc/WebIconDatabasePrivate.h: Removed.
  • WebCoreSupport/WebFrameLoaderClient.mm:

(webGetNSImage):

  • WebCoreSupport/WebIconDatabaseClient.mm:

(WebIconDatabaseClient::didRemoveAllIcons):
(WebIconDatabaseClient::didImportIconURLForPageURL):

  • WebView/WebView.mm:

(-[WebView setFrameLoadDelegate:]):
(-[WebView mainFrameIcon]):

Tools:

  • DumpRenderTree/mac/TestRunnerMac.mm:
Location:
trunk
Files:
3 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKitLegacy/WebKitLegacy.xcodeproj/project.pbxproj

    r219484 r219695  
    138138                5185F62810712B97007AA393 /* WebNavigationData.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5185F62710712B97007AA393 /* WebNavigationData.mm */; };
    139139                51AEDEF10CECF45700854328 /* WebDatabaseManagerInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 51AEDEF00CECF45700854328 /* WebDatabaseManagerInternal.h */; };
    140                 51B2A1000ADB15D0002A9BEE /* WebIconDatabaseDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 51B2A0FF0ADB15D0002A9BEE /* WebIconDatabaseDelegate.h */; };
    141140                51C714FB0B20F79F00E5E33C /* WebBackForwardListInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 51C714FA0B20F79F00E5E33C /* WebBackForwardListInternal.h */; };
    142141                51CBFCAD0D10E6C5002DBF51 /* WebCachedFramePlatformData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51CBFCAC0D10E6C5002DBF51 /* WebCachedFramePlatformData.h */; };
     
    177176                7E6FEF0808985A7200C44C3F /* WebScriptDebugDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E6FEF0508985A7200C44C3F /* WebScriptDebugDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
    178177                7E6FEF0908985A7200C44C3F /* WebScriptDebugDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7E6FEF0608985A7200C44C3F /* WebScriptDebugDelegate.mm */; };
    179                 9304B3000B02341500F7850D /* WebIconDatabaseInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 9304B2FF0B02341500F7850D /* WebIconDatabaseInternal.h */; };
    180178                931633EB0AEDFF930062B92D /* WebFrameLoaderClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 931633EA0AEDFF930062B92D /* WebFrameLoaderClient.h */; };
    181179                931633EF0AEDFFAE0062B92D /* WebFrameLoaderClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = 931633EE0AEDFFAE0062B92D /* WebFrameLoaderClient.mm */; };
     
    196194                939810160824BF01008DF038 /* WebCoreStatistics.h in Headers */ = {isa = PBXBuildFile; fileRef = F59EAE3E0253C7EE018635CA /* WebCoreStatistics.h */; settings = {ATTRIBUTES = (Private, ); }; };
    197195                939810180824BF01008DF038 /* WebIconDatabase.h in Headers */ = {isa = PBXBuildFile; fileRef = F528E3E9031E91AD01CA2ACA /* WebIconDatabase.h */; settings = {ATTRIBUTES = (Private, ); }; };
    198                 939810190824BF01008DF038 /* WebIconDatabasePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = F528E3EB031E91AD01CA2ACA /* WebIconDatabasePrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
    199196                9398101B0824BF01008DF038 /* WebKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 2568C72C0174912D0ECA149E /* WebKit.h */; settings = {ATTRIBUTES = (Private, ); }; };
    200197                9398101C0824BF01008DF038 /* WebKitErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = F5927D4E02D26C5E01CA2DBB /* WebKitErrors.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    978975                51A8B57D0428353A00CA2D3A /* WebViewPrivate.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebViewPrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    979976                51AEDEF00CECF45700854328 /* WebDatabaseManagerInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebDatabaseManagerInternal.h; sourceTree = "<group>"; };
    980                 51B2A0FF0ADB15D0002A9BEE /* WebIconDatabaseDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebIconDatabaseDelegate.h; sourceTree = "<group>"; };
    981977                51C714FA0B20F79F00E5E33C /* WebBackForwardListInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebBackForwardListInternal.h; sourceTree = "<group>"; };
    982978                51CBFCAC0D10E6C5002DBF51 /* WebCachedFramePlatformData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCachedFramePlatformData.h; sourceTree = "<group>"; };
     
    10521048                84AE905F062DE6A80075BBF9 /* WebDOMOperationsPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebDOMOperationsPrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    10531049                84CA5F7E042685E800CA2ACA /* WebKitErrorsPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebKitErrorsPrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    1054                 9304B2FF0B02341500F7850D /* WebIconDatabaseInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebIconDatabaseInternal.h; sourceTree = "<group>"; };
    10551050                930D02BB06275F640076701E /* WebViewInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebViewInternal.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    10561051                930D02BD06275F710076701E /* WebFrameInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebFrameInternal.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
     
    15711566                F528E3E9031E91AD01CA2ACA /* WebIconDatabase.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebIconDatabase.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    15721567                F528E3EA031E91AD01CA2ACA /* WebIconDatabase.mm */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebIconDatabase.mm; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    1573                 F528E3EB031E91AD01CA2ACA /* WebIconDatabasePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebIconDatabasePrivate.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    15741568                F53444CE02E87CBA018635CA /* WebKitStatistics.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = WebKitStatistics.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    15751569                F53444CF02E87CBA018635CA /* WebKitStatistics.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = WebKitStatistics.m; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
     
    17921786                                F528E3E9031E91AD01CA2ACA /* WebIconDatabase.h */,
    17931787                                F528E3EA031E91AD01CA2ACA /* WebIconDatabase.mm */,
    1794                                 51B2A0FF0ADB15D0002A9BEE /* WebIconDatabaseDelegate.h */,
    1795                                 9304B2FF0B02341500F7850D /* WebIconDatabaseInternal.h */,
    1796                                 F528E3EB031E91AD01CA2ACA /* WebIconDatabasePrivate.h */,
    17971788                                2568C72C0174912D0ECA149E /* WebKit.h */,
    17981789                                F5927D4E02D26C5E01CA2DBB /* WebKitErrors.h */,
     
    30643055                                939810180824BF01008DF038 /* WebIconDatabase.h in Headers */,
    30653056                                51494CD60C7EBDE0004178C5 /* WebIconDatabaseClient.h in Headers */,
    3066                                 51B2A1000ADB15D0002A9BEE /* WebIconDatabaseDelegate.h in Headers */,
    3067                                 9304B3000B02341500F7850D /* WebIconDatabaseInternal.h in Headers */,
    3068                                 939810190824BF01008DF038 /* WebIconDatabasePrivate.h in Headers */,
    30693057                                9321D5921A391DC3008052BE /* WebImmediateActionController.h in Headers */,
    30703058                                A560946614D8AD2600799A8A /* WebIndicateLayer.h in Headers */,
     
    32383226                                LastUpgradeCheck = 0700;
    32393227                        };
    3240                         buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */;
     3228                        buildConfigurationList = 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKitLegacy" */;
    32413229                        compatibilityVersion = "Xcode 3.2";
    32423230                        developmentRegion = English;
     
    38113799                        defaultConfigurationName = Production;
    38123800                };
    3813                 149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKit" */ = {
     3801                149C283208902B0F008A9EFC /* Build configuration list for PBXProject "WebKitLegacy" */ = {
    38143802                        isa = XCConfigurationList;
    38153803                        buildConfigurations = (
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r219648 r219695  
     12017-07-20  Brady Eidson  <beidson@apple.com>
     2
     3        Deprecate WebIconDatabase in WebKitLegacy/mac.
     4        https://bugs.webkit.org/show_bug.cgi?id=174607
     5
     6        Reviewed by Alex Christensen.
     7
     8        This patch:
     9        1 - Formally deprecates WebIconDatabase (which was never API anyways)
     10        2 - Guts the class to where it can only return the default icon at the small size
     11        3 - Reworks other parts of WebKitLegacy that used it for anything to either
     12            use something else or to not do anything.
     13       
     14        This patch *could* go much farther. A future patch is what will remove WebCore/IconDatabase
     15        and that patch will remove all of the last remnants of WebIconDatabase.
     16       
     17        * History/WebHistoryItem.mm:
     18        (-[WebHistoryItem icon]):
     19
     20        * Misc/WebIconDatabase.h:
     21        * Misc/WebIconDatabase.mm:
     22        (-[WebIconDatabase init]):
     23        (-[WebIconDatabase iconForURL:withSize:cache:]):
     24        (-[WebIconDatabase iconForURL:withSize:]):
     25        (-[WebIconDatabase defaultIconWithSize:]):
     26        (-[WebIconDatabase defaultIconForURL:withSize:]):
     27        (-[WebIconDatabase iconURLForURL:]):
     28        (-[WebIconDatabase retainIconForURL:]):
     29        (-[WebIconDatabase releaseIconForURL:]):
     30        (+[WebIconDatabase delayDatabaseCleanup]):
     31        (+[WebIconDatabase allowDatabaseCleanup]):
     32        (-[WebIconDatabase setDelegate:]):
     33        (-[WebIconDatabase delegate]):
     34        (+[WebIconDatabase initialize]): Deleted.
     35        (-[WebIconDatabase isEnabled]): Deleted.
     36        (-[WebIconDatabase setEnabled:]): Deleted.
     37        (-[WebIconDatabase removeAllIcons]): Deleted.
     38        (+[WebIconDatabase _checkIntegrityBeforeOpening]): Deleted.
     39        (-[WebIconDatabase _sendNotificationForURL:]): Deleted.
     40        (-[WebIconDatabase _sendDidRemoveAllIconsNotification]): Deleted.
     41        (-[WebIconDatabase _startUpIconDatabase]): Deleted.
     42        (-[WebIconDatabase _shutDownIconDatabase]): Deleted.
     43        (-[WebIconDatabase _applicationWillTerminate:]): Deleted.
     44        (-[WebIconDatabase _iconForFileURL:withSize:]): Deleted.
     45        (-[WebIconDatabase _resetCachedWebPreferences:]): Deleted.
     46        (-[WebIconDatabase _largestIconFromDictionary:]): Deleted.
     47        (-[WebIconDatabase _iconsBySplittingRepresentationsOfIcon:]): Deleted.
     48        (-[WebIconDatabase _iconFromDictionary:forSize:cache:]): Deleted.
     49        (-[WebIconDatabase _scaleIcon:toSize:]): Deleted.
     50        (-[WebIconDatabase _databaseDirectory]): Deleted.
     51        (webGetNSImage): Deleted.
     52
     53        * Misc/WebIconDatabaseDelegate.h: Removed.
     54        * Misc/WebIconDatabaseInternal.h: Removed.
     55        * Misc/WebIconDatabasePrivate.h: Removed.
     56
     57        * WebCoreSupport/WebFrameLoaderClient.mm:
     58        (webGetNSImage):
     59
     60        * WebCoreSupport/WebIconDatabaseClient.mm:
     61        (WebIconDatabaseClient::didRemoveAllIcons):
     62        (WebIconDatabaseClient::didImportIconURLForPageURL):
     63
     64        * WebView/WebView.mm:
     65        (-[WebView setFrameLoadDelegate:]):
     66        (-[WebView mainFrameIcon]):
     67
    1682017-07-18  Andy Estes  <aestes@apple.com>
    269
  • trunk/Source/WebKitLegacy/mac/Configurations/WebKitLegacy.xcconfig

    r219155 r219695  
    2525#include "Version.xcconfig"
    2626
    27 EXCLUDED_SOURCE_FILE_NAMES[sdk=iphone*] = *.defs *.nib *.pdf *.tiff CarbonUtils.* CarbonWindowAdapter.* CarbonWindowContentView.* CarbonWindowFrame.* HIViewAdapter.* HIWebView.* OutlookQuirksUserScript.js PopupMenuMac.* SearchPopupMenuMac.* WebClipView.* WebDashboardRegion.* WebDynamicScrollBarsView.* WebIconDatabase.* WebIconDatabasePrivate.* WebInspectorClient.* WebJavaScriptTextInputPanel.* WebNSEventExtras.* WebNSPasteboardExtras.* WebNSWindowExtras.* WebPanelAuthenticationHandler.* WebPluginsPrivate.* WebStringTruncator.* WebTextCompletionController.*;
     27EXCLUDED_SOURCE_FILE_NAMES[sdk=iphone*] = *.defs *.nib *.pdf *.tiff CarbonUtils.* CarbonWindowAdapter.* CarbonWindowContentView.* CarbonWindowFrame.* HIViewAdapter.* HIWebView.* OutlookQuirksUserScript.js PopupMenuMac.* SearchPopupMenuMac.* WebClipView.* WebDashboardRegion.* WebDynamicScrollBarsView.* WebIconDatabase.* WebInspectorClient.* WebJavaScriptTextInputPanel.* WebNSEventExtras.* WebNSPasteboardExtras.* WebNSWindowExtras.* WebPanelAuthenticationHandler.* WebPluginsPrivate.* WebStringTruncator.* WebTextCompletionController.*;
    2828EXCLUDED_SOURCE_FILE_NAMES[sdk=macosx*] = *IOS.mm MemoryMeasure.h WebCaretChangeListener.h WebFixedPositionContent.h WebFrameIOS.h WebFrameIPhone.h WebGeolocationCoreLocationProvider.h WebGeolocationPrivate.h WebGeolocationProviderIOS.h WebMIMETypeRegistry.h WebNSStringExtrasIOS.h WebNSStringExtrasIPhone.h WebPDFViewIOS.h WebPDFViewIPhone.h WebPDFViewPlaceholder.h WebSelectionRect.h WebUIKitDelegate.h WebUIKitSupport.h WebVisiblePosition.h DOMHTMLTextAreaElementPrivate.h DOMUIKitExtensions.h;
    2929
  • trunk/Source/WebKitLegacy/mac/History/WebHistoryItem.mm

    r219057 r219695  
    200200- (NSImage *)icon
    201201{
     202#pragma GCC diagnostic push
     203#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
    202204    return [[WebIconDatabase sharedIconDatabase] iconForURL:[self URLString] withSize:WebIconSmallSize];
     205#pragma GCC diagnostic pop
    203206}
    204207#endif
  • trunk/Source/WebKitLegacy/mac/Misc/WebIconDatabase.h

    r207934 r219695  
    3333#endif
    3434
    35 // Sent whenever a site icon has changed. The object of the notification is the icon database.
    36 // The userInfo contains the site URL whose icon has changed.
    37 // It can be accessed with the key WebIconNotificationUserInfoURLKey.
     35#define ICON_DATABASE_DEPRECATED __deprecated_msg("WebIconDatabase is not API and no longer handles icon loading. It will be removed in a future release.")
     36
    3837extern NSString *WebIconDatabaseDidAddIconNotification;
    3938
     
    6665    Retention methods can be called for icons that are not yet in the database.
    6766*/
     67
     68ICON_DATABASE_DEPRECATED
    6869@interface WebIconDatabase : NSObject {
    6970
     
    7778    @abstract Returns a shared instance of the icon database
    7879*/
    79 + (WebIconDatabase *)sharedIconDatabase;
     80+ (WebIconDatabase *)sharedIconDatabase ICON_DATABASE_DEPRECATED;
    8081
    8182#if !TARGET_OS_IPHONE
     
    8485    @discussion Calls iconForURL:withSize:cache: with YES for cache.
    8586*/
    86 - (NSImage *)iconForURL:(NSString *)URL withSize:(NSSize)size;
     87- (NSImage *)iconForURL:(NSString *)URL withSize:(NSSize)size ICON_DATABASE_DEPRECATED;
    8788
    8889/*!
     
    9394    @param cache If yes, caches the returned image in memory if not already cached
    9495*/
    95 - (NSImage *)iconForURL:(NSString *)URL withSize:(NSSize)size cache:(BOOL)cache;
     96- (NSImage *)iconForURL:(NSString *)URL withSize:(NSSize)size cache:(BOOL)cache ICON_DATABASE_DEPRECATED;
    9697#endif
    9798
     
    100101    @discussion Returns an icon URL for a web site URL from memory or disk. nil if none is found.
    101102*/
    102 - (NSString *)iconURLForURL:(NSString *)URL;
     103- (NSString *)iconURLForURL:(NSString *)URL ICON_DATABASE_DEPRECATED;
    103104
    104105#if !TARGET_OS_IPHONE
     
    106107    @method defaultIconWithSize:
    107108*/
    108 - (NSImage *)defaultIconWithSize:(NSSize)size;
    109 - (NSImage *)defaultIconForURL:(NSString *)URL withSize:(NSSize)size;
     109- (NSImage *)defaultIconWithSize:(NSSize)size ICON_DATABASE_DEPRECATED;
     110- (NSImage *)defaultIconForURL:(NSString *)URL withSize:(NSSize)size ICON_DATABASE_DEPRECATED;
    110111#endif
    111112
     
    114115    @abstract Increments the retain count of the icon.
    115116*/
    116 - (void)retainIconForURL:(NSString *)URL;
     117- (void)retainIconForURL:(NSString *)URL ICON_DATABASE_DEPRECATED;
    117118
    118119/*!
     
    120121    @abstract Decrements the retain count of the icon.
    121122*/
    122 - (void)releaseIconForURL:(NSString *)URL;
     123- (void)releaseIconForURL:(NSString *)URL ICON_DATABASE_DEPRECATED;
    123124
    124125/*!
     
    128129    The counter equals 0 at initialization.
    129130*/
    130 + (void)delayDatabaseCleanup;
     131+ (void)delayDatabaseCleanup ICON_DATABASE_DEPRECATED;
    131132
    132133/*!
     
    136137    The counter equals 0 at initialization.
    137138*/
    138 + (void)allowDatabaseCleanup;
     139+ (void)allowDatabaseCleanup ICON_DATABASE_DEPRECATED;
    139140
    140 - (void)setDelegate:(id)delegate;
    141 - (id)delegate;
     141- (void)setDelegate:(id)delegate ICON_DATABASE_DEPRECATED;
     142- (id)delegate ICON_DATABASE_DEPRECATED;
    142143
    143144@end
  • trunk/Source/WebKitLegacy/mac/Misc/WebIconDatabase.mm

    r219200 r219695  
    2929#if !PLATFORM(IOS)
    3030
    31 #import "WebIconDatabaseInternal.h"
     31#import "WebIconDatabase.h"
    3232
    33 #import "WebIconDatabaseClient.h"
    34 #import "WebIconDatabaseDelegate.h"
    35 #import "WebKitLogging.h"
    36 #import "WebKitNSStringExtras.h"
    3733#import "WebKitVersionChecks.h"
    38 #import "WebNSFileManagerExtras.h"
    39 #import "WebNSURLExtras.h"
    40 #import "WebPreferencesPrivate.h"
    41 #import "WebTypesInternal.h"
    42 #import <WebCore/IconDatabase.h>
    4334#import <WebCore/Image.h>
    44 #import <WebCore/IntSize.h>
    45 #import <WebCore/SharedBuffer.h>
    4635#import <WebCore/ThreadCheck.h>
    4736#import <runtime/InitializeThreading.h>
    4837#import <wtf/MainThread.h>
     38#import <wtf/NeverDestroyed.h>
    4939#import <wtf/RunLoop.h>
    5040
     
    6454NSSize WebIconLargeSize = {128, 128};
    6555
    66 #define UniqueFilePathSize (34)
    67 
    68 static WebIconDatabaseClient* defaultClient()
    69 {
    70 #if ENABLE(ICONDATABASE)
    71     static WebIconDatabaseClient* defaultClient = new WebIconDatabaseClient();
    72     return defaultClient;
    73 #else
    74     return 0;
    75 #endif
    76 }
    77 
    78 @interface WebIconDatabase (WebReallyInternal)
    79 - (void)_sendNotificationForURL:(NSString *)URL;
    80 - (void)_sendDidRemoveAllIconsNotification;
    81 - (NSImage *)_iconForFileURL:(NSString *)fileURL withSize:(NSSize)size;
    82 - (void)_resetCachedWebPreferences:(NSNotification *)notification;
    83 - (NSImage *)_largestIconFromDictionary:(NSMutableDictionary *)icons;
    84 - (NSMutableDictionary *)_iconsBySplittingRepresentationsOfIcon:(NSImage *)icon;
    85 - (NSImage *)_iconFromDictionary:(NSMutableDictionary *)icons forSize:(NSSize)size cache:(BOOL)cache;
    86 - (void)_scaleIcon:(NSImage *)icon toSize:(NSSize)size;
    87 - (NSString *)_databaseDirectory;
    88 @end
     56static const unsigned char defaultIconData[] = { 0x4D, 0x4D, 0x00, 0x2A, 0x00, 0x00, 0x03, 0x32, 0x80, 0x00, 0x20, 0x50, 0x38, 0x24, 0x16, 0x0D, 0x07, 0x84, 0x42, 0x61, 0x50, 0xB8,
     57    0x64, 0x08, 0x18, 0x0D, 0x0A, 0x0B, 0x84, 0xA2, 0xA1, 0xE2, 0x08, 0x5E, 0x39, 0x28, 0xAF, 0x48, 0x24, 0xD3, 0x53, 0x9A, 0x37, 0x1D, 0x18, 0x0E, 0x8A, 0x4B, 0xD1, 0x38,
     58    0xB0, 0x7C, 0x82, 0x07, 0x03, 0x82, 0xA2, 0xE8, 0x6C, 0x2C, 0x03, 0x2F, 0x02, 0x82, 0x41, 0xA1, 0xE2, 0xF8, 0xC8, 0x84, 0x68, 0x6D, 0x1C, 0x11, 0x0A, 0xB7, 0xFA, 0x91,
     59    0x6E, 0xD1, 0x7F, 0xAF, 0x9A, 0x4E, 0x87, 0xFB, 0x19, 0xB0, 0xEA, 0x7F, 0xA4, 0x95, 0x8C, 0xB7, 0xF9, 0xA9, 0x0A, 0xA9, 0x7F, 0x8C, 0x88, 0x66, 0x96, 0xD4, 0xCA, 0x69,
     60    0x2F, 0x00, 0x81, 0x65, 0xB0, 0x29, 0x90, 0x7C, 0xBA, 0x2B, 0x21, 0x1E, 0x5C, 0xE6, 0xB4, 0xBD, 0x31, 0xB6, 0xE7, 0x7A, 0xBF, 0xDD, 0x6F, 0x37, 0xD3, 0xFD, 0xD8, 0xF2,
     61    0xB6, 0xDB, 0xED, 0xAC, 0xF7, 0x03, 0xC5, 0xFE, 0x77, 0x53, 0xB6, 0x1F, 0xE6, 0x24, 0x8B, 0x1D, 0xFE, 0x26, 0x20, 0x9E, 0x1C, 0xE0, 0x80, 0x65, 0x7A, 0x18, 0x02, 0x01,
     62    0x82, 0xC5, 0xA0, 0xC0, 0xF1, 0x89, 0xBA, 0x23, 0x30, 0xAD, 0x1F, 0xE7, 0xE5, 0x5B, 0x6D, 0xFE, 0xE7, 0x78, 0x3E, 0x1F, 0xEE, 0x97, 0x8B, 0xE7, 0x37, 0x9D, 0xCF, 0xE7,
     63    0x92, 0x8B, 0x87, 0x0B, 0xFC, 0xA0, 0x8E, 0x68, 0x3F, 0xC6, 0x27, 0xA6, 0x33, 0xFC, 0x36, 0x5B, 0x59, 0x3F, 0xC1, 0x02, 0x63, 0x3B, 0x74, 0x00, 0x03, 0x07, 0x0B, 0x61,
     64    0x00, 0x20, 0x60, 0xC9, 0x08, 0x00, 0x1C, 0x25, 0x9F, 0xE0, 0x12, 0x8A, 0xD5, 0xFE, 0x6B, 0x4F, 0x35, 0x9F, 0xED, 0xD7, 0x4B, 0xD9, 0xFE, 0x8A, 0x59, 0xB8, 0x1F, 0xEC,
     65    0x56, 0xD3, 0xC1, 0xFE, 0x63, 0x4D, 0xF2, 0x83, 0xC6, 0xB6, 0x1B, 0xFC, 0x34, 0x68, 0x61, 0x3F, 0xC1, 0xA6, 0x25, 0xEB, 0xFC, 0x06, 0x58, 0x5C, 0x3F, 0xC0, 0x03, 0xE4,
     66    0xC3, 0xFC, 0x04, 0x0F, 0x1A, 0x6F, 0xE0, 0xE0, 0x20, 0xF9, 0x61, 0x7A, 0x02, 0x28, 0x2B, 0xBC, 0x46, 0x25, 0xF3, 0xFC, 0x66, 0x3D, 0x99, 0x27, 0xF9, 0x7E, 0x6B, 0x1D,
     67    0xC7, 0xF9, 0x2C, 0x5E, 0x1C, 0x87, 0xF8, 0xC0, 0x4D, 0x9A, 0xE7, 0xF8, 0xDA, 0x51, 0xB2, 0xC1, 0x68, 0xF2, 0x64, 0x1F, 0xE1, 0x50, 0xED, 0x0A, 0x04, 0x23, 0x79, 0x8A,
     68    0x7F, 0x82, 0xA3, 0x39, 0x80, 0x7F, 0x80, 0xC2, 0xB1, 0x5E, 0xF7, 0x04, 0x2F, 0xB2, 0x10, 0x02, 0x86, 0x63, 0xC9, 0xCC, 0x07, 0xBF, 0x87, 0xF8, 0x4A, 0x38, 0xAF, 0xC1,
     69    0x88, 0xF8, 0x66, 0x1F, 0xE1, 0xD9, 0x08, 0xD4, 0x8F, 0x25, 0x5B, 0x4A, 0x49, 0x97, 0x87, 0x39, 0xFE, 0x25, 0x12, 0x10, 0x68, 0xAA, 0x4A, 0x2F, 0x42, 0x29, 0x12, 0x69,
     70    0x9F, 0xE1, 0xC1, 0x00, 0x67, 0x1F, 0xE1, 0x58, 0xED, 0x00, 0x83, 0x23, 0x49, 0x82, 0x7F, 0x81, 0x21, 0xE0, 0xFC, 0x73, 0x21, 0x00, 0x50, 0x7D, 0x2B, 0x84, 0x03, 0x83,
     71    0xC2, 0x1B, 0x90, 0x06, 0x69, 0xFE, 0x23, 0x91, 0xAE, 0x50, 0x9A, 0x49, 0x32, 0xC2, 0x89, 0x30, 0xE9, 0x0A, 0xC4, 0xD9, 0xC4, 0x7F, 0x94, 0xA6, 0x51, 0xDE, 0x7F, 0x9D,
     72    0x07, 0x89, 0xF6, 0x7F, 0x91, 0x85, 0xCA, 0x88, 0x25, 0x11, 0xEE, 0x50, 0x7C, 0x43, 0x35, 0x21, 0x60, 0xF1, 0x0D, 0x82, 0x62, 0x39, 0x07, 0x2C, 0x20, 0xE0, 0x80, 0x72,
     73    0x34, 0x17, 0xA1, 0x80, 0xEE, 0xF0, 0x89, 0x24, 0x74, 0x1A, 0x2C, 0x93, 0xB3, 0x78, 0xCC, 0x52, 0x9D, 0x6A, 0x69, 0x56, 0xBB, 0x0D, 0x85, 0x69, 0xE6, 0x7F, 0x9E, 0x27,
     74    0xB9, 0xFD, 0x50, 0x54, 0x47, 0xF9, 0xCC, 0x78, 0x9F, 0x87, 0xF9, 0x98, 0x70, 0xB9, 0xC2, 0x91, 0x2C, 0x6D, 0x1F, 0xE1, 0xE1, 0x00, 0xBF, 0x02, 0xC1, 0xF5, 0x18, 0x84,
     75    0x01, 0xE1, 0x48, 0x8C, 0x42, 0x07, 0x43, 0xC9, 0x76, 0x7F, 0x8B, 0x04, 0xE4, 0xDE, 0x35, 0x95, 0xAB, 0xB0, 0xF0, 0x5C, 0x55, 0x23, 0xF9, 0x7E, 0x7E, 0x9F, 0xE4, 0x0C,
     76    0xA7, 0x55, 0x47, 0xC7, 0xF9, 0xE6, 0xCF, 0x1F, 0xE7, 0x93, 0x35, 0x52, 0x54, 0x63, 0x19, 0x46, 0x73, 0x1F, 0xE2, 0x61, 0x08, 0xF0, 0x82, 0xE1, 0x80, 0x92, 0xF9, 0x20,
     77    0xC0, 0x28, 0x18, 0x0A, 0x05, 0xA1, 0xA2, 0xF8, 0x6E, 0xDB, 0x47, 0x49, 0xFE, 0x3E, 0x17, 0xB6, 0x61, 0x13, 0x1A, 0x29, 0x26, 0xA9, 0xFE, 0x7F, 0x92, 0x70, 0x69, 0xFE,
     78    0x4C, 0x2F, 0x55, 0x01, 0xF1, 0x54, 0xD4, 0x35, 0x49, 0x4A, 0x69, 0x59, 0x83, 0x81, 0x58, 0x76, 0x9F, 0xE2, 0x20, 0xD6, 0x4C, 0x9B, 0xA0, 0x48, 0x1E, 0x0B, 0xB7, 0x48,
     79    0x58, 0x26, 0x11, 0x06, 0x42, 0xE8, 0xA4, 0x40, 0x17, 0x27, 0x39, 0x00, 0x60, 0x2D, 0xA4, 0xC3, 0x2C, 0x7F, 0x94, 0x56, 0xE4, 0xE1, 0x77, 0x1F, 0xE5, 0xB9, 0xD7, 0x66,
     80    0x1E, 0x07, 0xB3, 0x3C, 0x63, 0x1D, 0x35, 0x49, 0x0E, 0x63, 0x2D, 0xA2, 0xF1, 0x12, 0x60, 0x1C, 0xE0, 0xE0, 0x52, 0x1B, 0x8B, 0xAC, 0x38, 0x0E, 0x07, 0x03, 0x60, 0x28,
     81    0x1C, 0x0E, 0x87, 0x00, 0xF0, 0x66, 0x27, 0x11, 0xA2, 0xC1, 0x02, 0x5A, 0x1C, 0xE4, 0x21, 0x83, 0x1F, 0x13, 0x86, 0xFA, 0xD2, 0x55, 0x1D, 0xD6, 0x61, 0xBC, 0x77, 0xD3,
     82    0xE6, 0x91, 0xCB, 0x4C, 0x90, 0xA6, 0x25, 0xB8, 0x2F, 0x90, 0xC5, 0xA9, 0xCE, 0x12, 0x07, 0x02, 0x91, 0x1B, 0x9F, 0x68, 0x00, 0x16, 0x76, 0x0D, 0xA1, 0x00, 0x08, 0x06,
     83    0x03, 0x81, 0xA0, 0x20, 0x1A, 0x0D, 0x06, 0x80, 0x30, 0x24, 0x12, 0x89, 0x20, 0x98, 0x4A, 0x1F, 0x0F, 0x21, 0xA0, 0x9E, 0x36, 0x16, 0xC2, 0x88, 0xE6, 0x48, 0x9B, 0x83,
     84    0x31, 0x1C, 0x55, 0x1E, 0x43, 0x59, 0x1A, 0x56, 0x1E, 0x42, 0xF0, 0xFA, 0x4D, 0x1B, 0x9B, 0x08, 0xDC, 0x5B, 0x02, 0xA1, 0x30, 0x7E, 0x3C, 0xEE, 0x5B, 0xA6, 0xDD, 0xB8,
     85    0x6D, 0x5B, 0x62, 0xB7, 0xCD, 0xF3, 0x9C, 0xEA, 0x04, 0x80, 0x80, 0x00, 0x00, 0x0E, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x01, 0x01,
     86    0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10, 0x00, 0x00, 0x01, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0xE0, 0x01, 0x03, 0x00, 0x03, 0x00, 0x00,
     87    0x00, 0x01, 0x00, 0x05, 0x00, 0x00, 0x01, 0x06, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x11, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
     88    0x00, 0x08, 0x01, 0x15, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x00, 0x00, 0x01, 0x16, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02, 0x00, 0x01, 0x17,
     89    0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0x29, 0x01, 0x1A, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x03, 0xE8, 0x01, 0x1B, 0x00, 0x05, 0x00, 0x00,
     90    0x00, 0x01, 0x00, 0x00, 0x03, 0xF0, 0x01, 0x1C, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x28, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02,
     91    0x00, 0x00, 0x01, 0x52, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x0A,
     92    0xFC, 0x80, 0x00, 0x00, 0x27, 0x10, 0x00, 0x0A, 0xFC, 0x80, 0x00, 0x00, 0x27, 0x10 };
    8993
    9094@implementation WebIconDatabase
     
    113117- (id)init
    114118{
    115     self = [super init];
    116     if (!self)
    117         return nil;
    118119    WebCoreThreadViolationCheckRoundOne();
    119        
    120     _private = [[WebIconDatabasePrivate alloc] init];
    121    
    122     // Check the user defaults and see if the icon database should even be enabled.
    123     // Inform the bridge and, if we're disabled, bail from init right here
    124     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    125     // <rdar://problem/4741419> - IconDatabase should be disabled by default
    126     NSDictionary *initialDefaults = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithBool:YES], WebIconDatabaseEnabledDefaultsKey, nil];
    127     [defaults registerDefaults:initialDefaults];
    128     [initialDefaults release];
    129     BOOL enabled = [defaults boolForKey:WebIconDatabaseEnabledDefaultsKey];
    130     iconDatabase().setEnabled(enabled);
    131     if (enabled)
    132         [self _startUpIconDatabase];
    133     return self;
     120
     121    return [super init];
    134122}
    135123
    136124- (NSImage *)iconForURL:(NSString *)URL withSize:(NSSize)size cache:(BOOL)cache
    137125{
    138     ASSERT(size.width);
    139     ASSERT(size.height);
    140 
    141     if (!URL || ![self isEnabled])
    142         return [self defaultIconForURL:URL withSize:size];
    143 
    144     // FIXME - <rdar://problem/4697934> - Move the handling of FileURLs to WebCore and implement in ObjC++
    145     if ([URL _webkit_isFileURL])
    146         return [self _iconForFileURL:URL withSize:size];
    147    
    148     if (Image* image = iconDatabase().synchronousIconForPageURL(URL, IntSize(size)))
    149         if (NSImage *icon = webGetNSImage(image, size))
    150             return icon;
    151     return [self defaultIconForURL:URL withSize:size];
     126    return [self defaultIconWithSize:size];
    152127}
    153128
    154129- (NSImage *)iconForURL:(NSString *)URL withSize:(NSSize)size
    155130{
    156     return [self iconForURL:URL withSize:size cache:YES];
     131    return [self defaultIconWithSize:size];
     132}
     133
     134- (NSImage *)defaultIconWithSize:(NSSize)size
     135{
     136    static NeverDestroyed<RetainPtr<NSImage>> defaultImage;
     137
     138    static dispatch_once_t once;
     139    dispatch_once(&once, ^ {
     140        auto imageData = adoptNS([[NSData alloc] initWithBytes:defaultIconData length:sizeof(defaultIconData)]);
     141        defaultImage.get() = adoptNS([[NSImage alloc] initWithData:imageData.get()]);
     142    });
     143   
     144    return defaultImage.get().get();
     145}
     146
     147- (NSImage *)defaultIconForURL:(NSString *)URL withSize:(NSSize)size
     148{
     149    return [self defaultIconWithSize:size];
    157150}
    158151
    159152- (NSString *)iconURLForURL:(NSString *)URL
    160153{
    161     if (![self isEnabled])
    162         return nil;
    163 
    164     return iconDatabase().synchronousIconURLForPageURL(URL);
    165 }
    166 
    167 - (NSImage *)defaultIconWithSize:(NSSize)size
    168 {
    169     ASSERT(size.width);
    170     ASSERT(size.height);
    171    
    172     Image* image = iconDatabase().defaultIcon(IntSize(size));
    173     return image ? image->snapshotNSImage().autorelease() : nil;
    174 }
    175 
    176 - (NSImage *)defaultIconForURL:(NSString *)URL withSize:(NSSize)size
    177 {
    178     if (_private->delegateImplementsDefaultIconForURL)
    179         return [_private->delegate webIconDatabase:self defaultIconForURL:URL withSize:size];
    180     return [self defaultIconWithSize:size];
     154    return nil;
    181155}
    182156
    183157- (void)retainIconForURL:(NSString *)URL
    184158{
    185     ASSERT(URL);
    186     if (![self isEnabled])
    187         return;
    188 
    189     iconDatabase().retainIconForPageURL(URL);
    190159}
    191160
    192161- (void)releaseIconForURL:(NSString *)pageURL
    193162{
    194     ASSERT(pageURL);
    195     if (![self isEnabled])
    196         return;
    197 
    198     iconDatabase().releaseIconForPageURL(pageURL);
    199163}
    200164
    201165+ (void)delayDatabaseCleanup
    202166{
    203     IconDatabase::delayDatabaseCleanup();
    204167}
    205168
    206169+ (void)allowDatabaseCleanup
    207170{
    208     IconDatabase::allowDatabaseCleanup();
    209171}
    210172
    211173- (void)setDelegate:(id)delegate
    212174{
    213     _private->delegate = delegate;
    214     _private->delegateImplementsDefaultIconForURL = [delegate respondsToSelector:@selector(webIconDatabase:defaultIconForURL:withSize:)];
    215175}
    216176
    217177- (id)delegate
    218178{
    219     return _private->delegate;
     179    return nil;
    220180}
    221181
    222182@end
    223183
    224 
    225 @implementation WebIconDatabase (WebPendingPublic)
    226 
    227 - (BOOL)isEnabled
    228 {
    229     return iconDatabase().isEnabled();
    230 }
    231 
    232 - (void)setEnabled:(BOOL)flag
    233 {
    234     BOOL currentlyEnabled = [self isEnabled];
    235     if (currentlyEnabled && !flag) {
    236         iconDatabase().setEnabled(false);
    237         [self _shutDownIconDatabase];
    238     } else if (!currentlyEnabled && flag) {
    239         iconDatabase().setEnabled(true);
    240         [self _startUpIconDatabase];
    241     }
    242 }
    243 
    244 - (void)removeAllIcons
    245 {
    246     if (![self isEnabled])
    247         return;
    248 
    249     // Via the IconDatabaseClient interface, removeAllIcons() will send the WebIconDatabaseDidRemoveAllIconsNotification
    250     iconDatabase().removeAllIcons();
    251 }
    252 
    253 @end
    254 
    255 @implementation WebIconDatabase (WebPrivate)
    256 
    257 + (void)_checkIntegrityBeforeOpening
    258 {
    259     IconDatabase::checkIntegrityBeforeOpening();
    260 }
    261 
    262 @end
    263 
    264 @implementation WebIconDatabase (WebInternal)
    265 
    266 - (void)_sendNotificationForURL:(NSString *)URL
    267 {
    268     ASSERT(URL);
    269    
    270     dispatch_async(dispatch_get_main_queue(), ^{
    271         NSDictionary *userInfo = @{ WebIconNotificationUserInfoURLKey : URL };
    272         [[NSNotificationCenter defaultCenter] postNotificationName:WebIconDatabaseDidAddIconNotification object:self userInfo:userInfo];
    273     });
    274 }
    275 
    276 - (void)_sendDidRemoveAllIconsNotification
    277 {
    278     dispatch_async(dispatch_get_main_queue(), ^{
    279         [[NSNotificationCenter defaultCenter] postNotificationName:WebIconDatabaseDidRemoveAllIconsNotification object:self];
    280     });
    281 }
    282 
    283 - (void)_startUpIconDatabase
    284 {
    285     iconDatabase().setClient(defaultClient());
    286    
    287     // Figure out the directory we should be using for the icon.db
    288     NSString *databaseDirectory = [self _databaseDirectory];
    289    
    290     // Rename legacy icon database files to the new icon database name
    291     BOOL isDirectory = NO;
    292     NSString *legacyDB = [databaseDirectory stringByAppendingPathComponent:@"icon.db"];
    293     NSFileManager *defaultManager = [NSFileManager defaultManager];
    294     if ([defaultManager fileExistsAtPath:legacyDB isDirectory:&isDirectory] && !isDirectory) {
    295         NSString *newDB = [databaseDirectory stringByAppendingPathComponent:IconDatabase::defaultDatabaseFilename()];
    296         if (![defaultManager fileExistsAtPath:newDB])
    297             rename([legacyDB fileSystemRepresentation], [newDB fileSystemRepresentation]);
    298     }
    299    
    300     // Set the private browsing pref then open the WebCore icon database
    301     iconDatabase().setPrivateBrowsingEnabled([[WebPreferences standardPreferences] privateBrowsingEnabled]);
    302     if (!iconDatabase().open(databaseDirectory, IconDatabase::defaultDatabaseFilename()))
    303         LOG_ERROR("Unable to open icon database");
    304    
    305     // Register for important notifications
    306     [[NSNotificationCenter defaultCenter] addObserver:self
    307                                              selector:@selector(_applicationWillTerminate:)
    308                                                  name:NSApplicationWillTerminateNotification
    309                                                object:NSApp];
    310     [[NSNotificationCenter defaultCenter] addObserver:self
    311                                              selector:@selector(_resetCachedWebPreferences:)
    312                                                  name:WebPreferencesChangedInternalNotification
    313                                                object:nil];
    314 }
    315 
    316 - (void)_shutDownIconDatabase
    317 {
    318     // Unregister for important notifications
    319     [[NSNotificationCenter defaultCenter] removeObserver:self
    320                                                     name:NSApplicationWillTerminateNotification
    321                                                   object:NSApp];
    322     [[NSNotificationCenter defaultCenter] removeObserver:self
    323                                                     name:WebPreferencesChangedInternalNotification
    324                                                   object:nil];
    325 }
    326 
    327 - (void)_applicationWillTerminate:(NSNotification *)notification
    328 {
    329     iconDatabase().close();
    330 }
    331 
    332 - (NSImage *)_iconForFileURL:(NSString *)file withSize:(NSSize)size
    333 {
    334     ASSERT(size.width);
    335     ASSERT(size.height);
    336 
    337     NSWorkspace *workspace = [NSWorkspace sharedWorkspace];
    338     NSString *path = [[NSURL _web_URLWithDataAsString:file] path];
    339     NSString *suffix = [path pathExtension];
    340     NSImage *icon = nil;
    341    
    342     if ([suffix _webkit_isCaseInsensitiveEqualToString:@"htm"] || [suffix _webkit_isCaseInsensitiveEqualToString:@"html"]) {
    343         if (!_private->htmlIcons) {
    344             icon = [workspace iconForFileType:@"html"];
    345             _private->htmlIcons = [[self _iconsBySplittingRepresentationsOfIcon:icon] retain];
    346         }
    347         icon = [self _iconFromDictionary:_private->htmlIcons forSize:size cache:YES];
    348     } else {
    349         if (!path || ![path isAbsolutePath]) {
    350             // Return the generic icon when there is no path.
    351             icon = [workspace iconForFileType:NSFileTypeForHFSTypeCode(kGenericDocumentIcon)];
    352         } else {
    353             icon = [workspace iconForFile:path];
    354         }
    355         [self _scaleIcon:icon toSize:size];
    356     }
    357 
    358     return icon;
    359 }
    360 
    361 - (void)_resetCachedWebPreferences:(NSNotification *)notification
    362 {
    363     BOOL privateBrowsingEnabledNow = [[WebPreferences standardPreferences] privateBrowsingEnabled];
    364     iconDatabase().setPrivateBrowsingEnabled(privateBrowsingEnabledNow);
    365 }
    366 
    367 - (NSImage *)_largestIconFromDictionary:(NSMutableDictionary *)icons
    368 {
    369     ASSERT(icons);
    370    
    371     NSEnumerator *enumerator = [icons keyEnumerator];
    372     NSValue *currentSize, *largestSize=nil;
    373     float largestSizeArea=0;
    374 
    375     while ((currentSize = [enumerator nextObject]) != nil) {
    376         NSSize currentSizeSize = [currentSize sizeValue];
    377         float currentSizeArea = currentSizeSize.width * currentSizeSize.height;
    378         if(!largestSizeArea || (currentSizeArea > largestSizeArea)){
    379             largestSize = currentSize;
    380             largestSizeArea = currentSizeArea;
    381         }
    382     }
    383 
    384     return [icons objectForKey:largestSize];
    385 }
    386 
    387 - (NSMutableDictionary *)_iconsBySplittingRepresentationsOfIcon:(NSImage *)icon
    388 {
    389     ASSERT(icon);
    390 
    391     NSMutableDictionary *icons = [NSMutableDictionary dictionary];
    392     NSEnumerator *enumerator = [[icon representations] objectEnumerator];
    393     NSImageRep *rep;
    394 
    395     while ((rep = [enumerator nextObject]) != nil) {
    396         NSSize size = [rep size];
    397         NSImage *subIcon = [[NSImage alloc] initWithSize:size];
    398         [subIcon addRepresentation:rep];
    399         [icons setObject:subIcon forKey:[NSValue valueWithSize:size]];
    400         [subIcon release];
    401     }
    402 
    403     if([icons count] > 0)
    404         return icons;
    405 
    406     LOG_ERROR("icon has no representations");
    407    
    408     return nil;
    409 }
    410 
    411 - (NSImage *)_iconFromDictionary:(NSMutableDictionary *)icons forSize:(NSSize)size cache:(BOOL)cache
    412 {
    413     ASSERT(size.width);
    414     ASSERT(size.height);
    415 
    416     NSImage *icon = [icons objectForKey:[NSValue valueWithSize:size]];
    417 
    418     if(!icon){
    419         icon = [[[self _largestIconFromDictionary:icons] copy] autorelease];
    420         [self _scaleIcon:icon toSize:size];
    421 
    422         if(cache){
    423             [icons setObject:icon forKey:[NSValue valueWithSize:size]];
    424         }
    425     }
    426 
    427     return icon;
    428 }
    429 
    430 - (void)_scaleIcon:(NSImage *)icon toSize:(NSSize)size
    431 {
    432     ASSERT(size.width);
    433     ASSERT(size.height);
    434    
    435 #if !LOG_DISABLED
    436     double start = CFAbsoluteTimeGetCurrent();
    437 #endif
    438    
    439 #pragma clang diagnostic push
    440 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
    441     [icon setScalesWhenResized:YES];
    442 #pragma clang diagnostic pop
    443     [icon setSize:size];
    444    
    445 #if !LOG_DISABLED
    446     double duration = CFAbsoluteTimeGetCurrent() - start;
    447     LOG(Timing, "scaling icon took %f seconds.", duration);
    448 #endif
    449 }
    450 
    451 - (NSString *)_databaseDirectory
    452 {
    453     NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    454 
    455     // Figure out the directory we should be using for the icon.db
    456     NSString *databaseDirectory = [defaults objectForKey:WebIconDatabaseDirectoryDefaultsKey];
    457     if (!databaseDirectory) {
    458         databaseDirectory = WebIconDatabasePath;
    459         [defaults setObject:databaseDirectory forKey:WebIconDatabaseDirectoryDefaultsKey];
    460     }
    461    
    462     return [[databaseDirectory stringByExpandingTildeInPath] stringByStandardizingPath];
    463 }
    464 
    465 @end
    466 
    467 @implementation WebIconDatabasePrivate
    468 @end
    469 
    470 NSImage *webGetNSImage(Image* image, NSSize size)
    471 {
    472     ASSERT(size.width);
    473     ASSERT(size.height);
    474 
    475     // FIXME: We're doing the resize here for now because WebCore::Image doesn't yet support resizing/multiple representations
    476     // This makes it so there's effectively only one size of a particular icon in the system at a time. We should move this
    477     // to WebCore::Image at some point.
    478     if (!image)
    479         return nil;
    480     NSImage* nsImage = image->nsImage();
    481     if (!nsImage)
    482         return nil;
    483     if (!NSEqualSizes([nsImage size], size)) {
    484 #pragma clang diagnostic push
    485 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
    486         [nsImage setScalesWhenResized:YES];
    487 #pragma clang diagnostic pop
    488         [nsImage setSize:size];
    489     }
    490     return nsImage;
    491 }
    492 
    493184#endif // !PLATFORM(IOS)
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebFrameLoaderClient.mm

    r219099 r219695  
    5252#import "WebHistoryInternal.h"
    5353#import "WebHistoryItemInternal.h"
    54 #import "WebIconDatabaseInternal.h"
    5554#import "WebKitErrorsPrivate.h"
    5655#import "WebKitLogging.h"
     
    23152314}
    23162315
     2316#if !PLATFORM(IOS)
     2317static NSImage *webGetNSImage(Image* image, NSSize size)
     2318{
     2319    ASSERT(size.width);
     2320    ASSERT(size.height);
     2321
     2322    // FIXME: We're doing the resize here for now because WebCore::Image doesn't yet support resizing/multiple representations
     2323    // This makes it so there's effectively only one size of a particular icon in the system at a time. We should move this
     2324    // to WebCore::Image at some point.
     2325    if (!image)
     2326        return nil;
     2327    NSImage* nsImage = image->nsImage();
     2328    if (!nsImage)
     2329        return nil;
     2330    if (!NSEqualSizes([nsImage size], size)) {
     2331#pragma clang diagnostic push
     2332#pragma clang diagnostic ignored "-Wdeprecated-declarations"
     2333        [nsImage setScalesWhenResized:YES];
     2334#pragma clang diagnostic pop
     2335        [nsImage setSize:size];
     2336    }
     2337    return nsImage;
     2338}
     2339#endif // !PLATFORM(IOS)
     2340
    23172341void WebFrameLoaderClient::finishedLoadingIcon(uint64_t callbackID, SharedBuffer* iconData)
    23182342{
  • trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebIconDatabaseClient.mm

    r165676 r219695  
    2929#import "WebIconDatabaseClient.h"
    3030
    31 #import "WebIconDatabaseInternal.h"
    3231#import <wtf/text/WTFString.h>
    3332
     
    3635void WebIconDatabaseClient::didRemoveAllIcons()
    3736{
    38     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    39     [[WebIconDatabase sharedIconDatabase] _sendDidRemoveAllIconsNotification];
    40     [pool drain];
    4137}
    4238
    4339void WebIconDatabaseClient::didImportIconURLForPageURL(const String& pageURL)
    4440{
    45     // This is a quick notification that is likely to fire in a rapidly iterating loop
    46     // Therefore we let WebCore handle autorelease by draining its pool "from time to time"
    47     // instead of us doing it every iteration
    48     [[WebIconDatabase sharedIconDatabase] _sendNotificationForURL:pageURL];
    4941}
    5042
  • trunk/Source/WebKitLegacy/mac/WebView/WebView.mm

    r219626 r219695  
    7474#import "WebHTMLViewInternal.h"
    7575#import "WebHistoryItemInternal.h"
    76 #import "WebIconDatabaseInternal.h"
     76#import "WebIconDatabase.h"
    7777#import "WebInspector.h"
    7878#import "WebInspectorClient.h"
     
    62256225    _private->frameLoadDelegate = delegate;
    62266226    [self _cacheFrameLoadDelegateImplementations];
    6227 
    6228 #if ENABLE(ICONDATABASE)
    6229     // If this delegate wants callbacks for icons, fire up the icon database.
    6230     if (_private->frameLoadDelegateImplementations.didReceiveIconForFrameFunc)
    6231         [WebIconDatabase sharedIconDatabase];
    6232 #endif
    62336227}
    62346228
     
    69876981    if (auto *icon = _private->_mainFrameIcon.get())
    69886982        return icon;
    6989    
     6983
     6984#pragma GCC diagnostic push
     6985#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
    69906986    return [[WebIconDatabase sharedIconDatabase] defaultIconWithSize:WebIconSmallSize];
     6987#pragma GCC diagnostic pop
    69916988}
    69926989
  • trunk/Tools/ChangeLog

    r219689 r219695  
     12017-07-20  Brady Eidson  <beidson@apple.com>
     2
     3        Deprecate WebIconDatabase in WebKitLegacy/mac.
     4        https://bugs.webkit.org/show_bug.cgi?id=174607
     5
     6        Reviewed by Alex Christensen.
     7
     8        * DumpRenderTree/mac/TestRunnerMac.mm:
     9
    1102017-07-20  Jonathan Bedard  <jbedard@apple.com>
    211
  • trunk/Tools/DumpRenderTree/mac/TestRunnerMac.mm

    r219191 r219695  
    8080
    8181#if !PLATFORM(IOS)
    82 #import <WebKit/WebIconDatabasePrivate.h>
    8382#import <wtf/SoftLinking.h>
    8483#endif
Note: See TracChangeset for help on using the changeset viewer.