Commit e67107bd authored by rjw's avatar rjw

JavaScriptCore

        Use delete[] (not delete) operator to delete array.

        * kjs/property_map.cpp:

WebBrowser
        Use cleaned up API to enable/disable page cache.

        * Debug/DebugUtilities.m:
        (-[BrowserDocument toggleBackForwardEnabled:]):

WebCore
        Cleanup up leaking objects in page cache.

        * kwq/KWQKHTMLPart.mm:
        (KWQKHTMLPart::openURLFromPageCache):
        * kwq/WebCoreBridge.mm:
        (-[KWQPageState initWithDocument:DOM::URL:windowProperties:KJS::locationProperties:KJS::]):
        (-[KWQPageState dealloc]):

WebKit
        Cleanup leaking objects in page cache.
        Cleaned up API a bit.

        * History.subproj/WebBackForwardList.h:
        * History.subproj/WebBackForwardList.m:
        (-[WebBackForwardList dealloc]):
        (+[WebBackForwardList setUsesPageCache:]):
        (+[WebBackForwardList usesPageCache]):
        (+[WebBackForwardList setPageCacheSize:]):
        (+[WebBackForwardList pageCacheSize]):
        * History.subproj/WebHistoryItem.h:
        * History.subproj/WebHistoryItem.m:
        (-[WebHistoryItem setHasPageCache:]):
        * WebCoreSupport.subproj/WebBridge.m:
        (-[WebBridge saveDocumentToPageCache:]):
        * WebKit.exp:
        * WebView.subproj/WebFramePrivate.m:
        (-[WebFrame _canCachePage]):
        (-[WebFrame _purgePageCache]):
        (-[WebFrame _setState:]):
        (-[WebFrame _continueLoadRequestAfterNavigationPolicy:request:]):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2874 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent cd8e3a0d
2002-11-25 Richard Williamson <rjw@apple.com>
Use delete[] (not delete) operator to delete array.
* kjs/property_map.cpp:
2002-11-25 Richard Williamson <rjw@apple.com>
Added debugging info. Fixed property map save function.
......
2002-11-25 Richard Williamson <rjw@apple.com>
Use delete[] (not delete) operator to delete array.
* kjs/property_map.cpp:
2002-11-25 Richard Williamson <rjw@apple.com>
Added debugging info. Fixed property map save function.
......
2002-11-25 Richard Williamson <rjw@apple.com>
Use delete[] (not delete) operator to delete array.
* kjs/property_map.cpp:
2002-11-25 Richard Williamson <rjw@apple.com>
Added debugging info. Fixed property map save function.
......
......@@ -72,8 +72,9 @@ SavedProperties::SavedProperties() : _count(0), _properties(0) { }
SavedProperties::~SavedProperties()
{
if (_properties)
delete _properties;
if (_properties){
delete [] _properties;
}
}
// Algorithm concepts from Algorithms in C++, Sedgewick.
......
2002-11-25 Richard Williamson <rjw@apple.com>
Cleanup up leaking objects in page cache.
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::openURLFromPageCache):
* kwq/WebCoreBridge.mm:
(-[KWQPageState initWithDocument:DOM::URL:windowProperties:KJS::locationProperties:KJS::]):
(-[KWQPageState dealloc]):
2002-11-25 Richard Williamson <rjw@apple.com>
Added check for non-nil doc.
......
2002-11-25 Richard Williamson <rjw@apple.com>
Cleanup up leaking objects in page cache.
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::openURLFromPageCache):
* kwq/WebCoreBridge.mm:
(-[KWQPageState initWithDocument:DOM::URL:windowProperties:KJS::locationProperties:KJS::]):
(-[KWQPageState dealloc]):
2002-11-25 Richard Williamson <rjw@apple.com>
Added check for non-nil doc.
......
2002-11-25 Richard Williamson <rjw@apple.com>
Cleanup up leaking objects in page cache.
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::openURLFromPageCache):
* kwq/WebCoreBridge.mm:
(-[KWQPageState initWithDocument:DOM::URL:windowProperties:KJS::locationProperties:KJS::]):
(-[KWQPageState dealloc]):
2002-11-25 Richard Williamson <rjw@apple.com>
Added check for non-nil doc.
......
......@@ -463,8 +463,6 @@ void KWQKHTMLPart::restoreLocationProperties(KJS::SavedProperties *locationPrope
void KWQKHTMLPart::openURLFromPageCache(DOM::DocumentImpl *doc, KURL *url, KJS::SavedProperties *windowProperties, KJS::SavedProperties *locationProperties)
{
printf ("KWQKHTMLPart::openURLFromPageCache\n");
d->m_redirectionTimer.stop();
// We still have to close the previous part page.
......
......@@ -904,14 +904,16 @@ DOM::Node next = n.firstChild();
windowProperties = wp;
locationProperties =lp;
return self;
}
- (void)dealloc
{
KHTMLView *view = document->view();
document->setInPageCache(NO);
document->detach();
document->deref();
document = 0;
delete view;
delete URL;
URL = 0;
delete windowProperties;
......
2002-11-25 Richard Williamson <rjw@apple.com>
Cleanup leaking objects in page cache.
Cleaned up API a bit.
* History.subproj/WebBackForwardList.h:
* History.subproj/WebBackForwardList.m:
(-[WebBackForwardList dealloc]):
(+[WebBackForwardList setUsesPageCache:]):
(+[WebBackForwardList usesPageCache]):
(+[WebBackForwardList setPageCacheSize:]):
(+[WebBackForwardList pageCacheSize]):
* History.subproj/WebHistoryItem.h:
* History.subproj/WebHistoryItem.m:
(-[WebHistoryItem setHasPageCache:]):
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge saveDocumentToPageCache:]):
* WebKit.exp:
* WebView.subproj/WebFramePrivate.m:
(-[WebFrame _canCachePage]):
(-[WebFrame _purgePageCache]):
(-[WebFrame _setState:]):
(-[WebFrame _continueLoadRequestAfterNavigationPolicy:request:]):
2002-11-25 Richard Williamson <rjw@apple.com>
Changed ordering of cachability check.
......
2002-11-25 Richard Williamson <rjw@apple.com>
Cleanup leaking objects in page cache.
Cleaned up API a bit.
* History.subproj/WebBackForwardList.h:
* History.subproj/WebBackForwardList.m:
(-[WebBackForwardList dealloc]):
(+[WebBackForwardList setUsesPageCache:]):
(+[WebBackForwardList usesPageCache]):
(+[WebBackForwardList setPageCacheSize:]):
(+[WebBackForwardList pageCacheSize]):
* History.subproj/WebHistoryItem.h:
* History.subproj/WebHistoryItem.m:
(-[WebHistoryItem setHasPageCache:]):
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge saveDocumentToPageCache:]):
* WebKit.exp:
* WebView.subproj/WebFramePrivate.m:
(-[WebFrame _canCachePage]):
(-[WebFrame _purgePageCache]):
(-[WebFrame _setState:]):
(-[WebFrame _continueLoadRequestAfterNavigationPolicy:request:]):
2002-11-25 Richard Williamson <rjw@apple.com>
Changed ordering of cachability check.
......
......@@ -22,6 +22,33 @@
int _maximumSize;
}
/*!
@method setUsesPageCache:
@param flag set to true if pages should be cached
@abstract Pages in the back/forward list may be cached. Pages in this cache
will load much more quickly, however they may not always be up-to-date. The
page cache may not apply to all pages.
*/
+ (void)setUsesPageCache: (BOOL)flag;
/*!
@method usesPageCache
@result Returns YES if the page cache is enabled.
*/
+ (BOOL)usesPageCache;
/*!
@method setPageCacheSize:
@param size The number of pages to allow in the page cache.
*/
+ (void)setPageCacheSize: (unsigned)size;
/*!
@method pageCacheSize
@result Returns the number of pages that may be cached.
*/
+ (unsigned)pageCacheSize;
/*!
@method addEntry:
@abstract Adds an entry to the list.
......
......@@ -28,6 +28,11 @@ - (id)init
- (void)dealloc
{
unsigned i;
for (i = 0; i < [_entries count]; i++){
WebHistoryItem *item = [_entries objectAtIndex: i];
[item setHasPageCache: NO];
}
[_entries release];
[super dealloc];
}
......@@ -38,15 +43,24 @@ - (void)addEntry:(WebHistoryItem *)entry;
int currSize = [_entries count];
if (_current != currSize-1 && _current != -1) {
NSRange forwardRange = NSMakeRange(_current+1, currSize-(_current+1));
NSArray *subarray;
subarray = [_entries subarrayWithRange:forwardRange];
unsigned i;
for (i = 0; i < [subarray count]; i++){
WebHistoryItem *item = [subarray objectAtIndex: i];
[item setHasPageCache: NO];
}
[_entries removeObjectsInRange: forwardRange];
currSize -= forwardRange.length;
}
// Toss the first item if the list is getting too big, as long as we're not using it
if (currSize == _maximumSize && _current != 0) {
[_entries removeObjectAtIndex:0];
currSize--;
_current--;
WebHistoryItem *item = [_entries objectAtIndex: 0];
[item setHasPageCache: NO];
[_entries removeObjectAtIndex:0];
currSize--;
_current--;
}
[_entries addObject:entry];
......@@ -173,4 +187,31 @@ -(NSString *)description
return result;
}
// Off be default for now.
static BOOL usesPageCache = 0;
+ (void)setUsesPageCache: (BOOL)f
{
usesPageCache = f ? YES : NO;
}
+ (BOOL)usesPageCache
{
return usesPageCache;
}
static unsigned pageCacheSize = 10;
+ (void)setPageCacheSize: (unsigned)size
{
pageCacheSize = size;
}
+ (unsigned)pageCacheSize
{
return pageCacheSize;
}
@end
......@@ -66,9 +66,7 @@
@end
@interface WebHistoryItem (WebPrivate)
- (BOOL)pageCacheEnabled;
- (void)setPageCacheEnabled: (BOOL)f;
- (BOOL)hasPageCache;
- (void)setHasPageCache: (BOOL)f;
- (NSMutableDictionary *)pageCache;
+ (void)setUsePageCache: (BOOL)f;
+ (BOOL)usePageCache;
@end
......@@ -394,12 +394,12 @@ - (id)initFromDictionaryRepresentation:(NSDictionary *)dict
@implementation WebHistoryItem (WebPrivate)
- (BOOL)pageCacheEnabled;
- (BOOL)hasPageCache;
{
return pageCache != nil;
}
- (void)setPageCacheEnabled: (BOOL)f
- (void)setHasPageCache: (BOOL)f
{
if (f && !pageCache)
pageCache = [[NSMutableDictionary alloc] init];
......@@ -414,17 +414,5 @@ - (void)setPageCacheEnabled: (BOOL)f
return pageCache;
}
// Off be default for now.
static BOOL usePageCache = 0;
+ (void)setUsePageCache: (BOOL)f
{
usePageCache = f;
}
+ (BOOL)usePageCache
{
return usePageCache;
}
@end
......@@ -325,7 +325,7 @@ - (NSArray *)documentState
- (BOOL)saveDocumentToPageCache: documentInfo
{
WebHistoryItem *item = [frame _itemForSavingDocState];
if (![item pageCacheEnabled]){
if (![item hasPageCache]){
printf ("WebBridge saveDocumentToPageCache: not saving\n");
return false;
}
......
.objc_class_name_WebBackForwardList
.objc_class_name_WebBookmark
.objc_class_name_WebBookmarkGroup
.objc_class_name_WebBookmarkImporter
......
......@@ -533,12 +533,31 @@ - (void)_transitionToCommitted: (NSDictionary *)pageCache
- (BOOL)_canCachePage
{
return [WebHistoryItem usePageCache];
return [WebBackForwardList usesPageCache];
}
- (void)_purgePageCache
{
// This method implements the rule for purging the page cache.
unsigned sizeLimit = [WebBackForwardList pageCacheSize];
unsigned pagesCached = 0;
WebBackForwardList *backForwardList = [[self controller] backForwardList];
NSArray *backList = [backForwardList backListWithSizeLimit: 999999];
WebHistoryItem *oldestItem = nil;
unsigned i;
for (i = 0; i < [backList count]; i++){
WebHistoryItem *item = [backList objectAtIndex: i];
if ([item hasPageCache]){
if (oldestItem == nil)
oldestItem = item;
pagesCached++;
}
}
if (pagesCached > sizeLimit){
[oldestItem setHasPageCache: NO];
}
}
- (WebFrameState)_state
......@@ -574,7 +593,7 @@ - (void)_setState: (WebFrameState)newState
if ([self _canCachePage] && [_private->bridge canCachePage] && [_private currentItem]){
if (![[_private currentItem] pageCache]){
NSLog (@"saving page cache for %@, %@", [self name], [[self dataSource] URL]);
[[_private currentItem] setPageCacheEnabled: YES];
[[_private currentItem] setHasPageCache: YES];
[[self dataSource] _setStoredInPageCache: YES];
[[[_private currentItem] pageCache] setObject: [self dataSource] forKey: @"WebKitDataSource"];
[[[_private currentItem] pageCache] setObject: [[self webView] documentView] forKey: @"WebKitDocumentView"];
......@@ -1403,7 +1422,7 @@ -(void)_continueLoadRequestAfterNavigationPolicy:(BOOL)shouldContinue request:(W
if ((loadType == WebFrameLoadTypeForward ||
loadType == WebFrameLoadTypeBack ||
loadType == WebFrameLoadTypeIndexedBackForward) &&
[[_private provisionalItem] pageCacheEnabled]){
[[_private provisionalItem] hasPageCache]){
printf ("Restoring page from state, %s\n", [[[[_private provisionalItem] URL] absoluteString] cString]);
[_private->provisionalDataSource _startLoading: [[_private provisionalItem] pageCache]];
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment