[webkit-changes] cvs commit: WebKit/WebView.subproj WebFrame.m
WebUIDelegatePrivate.h WebView.m WebViewPrivate.h
Vicki
vicki at opensource.apple.com
Fri Nov 18 17:27:08 PST 2005
vicki 05/11/18 17:27:08
Modified: . ChangeLog
WebCoreSupport.subproj WebBridge.m
WebView.subproj WebFrame.m WebUIDelegatePrivate.h WebView.m
WebViewPrivate.h
Log:
Changes by Darin, reviewed by Beth and Vicki.
- fix <rdar://problem/3939265> support "before unload" event and onbeforeunload handler (supported by both IE and Mozilla)
* WebCoreSupport.subproj/WebBridge.m:
(-[WebBridge canRunBeforeUnloadConfirmPanel]):
(-[WebBridge runBeforeUnloadConfirmPanelWithMessage:]):
* WebView.subproj/WebFrame.m:
(-[WebFrame _checkNavigationPolicyForRequest:dataSource:formState:andCall:withSelector:]):
(-[WebFrame _continueLoadRequestAfterNavigationPolicy:formState:]):
* WebView.subproj/WebUIDelegatePrivate.h:
* WebView.subproj/WebView.m:
(-[WebView shouldClose]):
* WebView.subproj/WebViewPrivate.h:
Revision Changes Path
1.3371 +17 -0 WebKit/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebKit/ChangeLog,v
retrieving revision 1.3370
retrieving revision 1.3371
diff -u -r1.3370 -r1.3371
--- ChangeLog 11 Nov 2005 06:08:12 -0000 1.3370
+++ ChangeLog 19 Nov 2005 01:26:56 -0000 1.3371
@@ -1,3 +1,20 @@
+2005-11-18 Vicki Murley <vicki at apple.com>
+
+ Changes by Darin, reviewed by Beth and Vicki.
+
+ - fix <rdar://problem/3939265> support "before unload" event and onbeforeunload handler (supported by both IE and Mozilla)
+
+ * WebCoreSupport.subproj/WebBridge.m:
+ (-[WebBridge canRunBeforeUnloadConfirmPanel]):
+ (-[WebBridge runBeforeUnloadConfirmPanelWithMessage:]):
+ * WebView.subproj/WebFrame.m:
+ (-[WebFrame _checkNavigationPolicyForRequest:dataSource:formState:andCall:withSelector:]):
+ (-[WebFrame _continueLoadRequestAfterNavigationPolicy:formState:]):
+ * WebView.subproj/WebUIDelegatePrivate.h:
+ * WebView.subproj/WebView.m:
+ (-[WebView shouldClose]):
+ * WebView.subproj/WebViewPrivate.h:
+
2005-11-10 Maciej Stachowiak <mjs at apple.com>
Build fix, not reviewed.
1.374 +16 -0 WebKit/WebCoreSupport.subproj/WebBridge.m
Index: WebBridge.m
===================================================================
RCS file: /cvs/root/WebKit/WebCoreSupport.subproj/WebBridge.m,v
retrieving revision 1.373
retrieving revision 1.374
diff -u -r1.373 -r1.374
--- WebBridge.m 7 Nov 2005 21:18:03 -0000 1.373
+++ WebBridge.m 19 Nov 2005 01:27:04 -0000 1.374
@@ -402,6 +402,22 @@
return [[WebDefaultUIDelegate sharedUIDelegate] webView:wv runJavaScriptConfirmPanelWithMessage:message initiatedByFrame:_frame];
}
+- (BOOL)canRunBeforeUnloadConfirmPanel
+{
+ WebView *wv = [_frame webView];
+ id wd = [wv UIDelegate];
+ return [wd respondsToSelector:@selector(webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:)];
+}
+
+- (BOOL)runBeforeUnloadConfirmPanelWithMessage:(NSString *)message
+{
+ WebView *wv = [_frame webView];
+ id wd = [wv UIDelegate];
+ if ([wd respondsToSelector:@selector(webView:runBeforeUnloadConfirmPanelWithMessage:initiatedByFrame:)])
+ return [wd webView:wv runBeforeUnloadConfirmPanelWithMessage:message initiatedByFrame:_frame];
+ return YES;
+}
+
- (BOOL)runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText returningText:(NSString **)result
{
WebView *wv = [_frame webView];
1.256 +10 -3 WebKit/WebView.subproj/WebFrame.m
Index: WebFrame.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebFrame.m,v
retrieving revision 1.255
retrieving revision 1.256
diff -u -r1.255 -r1.256
--- WebFrame.m 11 Nov 2005 01:15:36 -0000 1.255
+++ WebFrame.m 19 Nov 2005 01:27:05 -0000 1.256
@@ -1711,13 +1711,13 @@
formState:(WebFormState *)formState
andCall:(id)target
withSelector:(SEL)selector
-{
+{
NSDictionary *action = [dataSource _triggeringAction];
if (action == nil) {
action = [self _actionInformationForNavigationType:WebNavigationTypeOther event:nil originalURL:[request URL]];
[dataSource _setTriggeringAction:action];
}
-
+
// Don't ask more than once for the same request or if we are loading an empty URL.
// This avoids confusion on the part of the client.
if ([request isEqual:[dataSource _lastCheckedRequest]] || [[request URL] _web_isEmpty]) {
@@ -2354,7 +2354,14 @@
ASSERT(_private->policyDataSource || [[self provisionalDataSource] unreachableURL] != nil);
WebHistoryItem *item = [_private provisionalItem];
- if (!request) {
+
+ // Two reasons we can't continue:
+ // 1) navigation policy delegate said we can't so request is nil.
+ // 2) before unload event handler caused an alert to come up and the user said cancel.
+ // The "before unload" event handler runs only for the main frame.
+ BOOL canContinue = request && ([[self webView] mainFrame] != self || [_private->bridge shouldClose]);
+
+ if (!canContinue) {
[self _setPolicyDataSource:nil];
// If the delegate punts on the navigation, we have the problem that we have optimistically moved
// the b/f cursor already, so move it back. For sanity we only do this if the navigation of the
1.16 +14 -1 WebKit/WebView.subproj/WebUIDelegatePrivate.h
Index: WebUIDelegatePrivate.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebUIDelegatePrivate.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- WebUIDelegatePrivate.h 7 Oct 2005 18:31:50 -0000 1.15
+++ WebUIDelegatePrivate.h 19 Nov 2005 01:27:05 -0000 1.16
@@ -67,7 +67,7 @@
@param sender The WebView sending the delegate method.
@param message The message to display.
@param frame The WebFrame whose JavaScript initiated this call.
- @result YES if the user hit OK, no if the user chose Cancel.
+ @result YES if the user hit OK, NO if the user chose Cancel.
@discussion Clients should visually indicate that this panel comes
from JavaScript initiated by the specified frame. The panel should have
two buttons, e.g. "OK" and "Cancel".
@@ -88,5 +88,18 @@
*/
- (NSString *)webView:(WebView *)sender runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WebFrame *)frame;
+/*!
+ @method webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:
+ @abstract Display a confirm panel by an "before unload" event handler.
+ @param sender The WebView sending the delegate method.
+ @param message The message to display.
+ @param frame The WebFrame whose JavaScript initiated this call.
+ @result YES if the user hit OK, NO if the user chose Cancel.
+ @discussion Clients should include a message in addition to the one
+ supplied by the web page that indicates. The panel should have
+ two buttons, e.g. "OK" and "Cancel".
+*/
+// FIXME: Should we indicate a distinction between navigation and close?
+- (BOOL)webView:(WebView *)sender runBeforeUnloadConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame;
@end
1.312 +8 -0 WebKit/WebView.subproj/WebView.m
Index: WebView.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebView.m,v
retrieving revision 1.311
retrieving revision 1.312
diff -u -r1.311 -r1.312
--- WebView.m 13 Oct 2005 01:08:25 -0000 1.311
+++ WebView.m 19 Nov 2005 01:27:05 -0000 1.312
@@ -2565,6 +2565,14 @@
return _private->scriptDebugDelegate;
}
+- (BOOL)shouldClose
+{
+ WebBridge *bridge = [self _bridgeForSelectedOrMainFrame];
+ if (!bridge)
+ return YES;
+ return [bridge shouldClose];
+}
+
@end
@implementation WebView (WebViewPrintingPrivate)
1.150 +2 -0 WebKit/WebView.subproj/WebViewPrivate.h
Index: WebViewPrivate.h
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebViewPrivate.h,v
retrieving revision 1.149
retrieving revision 1.150
diff -u -r1.149 -r1.150
--- WebViewPrivate.h 13 Oct 2005 01:08:26 -0000 1.149
+++ WebViewPrivate.h 19 Nov 2005 01:27:06 -0000 1.150
@@ -115,6 +115,8 @@
*/
- (id)scriptDebugDelegate;
+- (BOOL)shouldClose;
+
@end
@interface WebView (WebPrivate)
More information about the webkit-changes
mailing list