+2007-09-26 Geoffrey Garen <ggaren@apple.com>
+
+ Reviewed by Adele Peterson.
+
+ Fixed <rdar://problem/5507476> Promote cache model SPI to API
+
+ Promoted cache model SPI to API. This was just a move, with some small
+ edits to the documentation (changing 'application' to 'WebView' in
+ some cases, since the interface is now per-WebView).
+
+ * WebView/WebPreferences.h:
+ * WebView/WebPreferences.m:
+ (-[WebPreferences setCacheModel:]):
+ (-[WebPreferences cacheModel]):
+ * WebView/WebPreferencesPrivate.h:
+
2007-09-24 Timothy Hatcher <timothy@apple.com>
Reviewed by Darin.
#import <Foundation/Foundation.h>
+#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
+#define WebNSUInteger unsigned int
+#else
+#define WebNSUInteger NSUInteger
+#endif
+
+/*!
+@enum WebCacheModel
+
+@abstract Specifies a usage model for a WebView, which WebKit will use to
+determine its caching behavior.
+
+@constant WebCacheModelDocumentViewer Appropriate for a WebView displaying
+a fixed document -- like a splash screen, a chat document, or a word processing
+document -- with no UI for navigation. The WebView will behave like any other
+view, releasing resources when they are no longer referenced. Remote resources,
+if any, will be cached to disk. This is the most memory-efficient setting.
+
+Examples: iChat, Mail, TextMate, Growl.
+
+@constant WebCacheModelDocumentBrowser Appropriate for a WebView displaying
+a browsable series of documents with a UI for navigating between them -- for
+example, a reference materials browser or a website designer. The WebView will
+cache a reasonable number of resources and previously viewed documents in
+memory and/or on disk.
+
+Examples: Dictionary, Help Viewer, Coda.
+
+@constant WebCacheModelPrimaryWebBrowser Appropriate for a WebView in the
+application that acts as the user's primary web browser. The WebView will cache
+a very large number of resources and previously viewed documents in memory
+and/or on disk.
+
+Examples: Safari, OmniWeb, Shiira.
+*/
+enum {
+ WebCacheModelDocumentViewer = 0,
+ WebCacheModelDocumentBrowser = 1,
+ WebCacheModelPrimaryWebBrowser = 2
+};
+typedef WebNSUInteger WebCacheModel;
+
@class WebPreferencesPrivate;
extern NSString *WebPreferencesChangedNotification;
*/
- (BOOL)usesPageCache;
+/*!
+@method setCacheModel:
+
+@abstract Specifies a usage model for a WebView, which WebKit will use to
+determine its caching behavior.
+
+@param cacheModel The WebView's usage model for WebKit. If necessary, WebKit
+will prune its caches to match cacheModel.
+
+@discussion Research indicates that users tend to browse within clusters of
+documents that hold resources in common, and to revisit previously visited
+documents. WebKit and the frameworks below it include built-in caches that take
+advantage of these patterns, substantially improving document load speed in
+browsing situations. The WebKit cache model controls the behaviors of all of
+these caches, including NSURLCache and the various WebCore caches.
+
+Applications with a browsing interface can improve document load speed
+substantially by specifying WebCacheModelDocumentBrowser. Applications without
+a browsing interface can reduce memory usage substantially by specifying
+WebCacheModelDocumentViewer.
+
+If setCacheModel: is not called, WebKit will select a cache model automatically.
+*/
+- (void)setCacheModel:(WebCacheModel)cacheModel;
+
+/*!
+@method cacheModel:
+
+@abstract Returns the usage model according to which WebKit determines its
+caching behavior.
+
+@result The usage model.
+*/
+- (WebCacheModel)cacheModel;
+
@end
+
+#undef WebNSUInteger
return [self _boolValueForKey:WebKitUsesPageCachePreferenceKey];
}
+- (void)setCacheModel:(WebCacheModel)cacheModel
+{
+ [self _setIntegerValue:cacheModel forKey:WebKitCacheModelPreferenceKey];
+ [self setAutomaticallyDetectsCacheModel:NO];
+}
+
+- (WebCacheModel)cacheModel
+{
+ return [self _integerValueForKey:WebKitCacheModelPreferenceKey];
+}
+
@end
@implementation WebPreferences (WebPrivate)
[self _setBoolValue:flag forKey:WebKitShrinksStandaloneImagesToFit];
}
-- (void)setCacheModel:(WebCacheModel)cacheModel
-{
- [self _setIntegerValue:cacheModel forKey:WebKitCacheModelPreferenceKey];
- [self setAutomaticallyDetectsCacheModel:NO];
-}
-
-- (WebCacheModel)cacheModel
-{
- return [self _integerValueForKey:WebKitCacheModelPreferenceKey];
-}
-
- (BOOL)automaticallyDetectsCacheModel
{
return _private->automaticallyDetectsCacheModel;
#import <WebKit/WebPreferences.h>
#import <Quartz/Quartz.h>
-#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_4
-#define WebNSUInteger unsigned int
-#else
-#define WebNSUInteger NSUInteger
-#endif
-
// WebKitEditableLinkBehavior needs to match the EditableLinkBehavior enum in WebCore
typedef enum {
WebKitEditableLinkDefaultBehavior = 0,
WebKitEditableLinkNeverLive
} WebKitEditableLinkBehavior;
-/*!
-@enum WebCacheModel
-
-@abstract Specifies a usage model for a WebView, which WebKit will use to
-determine its caching behavior.
-
-@constant WebCacheModelDocumentViewer Appropriate for an application displaying
-fixed documents -- like splash screens, chat documents, or word processing
-documents -- with no UI for navigation. The WebView will behave like any other
-view, releasing resources when they are no longer referenced. Remote resources,
-if any, will be cached to disk. This is the most memory-efficient setting.
-
-Examples: iChat, Mail, TextMate, Growl.
-
-@constant WebCacheModelDocumentBrowser Appropriate for an application displaying
-a browsable series of documents with a UI for navigating between them -- for
-example, a reference materials browser or a website design application. The
-WebView will cache a reasonable number of resources and previously viewed
-documents in memory and/or on disk.
-
-Examples: Dictionary, Help Viewer, Coda.
-
-@constant WebCacheModelPrimaryWebBrowser Appropriate for the application that
-acts as the user's primary web browser. The WebView will cache a very large
-number of resources and previously viewed documents in memory and/or on disk.
-
-Examples: Safari, OmniWeb, Shiira.
-*/
-enum {
- WebCacheModelDocumentViewer = 0,
- WebCacheModelDocumentBrowser = 1,
- WebCacheModelPrimaryWebBrowser = 2
-};
-typedef WebNSUInteger WebCacheModel;
-
extern NSString *WebPreferencesChangedNotification;
extern NSString *WebPreferencesRemovedNotification;
- (BOOL)shrinksStandaloneImagesToFit;
- (void)setShrinksStandaloneImagesToFit:(BOOL)flag;
-/*!
-@method setCacheModel:
-
-@abstract Specifies a usage model for a WebView, which WebKit will use to
-determine its caching behavior.
-
-@param cacheModel The application's usage model for WebKit. If necessary,
-WebKit will prune its caches to match cacheModel.
-
-@discussion Research indicates that users tend to browse within clusters of
-documents that hold resources in common, and to revisit previously visited
-documents. WebKit and the frameworks below it include built-in caches that take
-advantage of these patterns, substantially improving document load speed in
-browsing situations. The WebKit cache model controls the behaviors of all of
-these caches, including NSURLCache and the various WebCore caches.
-
-Applications with a browsing interface can improve document load speed
-substantially by specifying WebCacheModelDocumentBrowser. Applications without
-a browsing interface can reduce memory usage substantially by specifying
-WebCacheModelDocumentViewer.
-
-If setCacheModel: is not called, WebKit will select a cache model automatically.
-*/
-- (void)setCacheModel:(WebCacheModel)cacheModel;
-
-/*!
-@method cacheModel:
-
-@abstract Returns the usage model according to which WebKit determines its
-caching behavior.
-
-@result The usage model.
-*/
-- (WebCacheModel)cacheModel;
-
- (BOOL)automaticallyDetectsCacheModel;
- (void)setAutomaticallyDetectsCacheModel:(BOOL)automaticallyDetectsCacheModel;
- (void)didRemoveFromWebView;
@end
-
-#undef WebNSUInteger