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

trey trey at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:12:29 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 95c721c43d815284017fcc4b6277c3d2e9453647
Author: trey <trey at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sat Dec 7 01:18:40 2002 +0000

    WebKit:
    
    	3118584 - implement desired behavior for load - reload - b/f
    	3119241 - page cache needs to be refreshed after reload
    	3118096 - isTargetItem:NO saved to disk with every bookmark
    
    	The most noticeable changes are the addition of the "Same" loadType, and that reload
    	does not restore form state.  3119241 was noticed in passing, and is related.
    	3118096 is a nit with a possible small perf benefit.
    
            Reviewed by: rjw
    
            * History.subproj/WebHistoryItem.h:
            * History.subproj/WebHistoryItem.m:
            (-[WebHistoryItem dealloc]):  New originalURL field.
            (-[WebHistoryItem originalURL]):  New getter.
            (-[WebHistoryItem setOriginalURL:]):  New setter.
            (-[WebHistoryItem dictionaryRepresentation]):  Dont save isTarget.
            (-[WebHistoryItem initFromDictionaryRepresentation:]):  Dont save isTarget.
            * WebView.subproj/WebFrame.m:
            (-[WebFrame loadRequest:]):  Test for going to same URL, invoke loadTypeSame case.
            * WebView.subproj/WebFramePrivate.h:  Add loadTypeSame
            * WebView.subproj/WebFramePrivate.m:
            (-[WebFrame _addBackForwardItemClippedAtTarget:]):  Remove a line of dead code.
            (-[WebFrame _createItem]):  Set originalURL when item is created.
            (-[WebFrame _transitionToCommitted:]):  For loadTypeSame, clear page cache
            (-[WebFrame _purgePageCache]):  Added logging.
            (-[WebFrame _setState:]):  Don't add to page cache if doing a reload.
            (-[WebFrame _isLoadComplete]):  LoadTypeSame is a NOP.
            (-[WebFrame _loadItem:fromItem:withLoadType:]):  LoadTypeSame is an ASSERT.
            (-[WebFrame _loadURL:loadType:triggeringEvent:isFormSubmission:]):  In
    	the LoadTypeSame case load from origin and never do anchor nav.  If asked to load
    	the same URL, invoke LoadTypeSame case.
            (-[WebFrame _loadURL:intoChild:]):  Latent bug: WebFrameLoadTypeReloadAllowingStaleData
    	should restore child frame content like reload does.
            (-[WebFrame _itemForRestoringDocState]):  Prevent form state restore on reload and loadSame.
            (-[WebFrame _shouldTreatURLAsSameAsCurrent:]):  New utility function.
    
    WebBrowser:
    
    	3118584 - implement desired behavior for load - reload - b/f
    	3119029 - assert if you control click on back button when it's enabled only to leave bookmarks view
    
    	The app no longer has a test in it to turn a standard nav into a reload. WK does it.
    
    	The bug was a result of the special case of the back button as a way to get out
    	of bookmarks view to the web view.  The back menu basically has to play the same game.
    
            Reviewed by: rjw, john sullivan (respectively)
    
            * BrowserDocument.m:
            (-[BrowserDocument goToRequest:]):  Remove test, let WK sort out when to reload.
            (-[BrowserDocument goToItem:]):   Special case if in bookmarks view.  Go back to
    	web view mode.
            (-[BrowserDocument backListMenuForButton:]):  Special case if in bookmarks view.  Add
    	current item to menu.
            * BrowserWindowController.h:  Export a couple existing methods.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2963 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index b048471..2defe1b 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,41 @@
+2002-12-06  Trey Matteson  <trey at apple.com>
+
+	3118584 - implement desired behavior for load - reload - b/f
+	3119241 - page cache needs to be refreshed after reload
+	3118096 - isTargetItem:NO saved to disk with every bookmark
+
+	The most noticeable changes are the addition of the "Same" loadType, and that reload
+	does not restore form state.  3119241 was noticed in passing, and is related.
+	3118096 is a nit with a possible small perf benefit.
+
+        Reviewed by: rjw
+
+        * History.subproj/WebHistoryItem.h:
+        * History.subproj/WebHistoryItem.m:
+        (-[WebHistoryItem dealloc]):  New originalURL field.
+        (-[WebHistoryItem originalURL]):  New getter.
+        (-[WebHistoryItem setOriginalURL:]):  New setter.
+        (-[WebHistoryItem dictionaryRepresentation]):  Dont save isTarget.
+        (-[WebHistoryItem initFromDictionaryRepresentation:]):  Dont save isTarget.
+        * WebView.subproj/WebFrame.m:
+        (-[WebFrame loadRequest:]):  Test for going to same URL, invoke loadTypeSame case.
+        * WebView.subproj/WebFramePrivate.h:  Add loadTypeSame
+        * WebView.subproj/WebFramePrivate.m:
+        (-[WebFrame _addBackForwardItemClippedAtTarget:]):  Remove a line of dead code.
+        (-[WebFrame _createItem]):  Set originalURL when item is created.
+        (-[WebFrame _transitionToCommitted:]):  For loadTypeSame, clear page cache
+        (-[WebFrame _purgePageCache]):  Added logging.
+        (-[WebFrame _setState:]):  Don't add to page cache if doing a reload.
+        (-[WebFrame _isLoadComplete]):  LoadTypeSame is a NOP.
+        (-[WebFrame _loadItem:fromItem:withLoadType:]):  LoadTypeSame is an ASSERT.
+        (-[WebFrame _loadURL:loadType:triggeringEvent:isFormSubmission:]):  In
+	the LoadTypeSame case load from origin and never do anchor nav.  If asked to load
+	the same URL, invoke LoadTypeSame case.
+        (-[WebFrame _loadURL:intoChild:]):  Latent bug: WebFrameLoadTypeReloadAllowingStaleData
+	should restore child frame content like reload does.
+        (-[WebFrame _itemForRestoringDocState]):  Prevent form state restore on reload and loadSame.
+        (-[WebFrame _shouldTreatURLAsSameAsCurrent:]):  New utility function.
+
 2002-12-06  Maciej Stachowiak  <mjs at apple.com>
 
         Reviewed by: Darin Adler
diff --git a/WebKit/History.subproj/WebHistoryItem.h b/WebKit/History.subproj/WebHistoryItem.h
index e79e415..e61dde8 100644
--- a/WebKit/History.subproj/WebHistoryItem.h
+++ b/WebKit/History.subproj/WebHistoryItem.h
@@ -5,12 +5,15 @@
 
 #import <Cocoa/Cocoa.h>
 
+ at class NSURL;
+
 /*!
     @class WebHistoryItem
 */
 @interface WebHistoryItem : NSObject
 {
     NSString *_URLString;
+    NSString *_originalURLString;
     NSString *_target;
     NSString *_parent;
     NSString *_title;
@@ -36,6 +39,7 @@
 
 - (NSURL *)URL;
 - (NSString *)URLString;
+- (NSString *)originalURLString;
 - (NSString *)target;
 - (NSString *)parent;
 - (NSString *)title;
@@ -48,6 +52,7 @@
 - (NSString *)anchor;
 
 - (void)setURL:(NSURL *)URL;
+- (void)setOriginalURLString:(NSString *)URL;
 - (void)setTarget:(NSString *)target;
 - (void)setParent:(NSString *)parent;
 - (void)setTitle:(NSString *)title;
diff --git a/WebKit/History.subproj/WebHistoryItem.m b/WebKit/History.subproj/WebHistoryItem.m
index b5433b7..49eb9fa 100644
--- a/WebKit/History.subproj/WebHistoryItem.m
+++ b/WebKit/History.subproj/WebHistoryItem.m
@@ -63,8 +63,9 @@
 - (void)dealloc
 {
     [self _retainIconInDatabase:NO];
-    
+
     [_URLString release];
+    [_originalURLString release];
     [_target release];
     [_parent release];
     [_title release];
@@ -90,6 +91,13 @@
     return _URLString;
 }
 
+// The first URL we loaded to get to where this history item points.  Includes both client
+// and server redirects.
+- (NSString *)originalURLString
+{
+    return _originalURLString;
+}
+
 - (NSString *)target
 {
     return _target;
@@ -146,6 +154,15 @@
     }
 }
 
+// The first URL we loaded to get to where this history item points.  Includes both client
+// and server redirects.
+- (void)setOriginalURLString:(NSString *)URL
+{
+    NSString *newURL = [URL copy];
+    [_originalURLString release];
+    _originalURLString = newURL;
+}
+
 - (void)setTitle:(NSString *)title
 {
     NSString *newTitle;
@@ -354,7 +371,6 @@
         }
         [dict setObject: childDicts forKey: @"children"];
     }
-    [dict setObject: (_isTargetItem ? @"YES" : @"NO") forKey: @"isTargetItem"];
     
     return dict;
 }
@@ -384,8 +400,6 @@
             [_subItems addObject: child];
         }
     }
-    NSString *value = [dict objectForKey:@"isTargetItem"];
-    _isTargetItem = (value != nil) && [value isEqualToString:@"YES"];
 
     return self;
 }
diff --git a/WebKit/WebView.subproj/WebFrame.m b/WebKit/WebView.subproj/WebFrame.m
index bb2c69f..b2fcd06 100644
--- a/WebKit/WebView.subproj/WebFrame.m
+++ b/WebKit/WebView.subproj/WebFrame.m
@@ -105,10 +105,18 @@
 
 - (void)loadRequest:(WebResourceRequest *)request
 {
+    WebFrameLoadType loadType;
+
     WebResourceRequest *r = [request copy];
     [self _addExtraFieldsToRequest:r];
+    if ([self _shouldTreatURLAsSameAsCurrent:[request URL]]) {
+        [r setRequestCachePolicy:WebRequestCachePolicyLoadFromOrigin];
+        loadType = WebFrameLoadTypeSame;
+    } else {
+        loadType = WebFrameLoadTypeStandard;
+    }
     WebDataSource *newDataSource = [[WebDataSource alloc] initWithRequest:r];
-    [self _loadDataSource:newDataSource withLoadType:WebFrameLoadTypeStandard];
+    [self _loadDataSource:newDataSource withLoadType:loadType];
     [newDataSource release];
 }
 
diff --git a/WebKit/WebView.subproj/WebFramePrivate.h b/WebKit/WebView.subproj/WebFramePrivate.h
index 682a367..24808a5 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.h
+++ b/WebKit/WebView.subproj/WebFramePrivate.h
@@ -39,6 +39,7 @@ typedef enum {
     WebFrameLoadTypeIndexedBackForward,		// a multi-item hop in the backforward list
     WebFrameLoadTypeReload,
     WebFrameLoadTypeReloadAllowingStaleData,
+    WebFrameLoadTypeSame,		// user loads same URL again (but not reload button)
     WebFrameLoadTypeInternal
 } WebFrameLoadType;
 
@@ -163,4 +164,7 @@ typedef enum {
 - (BOOL)_canCachePage;
 - (void)_purgePageCache;
 
+// used to decide to use loadType=Same
+- (BOOL)_shouldTreatURLAsSameAsCurrent:(NSURL *)URL;
+
 @end
diff --git a/WebKit/WebView.subproj/WebFramePrivate.m b/WebKit/WebView.subproj/WebFramePrivate.m
index 1fdb060..bb5a490 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.m
+++ b/WebKit/WebView.subproj/WebFramePrivate.m
@@ -47,13 +47,46 @@ static const char * const loadTypeNames[] = {
     "WebFrameLoadTypeStandard",
     "WebFrameLoadTypeBack",
     "WebFrameLoadTypeForward",
-    "WebFrameLoadTypeIndexedBackForward",		// a multi-item hop in the backforward list
+    "WebFrameLoadTypeIndexedBackForward",
     "WebFrameLoadTypeReload",
     "WebFrameLoadTypeReloadAllowingStaleData",
+    "WebFrameLoadTypeSame",
     "WebFrameLoadTypeInternal"
 };
 #endif
 
+/*
+Here is the current behavior matrix for four types of navigations:
+
+Standard Nav:
+
+ Restore form state:   YES
+ Restore scroll and focus state:  YES
+ WF Cache policy: WebRequestCachePolicyUseProtocolDefault
+ Add to back/forward list: YES
+ 
+Back/Forward:
+
+ Restore form state:   YES
+ Restore scroll and focus state:  YES
+ WF Cache policy: WebRequestCachePolicyReturnCacheObjectLoadFromOriginIfNoCacheObject
+ Add to back/forward list: NO
+
+Reload (meaning only the reload button):
+
+ Restore form state:   NO
+ Restore scroll and focus state:  YES
+ WF Cache policy: WebRequestCachePolicyLoadFromOrigin
+ Add to back/forward list: NO
+
+Repeat load of the same URL (by any other means of navigation other than the reload button, including hitting return in the location field):
+
+ Restore form state:   NO
+ Restore scroll and focus state:  NO, reset to initial conditions
+ WF Cache policy: WebRequestCachePolicyLoadFromOrigin
+ Add to back/forward list: NO
+*/
+
 @implementation WebFramePrivate
 
 - init
@@ -171,8 +204,7 @@ static const char * const loadTypeNames[] = {
 - (WebHistoryItem *)_addBackForwardItemClippedAtTarget:(BOOL)doClip
 {
     WebHistoryItem *bfItem = [[[self controller] mainFrame] _createItemTreeWithTargetFrame:self clippedAtTarget:doClip];
-    if (bfItem != [[[self controller] backForwardList] currentEntry])
-        [[[self controller] backForwardList] addEntry:bfItem];
+    [[[self controller] backForwardList] addEntry:bfItem];
     return bfItem;
 }
 
@@ -185,6 +217,7 @@ static const char * const loadTypeNames[] = {
     bfItem = [[[WebHistoryItem alloc] initWithURL:url target:[self name] parent:[[self parent] name] title:[dataSrc pageTitle]] autorelease];
     [bfItem setAnchor:[url fragment]];
     [dataSrc _addBackForwardItem:bfItem];
+    [bfItem setOriginalURLString:[[[dataSrc _originalRequest] URL] absoluteString]];
 
     // Set the item for which we will save document state
     [_private setPreviousItem:[_private currentItem]];
@@ -488,11 +521,19 @@ static const char * const loadTypeNames[] = {
                     [self _restoreScrollPosition];
                 }
                 break;
-                
+
             case WebFrameLoadTypeReload:
-                [self _saveScrollPositionToItem:[_private currentItem]];
+            case WebFrameLoadTypeSame:
+            {
+                WebHistoryItem *currItem = [_private currentItem];
+                printf ("Clearing back/forward cache, %s\n", [[[currItem URL] absoluteString] cString]);
+                [currItem setHasPageCache:NO];
+                if (loadType == WebFrameLoadTypeReload) {
+                    [self _saveScrollPositionToItem:currItem];
+                }
                 [[self webView] _makeDocumentViewForDataSource:ds];
                 break;
+            }
 
             case WebFrameLoadTypeStandard:
                 // Add item to history.
@@ -583,6 +624,7 @@ static const char * const loadTypeNames[] = {
     }
     
     if (pagesCached > sizeLimit){
+        printf ("Purging back/forward cache, %s\n", [[[oldestItem URL] absoluteString] cString]);
         [oldestItem setHasPageCache: NO];
     }
 }
@@ -617,8 +659,19 @@ static const char * const loadTypeNames[] = {
         [[[self webView] frameScrollView] setDrawsBackground:NO];
 
         // Cache the page, if possible.
+        // Don't write to the cache if in the middle of a redirect, since we will want to
+        // store the final page we end up on.
+        // No point writing to the cache on a reload or loadSame, since we will just write
+        // over it again when we leave that page.
         WebHistoryItem *item = [_private currentItem];
-        if ([self _canCachePage] && [_private->bridge canCachePage] && item && !_private->quickRedirectComing && ![[self dataSource] isLoading]){
+        WebFrameLoadType loadType = [self _loadType];
+        if ([self _canCachePage]
+            && [_private->bridge canCachePage]
+            && item
+            && !_private->quickRedirectComing
+            && loadType != WebFrameLoadTypeReload && loadType != WebFrameLoadTypeSame
+            && ![[self dataSource] isLoading])
+        {
             if (![item pageCache]){
                 printf ("Saving page to back/forward cache, %s\n", [[[[self dataSource] URL] absoluteString] cString]);
                 [item setHasPageCache: YES];
@@ -738,6 +791,7 @@ static const char * const loadTypeNames[] = {
                     case WebFrameLoadTypeStandard:
                     case WebFrameLoadTypeInternal:
                     case WebFrameLoadTypeReloadAllowingStaleData:
+                    case WebFrameLoadTypeSame:
                         // Do nothing.
                         break;
 
@@ -920,6 +974,7 @@ static const char * const loadTypeNames[] = {
                     case WebFrameLoadTypeReloadAllowingStaleData:
                         // no-op: leave as protocol default
                         break;
+                    case WebFrameLoadTypeSame:
                     default:
                         ASSERT_NOT_REACHED();
                 }
@@ -1210,6 +1265,9 @@ static const char * const loadTypeNames[] = {
     if (loadType == WebFrameLoadTypeReload) {
         [request setRequestCachePolicy:WebRequestCachePolicyLoadFromOrigin];
     }
+    // I believe this is never called with LoadSame.  If it is, we probably want to set the cache
+    // policy of LoadFromOrigin, but I didn't test that.
+    ASSERT(loadType != WebFrameLoadTypeSame);
 
     NSDictionary *action = nil;
 
@@ -1222,13 +1280,17 @@ static const char * const loadTypeNames[] = {
     }
 
     WebDataSource *oldDataSource = [[self dataSource] retain];
-    
-    if (!isFormSubmission
-            && loadType != WebFrameLoadTypeReload
-            && ![_private->bridge isFrameSet]
-            && [URL fragment]
-            && [[URL _web_URLByRemovingFragment] isEqual:[[NSURL _web_URLWithString:[_private->bridge URL]] _web_URLByRemovingFragment]]) {
 
+    BOOL sameURL = [self _shouldTreatURLAsSameAsCurrent:URL];
+
+    if (!isFormSubmission
+        && !sameURL
+        && loadType != WebFrameLoadTypeReload
+        && loadType != WebFrameLoadTypeSame
+        && ![_private->bridge isFrameSet]
+        && [URL fragment]
+        && [[URL _web_URLByRemovingFragment] isEqual:[[NSURL _web_URLWithString:[_private->bridge URL]] _web_URLByRemovingFragment]]) {
+        
         // Just do anchor navigation within the existing content.
         
         // We don't do this if we are submitting a form, explicitly reloading,
@@ -1254,8 +1316,11 @@ static const char * const loadTypeNames[] = {
             _private->quickRedirectComing = NO;
             
             // Inherit the loadType from the operation that spawned the redirect,
-            // unless the new load type is some kind of reload.
-            if (loadType != WebFrameLoadTypeReload && loadType != WebFrameLoadTypeReloadAllowingStaleData) {
+            // unless the new load type is some kind of reload imposed by WebKit.
+            if (loadType != WebFrameLoadTypeReload
+                && loadType != WebFrameLoadTypeSame
+                && loadType != WebFrameLoadTypeReloadAllowingStaleData)
+            {
                 [self _setLoadType:previousLoadType];
             }
 
@@ -1263,7 +1328,12 @@ static const char * const loadTypeNames[] = {
             WebDataSource *newDataSource = [self provisionalDataSource];
             [newDataSource _setIsClientRedirect:YES];
             [newDataSource _addBackForwardItems:[oldDataSource _backForwardItems]];
-        }
+        } else if (sameURL) {
+            // Example of this case are sites that reload the same URL with a different cookie
+            // driving the generated content, or a master frame with links that drive a target
+            // frame, where the user has clicked on the same link repeatedly.
+            [self _setLoadType:WebFrameLoadTypeSame];
+        }            
         [request release];
     }
 
@@ -1280,10 +1350,13 @@ static const char * const loadTypeNames[] = {
 
     // If we're moving in the backforward list, we might want to replace the content
     // of this child frame with whatever was there at that point.
-    if ((loadType == WebFrameLoadTypeForward || 
-        loadType == WebFrameLoadTypeBack ||
-        loadType == WebFrameLoadTypeIndexedBackForward ||
-        loadType == WebFrameLoadTypeReload) && childItems)
+    // Reload will maintain the frame contents, LoadSame will not.
+    if (childItems &&
+        (loadType == WebFrameLoadTypeForward
+         || loadType == WebFrameLoadTypeBack
+         || loadType == WebFrameLoadTypeIndexedBackForward
+         || loadType == WebFrameLoadTypeReload
+         || loadType == WebFrameLoadTypeReloadAllowingStaleData))
     {
         childItem = [parentItem childItemWithName:[childFrame name]];
         if (childItem) {
@@ -1296,7 +1369,12 @@ static const char * const loadTypeNames[] = {
     [childFrame _loadURL:URL loadType:childLoadType triggeringEvent:nil isFormSubmission:NO];
 
     if (childItem) {
-        if (loadType != WebFrameLoadTypeReload) {
+        // We only enter this second if block when the first one succeeded to find a
+        // matching child frame
+        if (loadType == WebFrameLoadTypeForward
+            || loadType == WebFrameLoadTypeBack
+            || loadType == WebFrameLoadTypeIndexedBackForward)
+        {
             // For back/forward, remember this item so we can traverse any child items as child frames load
             [childFrame->_private setProvisionalItem:childItem];
         } else {
@@ -1471,7 +1549,13 @@ static const char * const loadTypeNames[] = {
 
 - (WebHistoryItem *)_itemForRestoringDocState
 {
-    return [_private currentItem];
+    WebFrameLoadType loadType = [self _loadType];
+    if (loadType == WebFrameLoadTypeReload || loadType == WebFrameLoadTypeSame) {
+        // Don't restore any form state on reload or loadSame
+        return nil;
+    } else {
+        return [_private currentItem];
+    }
 }
 
 -(void)_continueLoadRequestAfterNavigationPolicy:(BOOL)shouldContinue request:(WebResourceRequest *)request
@@ -1552,5 +1636,12 @@ static const char * const loadTypeNames[] = {
     [_private setProvisionalDataSource: d];
 }
 
+// used to decide to use loadType=Same
+- (BOOL)_shouldTreatURLAsSameAsCurrent:(NSURL *)URL
+{
+    WebHistoryItem *item = [_private currentItem];
+    NSString* URLString = [URL absoluteString];
+    return [URLString isEqual:[item URLString]] || [URLString isEqual:[item originalURLString]];
+}    
 
 @end

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list