Commit 683c446f authored by rjw's avatar rjw

i Added a debug menu to turn back/forward cache on and off.

        Off by default.  Use with discretion.  Still leaks like
        a sieve.  Useful to provide a sense of potential speed up.

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

        Changes fro back/forward cache.

        * History.subproj/WebHistoryItem.h:
        * History.subproj/WebHistoryItem.m:
        (+[WebHistoryItem setUsePageCache:]):
        (+[WebHistoryItem usePageCache]):
        * WebCoreSupport.subproj/WebBridge.m:
        (-[WebBridge saveDocumentToPageCache:]):
        * WebView.subproj/WebFramePrivate.h:
        * WebView.subproj/WebFramePrivate.m:
        (-[WebFrame _detachFromParent]):
        (-[WebFrame _canCachePage]):
        (-[WebFrame _setState:]):

        Tweaked some debugging info.

        * khtml/xml/dom_docimpl.cpp:
        (DocumentImpl::~DocumentImpl):
        (DocumentImpl::detach):

        Added debugging info.  Fixed property map save function.

        * kjs/nodes.cpp:
        (FunctionCallNode::evaluate):
        * kjs/property_map.cpp:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2871 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 321d446b
2002-11-25 Richard Williamson <rjw@apple.com>
Added debugging info. Fixed property map save function.
* kjs/nodes.cpp:
(FunctionCallNode::evaluate):
* kjs/property_map.cpp:
2002-11-25 Richard Williamson <rjw@apple.com>
Changes for back/forward. Currently disabled.
......
2002-11-25 Richard Williamson <rjw@apple.com>
Added debugging info. Fixed property map save function.
* kjs/nodes.cpp:
(FunctionCallNode::evaluate):
* kjs/property_map.cpp:
2002-11-25 Richard Williamson <rjw@apple.com>
Changes for back/forward. Currently disabled.
......
2002-11-25 Richard Williamson <rjw@apple.com>
Added debugging info. Fixed property map save function.
* kjs/nodes.cpp:
(FunctionCallNode::evaluate):
* kjs/property_map.cpp:
2002-11-25 Richard Williamson <rjw@apple.com>
Changes for back/forward. Currently disabled.
......
......@@ -738,6 +738,10 @@ Value FunctionCallNode::evaluate(ExecState *exec)
Value v = ref.getValue(exec);
Object o = v.toObject(exec);
UString s = o.toString(exec);
//printf ("FunctionCallNode::evaluate %s\n", s.ascii());
if (v.type() != ObjectType) {
#ifndef NDEBUG
printInfo(exec, "WARNING: Failed function call attempt on", v, line);
......
......@@ -185,12 +185,36 @@ ValueImp *PropertyMap::get(const Identifier &name) const
return 0;
}
#ifdef DEBUG_PROPERTIES
static void printAttributes(int attributes)
{
if (attributes == 0)
printf ("None ");
if (attributes & ReadOnly)
printf ("ReadOnly ");
if (attributes & DontEnum)
printf ("DontEnum ");
if (attributes & DontDelete)
printf ("DontDelete ");
if (attributes & Internal)
printf ("Internal ");
if (attributes & Function)
printf ("Function ");
}
#endif
void PropertyMap::put(const Identifier &name, ValueImp *value, int attributes)
{
checkConsistency();
UString::Rep *rep = name._ustring.rep;
#ifdef DEBUG_PROPERTIES
printf ("adding property %s, attributes = 0x%08x (", name.ascii(), attributes);
printAttributes(attributes);
printf (")\n");
#endif
#if USE_SINGLE_ENTRY
if (!_table) {
UString::Rep *key = _singleEntry.key;
......@@ -418,7 +442,8 @@ void PropertyMap::save(SavedProperties &p) const
#endif
} else {
for (int i = 0; i != _table->size; ++i)
if (_table->entries[i].key && _table->entries[i].attributes == 0)
if (_table->entries[i].key && (_table->entries[i].attributes == 0 || _table->entries[i].attributes == (DontDelete | Internal)))
//if (_table->entries[i].key)
++count;
}
......@@ -427,7 +452,9 @@ void PropertyMap::save(SavedProperties &p) const
p._properties = 0;
return;
}
p._properties = new SavedProperty [count];
p._count = count;
SavedProperty *prop = p._properties;
......@@ -441,9 +468,11 @@ void PropertyMap::save(SavedProperties &p) const
#endif
} else {
for (int i = 0; i != _table->size; ++i) {
if (_table->entries[i].key && _table->entries[i].attributes == 0) {
if (_table->entries[i].key && (_table->entries[i].attributes == 0 || _table->entries[i].attributes == (DontDelete | Internal))) {
//if (_table->entries[i].key) {
prop->key = Identifier(_table->entries[i].key);
prop->value = Value(_table->entries[i].value);
++prop;
}
}
}
......@@ -451,8 +480,9 @@ void PropertyMap::save(SavedProperties &p) const
void PropertyMap::restore(const SavedProperties &p)
{
for (int i = 0; i != p._count; ++i)
for (int i = 0; i != p._count; ++i){
put(p._properties[i].key, p._properties[i].value.imp(), 0);
}
}
#if DO_CONSISTENCY_CHECK
......
2002-11-25 Richard Williamson <rjw@apple.com>
Tweaked some debugging info.
* khtml/xml/dom_docimpl.cpp:
(DocumentImpl::~DocumentImpl):
(DocumentImpl::detach):
2002-11-25 Chris Blumenberg <cblu@apple.com>
Use ^= to refer to OBJECTs with TYPEs that start with "image/". This is better than hard-coding image mime types.
......
2002-11-25 Richard Williamson <rjw@apple.com>
Tweaked some debugging info.
* khtml/xml/dom_docimpl.cpp:
(DocumentImpl::~DocumentImpl):
(DocumentImpl::detach):
2002-11-25 Chris Blumenberg <cblu@apple.com>
Use ^= to refer to OBJECTs with TYPEs that start with "image/". This is better than hard-coding image mime types.
......
2002-11-25 Richard Williamson <rjw@apple.com>
Tweaked some debugging info.
* khtml/xml/dom_docimpl.cpp:
(DocumentImpl::~DocumentImpl):
(DocumentImpl::detach):
2002-11-25 Chris Blumenberg <cblu@apple.com>
Use ^= to refer to OBJECTs with TYPEs that start with "image/". This is better than hard-coding image mime types.
......
......@@ -325,7 +325,10 @@ DocumentImpl::~DocumentImpl()
if (m_focusNode)
m_focusNode->deref();
delete m_renderArena;
if (m_renderArena){
delete m_renderArena;
m_renderArena = 0;
}
}
......@@ -1005,6 +1008,7 @@ void DocumentImpl::detach()
{
#if APPLE_CHANGES
if (!m_inPageCache){
//printf ("detaching document\n");
#endif
RenderObject* render = m_render;
......@@ -1018,10 +1022,15 @@ void DocumentImpl::detach()
m_view = 0;
delete m_renderArena;
m_renderArena = 0;
if (m_renderArena){
delete m_renderArena;
m_renderArena = 0;
}
#if APPLE_CHANGES
}
//else {
// printf ("not detaching document\n");
//}
#endif
}
......
2002-11-25 Richard Williamson <rjw@apple.com>
Changes fro back/forward cache.
* History.subproj/WebHistoryItem.h:
* History.subproj/WebHistoryItem.m:
(+[WebHistoryItem setUsePageCache:]):
(+[WebHistoryItem usePageCache]):
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge saveDocumentToPageCache:]):
* WebView.subproj/WebFramePrivate.h:
* WebView.subproj/WebFramePrivate.m:
(-[WebFrame _detachFromParent]):
(-[WebFrame _canCachePage]):
(-[WebFrame _setState:]):
2002-11-25 Chris Blumenberg <cblu@apple.com>
Fixed 2 drag-related crashes. Oops.
......
2002-11-25 Richard Williamson <rjw@apple.com>
Changes fro back/forward cache.
* History.subproj/WebHistoryItem.h:
* History.subproj/WebHistoryItem.m:
(+[WebHistoryItem setUsePageCache:]):
(+[WebHistoryItem usePageCache]):
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge saveDocumentToPageCache:]):
* WebView.subproj/WebFramePrivate.h:
* WebView.subproj/WebFramePrivate.m:
(-[WebFrame _detachFromParent]):
(-[WebFrame _canCachePage]):
(-[WebFrame _setState:]):
2002-11-25 Chris Blumenberg <cblu@apple.com>
Fixed 2 drag-related crashes. Oops.
......
......@@ -69,4 +69,6 @@
- (BOOL)pageCacheEnabled;
- (void)setPageCacheEnabled: (BOOL)f;
- (NSMutableDictionary *)pageCache;
+ (void)setUsePageCache: (BOOL)f;
+ (BOOL)usePageCache;
@end
......@@ -413,4 +413,18 @@ - (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
......@@ -329,6 +329,7 @@ - (BOOL)saveDocumentToPageCache: documentInfo
printf ("WebBridge saveDocumentToPageCache: not saving\n");
return false;
}
ASSERT ([[item pageCache] objectForKey: @"WebCorePageState"] == nil);
[[item pageCache] setObject: documentInfo forKey: @"WebCorePageState"];
printf ("WebBridge saveDocumentToPageCache: saving\n");
return true;
......
......@@ -156,4 +156,7 @@ typedef enum {
- (void)_setJustOpenedForTargetedLink:(BOOL)justOpened;
- (BOOL)_canCachePage;
- (void)_purgePageCache;
@end
......@@ -250,6 +250,7 @@ - (void)_detachFromParent
[self stopLoading];
[self _saveScrollPositionToItem:[_private currentItem]];
[bridge closeURL];
[[self children] makeObjectsPerformSelector:@selector(_detachFromParent)];
......@@ -532,7 +533,7 @@ - (void)_transitionToCommitted: (NSDictionary *)pageCache
- (BOOL)_canCachePage
{
return NO;
return [WebHistoryItem usePageCache];
}
- (void)_purgePageCache
......@@ -568,6 +569,22 @@ - (void)_setState: (WebFrameState)newState
// but in the case where someone does, it means garbage outside
// the occupied part of the scroll view.
[[[self webView] frameScrollView] setDrawsBackground:NO];
// Cache the page, if possible.
if ([_private->bridge canCachePage] && [self _canCachePage] && [_private currentItem]){
if (![[_private currentItem] pageCache]){
NSLog (@"saving page cache for %@, %@", [self name], [[self dataSource] URL]);
[[_private currentItem] setPageCacheEnabled: YES];
[[self dataSource] _setStoredInPageCache: YES];
[[[_private currentItem] pageCache] setObject: [self dataSource] forKey: @"WebKitDataSource"];
[[[_private currentItem] pageCache] setObject: [[self webView] documentView] forKey: @"WebKitDocumentView"];
[_private->bridge saveDocumentToPageCache];
[self _purgePageCache];
}
else {
NSLog (@"already have page cache for %@, %@", [self name], [[self dataSource] URL]);
}
}
}
if (_private->state == WebFrameStateComplete) {
......@@ -579,17 +596,6 @@ - (void)_setState: (WebFrameState)newState
[_private->scheduledLayoutTimer fire];
ASSERT(_private->scheduledLayoutTimer == nil);
[_private setPreviousItem:nil];
// Cache the page, if possible.
if ([_private->bridge canCachePage] && [self _canCachePage]){
LOG (PageCache, "enabling page cache for %@, %@", [self name], [[self dataSource] URL]);
[[_private currentItem] setPageCacheEnabled: YES];
[[self dataSource] _setStoredInPageCache: YES];
[[[_private currentItem] pageCache] setObject: [self dataSource] forKey: @"WebKitDataSource"];
[[[_private currentItem] pageCache] setObject: [[self webView] documentView] forKey: @"WebKitDocumentView"];
[_private->bridge saveDocumentToPageCache];
[self _purgePageCache];
}
}
}
......
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