Changeset 25430 in webkit
- Timestamp:
- Sep 7, 2007 5:40:53 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r25429 r25430 1 2007-09-05 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Darin Adler, Maciej Stachowiak, Mark Rowe, Tim Hatcher. 4 5 Fixed <rdar://problem/5326009> Make non-browser WebKit clients have no 6 memory cache, or a very tiny one 7 8 Added a client callback to notify WebKit when the first navigation has 9 taken place. "Navigation" here means a transition from one page to 10 another that ends up in the back/forward list. 11 12 WebKit Mac uses this notification to grow its cache model under certain 13 circumstances. 14 15 * loader/FrameLoader.cpp: 16 (WebCore::FrameLoader::addBackForwardItemClippedAtTarget): 17 * loader/FrameLoaderClient.h: 18 19 * platform/graphics/svg/SVGImageEmptyClients.h: 20 (WebCore::SVGEmptyFrameLoaderClient::didPerformFirstNavigation): Ah, 21 SVGEmptyFrameLoaderClient, my old friend. 22 1 23 2007-09-07 Adele Peterson <adele@apple.com> 2 24 -
trunk/WebCore/loader/FrameLoader.cpp
r25410 r25430 239 239 , m_creatingInitialEmptyDocument(false) 240 240 , m_committedFirstRealDocumentLoad(false) 241 , m_didPerformFirstNavigation(false) 241 242 #if USE(LOW_BANDWIDTH_DISPLAY) 242 243 , m_useLowBandwidthDisplay(true) … … 3758 3759 Frame* mainFrame = page->mainFrame(); 3759 3760 ASSERT(mainFrame); 3760 RefPtr<HistoryItem> item = mainFrame->loader()->createHistoryItemTree(m_frame, doClip); 3761 FrameLoader* frameLoader = mainFrame->loader(); 3762 3763 if (!frameLoader->m_didPerformFirstNavigation && page->backForwardList()->entries().size() == 1) { 3764 frameLoader->m_didPerformFirstNavigation = true; 3765 m_client->didPerformFirstNavigation(); 3766 } 3767 3768 RefPtr<HistoryItem> item = frameLoader->createHistoryItemTree(m_frame, doClip); 3761 3769 LOG(BackForward, "WebCoreBackForward - Adding backforward item %p for frame %s", item.get(), documentLoader()->URL().url().ascii()); 3762 3770 page->backForwardList()->addItem(item); -
trunk/WebCore/loader/FrameLoader.h
r25410 r25430 643 643 RefPtr<HistoryItem> m_previousHistoryItem; 644 644 RefPtr<HistoryItem> m_provisionalHistoryItem; 645 646 bool m_didPerformFirstNavigation; 645 647 646 648 #if USE(LOW_BANDWIDTH_DISPLAY) -
trunk/WebCore/loader/FrameLoaderClient.h
r25128 r25430 208 208 209 209 virtual void windowObjectCleared() const = 0; 210 virtual void didPerformFirstNavigation() const = 0; // "Navigation" here means a transition from one page to another that ends up in the back/forward list. 210 211 211 212 #if PLATFORM(MAC) -
trunk/WebCore/platform/graphics/svg/SVGImageEmptyClients.h
r25345 r25430 273 273 virtual void redirectDataToPlugin(WebCore::Widget*) {} 274 274 virtual void windowObjectCleared() const {} 275 virtual void didPerformFirstNavigation() const {} 275 276 276 277 #if PLATFORM(MAC) -
trunk/WebKit/ChangeLog
r25396 r25430 1 2007-09-05 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Darin Adler, Maciej Stachowiak, Mark Rowe, Tim Hatcher. 4 5 Fixed <rdar://problem/5326009> Make non-browser WebKit clients have no 6 memory cache, or a very tiny one 7 8 High level explanation: 9 - Added SPI for specifying a cache model on a per-WebView basis. 10 (Hopefully, this will become API soon.) We balance competing 11 cache models simply by using the largest one that pertains at a 12 given time. 13 14 - Added heuristic for guessing a default cache model in WebViews 15 that don't specify one: 16 1) Default to DocumentViewer for apps linked on or after this 17 WebKit. Default to DocumentBrowser otherwise. 18 19 2) Assign specific defaults to well-known clients based on 20 bundle ID. 21 22 3) Grow the default to DocumentBrowser if a navigation takes 23 place. 24 25 - As a part of the DocumentBrowser & PrimaryWebBrowser settings: 26 1) Make the Foundation disk cache much much bigger than the 27 default 20MB, if space allows. (This is a hedge against a small 28 WebCore cache in DocumentBrowser mode, but also an all-around 29 win for page load speed.) 30 31 2) Scaled the Foundation memory cache's capacity with physical 32 RAM, just like we do with other caches. This is a small win on 33 low memory systems. 34 35 * Misc/WebKitSystemBits.h: 36 * Misc/WebKitSystemBits.m: 37 (WebMemorySize): Renamed from "WebSystemMainMemory." 38 (WebHomeDirectoryFreeSize): Added function to measure the free space 39 on the user's home directory. We use this as a factor in determining 40 the disk cache's cacpacity. 41 42 * Misc/WebKitVersionChecks.h: Support for linked on or after check. 43 44 * WebCoreSupport/WebFrameLoaderClient.h: 45 * WebCoreSupport/WebFrameLoaderClient.mm: 46 (WebFrameLoaderClient::didPerformFirstNavigation): Implementation of 47 heuristic rule #3. 48 49 * WebView/WebPreferenceKeysPrivate.h: 50 * WebView/WebPreferences.m: 51 (cacheModelForMainBundle): Implementation of heuristic rule #2. 52 (-[NSMutableDictionary _web_checkLastReferenceForIdentifier:]): Added 53 notification for when a WebPreferences instance becomes inert. We use 54 this to shrink the cache model back down if possible. Moved this code 55 into a WebPreferences method, since it's not really a feature of 56 NSDictionary. 57 58 * WebView/WebPreferencesPrivate.h: SPI declarations. 59 60 * WebView/WebView.mm: Replaced manual notification posts with calls to 61 the _postPreferencesChangesNotification convenience method. 62 63 (-[WebView _preferencesChangedNotification:]): Merged dispersed code 64 for updating preferences-related settings into this one function. This 65 was needed for an earlier version of the patch, even though the 66 current version could probably do without it. 67 68 (+[WebView _preferencesChangedNotification:]): Added a class-level 69 listener for WebPreferences changes. This listener takes care of 70 modifying the class-level global cache model setting if necessary. 71 72 (+[WebPreferences standardPreferences]): Removed call to 73 _postPreferencesChangesNotification because the notification already 74 posts when you create the WebPreferences object. (I noticed this 75 inefficiency because my new _preferencesChangedNotification: method was 76 called excessively at startup.) 77 78 Also Added explicit tracking of WebPreferences clients, so we know when 79 a WebPreferences instance becomes inert: 80 81 (-[WebPreferences didRemoveFromWebView]): 82 (-[WebPreferences willAddToWebView]): 83 84 (+[WebView _setCacheModel:]): Translates a cache model into actual 85 settings in various APIs. Caches that have unbounded value grow 86 linearly relative to available space. Caches that have bounded value 87 grow inverse-squaredly relative to available space. 88 1 89 2007-09-05 Timothy Hatcher <timothy@apple.com> 2 90 -
trunk/WebKit/Misc/WebKitSystemBits.h
r17000 r25430 33 33 #endif 34 34 35 vm_size_t WebSystemMainMemory(void); 35 vm_size_t WebMemorySize(void); 36 unsigned long long WebVolumeFreeSize(NSString *path); 36 37 int WebNumberOfCPUs(void); 37 38 -
trunk/WebKit/Misc/WebKitSystemBits.m
r14021 r25430 57 57 } 58 58 59 vm_size_t Web SystemMainMemory(void)59 vm_size_t WebMemorySize(void) 60 60 { 61 61 pthread_once(&initControl, initCapabilities); … … 78 78 return numCPUs; 79 79 } 80 81 unsigned long long WebVolumeFreeSize(NSString *path) 82 { 83 NSDictionary *fileSystemAttributesDictionary = [[NSFileManager defaultManager] fileSystemAttributesAtPath:path]; 84 return [[fileSystemAttributesDictionary objectForKey:NSFileSystemFreeSize] unsignedLongLongValue]; 85 } -
trunk/WebKit/Misc/WebKitVersionChecks.h
r24381 r25430 32 32 A version of -1 is returned if the main executable did not link against WebKit (should never happen). */ 33 33 34 /* Please use the current WebKit version number, available in WebKit/Configurations/Version.xcconfig, 35 when adding a new version constant. */ 36 34 37 #define WEBKIT_FIRST_VERSION_WITH_3_0_CONTEXT_MENU_TAGS 0x020A0000 // 522.0.0 35 38 #define WEBKIT_FIRST_VERSION_WITH_LOCAL_RESOURCE_SECURITY_RESTRICTION 0x020A0000 // 522.0.0 … … 40 43 #define WEBKIT_FIRST_VERSION_WITHOUT_ADOBE_INSTALLER_QUIRK 0x020A0000 // 522.0.0 41 44 #define WEBKIT_FIRST_VERSION_WITH_INSPECT_ELEMENT_MENU_TAG 0x020A0C00 // 522.12.0 45 #define WEBKIT_FIRST_VERSION_WITH_CACHE_MODEL_API 0x020B0500 // 523.5.0 42 46 43 47 #ifdef __cplusplus -
trunk/WebKit/WebCoreSupport/WebFrameLoaderClient.h
r25128 r25430 196 196 197 197 virtual void windowObjectCleared() const; 198 virtual void didPerformFirstNavigation() const; 198 199 199 200 void deliverArchivedResourcesAfterDelay() const; -
trunk/WebKit/WebCoreSupport/WebFrameLoaderClient.mm
r25396 r25430 1242 1242 } 1243 1243 1244 void WebFrameLoaderClient::didPerformFirstNavigation() const 1245 { 1246 WebPreferences *preferences = [[m_webFrame.get() webView] preferences]; 1247 if ([preferences automaticallyDetectsCacheModel] && [preferences cacheModel] < WebCacheModelDocumentBrowser) 1248 [preferences setCacheModel:WebCacheModelDocumentBrowser]; 1249 } 1250 1244 1251 @implementation WebFramePolicyListener 1245 1252 -
trunk/WebKit/WebView/WebPreferenceKeysPrivate.h
r24289 r25430 54 54 #define WebKitAllowAnimatedImageLoopingPreferenceKey @"WebKitAllowAnimatedImageLoopingPreferenceKey" 55 55 #define WebKitDisplayImagesKey @"WebKitDisplayImagesKey" 56 #define WebKitPageCacheSizePreferenceKey @"WebKitPageCacheSizePreferenceKey"57 #define WebKitObjectCacheSizePreferenceKey @"WebKitObjectCacheSizePreferenceKey"58 56 #define WebKitBackForwardCacheExpirationIntervalKey @"WebKitBackForwardCacheExpirationIntervalKey" 59 57 #define WebKitTabToLinksPreferenceKey @"WebKitTabToLinksPreferenceKey" … … 75 73 #define WebKitUseSiteSpecificSpoofingPreferenceKey @"WebKitUseSiteSpecificSpoofing" 76 74 #define WebKitEditableLinkBehaviorPreferenceKey @"WebKitEditableLinkBehavior" 77 75 #define WebKitCacheModelPreferenceKey @"WebKitCacheModelPreferenceKey" 78 76 79 77 // CoreGraphics deferred updates are disabled if WebKitEnableCoalescedUpdatesPreferenceKey is set … … 81 79 // default. 82 80 #define WebKitEnableDeferredUpdatesPreferenceKey @"WebKitEnableDeferredUpdates" 81 82 // For debugging only. Don't use these. 83 #define WebKitPageCacheSizePreferenceKey @"WebKitPageCacheSizePreferenceKey" 84 #define WebKitObjectCacheSizePreferenceKey @"WebKitObjectCacheSizePreferenceKey" -
trunk/WebKit/WebView/WebPreferences.m
r25114 r25430 34 34 #import "WebKitNSStringExtras.h" 35 35 #import "WebKitSystemBits.h" 36 #import "WebKitSystemInterface.h" 37 #import "WebKitVersionChecks.h" 36 38 #import "WebNSDictionaryExtras.h" 37 39 #import "WebNSURLExtras.h" 38 #import "WebKitSystemInterface.h"39 40 40 41 NSString *WebPreferencesChangedNotification = @"WebPreferencesChangedNotification"; 42 NSString *WebPreferencesRemovedNotification = @"WebPreferencesRemovedNotification"; 41 43 42 44 #define KEY(x) (_private->identifier ? [_private->identifier stringByAppendingString:(x)] : (x)) 43 45 44 46 enum { WebPreferencesVersion = 1 }; 47 48 static WebPreferences *_standardPreferences; 49 static NSMutableDictionary *webPreferencesInstances; 50 51 static bool contains(const char* const array[], int count, const char* item) 52 { 53 if (!item) 54 return false; 55 56 for (int i = 0; i < count; i++) 57 if (!strcasecmp(array[i], item)) 58 return true; 59 return false; 60 } 61 62 static WebCacheModel cacheModelForMainBundle(void) 63 { 64 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 65 66 // Apps that probably need the small setting 67 static const char* const documentViewerIDs[] = { 68 "Microsoft/com.microsoft.Messenger", 69 "com.adiumX.adiumX", 70 "com.alientechnology.Proteus", 71 "com.apple.Dashcode", 72 "com.apple.iChat", 73 "com.barebones.bbedit", 74 "com.barebones.textwrangler", 75 "com.barebones.yojimbo", 76 "com.equinux.iSale4", 77 "com.growl.growlframework", 78 "com.intrarts.PandoraMan", 79 "com.karelia.Sandvox", 80 "com.macromates.textmate", 81 "com.realmacsoftware.rapidweaverpro", 82 "com.red-sweater.marsedit", 83 "com.yahoo.messenger3", 84 "de.codingmonkeys.SubEthaEdit", 85 "fi.karppinen.Pyro", 86 "info.colloquy", 87 "kungfoo.tv.ecto", 88 }; 89 90 // Apps that probably need the medium setting 91 static const char* const documentBrowserIDs[] = { 92 "com.apple.Dictionary", 93 "com.apple.Xcode", 94 "com.apple.dashboard.client", 95 "com.apple.helpviewer", 96 "com.culturedcode.xyle", 97 "com.macrabbit.CSSEdit", 98 "com.panic.Coda", 99 "com.ranchero.NetNewsWire", 100 "com.thinkmac.NewsLife", 101 "org.xlife.NewsFire", 102 "uk.co.opencommunity.vienna2", 103 }; 104 105 // Apps that probably need the large setting 106 static const char* const primaryWebBrowserIDs[] = { 107 "com.app4mac.KidsBrowser" 108 "com.freeverse.bumpercar", 109 "com.omnigroup.OmniWeb5", 110 "com.sunrisebrowser.Sunrise", 111 "net.hmdt-web.Shiira", 112 }; 113 114 WebCacheModel cacheModel; 115 116 const char* bundleID = [[[NSBundle mainBundle] bundleIdentifier] UTF8String]; 117 if (contains(documentViewerIDs, sizeof(documentViewerIDs) / sizeof(documentViewerIDs[0]), bundleID)) 118 cacheModel = WebCacheModelDocumentViewer; 119 else if (contains(documentBrowserIDs, sizeof(documentBrowserIDs) / sizeof(documentBrowserIDs[0]), bundleID)) 120 cacheModel = WebCacheModelDocumentBrowser; 121 else if (contains(primaryWebBrowserIDs, sizeof(primaryWebBrowserIDs) / sizeof(primaryWebBrowserIDs[0]), bundleID)) 122 cacheModel = WebCacheModelPrimaryWebBrowser; 123 else { 124 bool isLegacyApp = !WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_CACHE_MODEL_API); 125 if (isLegacyApp) 126 cacheModel = WebCacheModelDocumentBrowser; // To avoid regressions in apps that depended on old WebKit's large cache. 127 else 128 cacheModel = WebCacheModelDocumentViewer; // To save memory. 129 } 130 131 [pool drain]; 132 133 return cacheModel; 134 } 45 135 46 136 @interface WebPreferencesPrivate : NSObject … … 51 141 NSString *IBCreatorID; 52 142 BOOL autosaves; 143 BOOL automaticallyDetectsCacheModel; 144 unsigned numWebViews; 53 145 } 54 146 @end … … 97 189 } 98 190 99 static WebPreferences *_standardPreferences = nil;100 101 191 - (id)initWithIdentifier:(NSString *)anIdentifier 102 192 { … … 116 206 _private->values = [[NSMutableDictionary alloc] init]; 117 207 _private->identifier = [anIdentifier copy]; 118 208 _private->automaticallyDetectsCacheModel = YES; 209 119 210 [[self class] _setInstance:self forIdentifier:_private->identifier]; 120 211 121 [[NSNotificationCenter defaultCenter] 122 postNotificationName:WebPreferencesChangedNotification object:self userInfo:nil]; 212 [self _postPreferencesChangesNotification]; 123 213 124 214 return self; … … 135 225 _private = [[WebPreferencesPrivate alloc] init]; 136 226 _private->IBCreatorID = [[WebPreferences _IBCreatorID] retain]; 227 _private->automaticallyDetectsCacheModel = YES; 137 228 138 229 if ([decoder allowsKeyedCoding]){ … … 191 282 _standardPreferences = [[WebPreferences alloc] initWithIdentifier:nil]; 192 283 [_standardPreferences setAutosaves:YES]; 193 [_standardPreferences _postPreferencesChangesNotification];194 284 } 195 285 … … 200 290 + (void)initialize 201 291 { 202 // As a fudge factor, use 1000 instead of 1024, in case the reported memory doesn't align exactly to a megabyte boundary.203 vm_size_t memSize = WebSystemMainMemory() / 1024 / 1000;204 205 // Page cache size (in pages)206 int pageCacheSize;207 if (memSize >= 1024)208 pageCacheSize = 10;209 else if (memSize >= 512)210 pageCacheSize = 5;211 else if (memSize >= 384)212 pageCacheSize = 4;213 else if (memSize >= 256)214 pageCacheSize = 3;215 else if (memSize >= 128)216 pageCacheSize = 2;217 else if (memSize >= 64)218 pageCacheSize = 1;219 else220 pageCacheSize = 0;221 NSString *pageCacheSizeString = [NSString stringWithFormat:@"%d", pageCacheSize];222 223 // Object cache size (in bytes)224 int objectCacheSize;225 if (memSize >= 2048)226 objectCacheSize = 128 * 1024 * 1024;227 else if (memSize >= 1024)228 objectCacheSize = 64 * 1024 * 1024;229 else if (memSize >= 512)230 objectCacheSize = 32 * 1024 * 1024;231 else232 objectCacheSize = 24 * 1024 * 1024;233 NSString *objectCacheSizeString = [NSString stringWithFormat:@"%d", objectCacheSize];234 235 292 NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: 236 293 @"Times", WebKitStandardFontPreferenceKey, … … 245 302 @"13", WebKitDefaultFixedFontSizePreferenceKey, 246 303 @"ISO-8859-1", WebKitDefaultTextEncodingNamePreferenceKey, 247 pageCacheSizeString, WebKitPageCacheSizePreferenceKey,248 objectCacheSizeString, WebKitObjectCacheSizePreferenceKey,249 304 [NSNumber numberWithBool:NO], WebKitUserStyleSheetEnabledPreferenceKey, 250 305 @"", WebKitUserStyleSheetLocationPreferenceKey, … … 271 326 [NSNumber numberWithBool:NO], WebKitDOMPasteAllowedPreferenceKey, 272 327 [NSNumber numberWithBool:YES], WebKitUsesPageCachePreferenceKey, 328 [NSNumber numberWithInt:cacheModelForMainBundle()], WebKitCacheModelPreferenceKey, 273 329 nil]; 274 330 … … 677 733 } 678 734 679 - (size_t)_pageCacheSize 680 { 681 return [[NSUserDefaults standardUserDefaults] integerForKey:WebKitPageCacheSizePreferenceKey]; 682 } 683 684 - (size_t)_objectCacheSize 685 { 686 return [[NSUserDefaults standardUserDefaults] integerForKey:WebKitObjectCacheSizePreferenceKey]; 735 - (void)setCacheModel:(WebCacheModel)cacheModel 736 { 737 [self _setIntegerValue:cacheModel forKey:WebKitCacheModelPreferenceKey]; 738 [self setAutomaticallyDetectsCacheModel:NO]; 739 } 740 741 - (WebCacheModel)cacheModel 742 { 743 return [self _integerValueForKey:WebKitCacheModelPreferenceKey]; 744 } 745 746 - (BOOL)automaticallyDetectsCacheModel 747 { 748 return _private->automaticallyDetectsCacheModel; 749 } 750 751 - (void)setAutomaticallyDetectsCacheModel:(BOOL)automaticallyDetectsCacheModel 752 { 753 _private->automaticallyDetectsCacheModel = automaticallyDetectsCacheModel; 687 754 } 688 755 689 756 - (NSTimeInterval)_backForwardCacheExpirationInterval 690 757 { 758 // FIXME: There's probably no good reason to read from the standard user defaults instead of self. 691 759 return (NSTimeInterval)[[NSUserDefaults standardUserDefaults] floatForKey:WebKitBackForwardCacheExpirationIntervalKey]; 692 760 } … … 757 825 } 758 826 759 static NSMutableDictionary *webPreferencesInstances = nil;760 761 827 + (WebPreferences *)_getInstanceForIdentifier:(NSString *)ident 762 828 { 763 LOG (Encoding, "requesting for %@\n", ident); 764 765 if (!ident){ 766 if(_standardPreferences) 767 return _standardPreferences; 768 return nil; 769 } 829 LOG(Encoding, "requesting for %@\n", ident); 830 831 if (!ident) 832 return _standardPreferences; 770 833 771 834 WebPreferences *instance = [webPreferencesInstances objectForKey:[self _concatenateKeyWithIBCreatorID:ident]]; … … 780 843 if (ident) { 781 844 [webPreferencesInstances setObject:instance forKey:[self _concatenateKeyWithIBCreatorID:ident]]; 782 LOG (Encoding, "recording %p for %@\n", instance, [self _concatenateKeyWithIBCreatorID:ident]); 783 } 845 LOG(Encoding, "recording %p for %@\n", instance, [self _concatenateKeyWithIBCreatorID:ident]); 846 } 847 } 848 849 + (void)_checkLastReferenceForIdentifier:(id)identifier 850 { 851 // FIXME: This won't work at all under garbage collection because retainCount returns a constant. 852 // We may need to change WebPreferences API so there's an explicit way to end the lifetime of one. 853 WebPreferences *instance = [webPreferencesInstances objectForKey:identifier]; 854 if ([instance retainCount] == 1) 855 [webPreferencesInstances removeObjectForKey:identifier]; 784 856 } 785 857 786 858 + (void)_removeReferenceForIdentifier:(NSString *)ident 787 859 { 788 if (ident != nil) { 789 [webPreferencesInstances performSelector:@selector(_web_checkLastReferenceForIdentifier:) withObject: [self _concatenateKeyWithIBCreatorID:ident] afterDelay:.1]; 790 } 860 if (ident) 861 [self performSelector:@selector(_checkLastReferenceForIdentifier:) withObject:[self _concatenateKeyWithIBCreatorID:ident] afterDelay:0.1]; 791 862 } 792 863 … … 847 918 { 848 919 return [self _boolValueForKey:WebKitForceFTPDirectoryListings]; 920 } 921 922 - (void)didRemoveFromWebView 923 { 924 ASSERT(_private->numWebViews); 925 if (--_private->numWebViews == 0) 926 [[NSNotificationCenter defaultCenter] 927 postNotificationName:WebPreferencesRemovedNotification 928 object:self 929 userInfo:nil]; 930 } 931 932 - (void)willAddToWebView 933 { 934 ++_private->numWebViews; 849 935 } 850 936 … … 867 953 868 954 @end 869 870 @implementation NSMutableDictionary (WebInternal)871 872 - (void)_web_checkLastReferenceForIdentifier:(NSString *)identifier873 {874 WebPreferences *instance = [webPreferencesInstances objectForKey:identifier];875 if ([instance retainCount] == 1)876 [webPreferencesInstances removeObjectForKey:identifier];877 }878 879 @end -
trunk/WebKit/WebView/WebPreferencesPrivate.h
r24289 r25430 1 1 /* 2 * Copyright (C) 2005 Apple Computer, Inc. All rights reserved.2 * Copyright (C) 2005, 2007 Apple Computer, Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 28 28 29 29 #import <WebKit/WebPreferences.h> 30 #import <Quartz/Quartz.h> 30 31 31 #import <Quartz/Quartz.h> 32 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4 33 #define WebNSUInteger unsigned int 34 #else 35 #define WebNSUInteger NSUInteger 36 #endif 32 37 33 38 // WebKitEditableLinkBehavior needs to match the EditableLinkBehavior enum in WebCore … … 39 44 WebKitEditableLinkNeverLive 40 45 } WebKitEditableLinkBehavior; 46 47 /*! 48 @enum WebCacheModel 49 50 @abstract Specifies a usage model for a WebView, which WebKit will use to 51 determine its caching behavior. 52 53 @constant WebCacheModelDocumentViewer Appropriate for an application displaying 54 fixed documents -- like splash screens, chat documents, or word processing 55 documents -- with no UI for navigation. The WebView will behave like any other 56 view, releasing resources when they are no longer referenced. Remote resources, 57 if any, will be cached to disk. This is the most memory-efficient setting. 58 59 Examples: iChat, Mail, TextMate, Growl. 60 61 @constant WebCacheModelDocumentBrowser Appropriate for an application displaying 62 a browsable series of documents with a UI for navigating between them -- for 63 example, a reference materials browser or a website design application. The 64 WebView will cache a reasonable number of resources and previously viewed 65 documents in memory and/or on disk. 66 67 Examples: Dictionary, Help Viewer, Coda. 68 69 @constant WebCacheModelPrimaryWebBrowser Appropriate for the application that 70 acts as the user's primary web browser. The WebView will cache a very large 71 number of resources and previously viewed documents in memory and/or on disk. 72 73 Examples: Safari, OmniWeb, Shiira. 74 */ 75 enum { 76 WebCacheModelDocumentViewer = 0, 77 WebCacheModelDocumentBrowser = 1, 78 WebCacheModelPrimaryWebBrowser = 2 79 }; 80 typedef WebNSUInteger WebCacheModel; 81 82 extern NSString *WebPreferencesChangedNotification; 83 extern NSString *WebPreferencesRemovedNotification; 41 84 42 85 @interface WebPreferences (WebPrivate) … … 57 100 - (BOOL)shrinksStandaloneImagesToFit; 58 101 - (void)setShrinksStandaloneImagesToFit:(BOOL)flag; 102 103 /*! 104 @method setCacheModel: 105 106 @abstract Specifies a usage model for a WebView, which WebKit will use to 107 determine its caching behavior. 108 109 @param cacheModel The application's usage model for WebKit. If necessary, 110 WebKit will prune its caches to match cacheModel. 111 112 @discussion Research indicates that users tend to browse within clusters of 113 documents that hold resources in common, and to revisit previously visited 114 documents. WebKit and the frameworks below it include built-in caches that take 115 advantage of these patterns, substantially improving document load speed in 116 browsing situations. The WebKit cache model controls the behaviors of all of 117 these caches, including NSURLCache and the various WebCore caches. 118 119 Applications with a browsing interface can improve document load speed 120 substantially by specifying WebCacheModelDocumentBrowser. Applications without 121 a browsing interface can reduce memory usage substantially by specifying 122 WebCacheModelDocumentViewer. 123 124 If setCacheModel: is not called, WebKit will select a cache model automatically. 125 */ 126 - (void)setCacheModel:(WebCacheModel)cacheModel; 127 128 /*! 129 @method cacheModel: 130 131 @abstract Returns the usage model according to which WebKit determines its 132 caching behavior. 133 134 @result The usage model. 135 */ 136 - (WebCacheModel)cacheModel; 137 138 - (BOOL)automaticallyDetectsCacheModel; 139 - (void)setAutomaticallyDetectsCacheModel:(BOOL)automaticallyDetectsCacheModel; 59 140 60 141 // zero means do AutoScale … … 85 166 86 167 // Other private methods 87 - (size_t)_pageCacheSize;88 - (size_t)_objectCacheSize;89 168 - (void)_postPreferencesChangesNotification; 90 169 + (WebPreferences *)_getInstanceForIdentifier:(NSString *)identifier; … … 96 175 + (void)_setIBCreatorID:(NSString *)string; 97 176 177 // For WebView's use only. 178 - (void)willAddToWebView; 179 - (void)didRemoveFromWebView; 180 98 181 @end 182 183 #undef WebNSUInteger -
trunk/WebKit/WebView/WebView.mm
r25396 r25430 64 64 #import "WebKitNSStringExtras.h" 65 65 #import "WebKitStatisticsPrivate.h" 66 #import "WebKitSystemBits.h" 66 67 #import "WebKitVersionChecks.h" 67 68 #import "WebLocalizableStrings.h" … … 121 122 #import <WebKit/DOMPrivate.h> 122 123 #import <WebKitSystemInterface.h> 124 #import <mach-o/dyld.h> 123 125 #import <objc/objc-runtime.h> 124 126 #import <wtf/RefPtr.h> … … 239 241 #define WebKitOriginalBottomPrintingMarginKey @"WebKitOriginalBottomMargin" 240 242 243 static BOOL s_didSetCacheModel; 244 static WebCacheModel s_cacheModel = WebCacheModelDocumentViewer; 245 241 246 static BOOL applicationIsTerminating; 242 247 static int pluginDatabaseClientCount = 0; … … 344 349 345 350 @interface WebView (WebFileInternal) 351 + (void)_setCacheModel:(WebCacheModel)cacheModel; 352 + (WebCacheModel)_cacheModel; 346 353 - (WebFrame *)_selectedOrMainFrame; 347 354 - (WebFrameBridge *)_bridgeForSelectedOrMainFrame; … … 452 459 { 453 460 ASSERT(!page); 461 ASSERT(!preferences); 454 462 455 463 delete userAgent; … … 459 467 [backgroundColor release]; 460 468 461 [preferences release];462 469 [hostWindow release]; 463 470 … … 707 714 708 715 [[NSNotificationCenter defaultCenter] removeObserver:self]; 709 [WebPreferences _removeReferenceForIdentifier: [self preferencesIdentifier]]; 716 717 [WebPreferences _removeReferenceForIdentifier:[self preferencesIdentifier]]; 718 719 WebPreferences *preferences = _private->preferences; 720 _private->preferences = nil; 721 [preferences didRemoveFromWebView]; 722 [preferences release]; 723 710 724 pluginDatabaseClientCount--; 711 725 … … 881 895 } 882 896 883 - (void)_updateWebCoreSettingsFromPreferences:(WebPreferences *)preferences 884 { 897 - (void)_preferencesChangedNotification:(NSNotification *)notification 898 { 899 WebPreferences *preferences = (WebPreferences *)[notification object]; 900 ASSERT(preferences == [self preferences]); 901 902 if (!_private->userAgentOverridden) 903 *_private->userAgent = String(); 904 905 // Cache this value so we don't have to read NSUserDefaults on each page load 906 _private->useSiteSpecificSpoofing = [preferences _useSiteSpecificSpoofing]; 907 908 // Update corresponding WebCore Settings object. 885 909 if (!_private->page) 886 910 return; … … 921 945 settings->setUserStyleSheetLocation([NSURL URLWithString:@""]); 922 946 settings->setNeedsAdobeFrameReloadingQuirk([self _needsAdobeFrameReloadingQuirk]); 923 }924 925 - (void)_preferencesChangedNotification: (NSNotification *)notification926 {927 WebPreferences *preferences = (WebPreferences *)[notification object];928 929 ASSERT(preferences == [self preferences]);930 if (!_private->userAgentOverridden)931 *_private->userAgent = String();932 // Cache this value so we don't have to read NSUserDefaults on each page load933 _private->useSiteSpecificSpoofing = [preferences _useSiteSpecificSpoofing];934 [self _updateWebCoreSettingsFromPreferences: preferences];935 947 } 936 948 … … 1570 1582 { 1571 1583 _private->usesPageCache = usesPageCache; 1572 [self _updateWebCoreSettingsFromPreferences:[self preferences]]; 1584 1585 // Post a notification so the WebCore settings update. 1586 [[self preferences] _postPreferencesChangesNotification]; 1573 1587 } 1574 1588 … … 1657 1671 1658 1672 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationWillTerminate) name:NSApplicationWillTerminateNotification object:NSApp]; 1673 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesChangedNotification:) name:WebPreferencesChangedNotification object:nil]; 1674 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesRemovedNotification:) name:WebPreferencesRemovedNotification object:nil]; 1659 1675 1660 1676 // Older versions of Safari use the pasteboard types without initializing them. … … 1794 1810 - (void)_commonInitializationWithFrameName:(NSString *)frameName groupName:(NSString *)groupName 1795 1811 { 1812 WebPreferences *standardPreferences = [WebPreferences standardPreferences]; 1813 [standardPreferences willAddToWebView]; 1814 1815 _private->preferences = [standardPreferences retain]; 1796 1816 _private->catchesDelegateExceptions = YES; 1797 1817 _private->mainFrameDocumentReady = NO; … … 1799 1819 _private->smartInsertDeleteEnabled = YES; 1800 1820 _private->backgroundColor = [[NSColor whiteColor] retain]; 1801 1821 1802 1822 NSRect f = [self frame]; 1803 1823 WebFrameView *frameView = [[WebFrameView alloc] initWithFrame: NSMakeRect(0,0,f.size.width,f.size.height)]; … … 1809 1829 WebCore::InitializeLoggingChannelsIfNecessary(); 1810 1830 [WebHistoryItem initWindowWatcherIfNecessary]; 1811 [WebView _initializeCacheSizesIfNecessary];1812 1831 1813 1832 _private->page = new Page(new WebChromeClient(self), new WebContextMenuClient(self), new WebEditorClient(self), new WebDragClient(self), new WebInspectorClient(self)); … … 1836 1855 1837 1856 WebPreferences *prefs = [self preferences]; 1838 1839 // Update WebCore with preferences. These values will either come from an archived WebPreferences,1840 // or from the standard preferences, depending on whether this method was called from initWithCoder:1841 // or initWithFrame, respectively.1842 [self _updateWebCoreSettingsFromPreferences:prefs];1843 1844 // Initialize this cached value for the common case where we're using [WebPreferences standardPreferences],1845 // since neither setPreferences: nor _preferencesChangedNotification: will be called.1846 _private->useSiteSpecificSpoofing = [prefs _useSiteSpecificSpoofing];1847 1848 // Register to receive notifications whenever preference values change.1849 1857 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesChangedNotification:) 1850 1858 name:WebPreferencesChangedNotification object:prefs]; 1859 1860 // Post a notification so the WebCore settings update. 1861 [[self preferences] _postPreferencesChangesNotification]; 1851 1862 1852 1863 if (WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_LOCAL_RESOURCE_SECURITY_RESTRICTION)) … … 1981 1992 - (void)dealloc 1982 1993 { 1983 // call close to ensure we tear-down complet ly1994 // call close to ensure we tear-down completely 1984 1995 // this maintains our old behavior for existing applications 1985 1996 [self _close]; … … 2045 2056 - (void)setPreferences:(WebPreferences *)prefs 2046 2057 { 2047 if (_private->preferences != prefs) { 2048 [[NSNotificationCenter defaultCenter] removeObserver:self name:WebPreferencesChangedNotification object:[self preferences]]; 2049 [WebPreferences _removeReferenceForIdentifier:[_private->preferences identifier]]; 2050 [_private->preferences release]; 2051 _private->preferences = [prefs retain]; 2052 // Cache this value so we don't have to read NSUserDefaults on each page load 2053 _private->useSiteSpecificSpoofing = [prefs _useSiteSpecificSpoofing]; 2054 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesChangedNotification:) 2055 name:WebPreferencesChangedNotification object:[self preferences]]; 2056 [[NSNotificationCenter defaultCenter] 2057 postNotificationName:WebPreferencesChangedNotification object:prefs userInfo:nil]; 2058 } 2058 if (!prefs) 2059 prefs = [WebPreferences standardPreferences]; 2060 2061 if (_private->preferences == prefs) 2062 return; 2063 2064 [prefs willAddToWebView]; 2065 2066 WebPreferences *oldPrefs = _private->preferences; 2067 2068 [[NSNotificationCenter defaultCenter] removeObserver:self name:WebPreferencesChangedNotification object:[self preferences]]; 2069 [WebPreferences _removeReferenceForIdentifier:[oldPrefs identifier]]; 2070 2071 _private->preferences = [prefs retain]; 2072 2073 // After registering for the notification, post it so the WebCore settings update. 2074 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesChangedNotification:) 2075 name:WebPreferencesChangedNotification object:[self preferences]]; 2076 [[self preferences] _postPreferencesChangesNotification]; 2077 2078 [oldPrefs didRemoveFromWebView]; 2079 [oldPrefs release]; 2059 2080 } 2060 2081 2061 2082 - (WebPreferences *)preferences 2062 2083 { 2063 return _private->preferences ? _private->preferences : [WebPreferences standardPreferences];2084 return _private->preferences; 2064 2085 } 2065 2086 … … 3562 3583 @implementation WebView (WebFileInternal) 3563 3584 3585 + (void)_setCacheModel:(WebCacheModel)cacheModel 3586 { 3587 if (s_didSetCacheModel && cacheModel == s_cacheModel) 3588 return; 3589 3590 // As a fudge factor, use 1000 instead of 1024, in case the reported byte 3591 // count doesn't align exactly to a megabyte boundary. 3592 vm_size_t memSize = WebMemorySize() / 1024 / 1000; 3593 unsigned long long diskFreeSize = WebVolumeFreeSize(NSHomeDirectory()) / 1024 / 1000; 3594 NSURLCache *nsurlCache = [NSURLCache sharedURLCache]; 3595 3596 unsigned cacheTotalCapacity = 0; 3597 unsigned cacheMinDeadCapacity = 0; 3598 unsigned cacheMaxDeadCapacity = 0; 3599 3600 unsigned pageCacheCapacity = 0; 3601 3602 unsigned nsurlCacheMemoryCapacity = 0; 3603 unsigned nsurlCacheDiskCapacity = 0; 3604 3605 switch (cacheModel) { 3606 case WebCacheModelDocumentViewer: { 3607 // Page cache capacity (in pages) 3608 pageCacheCapacity = 0; 3609 3610 // Object cache capacities (in bytes) 3611 if (memSize >= 4096) 3612 cacheTotalCapacity = 256 * 1024 * 1024; 3613 else if (memSize >= 3072) 3614 cacheTotalCapacity = 192 * 1024 * 1024; 3615 else if (memSize >= 2048) 3616 cacheTotalCapacity = 128 * 1024 * 1024; 3617 else if (memSize >= 1536) 3618 cacheTotalCapacity = 86 * 1024 * 1024; 3619 else if (memSize >= 1024) 3620 cacheTotalCapacity = 64 * 1024 * 1024; 3621 else if (memSize >= 512) 3622 cacheTotalCapacity = 32 * 1024 * 1024; 3623 else if (memSize >= 256) 3624 cacheTotalCapacity = 16 * 1024 * 1024; 3625 3626 cacheMinDeadCapacity = 0; 3627 cacheMaxDeadCapacity = 0; 3628 3629 // Foundation memory cache capacity (in bytes) 3630 nsurlCacheMemoryCapacity = 0; 3631 3632 // Foundation disk cache capacity (in bytes) 3633 nsurlCacheDiskCapacity = [nsurlCache diskCapacity]; 3634 3635 break; 3636 } 3637 case WebCacheModelDocumentBrowser: { 3638 // Page cache capacity (in pages) 3639 if (memSize >= 1024) 3640 pageCacheCapacity = 3; 3641 else if (memSize >= 512) 3642 pageCacheCapacity = 2; 3643 else if (memSize >= 256) 3644 pageCacheCapacity = 1; 3645 else 3646 pageCacheCapacity = 0; 3647 3648 // Object cache capacities (in bytes) 3649 if (memSize >= 4096) 3650 cacheTotalCapacity = 256 * 1024 * 1024; 3651 else if (memSize >= 3072) 3652 cacheTotalCapacity = 192 * 1024 * 1024; 3653 else if (memSize >= 2048) 3654 cacheTotalCapacity = 128 * 1024 * 1024; 3655 else if (memSize >= 1536) 3656 cacheTotalCapacity = 86 * 1024 * 1024; 3657 else if (memSize >= 1024) 3658 cacheTotalCapacity = 64 * 1024 * 1024; 3659 else if (memSize >= 512) 3660 cacheTotalCapacity = 32 * 1024 * 1024; 3661 else if (memSize >= 256) 3662 cacheTotalCapacity = 16 * 1024 * 1024; 3663 3664 cacheMinDeadCapacity = cacheTotalCapacity * 0.125f; 3665 cacheMaxDeadCapacity = cacheTotalCapacity * 0.25f; 3666 3667 // Foundation memory cache capacity (in bytes) 3668 if (memSize >= 2048) 3669 nsurlCacheMemoryCapacity = 4 * 1024 * 1024; 3670 else if (memSize >= 1024) 3671 nsurlCacheMemoryCapacity = 2 * 1024 * 1024; 3672 else if (memSize >= 512) 3673 nsurlCacheMemoryCapacity = 1 * 1024 * 1024; 3674 else 3675 nsurlCacheMemoryCapacity = 512 * 1024; 3676 3677 // Foundation disk cache capacity (in bytes) 3678 if (diskFreeSize >= 16384) 3679 nsurlCacheDiskCapacity = 50 * 1024 * 1024; 3680 else if (diskFreeSize >= 8192) 3681 nsurlCacheDiskCapacity = 40 * 1024 * 1024; 3682 else if (diskFreeSize >= 4096) 3683 nsurlCacheDiskCapacity = 30 * 1024 * 1024; 3684 else 3685 nsurlCacheDiskCapacity = 20 * 1024 * 1024; 3686 3687 break; 3688 } 3689 case WebCacheModelPrimaryWebBrowser: { 3690 // Page cache capacity (in pages) 3691 // (Research indicates that value / page drops substantially after 3 pages.) 3692 if (memSize >= 8192) 3693 pageCacheCapacity = 7; 3694 if (memSize >= 4096) 3695 pageCacheCapacity = 6; 3696 else if (memSize >= 2048) 3697 pageCacheCapacity = 5; 3698 else if (memSize >= 1024) 3699 pageCacheCapacity = 4; 3700 else if (memSize >= 512) 3701 pageCacheCapacity = 3; 3702 else if (memSize >= 256) 3703 pageCacheCapacity = 2; 3704 else 3705 pageCacheCapacity = 1; 3706 3707 // Object cache capacities (in bytes) 3708 // (Testing indicates that value / MB depends heavily on content and 3709 // browsing pattern. Even growth above 128MB can have substantial 3710 // value / MB for some content / browsing patterns.) 3711 if (memSize >= 4096) 3712 cacheTotalCapacity = 512 * 1024 * 1024; 3713 else if (memSize >= 3072) 3714 cacheTotalCapacity = 384 * 1024 * 1024; 3715 else if (memSize >= 2048) 3716 cacheTotalCapacity = 256 * 1024 * 1024; 3717 else if (memSize >= 1536) 3718 cacheTotalCapacity = 172 * 1024 * 1024; 3719 else if (memSize >= 1024) 3720 cacheTotalCapacity = 128 * 1024 * 1024; 3721 else if (memSize >= 512) 3722 cacheTotalCapacity = 64 * 1024 * 1024; 3723 else if (memSize >= 256) 3724 cacheTotalCapacity = 32 * 1024 * 1024; 3725 3726 cacheMinDeadCapacity = cacheTotalCapacity * 0.25f; 3727 cacheMaxDeadCapacity = cacheTotalCapacity * 0.50f; 3728 3729 // This code is here to avoid a PLT regression. We can remove it if we 3730 // can prove that the overall system gain would justify the regression. 3731 cacheMaxDeadCapacity = max(24u, cacheMaxDeadCapacity); 3732 3733 // Foundation memory cache capacity (in bytes) 3734 // (These values are small because WebCore does most caching itself.) 3735 if (memSize >= 1024) 3736 nsurlCacheMemoryCapacity = 4 * 1024 * 1024; 3737 else if (memSize >= 512) 3738 nsurlCacheMemoryCapacity = 2 * 1024 * 1024; 3739 else if (memSize >= 256) 3740 nsurlCacheMemoryCapacity = 1 * 1024 * 1024; 3741 else 3742 nsurlCacheMemoryCapacity = 512 * 1024; 3743 3744 // Foundation disk cache capacity (in bytes) 3745 if (diskFreeSize >= 16384) 3746 nsurlCacheDiskCapacity = 175 * 1024 * 1024; 3747 else if (diskFreeSize >= 8192) 3748 nsurlCacheDiskCapacity = 150 * 1024 * 1024; 3749 else if (diskFreeSize >= 4096) 3750 nsurlCacheDiskCapacity = 125 * 1024 * 1024; 3751 else if (diskFreeSize >= 2048) 3752 nsurlCacheDiskCapacity = 100 * 1024 * 1024; 3753 else if (diskFreeSize >= 1024) 3754 nsurlCacheDiskCapacity = 75 * 1024 * 1024; 3755 else 3756 nsurlCacheDiskCapacity = 50 * 1024 * 1024; 3757 3758 break; 3759 } 3760 default: 3761 ASSERT_NOT_REACHED(); 3762 }; 3763 3764 #ifdef BUILDING_ON_TIGER 3765 // Don't use a big Foundation disk cache on Tiger because, according to the 3766 // PLT, the Foundation disk cache on Tiger is slower than the network. 3767 nsurlCacheDiskCapacity = [[NSURLCache sharedURLCache] diskCapacity]; 3768 #else 3769 // Don't use a big Foundation disk cache on older versions of Leopard because 3770 // doing so causes a SPOD on launch (<rdar://problem/5465260>). 3771 if (NSVersionOfLinkTimeLibrary("CFNetwork") < 211) 3772 nsurlCacheDiskCapacity = [[NSURLCache sharedURLCache] diskCapacity]; 3773 #endif 3774 3775 // Don't shrink a big disk cache, since that would cause churn. 3776 nsurlCacheDiskCapacity = max(nsurlCacheDiskCapacity, [nsurlCache diskCapacity]); 3777 3778 cache()->setCapacities(cacheMinDeadCapacity, cacheMaxDeadCapacity, cacheTotalCapacity); 3779 pageCache()->setCapacity(pageCacheCapacity); 3780 [nsurlCache setMemoryCapacity:nsurlCacheMemoryCapacity]; 3781 [nsurlCache setDiskCapacity:nsurlCacheDiskCapacity]; 3782 3783 s_cacheModel = cacheModel; 3784 s_didSetCacheModel = YES; 3785 } 3786 3787 + (WebCacheModel)_cacheModel 3788 { 3789 return s_cacheModel; 3790 } 3791 3792 + (WebCacheModel)_didSetCacheModel 3793 { 3794 return s_didSetCacheModel; 3795 } 3796 3797 + (WebCacheModel)_maxCacheModelInAnyInstance 3798 { 3799 WebCacheModel cacheModel = WebCacheModelDocumentViewer; 3800 NSEnumerator *enumerator = [(NSMutableSet *)allWebViewsSet objectEnumerator]; 3801 while (WebPreferences *preferences = [[enumerator nextObject] preferences]) 3802 cacheModel = max(cacheModel, [preferences cacheModel]); 3803 return cacheModel; 3804 } 3805 3806 + (void)_preferencesChangedNotification:(NSNotification *)notification 3807 { 3808 WebPreferences *preferences = (WebPreferences *)[notification object]; 3809 ASSERT([preferences isKindOfClass:[WebPreferences class]]); 3810 3811 WebCacheModel cacheModel = [preferences cacheModel]; 3812 if (![self _didSetCacheModel] || cacheModel > [self _cacheModel]) 3813 [self _setCacheModel:cacheModel]; 3814 else if (cacheModel < [self _cacheModel]) 3815 [self _setCacheModel:max([[WebPreferences standardPreferences] cacheModel], [self _maxCacheModelInAnyInstance])]; 3816 } 3817 3818 + (void)_preferencesRemovedNotification:(NSNotification *)notification 3819 { 3820 WebPreferences *preferences = (WebPreferences *)[notification object]; 3821 ASSERT([preferences isKindOfClass:[WebPreferences class]]); 3822 3823 if ([preferences cacheModel] == [self _cacheModel]) 3824 [self _setCacheModel:max([[WebPreferences standardPreferences] cacheModel], [self _maxCacheModelInAnyInstance])]; 3825 } 3826 3564 3827 - (WebFrame *)_focusedFrame 3565 3828 { … … 3769 4032 @implementation WebView (WebViewInternal) 3770 4033 3771 + (void)_initializeCacheSizesIfNecessary3772 {3773 static bool didInitialize;3774 if (didInitialize)3775 return;3776 3777 WebPreferences *standardPreferences = [WebPreferences standardPreferences];3778 pageCache()->setCapacity([standardPreferences _pageCacheSize]);3779 cache()->setCapacities(0, [standardPreferences _objectCacheSize], [standardPreferences _objectCacheSize]);3780 didInitialize = true;3781 3782 #ifndef NDEBUG3783 LOG(CacheSizes, "Object cache size set to %d bytes.", [standardPreferences _objectCacheSize]);3784 LOG(CacheSizes, "Page cache size set to %d pages.", [standardPreferences _pageCacheSize]);3785 #endif3786 }3787 3788 4034 - (BOOL)_becomingFirstResponderFromOutside 3789 4035 { -
trunk/WebKit/WebView/WebViewInternal.h
r25396 r25430 68 68 @interface WebView (WebViewMiscInternal) 69 69 70 + (void)_ initializeCacheSizesIfNecessary;70 + (void)_setCacheModelIfNecessary; 71 71 - (WebCorePage*)page; 72 72 - (NSMenu *)_menuForElement:(NSDictionary *)element defaultItems:(NSArray *)items; -
trunk/WebKit/gtk/ChangeLog
r25345 r25430 1 2007-09-05 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Darin Adler, Maciej Stachowiak, Mark Rowe, Tim Hatcher. 4 5 Fixed <rdar://problem/5326009> Make non-browser WebKit clients have no 6 memory cache, or a very tiny one 7 8 Keep the GTK build working with an empty stub. 9 10 * WebCoreSupport/FrameLoaderClientGtk.cpp: 11 (WebKit::FrameLoaderClient::didPerformFirstNavigation): 12 * WebCoreSupport/FrameLoaderClientGtk.h: 13 1 14 2007-09-01 Oliver Hunt <oliver@apple.com> 2 15 -
trunk/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.cpp
r25143 r25430 250 250 } 251 251 252 void FrameLoaderClient::didPerformFirstNavigation() const 253 { 254 } 255 252 256 void FrameLoaderClient::setMainFrameDocumentReady(bool) 253 257 { -
trunk/WebKit/gtk/WebCoreSupport/FrameLoaderClientGtk.h
r25136 r25430 120 120 virtual WebCore::String overrideMediaType() const; 121 121 virtual void windowObjectCleared() const; 122 virtual void didPerformFirstNavigation() const; 122 123 123 124 virtual WebCore::ObjectContentType objectContentType(const WebCore::KURL& url, const WebCore::String& mimeType); -
trunk/WebKit/win/ChangeLog
r25428 r25430 1 2007-09-05 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Darin Adler, Maciej Stachowiak, Mark Rowe, Tim Hatcher. 4 5 Fixed <rdar://problem/5326009> Make non-browser WebKit clients have no 6 memory cache, or a very tiny one 7 8 Keep the Windows build working with an empty stub. 9 10 * WebFrame.cpp: 11 (FrameLoaderClient::didPerformFirstNavigation): 12 * WebFrame.h: 13 1 14 2007-09-07 Ada Chan <adachan@apple.com> 2 15 -
trunk/WebKit/win/WebFrame.cpp
r25427 r25430 2342 2342 } 2343 2343 2344 void FrameLoaderClient::didPerformFirstNavigation() const 2345 { 2346 } 2347 2344 2348 static IntRect printerRect(HDC printDC) 2345 2349 { -
trunk/WebKit/win/WebFrame.h
r25288 r25430 314 314 315 315 virtual void windowObjectCleared() const; 316 virtual void didPerformFirstNavigation() const; 316 317 317 318 // WebFrame -
trunk/WebKitQt/ChangeLog
r25412 r25430 1 2007-09-05 Geoffrey Garen <ggaren@apple.com> 2 3 Reviewed by Darin Adler, Maciej Stachowiak, Mark Rowe, Tim Hatcher. 4 5 Fixed <rdar://problem/5326009> Make non-browser WebKit clients have no 6 memory cache, or a very tiny one 7 8 Keep the Qt build working with an empty stub. 9 10 * WebCoreSupport/FrameLoaderClientQt.cpp: 11 (WebCore::FrameLoaderClient::didPerformFirstNavigation): 12 * WebCoreSupport/FrameLoaderClientQt.h: 13 1 14 2007-09-07 George Staikos <staikos@kde.org> 2 15 -
trunk/WebKitQt/WebCoreSupport/FrameLoaderClientQt.cpp
r25389 r25430 581 581 } 582 582 583 void FrameLoaderClient::didPerformFirstNavigation() const 584 { 585 } 586 583 587 void FrameLoaderClientQt::setDocumentViewFromCachedPage(CachedPage*) 584 588 { -
trunk/WebKitQt/WebCoreSupport/FrameLoaderClientQt.h
r25144 r25430 213 213 214 214 virtual void windowObjectCleared() const; 215 virtual void didPerformFirstNavigation() const; 215 216 216 217 QString chooseFile(const QString& oldFile);
Note: See TracChangeset
for help on using the changeset viewer.