Changeset 95534 in webkit


Ignore:
Timestamp:
Sep 20, 2011 6:37:35 AM (13 years ago)
Author:
timothy@apple.com
Message:

Make WebViews in NSPopovers render as they would in active windows.

The NSWindowDid{Become,Resign}KeyNotifications are not fired when NSPopovers
are shown or hidden since they share key with the parent window. So WebView
and WebHTMLView need to also observe the will order on/off screen notifications.

https://webkit.org/b/68402
rdar://problem/9754099

Reviewed by John Sullivan.

  • WebView/WebHTMLView.mm:

(-[WebHTMLView _removeWindowObservers]): Remove order on/off screen notification obversers.
(-[WebHTMLView addWindowObservers]): Add order on/off screen notification obversers.
(-[WebHTMLView windowWillOrderOnScreen:]): Check if the window is already a key window,
which can be the case for NSPopovers.
(-[WebHTMLView windowWillOrderOffScreen:]): Remove the mouse moved observer.

  • WebView/WebView.mm:

(-[WebView addWindowObserversForWindow:]): Add order off screen notification obverser.
(-[WebView removeWindowObservers]): Remove order off screen notification obverser.
(-[WebView _windowWillOrderOnScreen:]): Call _updateActiveState.
(-[WebView _windowWillOrderOffScreen:]): Ditto.

Location:
trunk/Source/WebKit/mac
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/mac/ChangeLog

    r95513 r95534  
     12011-09-19  Timothy Hatcher  <timothy@apple.com>
     2
     3        Make WebViews in NSPopovers render as they would in active windows.
     4
     5        The NSWindowDid{Become,Resign}KeyNotifications are not fired when NSPopovers
     6        are shown or hidden since they share key with the parent window. So WebView
     7        and WebHTMLView need to also observe the will order on/off screen notifications.
     8
     9        https://webkit.org/b/68402
     10        rdar://problem/9754099
     11
     12        Reviewed by John Sullivan.
     13
     14        * WebView/WebHTMLView.mm:
     15        (-[WebHTMLView _removeWindowObservers]): Remove order on/off screen notification obversers.
     16        (-[WebHTMLView addWindowObservers]): Add order on/off screen notification obversers.
     17        (-[WebHTMLView windowWillOrderOnScreen:]): Check if the window is already a key window,
     18        which can be the case for NSPopovers.
     19        (-[WebHTMLView windowWillOrderOffScreen:]): Remove the mouse moved observer.
     20        * WebView/WebView.mm:
     21        (-[WebView addWindowObserversForWindow:]): Add order off screen notification obverser.
     22        (-[WebView removeWindowObservers]): Remove order off screen notification obverser.
     23        (-[WebView _windowWillOrderOnScreen:]): Call _updateActiveState.
     24        (-[WebView _windowWillOrderOffScreen:]): Ditto.
     25
    1262011-09-19  Mark Rowe  <mrowe@apple.com>
    227
  • trunk/Source/WebKit/mac/WebView/WebHTMLView.mm

    r95476 r95534  
    933933    [notificationCenter removeObserver:self name:NSWindowDidBecomeKeyNotification object:nil];
    934934    [notificationCenter removeObserver:self name:NSWindowDidResignKeyNotification object:nil];
     935    [notificationCenter removeObserver:self name:WKWindowWillOrderOnScreenNotification() object:window];
     936    [notificationCenter removeObserver:self name:WKWindowWillOrderOffScreenNotification() object:window];
    935937    [notificationCenter removeObserver:self name:NSWindowWillCloseNotification object:window];
    936938   
     
    28602862    [notificationCenter addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:nil];
    28612863    [notificationCenter addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:nil];
     2864    [notificationCenter addObserver:self selector:@selector(windowWillOrderOnScreen:) name:WKWindowWillOrderOnScreenNotification() object:window];
     2865    [notificationCenter addObserver:self selector:@selector(windowWillOrderOffScreen:) name:WKWindowWillOrderOffScreenNotification() object:window];
    28622866    [notificationCenter addObserver:self selector:@selector(windowWillClose:) name:NSWindowWillCloseNotification object:window];
    28632867   
     
    33773381        [_private->completionController endRevertingChange:NO moveLeft:NO];
    33783382    }
     3383}
     3384
     3385- (void)windowWillOrderOnScreen:(NSNotification *)notification
     3386{
     3387    if (!pthread_main_np()) {
     3388        [self performSelectorOnMainThread:_cmd withObject:notification waitUntilDone:NO];
     3389        return;
     3390    }
     3391
     3392    // Check if the window is already a key window, which can be the case for NSPopovers.
     3393    if ([[self window] isKeyWindow])
     3394        [self addMouseMovedObserver];
     3395}
     3396
     3397- (void)windowWillOrderOffScreen:(NSNotification *)notification
     3398{
     3399    if (!pthread_main_np()) {
     3400        [self performSelectorOnMainThread:_cmd withObject:notification waitUntilDone:NO];
     3401        return;
     3402    }
     3403
     3404    // When the WebView is in a NSPopover the NSWindowDidResignKeyNotification isn't sent
     3405    // unless the parent window loses key. So we need to remove the mouse moved observer.
     3406    [self removeMouseMovedObserver];
    33793407}
    33803408
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r95474 r95534  
    31953195        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowWillOrderOnScreen:)
    31963196            name:WKWindowWillOrderOnScreenNotification() object:window];
     3197        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowWillOrderOffScreen:)
     3198            name:WKWindowWillOrderOffScreenNotification() object:window];
    31973199        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidChangeResolution:)
    31983200            name:windowDidChangeResolutionNotification object:window];
     
    32103212        [[NSNotificationCenter defaultCenter] removeObserver:self
    32113213            name:WKWindowWillOrderOnScreenNotification() object:window];
     3214        [[NSNotificationCenter defaultCenter] removeObserver:self
     3215            name:WKWindowWillOrderOffScreenNotification() object:window];
    32123216        [[NSNotificationCenter defaultCenter] removeObserver:self
    32133217            name:windowDidChangeResolutionNotification object:window];
     
    32803284- (void)_windowWillOrderOnScreen:(NSNotification *)notification
    32813285{
     3286    // Update the active state here so WebViews in NSPopovers get the active state.
     3287    // This is needed because the normal NSWindowDidBecomeKeyNotification is not fired
     3288    // for NSPopover windows since they share key with their parent window.
     3289    [self _updateActiveState];
     3290
    32823291    if (![self shouldUpdateWhileOffscreen])
    32833292        [self setNeedsDisplay:YES];
     3293}
     3294
     3295- (void)_windowWillOrderOffScreen:(NSNotification *)notification
     3296{
     3297    // Update the active state here so WebViews in NSPopovers get the inactive state.
     3298    // This is needed because the normal NSWindowDidResignKeyNotification is not fired
     3299    // for NSPopover windows since they share key with their parent window.
     3300    [self _updateActiveState];
    32843301}
    32853302
Note: See TracChangeset for help on using the changeset viewer.