[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

rjw rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:13:02 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 763b3866a0c12f8b9fac9f4b0f23cec5073551d8
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Dec 9 23:24:32 2002 +0000

            Many changes for b/f list.
            1.  Always attempt to cache snap back items.
            2.  Lazily release resources from page cache.  This garners gains on the PLT (and presumably iBench) tests, both for uncached.
            3.  Set the page cache size to 4 (+ snap back items).  After releasing resources we hover around 28MB footprint.  Closing windows releases all resources.
            4.  Turn on the back/forward cache by default.  The menu item still allows you to toggle b/f on and off.  Useful when conducting speed comparison in the PLT.
            5.  Addition of lazy update to PLT memory statistics to show footprint after lazy release of page cache resources.
            6.  Delayed to leak detector to account for lazy release of resources.
            7.  A change when saving a page to back/forward cache to clear and restore the documents root renderer.  Without this fix pages would appear to 'flicker' more when content arrived.
            8.  A change to ensure a layout when restoring a page from the b/f cache.  Without this fix scrollbars wouldn't appear correctly.
            9.  A change to ensure that khtmlview layout and paint timers are unscheduled when a page is placed in the b/f cache.
            10.  A fix to decouple of khtmlview from it's part when placed in the b/f cache.  This fixed a crash caused by inappropriate deference of the part when a page cache item was released.
            11.  A comment in KHTMLPageCache.h explaining the that our page cache is not the same as the khtml page cache.  (Their cache just cached the html source.)
            12.  Reapply styles when loading page from cache.  This ensures that visited link get the appropriate style.
    
            Reviewed by kocienda.
    
            * History.subproj/WebBackForwardList.m:
            (+[WebBackForwardList pageCacheSize]):
            (+[WebBackForwardList setUsesPageCache:]):
            (+[WebBackForwardList usesPageCache]):
            * History.subproj/WebHistoryItem.h:
            * History.subproj/WebHistoryItem.m:
            (-[WebHistoryItem setAlwaysAttemptToUsePageCache:]):
            (-[WebHistoryItem alwaysAttemptToUsePageCache]):
            (+[WebHistoryItem _invalidateReleaseTimer]):
            (-[WebHistoryItem _scheduleRelease]):
            (+[WebHistoryItem _releaseAllPendingPageCaches]):
            (-[WebHistoryItem _releasePageCache:]):
            (-[WebHistoryItem setHasPageCache:]):
            (-[WebWindowWatcher windowWillClose:]):
            * WebView.subproj/WebDataSourcePrivate.h:
            * WebView.subproj/WebDataSourcePrivate.m:
            (-[WebDataSource _startLoading:]):
            (-[WebDataSource _commitIfReady:]):
            (-[WebDataSource _loadingFromPageCache]):
            * WebView.subproj/WebDynamicScrollBarsView.h:
            * WebView.subproj/WebFramePrivate.h:
            * WebView.subproj/WebFramePrivate.m:
            (-[WebFrame _purgePageCache]):
            (+[WebFrame _timeOfLastCompletedLoad]):
            (-[WebFrame _setState:]):
            (-[WebFrame _opened]):
            (-[WebFrame _continueLoadRequestAfterNavigationPolicy:request:]):
            * WebView.subproj/WebPreferences.m:
            (+[WebPreferences load]):
    
    WebCore
            Reviewed by kocienda.
    
            * khtml/html/html_documentimpl.cpp:
            (HTMLDocumentImpl::clearTimers):
            * khtml/html/html_documentimpl.h:
            * khtml/khtmlview.cpp:
            (KHTMLView::clearPart):
            (KHTMLView::timerEvent):
            * khtml/khtmlview.h:
            * khtml/xml/dom_docimpl.cpp:
            (DocumentImpl::restoreRenderer):
            (DocumentImpl::detach):
            * khtml/xml/dom_docimpl.h:
            * kwq/KWQKHTMLPageCache.h:
            * kwq/WebCoreBridge.mm:
            (-[WebCoreBridge openURL:reload:headers:lastModified:pageCache:]):
            (-[WebCoreBridge saveDocumentToPageCache]):
            (-[KWQPageState initWithDocument:DOM::URL:windowProperties:KJS::locationProperties:KJS::]):
            (-[KWQPageState dealloc]):
            (-[KWQPageState KJS::]):
            (-[KWQPageState khtml::]):
    
    WebBrowser
            Make the memory check fire again after a delay.
            This will show the high water mark first, and then
            the footprint after the lazy release of resource has completed.
    
            Reviewed by kocienda.
    
            * BrowserDocument.m:
            (-[BrowserDocument setSearchResultsForSnapBack:]):
            (-[BrowserDocument setPageForSnapBack:]):
            * Debug/DebugUtilities.m:
            (-[DebugUtilities createDebugMenu]):
            * Test/PageLoadTestController.m:
            (-[PageLoadTestController testFinishedNotification:]):
            * Test/PageLoadTestRunner.m:
            (-[PageLoadTestRunner checkForWorldLeaks]):
            (-[PageLoadTestRunner checkForWorldLeaksNow]):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2981 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 6743021..42dae80 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,41 @@
+2002-12-09  Richard Williamson   <rjw at apple.com>
+
+        Many changes for b/f list.
+        1.  Always attempt to cache snap back items.
+        2.  Lazily release resources from page cache.  This garners gains on the PLT (and presumably iBench) tests, both for uncached.
+        3.  Set the page cache size to 4 (+ snap back items).  After releasing resources we hover around 28MB footprint.  Closing windows releases all resources.
+        4.  Turn on the back/forward cache by default.  The menu item still allows you to toggle b/f on and off.  Useful when conducting speed comparison in the PLT.
+        5.  Addition of lazy update to PLT memory statistics to show footprint after lazy release of page cache resources.
+        6.  Delayed to leak detector to account for lazy release of resources.
+        7.  A change when saving a page to back/forward cache to clear and restore the documents root renderer.  Without this fix pages would appear to 'flicker' more when content arrived.
+        8.  A change to ensure a layout when restoring a page from the b/f cache.  Without this fix scrollbars wouldn't appear correctly.
+        9.  A change to ensure that khtmlview layout and paint timers are unscheduled when a page is placed in the b/f cache.
+        10.  A fix to decouple of khtmlview from it's part when placed in the b/f cache.  This fixed a crash caused by inappropriate deference of the part when a page cache item was released.
+        11.  A comment in KHTMLPageCache.h explaining the that our page cache is not the same as the khtml page cache.  (Their cache just cached the html source.)
+        12.  Reapply styles when loading page from cache.  This ensures that visited link get the appropriate style.
+
+        Reviewed by kocienda.
+
+        * khtml/html/html_documentimpl.cpp:
+        (HTMLDocumentImpl::clearTimers):
+        * khtml/html/html_documentimpl.h:
+        * khtml/khtmlview.cpp:
+        (KHTMLView::clearPart):
+        (KHTMLView::timerEvent):
+        * khtml/khtmlview.h:
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::restoreRenderer):
+        (DocumentImpl::detach):
+        * khtml/xml/dom_docimpl.h:
+        * kwq/KWQKHTMLPageCache.h:
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge openURL:reload:headers:lastModified:pageCache:]):
+        (-[WebCoreBridge saveDocumentToPageCache]):
+        (-[KWQPageState initWithDocument:DOM::URL:windowProperties:KJS::locationProperties:KJS::]):
+        (-[KWQPageState dealloc]):
+        (-[KWQPageState KJS::]):
+        (-[KWQPageState khtml::]):
+
 2002-12-08  Trey Matteson  <trey at apple.com>
 
 	Fixed 3115903 - exchangehomes.com sometimes has form state poorly restored
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 6743021..42dae80 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,41 @@
+2002-12-09  Richard Williamson   <rjw at apple.com>
+
+        Many changes for b/f list.
+        1.  Always attempt to cache snap back items.
+        2.  Lazily release resources from page cache.  This garners gains on the PLT (and presumably iBench) tests, both for uncached.
+        3.  Set the page cache size to 4 (+ snap back items).  After releasing resources we hover around 28MB footprint.  Closing windows releases all resources.
+        4.  Turn on the back/forward cache by default.  The menu item still allows you to toggle b/f on and off.  Useful when conducting speed comparison in the PLT.
+        5.  Addition of lazy update to PLT memory statistics to show footprint after lazy release of page cache resources.
+        6.  Delayed to leak detector to account for lazy release of resources.
+        7.  A change when saving a page to back/forward cache to clear and restore the documents root renderer.  Without this fix pages would appear to 'flicker' more when content arrived.
+        8.  A change to ensure a layout when restoring a page from the b/f cache.  Without this fix scrollbars wouldn't appear correctly.
+        9.  A change to ensure that khtmlview layout and paint timers are unscheduled when a page is placed in the b/f cache.
+        10.  A fix to decouple of khtmlview from it's part when placed in the b/f cache.  This fixed a crash caused by inappropriate deference of the part when a page cache item was released.
+        11.  A comment in KHTMLPageCache.h explaining the that our page cache is not the same as the khtml page cache.  (Their cache just cached the html source.)
+        12.  Reapply styles when loading page from cache.  This ensures that visited link get the appropriate style.
+
+        Reviewed by kocienda.
+
+        * khtml/html/html_documentimpl.cpp:
+        (HTMLDocumentImpl::clearTimers):
+        * khtml/html/html_documentimpl.h:
+        * khtml/khtmlview.cpp:
+        (KHTMLView::clearPart):
+        (KHTMLView::timerEvent):
+        * khtml/khtmlview.h:
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::restoreRenderer):
+        (DocumentImpl::detach):
+        * khtml/xml/dom_docimpl.h:
+        * kwq/KWQKHTMLPageCache.h:
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge openURL:reload:headers:lastModified:pageCache:]):
+        (-[WebCoreBridge saveDocumentToPageCache]):
+        (-[KWQPageState initWithDocument:DOM::URL:windowProperties:KJS::locationProperties:KJS::]):
+        (-[KWQPageState dealloc]):
+        (-[KWQPageState KJS::]):
+        (-[KWQPageState khtml::]):
+
 2002-12-08  Trey Matteson  <trey at apple.com>
 
 	Fixed 3115903 - exchangehomes.com sometimes has form state poorly restored
diff --git a/WebCore/khtml/html/html_documentimpl.cpp b/WebCore/khtml/html/html_documentimpl.cpp
index 13f0a84..c200ab3 100644
--- a/WebCore/khtml/html/html_documentimpl.cpp
+++ b/WebCore/khtml/html/html_documentimpl.cpp
@@ -296,6 +296,14 @@ static bool isTransitional(const QString &spec, int start)
     return false;
 }
 
+#ifdef APPLE_CHANGES
+void HTMLDocumentImpl::clearTimers()
+{
+    view()->unscheduleRelayout();
+    view()->unscheduleRepaint();
+}
+#endif
+
 void HTMLDocumentImpl::close()
 {
     // First fire the onload.
diff --git a/WebCore/khtml/html/html_documentimpl.h b/WebCore/khtml/html/html_documentimpl.h
index 3d0a485..578f1fb 100644
--- a/WebCore/khtml/html/html_documentimpl.h
+++ b/WebCore/khtml/html/html_documentimpl.h
@@ -64,6 +64,7 @@ public:
 #if APPLE_CHANGES
     DOMString policyBaseURL() const { return m_policyBaseURL; }
     void setPolicyBaseURL(const DOMString &s) { m_policyBaseURL = s; }
+    void clearTimers();
 #endif
 
     HTMLElementImpl *body();
diff --git a/WebCore/khtml/khtmlview.cpp b/WebCore/khtml/khtmlview.cpp
index 5ac043e..94bae22 100644
--- a/WebCore/khtml/khtmlview.cpp
+++ b/WebCore/khtml/khtmlview.cpp
@@ -248,6 +248,14 @@ KHTMLView::~KHTMLView()
     delete d; d = 0;
 }
 
+void KHTMLView::clearPart()
+{
+    if (m_part){
+        m_part->deref();
+        m_part = 0;
+    }
+}
+
 void KHTMLView::init()
 {
 #if !APPLE_CHANGES
@@ -1467,14 +1475,16 @@ void KHTMLView::timerEvent ( QTimerEvent *e )
     if( m_part->xmlDocImpl() ) {
         DOM::DocumentImpl *document = m_part->xmlDocImpl();
         khtml::RenderRoot* root = static_cast<khtml::RenderRoot *>(document->renderer());
-        if ( !root->layouted() ) {
-            killTimer(d->repaintTimerId);
-            d->repaintTimerId = 0;
-            //qDebug("not layouted, delaying repaint");
-            scheduleRelayout();
-            return;
+        if (root){
+            if ( !root->layouted() ) {
+                killTimer(d->repaintTimerId);
+                d->repaintTimerId = 0;
+                //qDebug("not layouted, delaying repaint");
+                scheduleRelayout();
+                return;
+            }
+            resizeContents(root->docWidth(), root->docHeight());
         }
-        resizeContents(root->docWidth(), root->docHeight());
     }
     setStaticBackground(d->useSlowRepaints);
 
diff --git a/WebCore/khtml/khtmlview.h b/WebCore/khtml/khtmlview.h
index c510838..ea1d827 100644
--- a/WebCore/khtml/khtmlview.h
+++ b/WebCore/khtml/khtmlview.h
@@ -153,6 +153,7 @@ protected:
 
 #if APPLE_CHANGES
 public:
+    void clearPart();
 #endif
     virtual void resizeEvent ( QResizeEvent * event );
     virtual void showEvent ( QShowEvent * );
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index a8a096c..3da7ce0 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -1004,6 +1004,11 @@ void DocumentImpl::attach()
     m_render = render;
 }
 
+void DocumentImpl::restoreRenderer(RenderObject* render)
+{
+    m_render = render;
+}
+
 void DocumentImpl::detach()
 {
 #if APPLE_CHANGES
@@ -1028,9 +1033,9 @@ void DocumentImpl::detach()
     }
 #if APPLE_CHANGES
     }
-    //else {
-    //    printf ("not detaching document\n");
-    //}
+    else {
+        m_render = 0;
+    }
 #endif
 }
 
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index 631c8ec..1d0a5f4 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -416,6 +416,7 @@ public:
 
     bool inPageCache();
     void setInPageCache (bool flag);
+    void restoreRenderer(khtml::RenderObject* render);
    
 private:
     bool m_inPageCache;
diff --git a/WebCore/kwq/KWQKHTMLPageCache.h b/WebCore/kwq/KWQKHTMLPageCache.h
index c45b225..4380cec 100644
--- a/WebCore/kwq/KWQKHTMLPageCache.h
+++ b/WebCore/kwq/KWQKHTMLPageCache.h
@@ -30,6 +30,12 @@
 
 class QObject;
 
+#ifdef APPLE_CHANGES
+/*
+    This class is not used by WebCore.  The WebCore/WebKit page cache is
+    a cache of a fully constructed DOM and associated render objects.
+*/
+#endif
 class KHTMLPageCache
 {
 public:
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index fb4e155..c541dad 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -83,12 +83,14 @@ NSString *WebCoreElementStringKey = 		@"WebElementString";
     KURL *URL;
     KJS::SavedProperties *windowProperties;
     KJS::SavedProperties *locationProperties;
+    khtml::RenderObject *docRenderer; 
 }
 - initWithDocument: (DOM::DocumentImpl *)doc URL: (KURL)u windowProperties: (KJS::SavedProperties *)wp locationProperties: (KJS::SavedProperties *)lp;
 - (DOM::DocumentImpl *)document;
 - (KURL *)URL;
 - (KJS::SavedProperties *)windowProperties;
 - (KJS::SavedProperties *)locationProperties;
+- (khtml::RenderObject *)renderer;
 @end
 
 @implementation WebCoreBridge
@@ -144,6 +146,7 @@ NSString *WebCoreElementStringKey = 		@"WebElementString";
 {
     if (pageCache) {
         KWQPageState *state = [pageCache objectForKey:@"WebCorePageState"];
+        [state document]->restoreRenderer([state renderer]);
         _part->kwq->openURLFromPageCache([state document], [state URL], [state windowProperties], [state locationProperties]);
         return;
     }
@@ -231,6 +234,10 @@ NSString *WebCoreElementStringKey = 		@"WebElementString";
 
         _part->kwq->saveWindowProperties(windowProperties);
         _part->kwq->saveLocationProperties(locationProperties);
+        if (doc->isHTMLDocument()) {
+            DOM::HTMLDocumentImpl* hdoc = static_cast<HTMLDocumentImpl*>(doc);
+            hdoc->clearTimers();
+        }
         KWQPageState *pageState = [[[KWQPageState alloc] initWithDocument: doc URL:_part->m_url windowProperties:windowProperties locationProperties:locationProperties] autorelease];
         return [self saveDocumentToPageCache: pageState];
     }
@@ -914,6 +921,7 @@ DOM::Node next = n.firstChild();
     [super init];
     doc->ref();
     document = doc;
+    docRenderer = doc->renderer();
     document->setInPageCache(YES);
     URL = new KURL(u);
     windowProperties = wp;
@@ -924,11 +932,19 @@ DOM::Node next = n.firstChild();
 - (void)dealloc
 {
     KHTMLView *view = document->view();
+
+    if (document->isHTMLDocument()) {
+        DOM::HTMLDocumentImpl* hdoc = static_cast<HTMLDocumentImpl*>(document);
+        hdoc->clearTimers();
+    }
     document->setInPageCache(NO);
     document->detach();
     document->deref();
     document = 0;
+    
+    view->clearPart();
     delete view;
+    
     delete URL;
     URL = 0;
     delete windowProperties;
@@ -956,6 +972,11 @@ DOM::Node next = n.firstChild();
     return locationProperties;
 }
 
+- (khtml::RenderObject *)renderer
+{
+    return docRenderer;
+}
+
 
 @end
 
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 28baa87..ccf4721 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,51 @@
+2002-12-09  Richard Williamson   <rjw at apple.com>
+
+        Many changes for b/f list.
+        1.  Always attempt to cache snap back items.
+        2.  Lazily release resources from page cache.  This garners gains on the PLT (and presumably iBench) tests, both for uncached.
+        3.  Set the page cache size to 4 (+ snap back items).  After releasing resources we hover around 28MB footprint.  Closing windows releases all resources.
+        4.  Turn on the back/forward cache by default.  The menu item still allows you to toggle b/f on and off.  Useful when conducting speed comparison in the PLT.
+        5.  Addition of lazy update to PLT memory statistics to show footprint after lazy release of page cache resources.
+        6.  Delayed to leak detector to account for lazy release of resources.
+        7.  A change when saving a page to back/forward cache to clear and restore the documents root renderer.  Without this fix pages would appear to 'flicker' more when content arrived.
+        8.  A change to ensure a layout when restoring a page from the b/f cache.  Without this fix scrollbars wouldn't appear correctly.
+        9.  A change to ensure that khtmlview layout and paint timers are unscheduled when a page is placed in the b/f cache.
+        10.  A fix to decouple of khtmlview from it's part when placed in the b/f cache.  This fixed a crash caused by inappropriate deference of the part when a page cache item was released.
+        11.  A comment in KHTMLPageCache.h explaining the that our page cache is not the same as the khtml page cache.  (Their cache just cached the html source.)
+        12.  Reapply styles when loading page from cache.  This ensures that visited link get the appropriate style.
+
+        Reviewed by kocienda.
+
+        * History.subproj/WebBackForwardList.m:
+        (+[WebBackForwardList pageCacheSize]):
+        (+[WebBackForwardList setUsesPageCache:]):
+        (+[WebBackForwardList usesPageCache]):
+        * History.subproj/WebHistoryItem.h:
+        * History.subproj/WebHistoryItem.m:
+        (-[WebHistoryItem setAlwaysAttemptToUsePageCache:]):
+        (-[WebHistoryItem alwaysAttemptToUsePageCache]):
+        (+[WebHistoryItem _invalidateReleaseTimer]):
+        (-[WebHistoryItem _scheduleRelease]):
+        (+[WebHistoryItem _releaseAllPendingPageCaches]):
+        (-[WebHistoryItem _releasePageCache:]):
+        (-[WebHistoryItem setHasPageCache:]):
+        (-[WebWindowWatcher windowWillClose:]):
+        * WebView.subproj/WebDataSourcePrivate.h:
+        * WebView.subproj/WebDataSourcePrivate.m:
+        (-[WebDataSource _startLoading:]):
+        (-[WebDataSource _commitIfReady:]):
+        (-[WebDataSource _loadingFromPageCache]):
+        * WebView.subproj/WebDynamicScrollBarsView.h:
+        * WebView.subproj/WebFramePrivate.h:
+        * WebView.subproj/WebFramePrivate.m:
+        (-[WebFrame _purgePageCache]):
+        (+[WebFrame _timeOfLastCompletedLoad]):
+        (-[WebFrame _setState:]):
+        (-[WebFrame _opened]):
+        (-[WebFrame _continueLoadRequestAfterNavigationPolicy:request:]):
+        * WebView.subproj/WebPreferences.m:
+        (+[WebPreferences load]):
+
 2002-12-09  Darin Adler  <darin at apple.com>
 
         Reviewed by Chris.
diff --git a/WebKit/History.subproj/WebBackForwardList.m b/WebKit/History.subproj/WebBackForwardList.m
index 68a27ec..e5760c7 100644
--- a/WebKit/History.subproj/WebBackForwardList.m
+++ b/WebKit/History.subproj/WebBackForwardList.m
@@ -189,21 +189,8 @@
     return result;
 }
 
-// Off be default for now.
-static BOOL usesPageCache = 0;
-
-+ (void)setUsesPageCache: (BOOL)f
-{
-    usesPageCache = f ? YES : NO;
-}
-
-+ (BOOL)usesPageCache
-{
-    return usesPageCache;
-}
-
 static BOOL pageCacheSizeModified = NO;
-static unsigned pageCacheSize = 10;
+static unsigned pageCacheSize = 4;
 
 + (void)setPageCacheSize: (unsigned)size
 {
@@ -219,5 +206,20 @@ static unsigned pageCacheSize = 10;
     return pageCacheSize;
 }
 
+// On be default for now.
+static BOOL usesPageCache = YES;
+
++ (void)setUsesPageCache: (BOOL)f
+{
+    usesPageCache = f ? YES : NO;
+}
+
++ (BOOL)usesPageCache
+{
+    if ([WebBackForwardList pageCacheSize] == 0)
+        return NO;
+    return usesPageCache;
+}
+
 
 @end
diff --git a/WebKit/History.subproj/WebHistoryItem.h b/WebKit/History.subproj/WebHistoryItem.h
index e61dde8..39bcc15 100644
--- a/WebKit/History.subproj/WebHistoryItem.h
+++ b/WebKit/History.subproj/WebHistoryItem.h
@@ -27,6 +27,7 @@
     NSMutableDictionary *pageCache;
     BOOL _loadedIcon;
     BOOL _isTargetItem;
+    BOOL _alwaysAttemptToUsePageCache;
 }
 
 + (WebHistoryItem *)entryWithURL:(NSURL *)URL;
@@ -68,9 +69,13 @@
 - (WebHistoryItem *)childItemWithName:(NSString *)name;
 - (WebHistoryItem *)targetItem;
 
+- (void)setAlwaysAttemptToUsePageCache: (BOOL)flag;
+- (BOOL)alwaysAttemptToUsePageCache;
+
 @end
 
 @interface WebHistoryItem (WebPrivate)
++ (void)_releaseAllPendingPageCaches;
 - (BOOL)hasPageCache;
 - (void)setHasPageCache: (BOOL)f;
 - (NSMutableDictionary *)pageCache;
diff --git a/WebKit/History.subproj/WebHistoryItem.m b/WebKit/History.subproj/WebHistoryItem.m
index 49eb9fa..c1b4ef3 100644
--- a/WebKit/History.subproj/WebHistoryItem.m
+++ b/WebKit/History.subproj/WebHistoryItem.m
@@ -5,12 +5,16 @@
 
 #import <WebKit/WebHistoryItem.h>
 
+#import <WebKit/WebFramePrivate.h>
 #import <WebKit/WebIconDatabase.h>
 #import <WebKit/WebIconLoader.h>
+#import <WebKit/WebKitLogging.h>
 
+#import <WebFoundation/WebAssertions.h>
 #import <WebFoundation/WebNSDictionaryExtras.h>
 #import <WebFoundation/WebNSURLExtras.h>
 
+#import <CoreGraphics/CoreGraphicsPrivate.h>
 
 @implementation WebHistoryItem
 
@@ -404,21 +408,102 @@
     return self;
 }
 
+- (void)setAlwaysAttemptToUsePageCache: (BOOL)flag
+{
+    _alwaysAttemptToUsePageCache = flag;
+}
+
+- (BOOL)alwaysAttemptToUsePageCache
+{
+    return _alwaysAttemptToUsePageCache;
+}
+
+
+ at end
+
+ at interface WebWindowWatcher : NSObject
 @end
 
 @implementation WebHistoryItem (WebPrivate)
 
+static WebWindowWatcher *_windowWatcher;
+static NSMutableSet *_pendingPageCacheToRelease = nil;
+static NSTimer *_pageCacheReleaseTimer = nil;
+
 - (BOOL)hasPageCache;
 {
     return pageCache != nil;
 }
 
++ (void)_invalidateReleaseTimer
+{
+    if (_pageCacheReleaseTimer){
+        [_pageCacheReleaseTimer invalidate];
+        [_pageCacheReleaseTimer release];
+        _pageCacheReleaseTimer = nil;
+    }
+}
+
+- (void)_scheduleRelease
+{
+    LOG (PageCache, "Scheduling release of %@", [self URLString]);
+    if (!_pageCacheReleaseTimer){
+        _pageCacheReleaseTimer = [[NSTimer scheduledTimerWithTimeInterval: 2.5 target:self selector:@selector(_releasePageCache:) userInfo:nil repeats:NO] retain];
+        if (_pendingPageCacheToRelease == nil){
+            _pendingPageCacheToRelease = [[NSMutableSet alloc] init];
+        }
+    }
+    
+    // Only add the pageCache on first scheduled attempt.
+    if (pageCache){
+        [_pendingPageCacheToRelease addObject: pageCache];
+        [pageCache release]; // Last reference held by _pendingPageCacheToRelease.
+    }
+    
+    if (!_windowWatcher){
+        _windowWatcher = [[WebWindowWatcher alloc] init];
+        [[NSNotificationCenter defaultCenter] addObserver:_windowWatcher selector:@selector(windowWillClose:)
+                        name:NSWindowWillCloseNotification object:nil];
+    }
+}
+
++ (void)_releaseAllPendingPageCaches
+{
+    LOG (PageCache, "releasing %d items\n", [_pendingPageCacheToRelease count]);
+    [WebHistoryItem _invalidateReleaseTimer];
+    [_pendingPageCacheToRelease removeAllObjects];
+}
+
+- (void)_releasePageCache: (NSTimer *)timer
+{
+    CGSRealTimeDelta userDelta;
+    CFAbsoluteTime loadDelta;
+    
+    loadDelta = CFAbsoluteTimeGetCurrent()-[WebFrame _timeOfLastCompletedLoad];
+    userDelta = CGSSecondsSinceLastInputEvent(kCGSAnyInputEventType);
+
+    [_pageCacheReleaseTimer release];
+    _pageCacheReleaseTimer = nil;
+
+    if ((userDelta < 0.5 || loadDelta < 1.25) && [_pendingPageCacheToRelease count] < 42){
+        LOG (PageCache, "postponing again because not quiescent for more than a second (%f since last input, %f since last load).", userDelta, loadDelta);
+        [self _scheduleRelease];
+        return;
+    }
+    else
+        LOG (PageCache, "releasing, quiescent for more than a second (%f since last input, %f since last load).", userDelta, loadDelta);
+
+    [WebHistoryItem _releaseAllPendingPageCaches];
+    
+    LOG (PageCache, "Done releasing %p %@", self, [self URLString]);
+}
+
 - (void)setHasPageCache: (BOOL)f
 {
     if (f && !pageCache)
         pageCache = [[NSMutableDictionary alloc] init];
     if (!f && pageCache){
-        [pageCache release];
+        [self _scheduleRelease];
         pageCache = 0;
     }
 }
@@ -430,3 +515,12 @@
 
 
 @end
+
+ at implementation WebWindowWatcher
+-(void)windowWillClose:(NSNotification *)notification
+{
+    [WebHistoryItem _releaseAllPendingPageCaches];
+}
+ at end
+
+
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.h b/WebKit/WebView.subproj/WebDataSourcePrivate.h
index 63f1323..ae96258 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.h
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.h
@@ -147,5 +147,6 @@
 - (BOOL)_justOpenedForTargetedLink;
 - (void)_setStoredInPageCache:(BOOL)f;
 - (BOOL)_storedInPageCache;
+- (BOOL)_loadingFromPageCache;
 
 @end
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.m b/WebKit/WebView.subproj/WebDataSourcePrivate.m
index a9b3b55..de00775 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.m
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.m
@@ -158,6 +158,7 @@
         _private->loadingFromPageCache = YES;
         [self _commitIfReady: pageCache];
     } else if (!_private->mainClient) {
+        _private->loadingFromPageCache = NO;
         if ([self webFrame] == [[self controller] mainFrame]) {
 	    [_private->request setCookiePolicyBaseURL:[self URL]];
 	} else {
@@ -464,6 +465,8 @@
                 headers:headers 
                 lastModified: (pageCache ? nil : [_private->response lastModifiedDate])
                 pageCache: pageCache];
+
+        [[self webFrame] _opened];
     }
 }
 
@@ -651,5 +654,11 @@
 {
     return _private->storedInPageCache;
 }
+
+- (BOOL)_loadingFromPageCache
+{
+    return _private->loadingFromPageCache;
+}
+
 @end
 
diff --git a/WebKit/WebView.subproj/WebDynamicScrollBarsView.h b/WebKit/WebView.subproj/WebDynamicScrollBarsView.h
index 2cf0888..43891ea 100644
--- a/WebKit/WebView.subproj/WebDynamicScrollBarsView.h
+++ b/WebKit/WebView.subproj/WebDynamicScrollBarsView.h
@@ -21,5 +21,6 @@
 
 - (void)setAllowsScrolling:(BOOL)flag;
 - (BOOL)allowsScrolling;
+- (void)updateScrollers;
 
 @end
diff --git a/WebKit/WebView.subproj/WebFramePrivate.h b/WebKit/WebView.subproj/WebFramePrivate.h
index 24808a5..2d79608 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.h
+++ b/WebKit/WebView.subproj/WebFramePrivate.h
@@ -161,9 +161,11 @@ typedef enum {
 
 - (void)_setProvisionalDataSource: (WebDataSource *)d;
 
++ (CFAbsoluteTime)_timeOfLastCompletedLoad;
 - (BOOL)_canCachePage;
 - (void)_purgePageCache;
 
+- (void)_opened;
 // used to decide to use loadType=Same
 - (BOOL)_shouldTreatURLAsSameAsCurrent:(NSURL *)URL;
 
diff --git a/WebKit/WebView.subproj/WebFramePrivate.m b/WebKit/WebView.subproj/WebFramePrivate.m
index 2eb73c3..6e3ee46 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.m
+++ b/WebKit/WebView.subproj/WebFramePrivate.m
@@ -623,7 +623,8 @@ Repeat load of the same URL (by any other means of navigation other than the rel
         }
     }
     
-    if (pagesCached > sizeLimit){
+    // Snapback items are never directly purged here.
+    if (pagesCached >= sizeLimit && ![oldestItem alwaysAttemptToUsePageCache]){
         LOG(PageCache, "Purging back/forward cache, %s\n", [[[oldestItem URL] absoluteString] cString]);
         [oldestItem setHasPageCache: NO];
     }
@@ -634,6 +635,12 @@ Repeat load of the same URL (by any other means of navigation other than the rel
     return _private->state;
 }
 
+static CFAbsoluteTime _timeOfLastCompletedLoad;
++ (CFAbsoluteTime)_timeOfLastCompletedLoad
+{
+    return _timeOfLastCompletedLoad;
+}
+
 - (void)_setState: (WebFrameState)newState
 {
     LOG(Loading, "%@:  transition from %s to %s", [self name], stateNames[_private->state], stateNames[newState]);
@@ -693,6 +700,19 @@ Repeat load of the same URL (by any other means of navigation other than the rel
         [_private->scheduledLayoutTimer fire];
         ASSERT(_private->scheduledLayoutTimer == nil);
         [_private setPreviousItem:nil];
+        _timeOfLastCompletedLoad = CFAbsoluteTimeGetCurrent();
+    }
+}
+
+// Called after we send an openURL:... down to WebCore.
+- (void)_opened
+{
+    if ([[self dataSource] _loadingFromPageCache]){
+        // Force a layout to update view size and thereby
+        // update scrollbars.
+        [_private->bridge reapplyStyles];
+        [[[self webView] documentView] setNeedsLayout: YES];
+        [[[self webView] documentView] layout];
     }
 }
 
@@ -1579,7 +1599,7 @@ Repeat load of the same URL (by any other means of navigation other than the rel
         loadType == WebFrameLoadTypeBack ||
         loadType == WebFrameLoadTypeIndexedBackForward) &&
         [[_private provisionalItem] hasPageCache]){
-        LOG(PageCache, "Restoring page from back/forward cache, %s\n", [[[[_private provisionalItem] URL] absoluteString] cString]);
+        LOG (PageCache, "Restoring page from back/forward cache, %s\n", [[[[_private provisionalItem] URL] absoluteString] cString]);
         [_private->provisionalDataSource _startLoading: [[_private provisionalItem] pageCache]];
     }
     else 
diff --git a/WebKit/WebView.subproj/WebPreferences.m b/WebKit/WebView.subproj/WebPreferences.m
index c1e834d..f25e611 100644
--- a/WebKit/WebView.subproj/WebPreferences.m
+++ b/WebKit/WebView.subproj/WebPreferences.m
@@ -94,7 +94,7 @@
         @"1.00",                        WebKitInitialTimedLayoutDelayPreferenceKey,
         @"4096",                        WebKitInitialTimedLayoutSizePreferenceKey,
         @"1.00",                        WebKitResourceTimedLayoutDelayPreferenceKey,
-        @"10",                          WebKitPageCacheSizePreferenceKey,
+        @"4",                          WebKitPageCacheSizePreferenceKey,
         [NSNumber numberWithBool:YES],  WebKitInitialTimedLayoutEnabledPreferenceKey,
         [NSNumber numberWithBool:YES],  WebKitResourceTimedLayoutEnabledPreferenceKey,
         [NSNumber numberWithBool:NO],   WebKitUserStyleSheetEnabledPreferenceKey,

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list