[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:13:31 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 94f4668fd6b44933abdcbc16a513c65d86f39612
Author: trey <trey at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Dec 11 08:52:49 2002 +0000
WebKit:
3092966 - going back goes to different page (can't go back to a POST page)
We will rePOST data upon back/forward/refresh if our caches fail us. The policy delegate
gets a crack at confirming this operation. Latent bugs where the policy delegate was double
queried are fixed. A bug in the b/f cursor when a page failed to load is fixed.
Reviewed by Maciej.
* English.lproj/StringsNotToBeLocalized.txt: Usual suspects.
* History.subproj/WebHistoryItem.h: Add state for reposting forms.
* History.subproj/WebHistoryItem.m: Boilerplate changes for new state.
(-[WebHistoryItem dealloc]):
(-[WebHistoryItem setFormData:]):
(-[WebHistoryItem setFormContentType:]):
(-[WebHistoryItem formData]):
(-[WebHistoryItem formContentType]):
(-[WebHistoryItem description]):
* WebView.subproj/WebController.m:
(-[WebController _goToItem:withLoadType:]): Tighten up an assert as I clarified an
assumption as I worked through this task.
* WebView.subproj/WebControllerPolicyDelegate.h: New WebNavigationType's for back/forward,
refresh, and repost.
* WebView.subproj/WebFrame.m:
(-[WebFrame loadRequest:]): Eliminate extra copy of a request.
(-[WebFrame reload]): Eliminate extra copy of a request. Setup triggeringAction properly
if we're about to rePOST.
* WebView.subproj/WebFramePrivate.h: Started moving some private methods into the .m file.
* WebView.subproj/WebFramePrivate.m:
(-[WebFrame _createItem]): Save form state with history items.
(-[WebFrame _isLoadComplete]): Fix up b/f cursor on page error before commit succeeds.
(-[WebFrame _loadItem:fromItem:withLoadType:]): Set up request to rePOST if that's what the
HistoryItem demands. Add call to _addExtraFieldsToRequest so we don't do a double
query of the policy delegate. Pre-flight the form post vs. WF cache to setup triggering
action properly.
(-[WebFrame _actionInformationForLoadType:isFormSubmission:event:originalURL:]):
New utility method to help build action dict.
(-[WebFrame _continueAfterNavigationPolicy:]): Comment only.
(-[WebFrame _loadURL:loadType:triggeringEvent:isFormSubmission:]): Call new utility method
instead (just code factoring).
(-[WebFrame _postWithURL:data:contentType:triggeringEvent:]): Call new utility method
instead (just code factoring). Add call to _addExtraFieldsToRequest so we don't do a double
query of the policy delegate.
(-[WebFrame _reloadAllowingStaleDataWithOverrideEncoding:]): Whitespace only.
(-[WebFrame _resetBackForwardListToCurrent]): Utility routine to fix up b/f cursor on page error.
(-[WebFrame _continueLoadRequestAfterNavigationPolicy:request:]): Fix up b/f cursor on page
error before commit succeeds.
WebBrowser:
3092966 - going back goes to different page (can't go back to a POST page)
The app now puts up a confirmation sheet when the user tries to return to a
page resulting from a POST, if all of our caches failed.
Reviewed by Maciej.
* BrowserWebController.m:
(-[BrowserWebController confirmSendSheetDidEnd:returnCode:contextInfo:]): Changed name of
existing routine to be more generic, as its used for two sheets.
(-[BrowserWebController decideNavigationPolicyForAction:andRequest:inFrame:decisionListener:]):
Put up the sheet if we're about to rePOST.
* English.lproj/Localizable.strings: The usual.
* English.lproj/StringsNotToBeLocalized.txt: The usual.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2998 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index c8f49c2..5b2d04d 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,52 @@
+2002-12-10 Trey Matteson <trey at apple.com>
+
+ 3092966 - going back goes to different page (can't go back to a POST page)
+
+ We will rePOST data upon back/forward/refresh if our caches fail us. The policy delegate
+ gets a crack at confirming this operation. Latent bugs where the policy delegate was double
+ queried are fixed. A bug in the b/f cursor when a page failed to load is fixed.
+
+ Reviewed by Maciej.
+
+ * English.lproj/StringsNotToBeLocalized.txt: Usual suspects.
+ * History.subproj/WebHistoryItem.h: Add state for reposting forms.
+ * History.subproj/WebHistoryItem.m: Boilerplate changes for new state.
+ (-[WebHistoryItem dealloc]):
+ (-[WebHistoryItem setFormData:]):
+ (-[WebHistoryItem setFormContentType:]):
+ (-[WebHistoryItem formData]):
+ (-[WebHistoryItem formContentType]):
+ (-[WebHistoryItem description]):
+ * WebView.subproj/WebController.m:
+ (-[WebController _goToItem:withLoadType:]): Tighten up an assert as I clarified an
+ assumption as I worked through this task.
+ * WebView.subproj/WebControllerPolicyDelegate.h: New WebNavigationType's for back/forward,
+ refresh, and repost.
+ * WebView.subproj/WebFrame.m:
+ (-[WebFrame loadRequest:]): Eliminate extra copy of a request.
+ (-[WebFrame reload]): Eliminate extra copy of a request. Setup triggeringAction properly
+ if we're about to rePOST.
+ * WebView.subproj/WebFramePrivate.h: Started moving some private methods into the .m file.
+ * WebView.subproj/WebFramePrivate.m:
+ (-[WebFrame _createItem]): Save form state with history items.
+ (-[WebFrame _isLoadComplete]): Fix up b/f cursor on page error before commit succeeds.
+ (-[WebFrame _loadItem:fromItem:withLoadType:]): Set up request to rePOST if that's what the
+ HistoryItem demands. Add call to _addExtraFieldsToRequest so we don't do a double
+ query of the policy delegate. Pre-flight the form post vs. WF cache to setup triggering
+ action properly.
+ (-[WebFrame _actionInformationForLoadType:isFormSubmission:event:originalURL:]):
+ New utility method to help build action dict.
+ (-[WebFrame _continueAfterNavigationPolicy:]): Comment only.
+ (-[WebFrame _loadURL:loadType:triggeringEvent:isFormSubmission:]): Call new utility method
+ instead (just code factoring).
+ (-[WebFrame _postWithURL:data:contentType:triggeringEvent:]): Call new utility method
+ instead (just code factoring). Add call to _addExtraFieldsToRequest so we don't do a double
+ query of the policy delegate.
+ (-[WebFrame _reloadAllowingStaleDataWithOverrideEncoding:]): Whitespace only.
+ (-[WebFrame _resetBackForwardListToCurrent]): Utility routine to fix up b/f cursor on page error.
+ (-[WebFrame _continueLoadRequestAfterNavigationPolicy:request:]): Fix up b/f cursor on page
+ error before commit succeeds.
+
2002-12-10 Darin Adler <darin at apple.com>
Reviewed by Maciej.
diff --git a/WebKit/English.lproj/StringsNotToBeLocalized.txt b/WebKit/English.lproj/StringsNotToBeLocalized.txt
index e6f9dc2..e9f374c 100644
--- a/WebKit/English.lproj/StringsNotToBeLocalized.txt
+++ b/WebKit/English.lproj/StringsNotToBeLocalized.txt
@@ -1,4 +1,5 @@
" "
+" *POST*"
" *target*"
" >>>"
"%2d) "
diff --git a/WebKit/History.subproj/WebHistoryItem.h b/WebKit/History.subproj/WebHistoryItem.h
index 39bcc15..201ae8b 100644
--- a/WebKit/History.subproj/WebHistoryItem.h
+++ b/WebKit/History.subproj/WebHistoryItem.h
@@ -28,6 +28,10 @@
BOOL _loadedIcon;
BOOL _isTargetItem;
BOOL _alwaysAttemptToUsePageCache;
+ // info used to repost form data
+ NSData *_formData;
+ NSString *_formContentType;
+ NSString *_formReferrer;
}
+ (WebHistoryItem *)entryWithURL:(NSURL *)URL;
@@ -51,6 +55,9 @@
- (NSArray *)documentState;
- (BOOL)isTargetItem;
- (NSString *)anchor;
+- (NSData *)formData;
+- (NSString *)formContentType;
+- (NSString *)formReferrer;
- (void)setURL:(NSURL *)URL;
- (void)setOriginalURLString:(NSString *)URL;
@@ -61,8 +68,11 @@
- (void)setLastVisitedDate:(NSCalendarDate *)date;
- (void)setScrollPoint:(NSPoint)p;
- (void)setDocumentState:(NSArray *)state;
-- (void)setAnchor:(NSString *)anchor;
- (void)setIsTargetItem:(BOOL)flag;
+- (void)setAnchor:(NSString *)anchor;
+- (void)setFormData:(NSData *)data;
+- (void)setFormContentType:(NSString *)type;
+- (void)setFormReferrer:(NSString *)referrer;
- (NSArray *)children;
- (void)addChildItem:(WebHistoryItem *)item;
diff --git a/WebKit/History.subproj/WebHistoryItem.m b/WebKit/History.subproj/WebHistoryItem.m
index c1b4ef3..836dc26 100644
--- a/WebKit/History.subproj/WebHistoryItem.m
+++ b/WebKit/History.subproj/WebHistoryItem.m
@@ -80,7 +80,10 @@
[_documentState release];
[_subItems release];
[pageCache release];
-
+ [_formData release];
+ [_formContentType release];
+ [_formReferrer release];
+
[super dealloc];
}
@@ -290,6 +293,42 @@
}
}
+- (NSData *)formData
+{
+ return _formData;
+}
+
+- (void)setFormData:(NSData *)data
+{
+ NSData *copy = [data copy];
+ [_formData release];
+ _formData = copy;
+}
+
+- (NSString *)formContentType
+{
+ return _formContentType;
+}
+
+- (void)setFormContentType:(NSString *)type
+{
+ NSString *copy = [type copy];
+ [_formContentType release];
+ _formContentType = copy;
+}
+
+- (NSString *)formReferrer
+{
+ return _formReferrer;
+}
+
+- (void)setFormReferrer:(NSString *)referrer
+{
+ NSString *copy = [referrer copy];
+ [_formReferrer release];
+ _formReferrer = copy;
+}
+
- (BOOL)isEqual:(id)anObject
{
if (![anObject isMemberOfClass:[WebHistoryItem class]]) {
@@ -335,6 +374,9 @@
if (_isTargetItem) {
[result appendString:@" *target*"];
}
+ if (_formData) {
+ [result appendString:@" *POST*"];
+ }
if (_subItems) {
int currPos = [result length];
int i;
diff --git a/WebKit/WebView.subproj/WebController.m b/WebKit/WebView.subproj/WebController.m
index 5484c4e..2d54c6d 100644
--- a/WebKit/WebView.subproj/WebController.m
+++ b/WebKit/WebView.subproj/WebController.m
@@ -255,7 +255,8 @@ NSString *WebElementStringKey = @"WebElementString";
// abort any current load if we're going back/forward
[[self mainFrame] stopLoading];
targetFrame = [self _findFrameNamed: [item target]];
- ASSERT(targetFrame != nil);
+ // We never go back/forward on a per-frame basis, so the target must be the main frame
+ ASSERT(targetFrame != nil && targetFrame == [self mainFrame]);
[targetFrame _goToItem: item withLoadType: type];
}
diff --git a/WebKit/WebView.subproj/WebControllerPolicyDelegate.h b/WebKit/WebView.subproj/WebControllerPolicyDelegate.h
index 50635a8..59b546b 100644
--- a/WebKit/WebView.subproj/WebControllerPolicyDelegate.h
+++ b/WebKit/WebView.subproj/WebControllerPolicyDelegate.h
@@ -17,14 +17,20 @@
/*!
@enum WebNavigationType
@abstract The type of action that triggered a possible navigation.
- @constant WebActionTypeLinkClicked A link with an href was clicked.
- @constant WebActionTypeFormSubmitted A form was submitted.
+ @constant WebNavigationTypeLinkClicked A link with an href was clicked.
+ @constant WebNavigationTypeFormSubmitted A form was submitted.
+ @constant WebNavigationTypeBackForward The user chose back or forward.
+ @constant WebNavigationTypeReload The User hit the reload button.
+ @constant WebNavigationTypeFormResubmitted A form was resubmitted (by virtue of doing back, forward or reload).
@constant WebNavigationTypeOther Navigation is taking place for some other reason.
*/
typedef enum {
WebNavigationTypeLinkClicked,
WebNavigationTypeFormSubmitted,
+ WebNavigationTypeBackForward,
+ WebNavigationTypeReload,
+ WebNavigationTypeFormResubmitted,
WebNavigationTypeOther
} WebNavigationType;
diff --git a/WebKit/WebView.subproj/WebFrame.m b/WebKit/WebView.subproj/WebFrame.m
index b2fcd06..f71714f 100644
--- a/WebKit/WebView.subproj/WebFrame.m
+++ b/WebKit/WebView.subproj/WebFrame.m
@@ -23,6 +23,8 @@
#import <WebFoundation/WebNSURLExtras.h>
#import <WebFoundation/WebResourceRequest.h>
+#import <WebFoundation/WebHTTPResourceRequest.h>
+#import <WebFoundation/WebNSStringExtras.h>
@implementation WebFrame
@@ -107,7 +109,9 @@
{
WebFrameLoadType loadType;
- WebResourceRequest *r = [request copy];
+ // note this copies request
+ WebDataSource *newDataSource = [[WebDataSource alloc] initWithRequest:request];
+ WebResourceRequest *r = [newDataSource request];
[self _addExtraFieldsToRequest:r];
if ([self _shouldTreatURLAsSameAsCurrent:[request URL]]) {
[r setRequestCachePolicy:WebRequestCachePolicyLoadFromOrigin];
@@ -115,7 +119,6 @@
} else {
loadType = WebFrameLoadTypeStandard;
}
- WebDataSource *newDataSource = [[WebDataSource alloc] initWithRequest:r];
[self _loadDataSource:newDataSource withLoadType:loadType];
[newDataSource release];
}
@@ -140,11 +143,17 @@
return;
}
- WebResourceRequest *request = [[dataSource request] copy];
+ // initWithRequest copies the request
+ WebDataSource *newDataSource = [[WebDataSource alloc] initWithRequest:[dataSource request]];
+ WebResourceRequest *request = [newDataSource request];
[request setRequestCachePolicy:WebRequestCachePolicyLoadFromOrigin];
- WebDataSource *newDataSource = [[WebDataSource alloc] initWithRequest:request];
- [request release];
-
+
+ // If we're about to rePOST, set up action so the app can warn the user
+ if ([[request method] _web_isCaseInsensitiveEqualToString:@"POST"]) {
+ NSDictionary *action = [self _actionInformationForNavigationType:WebNavigationTypeFormResubmitted event:nil originalURL:[request URL]];
+ [newDataSource _setTriggeringAction:action];
+ }
+
[newDataSource _setOverrideEncoding:[dataSource _overrideEncoding]];
[self _loadDataSource:newDataSource withLoadType:WebFrameLoadTypeReload];
diff --git a/WebKit/WebView.subproj/WebFramePrivate.h b/WebKit/WebView.subproj/WebFramePrivate.h
index 2d79608..cc7eb87 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.h
+++ b/WebKit/WebView.subproj/WebFramePrivate.h
@@ -123,7 +123,6 @@ typedef enum {
- (void)_invalidatePendingPolicyDecisionCallingDefaultAction:(BOOL)call;
-- (NSDictionary *)_actionInformationForNavigationType:(WebNavigationType)navigationType event:(NSEvent *)event originalURL:(NSURL *)URL;
- (void)_goToItem: (WebHistoryItem *)item withLoadType: (WebFrameLoadType)type;
- (void)_loadURL:(NSURL *)URL loadType:(WebFrameLoadType)loadType triggeringEvent:(NSEvent *)event isFormSubmission:(BOOL)isFormSubmission;
- (void)_loadURL:(NSURL *)URL intoChild:(WebFrame *)childFrame;
@@ -132,9 +131,6 @@ typedef enum {
- (void)_clientRedirectedTo:(NSURL *)URL delay:(NSTimeInterval)seconds fireDate:(NSDate *)date;
- (void)_clientRedirectCancelled;
-- (void)_saveScrollPositionToItem:(WebHistoryItem *)item;
-- (void)_restoreScrollPosition;
-- (void)_scrollToTop;
- (void)_textSizeMultiplierChanged;
- (void)_defersCallbacksChanged;
@@ -147,7 +143,7 @@ typedef enum {
- (WebPluginController *)_pluginController;
-- (WebHistoryItem *)_createItemTreeWithTargetFrame:(WebFrame *)targetFrame clippedAtTarget:(BOOL)doClip;
+- (NSDictionary *)_actionInformationForNavigationType:(WebNavigationType)navigationType event:(NSEvent *)event originalURL:(NSURL *)URL;
- (WebHistoryItem *)_itemForSavingDocState;
- (WebHistoryItem *)_itemForRestoringDocState;
diff --git a/WebKit/WebView.subproj/WebFramePrivate.m b/WebKit/WebView.subproj/WebFramePrivate.m
index 0525c95..47c73bc 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.m
+++ b/WebKit/WebView.subproj/WebFramePrivate.m
@@ -33,6 +33,7 @@
#import <WebFoundation/WebResourceHandle.h>
#import <WebFoundation/WebResourceRequest.h>
#import <WebFoundation/WebHTTPResourceRequest.h>
+#import <WebFoundation/WebSynchronousResult.h>
#ifndef NDEBUG
static const char * const stateNames[] = {
@@ -87,6 +88,20 @@ Repeat load of the same URL (by any other means of navigation other than the rel
Add to back/forward list: NO
*/
+ at interface WebFrame (ForwardDecls)
+- (void)_loadRequest:(WebResourceRequest *)request triggeringAction:(NSDictionary *)action loadType:(WebFrameLoadType)loadType;
+
+- (NSDictionary *)_actionInformationForLoadType:(WebFrameLoadType)loadType isFormSubmission:(BOOL)isFormSubmission event:(NSEvent *)event originalURL:(NSURL *)URL;
+
+- (void)_saveScrollPositionToItem:(WebHistoryItem *)item;
+- (void)_restoreScrollPosition;
+- (void)_scrollToTop;
+
+- (WebHistoryItem *)_createItemTreeWithTargetFrame:(WebFrame *)targetFrame clippedAtTarget:(BOOL)doClip;
+
+- (void)_resetBackForwardListToCurrent;
+ at end
+
@implementation WebFramePrivate
- init
@@ -211,14 +226,22 @@ Repeat load of the same URL (by any other means of navigation other than the rel
- (WebHistoryItem *)_createItem
{
WebDataSource *dataSrc = [self dataSource];
- NSURL *url = [[dataSrc request] URL];
+ WebResourceRequest *request = [dataSrc request];
+ NSURL *URL = [request URL];
WebHistoryItem *bfItem;
- bfItem = [[[WebHistoryItem alloc] initWithURL:url target:[self name] parent:[[self parent] name] title:[dataSrc pageTitle]] autorelease];
- [bfItem setAnchor:[url fragment]];
+ 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]];
+ // save form state if this is a POST
+ if ([[request method] _web_isCaseInsensitiveEqualToString:@"POST"]) {
+ [bfItem setFormData:[request data]];
+ [bfItem setFormContentType:[request contentType]];
+ [bfItem setFormReferrer:[request referrer]];
+ }
+
// Set the item for which we will save document state
[_private setPreviousItem:[_private currentItem]];
[_private setCurrentItem:bfItem];
@@ -731,6 +754,7 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
if ([pd mainDocumentError]) {
// Check all children first.
LOG(Loading, "%@: checking complete, current state WebFrameStateProvisional", [self name]);
+ [self _resetBackForwardListToCurrent];
if (![pd isLoading]) {
LOG(Loading, "%@: checking complete in WebFrameStateProvisional, load done", [self name]);
@@ -929,22 +953,25 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
}
// loads content into this frame, as specified by item
-- (void)_loadItem:(WebHistoryItem *)item fromItem:(WebHistoryItem *)fromItem withLoadType:(WebFrameLoadType)type
+- (void)_loadItem:(WebHistoryItem *)item fromItem:(WebHistoryItem *)fromItem withLoadType:(WebFrameLoadType)loadType
{
NSURL *itemURL = [item URL];
NSURL *currentURL = [[[self dataSource] request] URL];
+ NSData *formData = [item formData];
// Are we navigating to an anchor within the page?
// Note if we have child frames we do a real reload, since the child frames might not
// match our current frame structure, or they might not have the right content. We could
// check for all that as an additional optimization.
+ // We also do not do anchor-style navigation if we're posting a form.
// FIXME: These checks don't match the ones in _loadURL:loadType:triggeringEvent:isFormSubmission:
// Perhaps they should.
- if ([item anchor] &&
- [[itemURL _web_URLByRemovingFragment] isEqual: [currentURL _web_URLByRemovingFragment]] &&
- (!_private->children || ![_private->children count]))
+ if (!formData
+ && [item anchor]
+ && [[itemURL _web_URLByRemovingFragment] isEqual: [currentURL _web_URLByRemovingFragment]]
+ && (!_private->children || ![_private->children count]))
{
// must do this maintenance here, since we don't go through a real page reload
[self _saveScrollPositionToItem:[_private currentItem]];
@@ -965,23 +992,39 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
WebDataSource *newDataSource;
if ([item hasPageCache]){
newDataSource = [[item pageCache] objectForKey: @"WebKitDataSource"];
- [self _loadDataSource:newDataSource withLoadType:type];
+ [self _loadDataSource:newDataSource withLoadType:loadType];
}
else {
WebResourceRequest *request = [[WebResourceRequest alloc] initWithURL:itemURL];
-
- // set the request cache policy based on the type of request we have
- // however, allow any previously set value to take precendence
- if ([request requestCachePolicy] == WebRequestCachePolicyUseProtocolDefault) {
- switch (type) {
- case WebFrameLoadTypeStandard:
- // if it's not a GET, reload from origin
- // unsure whether this is the best policy
- // other methods might be OK to get from the cache
- if (![[request method] _web_isCaseInsensitiveEqualToString:@"GET"]) {
- [request setRequestCachePolicy:WebRequestCachePolicyLoadFromOrigin];
- }
- break;
+ [self _addExtraFieldsToRequest:request];
+
+ // If this was a repost that failed the page cache, we might try to repost the form.
+ NSDictionary *action;
+ if (formData) {
+ [request setMethod:@"POST"];
+ [request setData:formData];
+ [request setContentType:[item formContentType]];
+ [request setReferrer:[item formReferrer]];
+
+ // Slight hack to test if the WF cache contains the page we're going to. We want
+ // to know this before talking to the policy delegate, since it affects whether we
+ // show the DoYouReallyWantToRepost nag.
+ //
+ // This trick has a small bug (3123893) where we might find a cache hit, but then
+ // have the item vanish when we try to use it in the ensuing nav. This should be
+ // extremely rare, but in that case the user will get an error on the navigation.
+ [request setRequestCachePolicy:WebRequestCachePolicyReturnCacheObjectDontLoadFromOriginIfNoCacheObject];
+ WebSynchronousResult *result = [WebResourceHandle sendSynchronousRequest:request];
+ if ([result error]) {
+ // Not in WF cache
+ [request setRequestCachePolicy:WebRequestCachePolicyLoadFromOrigin];
+ action = [self _actionInformationForNavigationType:WebNavigationTypeFormResubmitted event:nil originalURL:itemURL];
+ } else {
+ // We can use the cache, don't use navType=resubmit
+ action = [self _actionInformationForLoadType:loadType isFormSubmission:NO event:nil originalURL:itemURL];
+ }
+ } else {
+ switch (loadType) {
case WebFrameLoadTypeReload:
[request setRequestCachePolicy:WebRequestCachePolicyLoadFromOrigin];
break;
@@ -990,20 +1033,22 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
case WebFrameLoadTypeIndexedBackForward:
[request setRequestCachePolicy:WebRequestCachePolicyReturnCacheObjectLoadFromOriginIfNoCacheObject];
break;
+ case WebFrameLoadTypeStandard:
case WebFrameLoadTypeInternal:
- case WebFrameLoadTypeReloadAllowingStaleData:
// no-op: leave as protocol default
+ // FIXME: I wonder if we ever hit this case
break;
case WebFrameLoadTypeSame:
+ case WebFrameLoadTypeReloadAllowingStaleData:
default:
ASSERT_NOT_REACHED();
}
+
+ action = [self _actionInformationForLoadType:loadType isFormSubmission:NO event:nil originalURL:itemURL];
}
-
- newDataSource = [[WebDataSource alloc] initWithRequest:request];
+
+ [self _loadRequest:request triggeringAction:action loadType:loadType];
[request release];
- [self _loadDataSource:newDataSource withLoadType:type];
- [newDataSource release];
}
}
}
@@ -1118,6 +1163,27 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
}
}
+-(NSDictionary *)_actionInformationForLoadType:(WebFrameLoadType)loadType isFormSubmission:(BOOL)isFormSubmission event:(NSEvent *)event originalURL:(NSURL *)URL
+{
+ WebNavigationType navType;
+ if (isFormSubmission) {
+ navType = WebNavigationTypeFormSubmitted;
+ } else if (event == nil) {
+ if (loadType == WebFrameLoadTypeReload) {
+ navType = WebNavigationTypeReload;
+ } else if (loadType == WebFrameLoadTypeForward
+ || loadType == WebFrameLoadTypeBack
+ || loadType == WebFrameLoadTypeIndexedBackForward) {
+ navType = WebNavigationTypeBackForward;
+ } else {
+ navType = WebNavigationTypeOther;
+ }
+ } else {
+ navType = WebNavigationTypeLinkClicked;
+ }
+ return [self _actionInformationForNavigationType:navType event:event originalURL:URL];
+}
+
- (void) _invalidatePendingPolicyDecisionCallingDefaultAction:(BOOL)call
{
[_private->listener _invalidate];
@@ -1182,6 +1248,8 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
BOOL shouldContinue = NO;
+ // If we've just opened a new window as part of finding the right frame to load, no point
+ // in immediately opening another window.
if ([[self provisionalDataSource] _justOpenedForTargetedLink] &&
(policy == WebPolicyOpenNewWindow || policy == WebPolicyOpenNewWindowBehind)) {
policy = WebPolicyUse;
@@ -1289,15 +1357,7 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
// policy of LoadFromOrigin, but I didn't test that.
ASSERT(loadType != WebFrameLoadTypeSame);
- NSDictionary *action = nil;
-
- if (isFormSubmission) {
- action = [self _actionInformationForNavigationType:WebNavigationTypeFormSubmitted event:event originalURL:URL];
- } else if (event == nil) {
- action = [self _actionInformationForNavigationType:WebNavigationTypeOther event:event originalURL:URL];
- } else {
- action = [self _actionInformationForNavigationType:WebNavigationTypeLinkClicked event:event originalURL:URL];
- }
+ NSDictionary *action = [self _actionInformationForLoadType:loadType isFormSubmission:isFormSubmission event:event originalURL:URL];
WebDataSource *oldDataSource = [[self dataSource] retain];
@@ -1412,13 +1472,14 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
// This prevents a potential bug which may cause a page with a form that uses itself
// as an action to be returned from the cache without submitting.
WebResourceRequest *request = [[WebResourceRequest alloc] initWithURL:URL];
+ [self _addExtraFieldsToRequest:request];
[request setRequestCachePolicy:WebRequestCachePolicyLoadFromOrigin];
[request setMethod:@"POST"];
[request setData:data];
[request setContentType:contentType];
[request setReferrer:[_private->bridge referrer]];
- NSDictionary *action = [self _actionInformationForNavigationType:WebNavigationTypeFormSubmitted event:event originalURL:URL];
+ NSDictionary *action = [self _actionInformationForLoadType:WebFrameLoadTypeStandard isFormSubmission:YES event:event originalURL:URL];
[self _loadRequest:request triggeringAction:action loadType:WebFrameLoadTypeStandard];
@@ -1495,8 +1556,7 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
[newDataSource _setOverrideEncoding:encoding];
- [self _loadDataSource:newDataSource
- withLoadType:WebFrameLoadTypeReloadAllowingStaleData];
+ [self _loadDataSource:newDataSource withLoadType:WebFrameLoadTypeReloadAllowingStaleData];
[newDataSource release];
}
@@ -1552,6 +1612,20 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
return path;
}
+// If we bailed out of a b/f navigation, we need to set the b/f cursor back to the current
+// item, because we optimistically move it right away at the start of the operation
+- (void)_resetBackForwardListToCurrent {
+ WebFrameLoadType loadType = [self _loadType];
+ if ((loadType == WebFrameLoadTypeForward
+ || loadType == WebFrameLoadTypeBack
+ || loadType == WebFrameLoadTypeIndexedBackForward)
+ && [_private currentItem]
+ && self == [[self controller] mainFrame])
+ {
+ [[[self controller] backForwardList] goToEntry:[_private currentItem]];
+ }
+}
+
- (WebHistoryItem *)_itemForSavingDocState
{
// For a standard page load, we will have a previous item set, which will be used to
@@ -1583,6 +1657,7 @@ static CFAbsoluteTime _timeOfLastCompletedLoad;
-(void)_continueLoadRequestAfterNavigationPolicy:(BOOL)shouldContinue request:(WebResourceRequest *)request
{
if (!shouldContinue) {
+ [self _resetBackForwardListToCurrent];
[self _setLoadType: WebFrameLoadTypeStandard];
[_private setProvisionalDataSource:nil];
return;
diff --git a/WebKit/WebView.subproj/WebPolicyDelegate.h b/WebKit/WebView.subproj/WebPolicyDelegate.h
index 50635a8..59b546b 100644
--- a/WebKit/WebView.subproj/WebPolicyDelegate.h
+++ b/WebKit/WebView.subproj/WebPolicyDelegate.h
@@ -17,14 +17,20 @@
/*!
@enum WebNavigationType
@abstract The type of action that triggered a possible navigation.
- @constant WebActionTypeLinkClicked A link with an href was clicked.
- @constant WebActionTypeFormSubmitted A form was submitted.
+ @constant WebNavigationTypeLinkClicked A link with an href was clicked.
+ @constant WebNavigationTypeFormSubmitted A form was submitted.
+ @constant WebNavigationTypeBackForward The user chose back or forward.
+ @constant WebNavigationTypeReload The User hit the reload button.
+ @constant WebNavigationTypeFormResubmitted A form was resubmitted (by virtue of doing back, forward or reload).
@constant WebNavigationTypeOther Navigation is taking place for some other reason.
*/
typedef enum {
WebNavigationTypeLinkClicked,
WebNavigationTypeFormSubmitted,
+ WebNavigationTypeBackForward,
+ WebNavigationTypeReload,
+ WebNavigationTypeFormResubmitted,
WebNavigationTypeOther
} WebNavigationType;
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index 5484c4e..2d54c6d 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -255,7 +255,8 @@ NSString *WebElementStringKey = @"WebElementString";
// abort any current load if we're going back/forward
[[self mainFrame] stopLoading];
targetFrame = [self _findFrameNamed: [item target]];
- ASSERT(targetFrame != nil);
+ // We never go back/forward on a per-frame basis, so the target must be the main frame
+ ASSERT(targetFrame != nil && targetFrame == [self mainFrame]);
[targetFrame _goToItem: item withLoadType: type];
}
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list