Changeset 32874 in webkit


Ignore:
Timestamp:
May 5, 2008 9:34:03 AM (16 years ago)
Author:
Darin Adler
Message:

2008-05-05 Darin Adler <Darin Adler>

Reviewed by Mitz.

  • 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.
Location:
trunk/WebKit/mac
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/mac/ChangeLog

    r32852 r32874  
     12008-05-05  Darin Adler  <darin@apple.com>
     2
     3        Reviewed by Mitz.
     4
     5        - https://bugs.webkit.org/show_bug.cgi?id=18789
     6          fix some shouldCloseWithWindow edge cases
     7
     8        * WebView/WebView.mm:
     9        (-[WebView viewWillMoveToWindow:]): Fix bug where we would stop observing the
     10        NSWindowWillCloseNotification if the view was moved out of the window but still
     11        had that window set as the host window. Also make sure this function doesn't do
     12        anything if the WebView is already closed.
     13        (-[WebView setHostWindow:]): Ditto.
     14
    1152008-05-04  David Kilzer  <ddkilzer@apple.com>
    216
  • trunk/WebKit/mac/WebView/WebView.mm

    r32750 r32874  
    20722072- (void)viewWillMoveToWindow:(NSWindow *)window
    20732073{
    2074     // Don't do anything if we aren't initialized.  This happens when decoding a WebView.
     2074    // Don't do anything if the WebView isn't initialized.
     2075    // This happens when decoding a WebView in a nib.
     2076    // FIXME: What sets up the observer of NSWindowWillCloseNotification in this case?
    20752077    if (!_private)
    20762078        return;
    2077    
    2078     if ([self window])
     2079
     2080    if (_private->closed)
     2081        return;
     2082   
     2083    if ([self window] && [self window] != [self hostWindow])
    20792084        [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowWillCloseNotification object:[self window]];
    20802085
     
    20822087        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowWillClose:) name:NSWindowWillCloseNotification object:window];
    20832088
    2084         // Ensure that we will receive the events that WebHTMLView (at least) needs. It's expensive enough
    2085         // that we don't want to call it over and over.
     2089        // Ensure that we will receive the events that WebHTMLView (at least) needs.
     2090        // The following are expensive enough that we don't want to call them over
     2091        // and over, so do them when we move into a window.
    20862092        [window setAcceptsMouseMovedEvents:YES];
    20872093        WKSetNSWindowShouldPostEventNotifications(window, YES);
     
    24812487- (void)setHostWindow:(NSWindow *)hostWindow
    24822488{
    2483     if (!_private->closed && hostWindow != _private->hostWindow) {
    2484         Frame* coreFrame = core([self mainFrame]);
    2485         for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame))
    2486             [[[kit(frame) frameView] documentView] viewWillMoveToHostWindow:hostWindow];
    2487         if (_private->hostWindow)
    2488             [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowWillCloseNotification object:_private->hostWindow];
    2489         if (hostWindow)
    2490             [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowWillClose:) name:NSWindowWillCloseNotification object:hostWindow];
    2491         [_private->hostWindow release];
    2492         _private->hostWindow = [hostWindow retain];
    2493         for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame))
    2494             [[[kit(frame) frameView] documentView] viewDidMoveToHostWindow];
    2495     }
     2489    if (_private->closed)
     2490        return;
     2491    if (hostWindow == _private->hostWindow)
     2492        return;
     2493
     2494    Frame* coreFrame = core([self mainFrame]);
     2495    for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame))
     2496        [[[kit(frame) frameView] documentView] viewWillMoveToHostWindow:hostWindow];
     2497    if (_private->hostWindow && [self window] != _private->hostWindow)
     2498        [[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowWillCloseNotification object:_private->hostWindow];
     2499    if (hostWindow)
     2500        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowWillClose:) name:NSWindowWillCloseNotification object:hostWindow];
     2501    [_private->hostWindow release];
     2502    _private->hostWindow = [hostWindow retain];
     2503    for (Frame* frame = coreFrame; frame; frame = frame->tree()->traverseNext(coreFrame))
     2504        [[[kit(frame) frameView] documentView] viewDidMoveToHostWindow];
    24962505}
    24972506
Note: See TracChangeset for help on using the changeset viewer.