Commit 368154da authored by mjs's avatar mjs
Browse files

WebCore:

	- fixed 3050447 - Policy handlers have no way of telling client
	that the proposed navigation is a form post

        * khtml/khtml_part.cpp:
        (KHTMLPart::submitForm): Call kwq->submitForm
        * kwq/KWQKHTMLPart.h:
        * kwq/KWQKHTMLPart.mm:
        (KWQKHTMLPart::openURL): Adjusted for bridge API change.
        (KWQKHTMLPart::openURLRequest): Removed POST handling.
	(KWQKHTMLPart::submitForm): Added this back, because we need to
	know what URL navigations are caused by form submission, even if
	they are not POSTs.
        (KWQKHTMLPart::urlSelected): Adjusted for bridge API change.
        * kwq/WebCoreBridge.h: Add triggeringEvent: parameter to postURL:
	and isFormSubmission: parameter to loadURL:.

WebKit:

	- fixed 3050447 - Policy handlers have no way of telling client
	that the proposed navigation is a form post

	Now we pass form submissions through all the normal policy steps.

        * WebCoreSupport.subproj/WebBridge.m:
        (-[WebBridge loadURL:reload:triggeringEvent:isFormSubmission:]):
        (-[WebBridge postWithURL:data:contentType:triggeringEvent:]):
        (-[WebBridge createChildFrameNamed:withURL:renderPart:allowsScrolling:marginWidth:marginHeight:]):
        * WebView.subproj/WebDataSourcePrivate.h:
        * WebView.subproj/WebDataSourcePrivate.m:
        (-[WebDataSourcePrivate dealloc]):
        (-[WebDataSource _setTriggeringAction:]):
        (-[WebDataSource _triggeringAction]):
        (-[WebDataSource _lastCheckedRequest]):
        (-[WebDataSource _setLastCheckedRequest:]):
        * WebView.subproj/WebFrame.m:
        (-[WebFrame setProvisionalDataSource:]):
        * WebView.subproj/WebFramePrivate.h:
        * WebView.subproj/WebFramePrivate.m:
        (-[WebFrame _shouldShowRequest:]):
        (-[WebFrame _loadRequest:triggeringAction:]):
        (-[WebFrame _actionInformationForNavigationType:event:]):
        (-[WebFrame _continueAfterNavigationPolicyForRequest:dataSource:]):
        (-[WebFrame _loadURL:loadType:clientRedirect:triggeringEvent:isFormSubmission:]):
        (-[WebFrame _loadURL:intoChild:]):
        (-[WebFrame _postWithURL:data:contentType:triggeringEvent:]):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2652 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 8e4ec943
2002-11-13 Maciej Stachowiak <mjs@apple.com>
- fixed 3050447 - Policy handlers have no way of telling client
that the proposed navigation is a form post
* khtml/khtml_part.cpp:
(KHTMLPart::submitForm): Call kwq->submitForm
* kwq/KWQKHTMLPart.h:
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::openURL): Adjusted for bridge API change.
(KWQKHTMLPart::openURLRequest): Removed POST handling.
(KWQKHTMLPart::submitForm): Added this back, because we need to
know what URL navigations are caused by form submission, even if
they are not POSTs.
(KWQKHTMLPart::urlSelected): Adjusted for bridge API change.
* kwq/WebCoreBridge.h: Add triggeringEvent: parameter to postURL:
and isFormSubmission: parameter to loadURL:.
2002-11-12 David Hyatt <hyatt@apple.com>
 
Fix for 3032869, the background image for the body was being
......
2002-11-13 Maciej Stachowiak <mjs@apple.com>
- fixed 3050447 - Policy handlers have no way of telling client
that the proposed navigation is a form post
* khtml/khtml_part.cpp:
(KHTMLPart::submitForm): Call kwq->submitForm
* kwq/KWQKHTMLPart.h:
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::openURL): Adjusted for bridge API change.
(KWQKHTMLPart::openURLRequest): Removed POST handling.
(KWQKHTMLPart::submitForm): Added this back, because we need to
know what URL navigations are caused by form submission, even if
they are not POSTs.
(KWQKHTMLPart::urlSelected): Adjusted for bridge API change.
* kwq/WebCoreBridge.h: Add triggeringEvent: parameter to postURL:
and isFormSubmission: parameter to loadURL:.
2002-11-12 David Hyatt <hyatt@apple.com>
 
Fix for 3032869, the background image for the body was being
......
2002-11-13 Maciej Stachowiak <mjs@apple.com>
- fixed 3050447 - Policy handlers have no way of telling client
that the proposed navigation is a form post
* khtml/khtml_part.cpp:
(KHTMLPart::submitForm): Call kwq->submitForm
* kwq/KWQKHTMLPart.h:
* kwq/KWQKHTMLPart.mm:
(KWQKHTMLPart::openURL): Adjusted for bridge API change.
(KWQKHTMLPart::openURLRequest): Removed POST handling.
(KWQKHTMLPart::submitForm): Added this back, because we need to
know what URL navigations are caused by form submission, even if
they are not POSTs.
(KWQKHTMLPart::urlSelected): Adjusted for bridge API change.
* kwq/WebCoreBridge.h: Add triggeringEvent: parameter to postURL:
and isFormSubmission: parameter to loadURL:.
2002-11-12 David Hyatt <hyatt@apple.com>
 
Fix for 3032869, the background image for the body was being
......
......@@ -3169,7 +3169,11 @@ void KHTMLPart::submitForm( const char *action, const QString &url, const QByteA
}
else
{
#if APPLE_CHANGES
kwq->submitForm( u, args);
#else
emit d->m_extension->openURLRequest( u, args );
#endif
}
}
......
......@@ -80,6 +80,7 @@ public:
void openURL(const KURL &);
void openURLRequest(const KURL &, const KParts::URLArgs &);
void submitForm(const KURL &, const KParts::URLArgs &);
void slotData(NSString *, bool forceEncoding, const char *bytes, int length, bool complete = false);
......
......@@ -144,7 +144,7 @@ void KWQKHTMLPart::openURL(const KURL &url)
// FIXME: The lack of args here to get the reload flag from
// indicates a problem in how we use KHTMLPart::processObjectRequest,
// where we are opening the URL before the args are set up.
[_bridge loadURL:cocoaURL reload:NO triggeringEvent:nil];
[_bridge loadURL:cocoaURL reload:NO triggeringEvent:nil isFormSubmission:NO];
}
void KWQKHTMLPart::openURLRequest(const KURL &url, const URLArgs &args)
......@@ -155,14 +155,25 @@ void KWQKHTMLPart::openURLRequest(const KURL &url, const URLArgs &args)
return;
}
[bridgeForFrameName(args.frameName) loadURL:cocoaURL reload:args.reload triggeringEvent:nil isFormSubmission:NO];
}
void KWQKHTMLPart::submitForm(const KURL &url, const URLArgs &args)
{
NSURL *cocoaURL = url.getNSURL();
if (cocoaURL == nil) {
// FIXME: Do we need to report an error to someone?
return;
}
if (!args.doPost()) {
[bridgeForFrameName(args.frameName) loadURL:cocoaURL reload:args.reload triggeringEvent:nil];
[bridgeForFrameName(args.frameName) loadURL:cocoaURL reload:args.reload triggeringEvent:_currentEvent isFormSubmission:YES];
} else {
QString contentType = args.contentType();
ASSERT(contentType.startsWith("Content-Type: "));
[bridgeForFrameName(args.frameName) postWithURL:cocoaURL
data:[NSData dataWithBytes:args.postData.data() length:args.postData.size()]
contentType:contentType.mid(14).getNSString()];
contentType:contentType.mid(14).getNSString() triggeringEvent:_currentEvent];
}
}
......@@ -193,7 +204,7 @@ void KWQKHTMLPart::urlSelected(const KURL &url, int button, int state, const URL
return;
}
[bridgeForFrameName(args.frameName) loadURL:cocoaURL reload:args.reload triggeringEvent:_currentEvent];
[bridgeForFrameName(args.frameName) loadURL:cocoaURL reload:args.reload triggeringEvent:_currentEvent isFormSubmission:NO];
}
class KWQPluginPart : public ReadOnlyPart
......
......@@ -178,8 +178,8 @@ enum FrameBorderStyle {
/* Creates a name for an frame unnamed in the HTML. It should produce repeatable results for loads of the same frameset. */
- (NSString *)generateFrameName;
- (void)loadURL:(NSURL *)URL reload:(BOOL)reload triggeringEvent:(NSEvent *)event;
- (void)postWithURL:(NSURL *)URL data:(NSData *)data contentType:(NSString *)contentType;
- (void)loadURL:(NSURL *)URL reload:(BOOL)reload triggeringEvent:(NSEvent *)event isFormSubmission:(BOOL)isFormSubmission;
- (void)postWithURL:(NSURL *)URL data:(NSData *)data contentType:(NSString *)contentType triggeringEvent:(NSEvent *)event;
- (WebCoreBridge *)createWindowWithURL:(NSURL *)URL frameName:(NSString *)name;
- (void)showWindow;
......
2002-11-13 Maciej Stachowiak <mjs@apple.com>
- fixed 3050447 - Policy handlers have no way of telling client
that the proposed navigation is a form post
Now we pass form submissions through all the normal policy steps.
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge loadURL:reload:triggeringEvent:isFormSubmission:]):
(-[WebBridge postWithURL:data:contentType:triggeringEvent:]):
(-[WebBridge createChildFrameNamed:withURL:renderPart:allowsScrolling:marginWidth:marginHeight:]):
* WebView.subproj/WebDataSourcePrivate.h:
* WebView.subproj/WebDataSourcePrivate.m:
(-[WebDataSourcePrivate dealloc]):
(-[WebDataSource _setTriggeringAction:]):
(-[WebDataSource _triggeringAction]):
(-[WebDataSource _lastCheckedRequest]):
(-[WebDataSource _setLastCheckedRequest:]):
* WebView.subproj/WebFrame.m:
(-[WebFrame setProvisionalDataSource:]):
* WebView.subproj/WebFramePrivate.h:
* WebView.subproj/WebFramePrivate.m:
(-[WebFrame _shouldShowRequest:]):
(-[WebFrame _loadRequest:triggeringAction:]):
(-[WebFrame _actionInformationForNavigationType:event:]):
(-[WebFrame _continueAfterNavigationPolicyForRequest:dataSource:]):
(-[WebFrame _loadURL:loadType:clientRedirect:triggeringEvent:isFormSubmission:]):
(-[WebFrame _loadURL:intoChild:]):
(-[WebFrame _postWithURL:data:contentType:triggeringEvent:]):
2002-11-12 Maciej Stachowiak <mjs@apple.com>
 
Combine click policy and URL policy into navigation policy.
......
2002-11-13 Maciej Stachowiak <mjs@apple.com>
- fixed 3050447 - Policy handlers have no way of telling client
that the proposed navigation is a form post
Now we pass form submissions through all the normal policy steps.
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge loadURL:reload:triggeringEvent:isFormSubmission:]):
(-[WebBridge postWithURL:data:contentType:triggeringEvent:]):
(-[WebBridge createChildFrameNamed:withURL:renderPart:allowsScrolling:marginWidth:marginHeight:]):
* WebView.subproj/WebDataSourcePrivate.h:
* WebView.subproj/WebDataSourcePrivate.m:
(-[WebDataSourcePrivate dealloc]):
(-[WebDataSource _setTriggeringAction:]):
(-[WebDataSource _triggeringAction]):
(-[WebDataSource _lastCheckedRequest]):
(-[WebDataSource _setLastCheckedRequest:]):
* WebView.subproj/WebFrame.m:
(-[WebFrame setProvisionalDataSource:]):
* WebView.subproj/WebFramePrivate.h:
* WebView.subproj/WebFramePrivate.m:
(-[WebFrame _shouldShowRequest:]):
(-[WebFrame _loadRequest:triggeringAction:]):
(-[WebFrame _actionInformationForNavigationType:event:]):
(-[WebFrame _continueAfterNavigationPolicyForRequest:dataSource:]):
(-[WebFrame _loadURL:loadType:clientRedirect:triggeringEvent:isFormSubmission:]):
(-[WebFrame _loadURL:intoChild:]):
(-[WebFrame _postWithURL:data:contentType:triggeringEvent:]):
2002-11-12 Maciej Stachowiak <mjs@apple.com>
 
Combine click policy and URL policy into navigation policy.
......
......@@ -276,15 +276,15 @@ - (void)setIconURL:(NSURL *)URL withType:(NSString *)type
[[self dataSource] _setIconURL:URL withType:type];
}
- (void)loadURL:(NSURL *)URL reload:(BOOL)reload triggeringEvent:(NSEvent *)event
- (void)loadURL:(NSURL *)URL reload:(BOOL)reload triggeringEvent:(NSEvent *)event isFormSubmission:(BOOL)isFormSubmission
{
[frame _loadURL:URL loadType:(reload ? WebFrameLoadTypeReload : WebFrameLoadTypeStandard) clientRedirect:_doingClientRedirect triggeringEvent:event];
[frame _loadURL:URL loadType:(reload ? WebFrameLoadTypeReload : WebFrameLoadTypeStandard) clientRedirect:_doingClientRedirect triggeringEvent:event isFormSubmission:isFormSubmission];
_doingClientRedirect = NO;
}
- (void)postWithURL:(NSURL *)URL data:(NSData *)data contentType:(NSString *)contentType
- (void)postWithURL:(NSURL *)URL data:(NSData *)data contentType:(NSString *)contentType triggeringEvent:(NSEvent *)event
{
[frame _postWithURL:URL data:data contentType:contentType];
[frame _postWithURL:URL data:data contentType:contentType triggeringEvent:event];
}
- (NSString *)generateFrameName
......@@ -308,7 +308,7 @@ - (WebCoreBridge *)createChildFrameNamed:(NSString *)frameName withURL:(NSURL *)
[[newFrame webView] _setMarginHeight:height];
// We must avoid loading the document itself as a subframe, like
// other browsers do, otherwise bugs like Radar 3083732
// other browsers do, otherwise bugs like Radar 3083732 occur
if (![[[URL _web_URLByRemovingFragment] absoluteURL] isEqual:[[[frame dataSource] URL] absoluteURL]]) {
[frame _loadURL:URL intoChild:newFrame];
}
......
......@@ -71,10 +71,14 @@
// BF items that reference what we loaded - we must keep their titles up to date
NSMutableArray *ourBackForwardItems;
// The event that triggered loading of this data source, if any -
// The action that triggered loading of this data source -
// we keep this around for the benefit of the various policy
// handlers.
NSEvent *triggeringEvent;
NSDictionary *triggeringAction;
// The last request that we checked click policy for - kept around
// so we can avoid asking again needlessly.
WebResourceRequest *lastCheckedRequest;
BOOL isDownloading;
NSString *downloadPath;
......@@ -125,14 +129,12 @@
- (void)_makeRepresentation;
- (void)_receivedData:(NSData *)data;
- (void)_finishedLoading;
- (void)_defersCallbacksChanged;
- (WebResourceRequest *)_originalRequest;
- (void)_setTriggeringEvent:(NSEvent *)event;
- (NSEvent *)_triggeringEvent;
- (NSDictionary *)_triggeringAction;
- (void)_setTriggeringAction:(NSDictionary *)action;
- (WebResourceRequest *)_lastCheckedRequest;
- (void)_setLastCheckedRequest:(WebResourceRequest *)request;
- (void)_setIsDownloading:(BOOL)isDownloading;
- (void)_setDownloadPath:(NSString *)downloadPath;
......
......@@ -57,7 +57,8 @@ - (void)dealloc
[iconLoader release];
[iconURL release];
[ourBackForwardItems release];
[triggeringEvent release];
[triggeringAction release];
[lastCheckedRequest release];
[downloadPath release];
[super dealloc];
......@@ -538,19 +539,33 @@ - (WebResourceRequest *)_originalRequest
return _private->originalRequest;
}
- (void)_setTriggeringEvent:(NSEvent *)event
- (void)_setTriggeringAction:(NSDictionary *)action
{
[event retain];
[_private->triggeringEvent release];
_private->triggeringEvent = event;
[action retain];
[_private->triggeringAction release];
_private->triggeringAction = action;
}
- (NSEvent *)_triggeringEvent
- (NSDictionary *)_triggeringAction
{
return [[_private->triggeringEvent retain] autorelease];
return [[_private->triggeringAction retain] autorelease];
}
- (WebResourceRequest *)_lastCheckedRequest
{
// It's OK not to make a copy here because we know the caller
// isn't going to modify this request
return [[_private->lastCheckedRequest retain] autorelease];
}
- (void)_setLastCheckedRequest:(WebResourceRequest *)request
{
WebResourceRequest *oldRequest = _private->lastCheckedRequest;
_private->lastCheckedRequest = [request copy];
[oldRequest release];
}
- (void)_setIsDownloading:(BOOL)isDownloading
{
_private->isDownloading = isDownloading;
......
......@@ -126,10 +126,11 @@ - (BOOL)setProvisionalDataSource: (WebDataSource *)newDataSource
[self _setLoadType: WebFrameLoadTypeStandard];
// _shouldShowRequest asks the client for the URL policies and reports errors if there are any
// _continueAfterNavigationPolicyForRequest:dataSource: asks the
// client for the URL policies and reports errors if there are any
// returns YES if we should show the data source
if (![self _shouldShowRequest:[newDataSource request]]) {
if (![self _continueAfterNavigationPolicyForRequest:[newDataSource request] dataSource:newDataSource]) {
return NO;
}
......
......@@ -108,11 +108,11 @@ typedef enum {
- (WebFrameLoadType)_loadType;
- (NSDictionary *)_actionInformationForNavigationType:(WebNavigationType)navigationType event:(NSEvent *)event;
- (BOOL)_continueAfterNavigationPolicyForRequest:(WebResourceRequest *)request event:(NSEvent *)event;
- (BOOL)_continueAfterNavigationPolicyForRequest:(WebResourceRequest *)request dataSource:(WebDataSource *)dataSource;
- (void)_goToItem: (WebHistoryItem *)item withLoadType: (WebFrameLoadType)type;
- (void)_loadURL:(NSURL *)URL loadType:(WebFrameLoadType)loadType clientRedirect:(BOOL)clientRedirect triggeringEvent:(NSEvent *)event;
- (void)_loadURL:(NSURL *)URL loadType:(WebFrameLoadType)loadType clientRedirect:(BOOL)clientRedirect triggeringEvent:(NSEvent *)event isFormSubmission:(BOOL)isFormSubmission;
- (void)_loadURL:(NSURL *)URL intoChild:(WebFrame *)childFrame;
- (void)_postWithURL:(NSURL *)URL data:(NSData *)data contentType:(NSString *)contentType;
- (void)_postWithURL:(NSURL *)URL data:(NSData *)data contentType:(NSString *)contentType triggeringEvent:(NSEvent *)event;
- (void)_saveScrollPositionToItem:(WebHistoryItem *)item;
- (void)_restoreScrollPosition;
......
......@@ -727,7 +727,7 @@ - (void)handleUnimplementablePolicy:(WebPolicyAction)policy errorCode:(int)code
- (BOOL)_shouldShowRequest:(WebResourceRequest *)request
{
return [self _continueAfterNavigationPolicyForRequest:request event:[[self provisionalDataSource] _triggeringEvent]];
return [self _continueAfterNavigationPolicyForRequest:request dataSource:[self provisionalDataSource]];
}
- (void)_setProvisionalDataSource:(WebDataSource *)d
......@@ -883,10 +883,10 @@ - (void)_goToItem: (WebHistoryItem *)item withLoadType: (WebFrameLoadType)type
[self _recursiveGoToItem:item fromItem:currItem withLoadType:type];
}
- (void)_loadRequest:(WebResourceRequest *)request triggeringEvent:(NSEvent *)event
- (void)_loadRequest:(WebResourceRequest *)request triggeringAction:(NSDictionary *)action
{
WebDataSource *newDataSource = [[WebDataSource alloc] initWithRequest:request];
[newDataSource _setTriggeringEvent:event];
[newDataSource _setTriggeringAction:action];
if ([self setProvisionalDataSource:newDataSource]) {
[self startLoading];
......@@ -896,38 +896,26 @@ - (void)_loadRequest:(WebResourceRequest *)request triggeringEvent:(NSEvent *)ev
-(NSDictionary *)_actionInformationForNavigationType:(WebNavigationType)navigationType event:(NSEvent *)event
{
switch (navigationType) {
case WebNavigationTypeLinkClicked:
case WebNavigationTypeFormSubmitted:
;
if (event != nil) {
NSView *topViewInEventWindow = [[event window] contentView];
NSView *viewContainingPoint = [topViewInEventWindow hitTest:[topViewInEventWindow convertPoint:[event locationInWindow] fromView:nil]];
ASSERT(viewContainingPoint != nil);
ASSERT([viewContainingPoint isKindOfClass:[WebHTMLView class]]);
NSPoint point = [viewContainingPoint convertPoint:[event locationInWindow] fromView:nil];
NSDictionary *elementInfo = [(WebHTMLView *)viewContainingPoint _elementAtPoint:point];
return [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:navigationType], WebActionNavigationTypeKey,
[NSNumber numberWithInt:navigationType], WebActionNavigationTypeKey,
elementInfo, WebActionElementKey,
[NSNumber numberWithInt:[event type]], WebActionButtonKey,
[NSNumber numberWithInt:[event modifierFlags]], WebActionModifierFlagsKey,
nil];
break;
case WebNavigationTypeOther:
return [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:navigationType]
forKey:WebActionNavigationTypeKey];
break;
default:
ASSERT_NOT_REACHED();
return nil;
}
return [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:navigationType]
forKey:WebActionNavigationTypeKey];
}
-(BOOL)_continueAfterFileURLPolicyForRequest:(WebResourceRequest *)request
......@@ -983,14 +971,24 @@ -(BOOL)_continueAfterFileURLPolicyForRequest:(WebResourceRequest *)request
}
}
-(BOOL)_continueAfterNavigationPolicyForRequest:(WebResourceRequest *)request event:(NSEvent *)event
-(BOOL)_continueAfterNavigationPolicyForRequest:(WebResourceRequest *)request dataSource:(WebDataSource *)dataSource
{
WebController *controller = [self controller];
WebPolicyAction policy;
NSDictionary *action = [dataSource _triggeringAction];
if (action == nil) {
action = [self _actionInformationForNavigationType:WebNavigationTypeOther event:nil];
[dataSource _setTriggeringAction:action];
}
policy = [[controller policyDelegate] navigationPolicyForAction:[self _actionInformationForNavigationType:(event != nil ? WebNavigationTypeLinkClicked : WebNavigationTypeOther) event:event]
andRequest:request
inFrame:self];
// Don't ask more than once for the same request
if ([request isEqual:[dataSource _lastCheckedRequest]]) {
return YES;
}
[dataSource _setLastCheckedRequest:request];
WebPolicyAction policy = [[[self controller] policyDelegate] navigationPolicyForAction:action
andRequest:request
inFrame:self];
switch (policy) {
case WebPolicyIgnore:
......@@ -1001,13 +999,13 @@ -(BOOL)_continueAfterNavigationPolicyForRequest:(WebResourceRequest *)request ev
}
break;
case WebPolicyOpenNewWindow:
[controller _openNewWindowWithRequest:request behind:NO];
[[self controller] _openNewWindowWithRequest:request behind:NO];
break;
case WebPolicyOpenNewWindowBehind:
[controller _openNewWindowWithRequest:request behind:YES];
[[self controller] _openNewWindowWithRequest:request behind:YES];
break;
case WebPolicySave:
[controller _downloadURL:[request URL]];
[[self controller] _downloadURL:[request URL]];
break;
case WebPolicyUse:
if ([[request URL] isFileURL]) {
......@@ -1015,10 +1013,11 @@ -(BOOL)_continueAfterNavigationPolicyForRequest:(WebResourceRequest *)request ev
} else {
if (![WebResourceHandle canInitWithRequest:request]) {
[self handleUnimplementablePolicy:policy errorCode:WebErrorCannotShowURL forURL:[request URL]];
break;
} else {
return YES;
}
return YES;
}
break;
default:
[NSException raise:NSInvalidArgumentException
format:@"clickPolicyForElement:button:modifierFlags: returned an invalid WebClickPolicy"];
......@@ -1028,7 +1027,7 @@ -(BOOL)_continueAfterNavigationPolicyForRequest:(WebResourceRequest *)request ev
}
// main funnel for navigating via callback from WebCore (e.g., clicking a link, redirect)
- (void)_loadURL:(NSURL *)URL loadType:(WebFrameLoadType)loadType clientRedirect:(BOOL)clientRedirect triggeringEvent:(NSEvent *)event
- (void)_loadURL:(NSURL *)URL loadType:(WebFrameLoadType)loadType clientRedirect:(BOOL)clientRedirect triggeringEvent:(NSEvent *)event isFormSubmission:(BOOL)isFormSubmission
{
WebResourceRequest *request = [[WebResourceRequest alloc] initWithURL:URL];
[request setReferrer:[_private->bridge referrer]];
......@@ -1036,8 +1035,14 @@ - (void)_loadURL:(NSURL *)URL loadType:(WebFrameLoadType)loadType clientRedirect
[request setRequestCachePolicy:WebRequestCachePolicyLoadFromOrigin];
}
if (event != nil && ![self _continueAfterNavigationPolicyForRequest:request event:event]) {
return;
NSDictionary *action = nil;
if (isFormSubmission) {
action = [self _actionInformationForNavigationType:WebNavigationTypeFormSubmitted event:event];
} else if (event == nil) {
action = [self _actionInformationForNavigationType:WebNavigationTypeOther event:event];
} else {
action = [self _actionInformationForNavigationType:WebNavigationTypeLinkClicked event:event];
}
// FIXME: This logic doesn't exactly match what KHTML does in openURL, so it's possible
......@@ -1047,8 +1052,12 @@ - (void)_loadURL:(NSURL *)URL loadType:(WebFrameLoadType)loadType clientRedirect
// an anchor in the URL - otherwise this check might prevent us from reloading a document
// that has subframes that are different than what we're displaying (in other words, a link
// from within a frame is trying to reload the frameset into _top).
WebDataSource *dataSrc = [self dataSource];
[dataSrc _setTriggeringEvent:event];
[dataSrc _setTriggeringAction:action];
if (![self _continueAfterNavigationPolicyForRequest:request dataSource:dataSrc]) {
return;
}
// save scroll position before we open URL, which will jump to anchor
[self _saveScrollPositionToItem:[_private currentItem]];
......@@ -1071,7 +1080,7 @@ - (void)_loadURL:(NSURL *)URL loadType:(WebFrameLoadType)loadType clientRedirect
WebDataSource *oldDataSource = [[self dataSource] retain];
WebFrameState stateBeforeStartingLoad = [self _state];
[self _loadRequest:request triggeringEvent:event];
[self _loadRequest:request triggeringAction:action];
// NB: must be done after loadRequest:, which sets the provDataSource, which
// inits the load type to Standard
[self _setLoadType:loadType];
......@@ -1113,7 +1122,7 @@ - (void)_loadURL:(NSURL *)URL intoChild:(WebFrame *)childFrame
}
}
[childFrame _loadURL:URL loadType:childLoadType clientRedirect:NO triggeringEvent:nil];
[childFrame _loadURL:URL loadType:childLoadType clientRedirect:NO triggeringEvent:nil isFormSubmission:NO];
// want this here???
if (childItem) {
if (loadType != WebFrameLoadTypeReload) {
......@@ -1126,7 +1135,7 @@ - (void)_loadURL:(NSURL *)URL intoChild:(WebFrame *)childFrame
}
}
- (void)_postWithURL:(NSURL *)URL data:(NSData *)data contentType:(NSString *)contentType
- (void)_postWithURL:(NSURL *)URL data:(NSData *)data contentType:(NSString *)contentType triggeringEvent:(NSEvent *)event
{
// When posting, use the WebResourceHandleFlagLoadFromOrigin load flag.
// This prevents a potential bug which may cause a page with a form that uses itself
......@@ -1137,7 +1146,11 @@ - (void)_postWithURL:(NSURL *)URL data:(NSData *)data contentType:(NSString *)co
[request setData:data];
[request setContentType:contentType];
[request setReferrer:[_private->bridge referrer]];
[self _loadRequest:request triggeringEvent:nil];
NSDictionary *action = [self _actionInformationForNavigationType:WebNavigationTypeFormSubmitted event:event];
[self _loadRequest:request triggeringAction:action];
[request release];
}
......
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