From: darin@apple.com Date: Mon, 5 May 2008 16:34:03 +0000 (+0000) Subject: 2008-05-05 Darin Adler X-Git-Url: http://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=d3168749696e9ba3d21e999d1a80c73e1b28c09f 2008-05-05 Darin Adler Reviewed by Mitz. - https://bugs.webkit.org/show_bug.cgi?id=18789 fix some shouldCloseWithWindow edge cases * WebView/WebView.mm: (-[WebView viewWillMoveToWindow:]): Fix bug where we would stop observing the NSWindowWillCloseNotification if the view was moved out of the window but still had that window set as the host window. Also make sure this function doesn't do anything if the WebView is already closed. (-[WebView setHostWindow:]): Ditto. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@32874 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog index 943bc41..203b648 100644 --- a/WebKit/mac/ChangeLog +++ b/WebKit/mac/ChangeLog @@ -1,3 +1,17 @@ +2008-05-05 Darin Adler + + Reviewed by Mitz. + + - https://bugs.webkit.org/show_bug.cgi?id=18789 + fix some shouldCloseWithWindow edge cases + + * WebView/WebView.mm: + (-[WebView viewWillMoveToWindow:]): Fix bug where we would stop observing the + NSWindowWillCloseNotification if the view was moved out of the window but still + had that window set as the host window. Also make sure this function doesn't do + anything if the WebView is already closed. + (-[WebView setHostWindow:]): Ditto. + 2008-05-04 David Kilzer Make parameters match for WebChromeClient::addMessageToConsole() diff --git a/WebKit/mac/WebView/WebView.mm b/WebKit/mac/WebView/WebView.mm index 2c25751..a6ff366 100644 --- a/WebKit/mac/WebView/WebView.mm +++ b/WebKit/mac/WebView/WebView.mm @@ -2071,18 +2071,24 @@ static void WebKitInitializeApplicationCachePathIfNecessary() - (void)viewWillMoveToWindow:(NSWindow *)window { - // Don't do anything if we aren't initialized. This happens when decoding a WebView. + // Don't do anything if the WebView isn't initialized. + // This happens when decoding a WebView in a nib. + // FIXME: What sets up the observer of NSWindowWillCloseNotification in this case? if (!_private) return; + + if (_private->closed) + return; - if ([self window]) + if ([self window] && [self window] != [self hostWindow]) [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowWillCloseNotification object:[self window]]; if (window) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowWillClose:) name:NSWindowWillCloseNotification object:window]; - // Ensure that we will receive the events that WebHTMLView (at least) needs. It's expensive enough - // that we don't want to call it over and over. + // Ensure that we will receive the events that WebHTMLView (at least) needs. + // The following are expensive enough that we don't want to call them over + // and over, so do them when we move into a window. [window setAcceptsMouseMovedEvents:YES]; WKSetNSWindowShouldPostEventNotifications(window, YES); } @@ -2480,19 +2486,22 @@ static void WebKitInitializeApplicationCachePathIfNecessary() - (void)setHostWindow:(NSWindow *)hostWindow { - if (!_private->closed && hostWindow != _private->hostWindow) { - Frame* coreFrame = core([self mainFrame]); - for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) - [[[kit(frame) frameView] documentView] viewWillMoveToHostWindow:hostWindow]; - if (_private->hostWindow) - [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowWillCloseNotification object:_private->hostWindow]; - if (hostWindow) - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowWillClose:) name:NSWindowWillCloseNotification object:hostWindow]; - [_private->hostWindow release]; - _private->hostWindow = [hostWindow retain]; - for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) - [[[kit(frame) frameView] documentView] viewDidMoveToHostWindow]; - } + if (_private->closed) + return; + if (hostWindow == _private->hostWindow) + return; + + Frame* coreFrame = core([self mainFrame]); + for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) + [[[kit(frame) frameView] documentView] viewWillMoveToHostWindow:hostWindow]; + if (_private->hostWindow && [self window] != _private->hostWindow) + [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowWillCloseNotification object:_private->hostWindow]; + if (hostWindow) + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowWillClose:) name:NSWindowWillCloseNotification object:hostWindow]; + [_private->hostWindow release]; + _private->hostWindow = [hostWindow retain]; + for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame)) + [[[kit(frame) frameView] documentView] viewDidMoveToHostWindow]; } - (NSWindow *)hostWindow