From 898fb4034604973825fca26efa55458f3282690a Mon Sep 17 00:00:00 2001 From: darin Date: Sun, 10 Sep 2006 20:22:03 +0000 Subject: [PATCH] Reviewed by Brady. - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=10547 REGRESSION: Links that should open in a new window open in the same window, while opening another blank window * WebView/WebFrame.m: (-[WebFrame _continueLoadRequestAfterNewWindowPolicy:frameName:formState:]): Changed a mistaken "self" to "frame", which was the cause of the bug. Also fixed the method so that it won't crash if createWebViewWithRequest does something that has a side effect of releasing this WebView or this frame by retaining "self" and "frame" as needed. Also fixed a problem where the code to set "opener" was backwards, and would set the opener of the old frame to point to the new frame instead of vice versa. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16288 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- WebKit/ChangeLog | 17 +++++++++++++++++ WebKit/WebView/WebFrame.m | 25 ++++++++++++++++++------- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog index 0112e3d666ff..9005bb2b9973 100644 --- a/WebKit/ChangeLog +++ b/WebKit/ChangeLog @@ -1,3 +1,20 @@ +2006-09-10 Darin Adler + + Reviewed by Brady. + + - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=10547 + REGRESSION: Links that should open in a new window open in the same window, + while opening another blank window + + * WebView/WebFrame.m: + (-[WebFrame _continueLoadRequestAfterNewWindowPolicy:frameName:formState:]): + Changed a mistaken "self" to "frame", which was the cause of the bug. Also + fixed the method so that it won't crash if createWebViewWithRequest does + something that has a side effect of releasing this WebView or this frame + by retaining "self" and "frame" as needed. Also fixed a problem where the + code to set "opener" was backwards, and would set the opener of the old + frame to point to the new frame instead of vice versa. + 2006-09-09 Sam Weinig Reviewed by Eric. diff --git a/WebKit/WebView/WebFrame.m b/WebKit/WebView/WebFrame.m index 465dff4088bc..75e9444a2c2c 100644 --- a/WebKit/WebView/WebFrame.m +++ b/WebKit/WebView/WebFrame.m @@ -1578,10 +1578,11 @@ static inline WebFrame *Frame(WebCoreFrameBridge *bridge) - (void)_continueLoadRequestAfterNewWindowPolicy:(NSURLRequest *)request frameName:(NSString *)frameName formState:(WebFormState *)formState { - if (!request) { + if (!request) return; - } - + + [self retain]; + WebView *webView = nil; WebView *currentWebView = [self webView]; id wd = [currentWebView UIDelegate]; @@ -1589,17 +1590,27 @@ static inline WebFrame *Frame(WebCoreFrameBridge *bridge) webView = [wd webView:currentWebView createWebViewWithRequest:nil]; else webView = [[WebDefaultUIDelegate sharedUIDelegate] webView:currentWebView createWebViewWithRequest:nil]; - + if (!webView) + goto exit; WebFrame *frame = [webView mainFrame]; + if (!frame) + goto exit; + + [frame retain]; + [[frame _bridge] setName:frameName]; [[webView _UIDelegateForwarder] webViewShow:webView]; - [[self _bridge] setOpener:[frame _bridge]]; - [_private->frameLoader _loadRequest:request triggeringAction:nil loadType:WebFrameLoadTypeStandard formState:formState]; -} + [[frame _bridge] setOpener:[self _bridge]]; + [frame->_private->frameLoader _loadRequest:request triggeringAction:nil loadType:WebFrameLoadTypeStandard formState:formState]; + [frame release]; + +exit: + [self release]; +} // main funnel for navigating via callback from WebCore (e.g., clicking a link, redirect) - (void)_loadURL:(NSURL *)URL referrer:(NSString *)referrer loadType:(WebFrameLoadType)loadType target:(NSString *)target triggeringEvent:(NSEvent *)event form:(DOMElement *)form formValues:(NSDictionary *)values -- 2.36.0