⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 157968 in webkit


Ignore:
Timestamp:
Oct 24, 2013, 5:43:54 PM (13 years ago)
Author:
barraclough@apple.com
Message:

Simplify window occlusion detection code
​https://bugs.webkit.org/show_bug.cgi?id=123300

Reviewed by Tim Horton.

Currently the WKView tries to maintain a copy of the window's occluded state,
but forced to NO when occlusion detection is disabled (and capable of handling
dectection being dynamically toggled). Simpler to just rely on the actual value
from the window, && the enabled setting. Cleaning this up revealed that we're
not sending a viewStateDidChange to the WebPageProxy when the occlusion state
changes, which we probably should be.

  • UIProcess/API/mac/PageClientImpl.mm:

(WebKit::PageClientImpl::isViewVisible):

  • check the real value of occlusion state from the window.
  • UIProcess/API/mac/WKView.mm:

(-[WKView viewDidMoveToWindow]):

  • don't update cached value.

(-[WKView _windowDidChangeOcclusionState:]):

  • don't update cached value, but do send viewStateDidChange to the WebPageProxy.

(-[WKView initWithFrame:contextRef:pageGroupRef:relatedToPage:]):

  • removed _isWindowOccluded.

(-[WKView windowOcclusionDetectionEnabled]):
(-[WKView setWindowOcclusionDetectionEnabled:]):

  • Just toggle the flag - no cached state to update any more.
  • UIProcess/API/mac/WKViewInternal.h:
    • removed _isWindowOccluded.
Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r157967 r157968  
     12013-10-24  Gavin Barraclough  <barraclough@apple.com>
     2
     3        Simplify window occlusion detection code
     4        https://bugs.webkit.org/show_bug.cgi?id=123300
     5
     6        Reviewed by Tim Horton.
     7
     8        Currently the WKView tries to maintain a copy of the window's occluded state,
     9        but forced to NO when occlusion detection is disabled (and capable of handling
     10        dectection being dynamically toggled). Simpler to just rely on the actual value
     11        from the window, && the enabled setting. Cleaning this up revealed that we're
     12        not sending a viewStateDidChange to the WebPageProxy when the occlusion state
     13        changes, which we probably should be.
     14
     15        * UIProcess/API/mac/PageClientImpl.mm:
     16        (WebKit::PageClientImpl::isViewVisible):
     17            - check the real value of occlusion state from the window.
     18        * UIProcess/API/mac/WKView.mm:
     19        (-[WKView viewDidMoveToWindow]):
     20            - don't update cached value.
     21        (-[WKView _windowDidChangeOcclusionState:]):
     22            - don't update cached value, but do send viewStateDidChange to the WebPageProxy.
     23        (-[WKView initWithFrame:contextRef:pageGroupRef:relatedToPage:]):
     24            - removed _isWindowOccluded.
     25        (-[WKView windowOcclusionDetectionEnabled]):
     26        (-[WKView setWindowOcclusionDetectionEnabled:]):
     27            - Just toggle the flag - no cached state to update any more.
     28        * UIProcess/API/mac/WKViewInternal.h:
     29            - removed _isWindowOccluded.
     30
    1312013-10-24  Gavin Barraclough  <barraclough@apple.com>
    232
  • trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm

    r157319 r157968  
    3939#import "WKStringCF.h"
    4040#import "WKViewInternal.h"
     41#import "WKViewPrivate.h"
    4142#import "StringUtilities.h"
    4243#import "WebColorPickerMac.h"
    … …  
    202203        return false;
    203204
    204     if ([m_wkView _isWindowOccluded])
     205#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
     206    if ([m_wkView windowOcclusionDetectionEnabled] && ([[m_wkView window] occlusionState] & NSWindowOcclusionStateVisible) != NSWindowOcclusionStateVisible)
    205207        return false;
     208#endif
    206209
    207210    return true;
  • trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm

    r157681 r157968  
    147147- (void)_setDrawingAreaSize:(NSSize)size;
    148148- (void)_setPluginComplexTextInputState:(PluginComplexTextInputState)pluginComplexTextInputState;
    149 
    150 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
    151 - (void)_setIsWindowOccluded:(BOOL)isWindowOccluded;
    152 #endif
    153149@end
    154150
    … …  
    238234    NSRect _contentPreparationRect;
    239235    BOOL _useContentPreparationRectForVisibleRect;
    240 
    241 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
    242     BOOL _isWindowOccluded;
    243236    BOOL _windowOcclusionDetectionEnabled;
    244 #endif
    245237}
    246238
    … …  
    19421934    // update the active state.
    19431935    if ([self window]) {
    1944 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
    1945         if (_data->_windowOcclusionDetectionEnabled)
    1946             [self _setIsWindowOccluded:([[self window] occlusionState] & NSWindowOcclusionStateVisible) != NSWindowOcclusionStateVisible];
    1947 #endif
    19481936        _data->_windowHasValidBackingStore = NO;
    19491937        [self doWindowDidChangeScreen];
    … …  
    20722060- (void)_windowDidChangeOcclusionState:(NSNotification *)notification
    20732061{
    2074     if (!_data->_windowOcclusionDetectionEnabled)
    2075         return;
    2076 
    2077     [self _setIsWindowOccluded:([self.window occlusionState] & NSWindowOcclusionStateVisible) != NSWindowOcclusionStateVisible];
     2062    _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
    20782063}
    20792064#endif
    … …  
    22572242    NSPoint locationInViewCoordinates = [self convertPoint:[event locationInWindow] fromView:nil];
    22582243    _data->_page->performDictionaryLookupAtLocation(FloatPoint(locationInViewCoordinates.x, locationInViewCoordinates.y));
    2259 }
    2260 #endif
    2261 
    2262 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
    2263 - (void)_setIsWindowOccluded:(BOOL)isWindowOccluded
    2264 {
    2265     if (_data->_isWindowOccluded == isWindowOccluded)
    2266         return;
    2267    
    2268     _data->_isWindowOccluded = isWindowOccluded;
    2269     _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
    22702244}
    22712245#endif
    … …  
    29192893}
    29202894
    2921 - (BOOL)_isWindowOccluded
    2922 {
    2923 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
    2924     return _data->_isWindowOccluded;
    2925 #else
    2926     return NO;
    2927 #endif
    2928 }
    2929 
    29302895@end
    29312896
    … …  
    29832948    _data->_clipsToVisibleRect = NO;
    29842949    _data->_useContentPreparationRectForVisibleRect = NO;
     2950    _data->_windowOcclusionDetectionEnabled = YES;
    29852951
    29862952    _data->_intrinsicContentSize = NSMakeSize(NSViewNoInstrinsicMetric, NSViewNoInstrinsicMetric);
    2987 
    2988 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
    2989     _data->_isWindowOccluded = NO;
    2990     _data->_windowOcclusionDetectionEnabled = YES;
    2991 #endif
    29922953
    29932954    _data->_needsViewFrameInWindowCoordinates = _data->_page->pageGroup()->preferences()->pluginsEnabled();
    … …  
    32533214- (BOOL)windowOcclusionDetectionEnabled
    32543215{
    3255 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
    32563216    return _data->_windowOcclusionDetectionEnabled;
    3257 #else
    3258     return NO;
    3259 #endif
    32603217}
    32613218
    32623219- (void)setWindowOcclusionDetectionEnabled:(BOOL)flag
    32633220{
    3264 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
    3265     if (_data->_windowOcclusionDetectionEnabled == flag)
    3266         return;
    3267 
    32683221    _data->_windowOcclusionDetectionEnabled = flag;
    3269 
    3270     if (flag) {
    3271         // When enabling window occlusion detection, update the view's current occluded state
    3272         // immediately, as the notification only fires when it changes.
    3273         if (self.window)
    3274             [self _setIsWindowOccluded:([self.window occlusionState] & NSWindowOcclusionStateVisible) != NSWindowOcclusionStateVisible];
    3275     } else {
    3276         // When disabling window occlusion detection, force the view to think it is not occluded,
    3277         // as it may already be occluded at the time of calling.
    3278         [self _setIsWindowOccluded:NO];
    3279     }
    3280 #endif
    32813222}
    32823223
  • trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h

    r157681 r157968  
    9797- (BOOL)_suppressVisibilityUpdates;
    9898
    99 - (BOOL)_isWindowOccluded;
    100 
    10199@end
Note: See TracChangeset for help on using the changeset viewer.