From 36de84df4b3c3f65690fc62c8e178645b96a8c41 Mon Sep 17 00:00:00 2001 From: darin Date: Sun, 8 Oct 2006 20:42:22 +0000 Subject: [PATCH] Reviewed by Mitz. - fix http://bugs.webkit.org/show_bug.cgi?id=11218 REGRESSION: Assertion failure in WebFrameLoader when going back from a file: or data: URL Also added a helper function in WebFrameLoader so code that checks for back/forward load types is easier to read. * Loader/WebFrameLoader.m: (-[WebFrameLoader _setPolicyDocumentLoadState:]): Fixed line of code that was setting the load state to nil instead of the passed-in object. (isBackForwardLoadType): Added. (-[WebFrameLoader shouldReloadToHandleUnreachableURLFromRequest:]): Use isBackForwardLoadType. (-[WebFrameLoader checkNavigationPolicyForRequest:dataSource:formState:andCall:withSelector:]): Ditto. (-[WebFrameLoader continueLoadRequestAfterNavigationPolicy:formState:]): Ditto. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16889 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebKit/ChangeLog | 19 ++++++++++++++++ WebKit/Loader/WebFrameLoader.m | 41 +++++++++++++++++++++------------- 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog index e06ba4d535f9..631f8a3cf56b 100644 --- a/WebKit/ChangeLog +++ b/WebKit/ChangeLog @@ -1,3 +1,22 @@ +2006-10-08 Darin Adler + + Reviewed by Mitz. + + - fix http://bugs.webkit.org/show_bug.cgi?id=11218 + REGRESSION: Assertion failure in WebFrameLoader when going back from a file: or data: URL + + Also added a helper function in WebFrameLoader so code that checks for back/forward load types + is easier to read. + + * Loader/WebFrameLoader.m: + (-[WebFrameLoader _setPolicyDocumentLoadState:]): Fixed line of code that was setting the load + state to nil instead of the passed-in object. + (isBackForwardLoadType): Added. + (-[WebFrameLoader shouldReloadToHandleUnreachableURLFromRequest:]): Use isBackForwardLoadType. + (-[WebFrameLoader checkNavigationPolicyForRequest:dataSource:formState:andCall:withSelector:]): + Ditto. + (-[WebFrameLoader continueLoadRequestAfterNavigationPolicy:formState:]): Ditto. + 2006-10-08 Darin Adler Reviewed by Maciej. diff --git a/WebKit/Loader/WebFrameLoader.m b/WebKit/Loader/WebFrameLoader.m index 0ce96a42003c..7fef1e7f64df 100644 --- a/WebKit/Loader/WebFrameLoader.m +++ b/WebKit/Loader/WebFrameLoader.m @@ -264,7 +264,7 @@ [policyDocumentLoadState release]; [loadState retain]; - policyDocumentLoadState = nil; + policyDocumentLoadState = loadState; } - (void)clearDataSource @@ -848,18 +848,33 @@ static BOOL isCaseInsensitiveEqual(NSString *a, NSString *b) listener = nil; } +static inline BOOL isBackForwardLoadType(WebFrameLoadType type) +{ + switch (type) { + case WebFrameLoadTypeStandard: + case WebFrameLoadTypeReload: + case WebFrameLoadTypeReloadAllowingStaleData: + case WebFrameLoadTypeSame: + case WebFrameLoadTypeInternal: + case WebFrameLoadTypeReplace: + return false; + case WebFrameLoadTypeBack: + case WebFrameLoadTypeForward: + case WebFrameLoadTypeIndexedBackForward: + return true; + } + ASSERT_NOT_REACHED(); + return false; +} + - (BOOL)shouldReloadToHandleUnreachableURLFromRequest:(NSURLRequest *)request { NSURL *unreachableURL = [request _webDataRequestUnreachableURL]; - if (unreachableURL == nil) { + if (unreachableURL == nil) return NO; - } - if (policyLoadType != WebFrameLoadTypeForward - && policyLoadType != WebFrameLoadTypeBack - && policyLoadType != WebFrameLoadTypeIndexedBackForward) { + if (!isBackForwardLoadType(policyLoadType)) return NO; - } // We only treat unreachableURLs specially during the delegate callbacks // for provisional load errors and navigation policy decisions. The former @@ -1186,11 +1201,8 @@ static BOOL isCaseInsensitiveEqual(NSString *a, NSString *b) // We are always willing to show alternate content for unreachable URLs; // treat it like a reload so it maintains the right state for b/f list. if ([request _webDataRequestUnreachableURL] != nil) { - if (policyLoadType == WebFrameLoadTypeForward - || policyLoadType == WebFrameLoadTypeBack - || policyLoadType == WebFrameLoadTypeIndexedBackForward) { + if (isBackForwardLoadType(policyLoadType)) policyLoadType = WebFrameLoadTypeReload; - } [target performSelector:selector withObject:request withObject:nil]; return; } @@ -1288,14 +1300,13 @@ static BOOL isCaseInsensitiveEqual(NSString *a, NSString *b) [client _clientRedirectCancelledOrFinished:NO]; [self _setPolicyDocumentLoadState:nil]; + // If the navigation request came from the back/forward menu, and we punt on it, we have the // problem that we have optimistically moved the b/f cursor already, so move it back. For sanity, // we only do this when punting a navigation for the target frame or top-level frame. - if ((isTargetItem || [[client webView] mainFrame] == client) - && (policyLoadType == WebFrameLoadTypeForward - || policyLoadType == WebFrameLoadTypeBack - || policyLoadType == WebFrameLoadTypeIndexedBackForward)) + if ((isTargetItem || [[client webView] mainFrame] == client) && isBackForwardLoadType(policyLoadType)) [(WebFrame *)[[client webView] mainFrame] _resetBackForwardList]; + return; } -- 2.36.0