Add private API to disable WKView window occlusion detection
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Feb 2013 23:59:11 +0000 (23:59 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 28 Feb 2013 23:59:11 +0000 (23:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=111107

Patch by Kiran Muppala <cmuppala@apple.com> on 2013-02-28
Reviewed by Simon Fraser.

* UIProcess/API/mac/WKView.mm:
(-[WKView _enableWindowOcclusionNotifications]): Check if occlusion
detection is enabled before enabling notifications.
(windowBecameOccluded): Ditto before changing window occlusion state.
(-[WKView initWithFrame:contextRef:pageGroupRef:relatedToPage:]):
Initialize occlusion detection enabled flag to "YES".
(-[WKView windowOcclusionDetectionEnabled]):
(-[WKView setWindowOcclusionDetectionEnabled:]):
* UIProcess/API/mac/WKViewPrivate.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@144389 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/mac/WKView.mm
Source/WebKit2/UIProcess/API/mac/WKViewPrivate.h

index 257fbc2..e4c8ab2 100644 (file)
@@ -1,3 +1,20 @@
+2013-02-28  Kiran Muppala  <cmuppala@apple.com>
+
+        Add private API to disable WKView window occlusion detection
+        https://bugs.webkit.org/show_bug.cgi?id=111107
+
+        Reviewed by Simon Fraser.
+
+        * UIProcess/API/mac/WKView.mm:
+        (-[WKView _enableWindowOcclusionNotifications]): Check if occlusion
+        detection is enabled before enabling notifications.
+        (windowBecameOccluded): Ditto before changing window occlusion state.
+        (-[WKView initWithFrame:contextRef:pageGroupRef:relatedToPage:]):
+        Initialize occlusion detection enabled flag to "YES".
+        (-[WKView windowOcclusionDetectionEnabled]):
+        (-[WKView setWindowOcclusionDetectionEnabled:]):
+        * UIProcess/API/mac/WKViewPrivate.h:
+
 2013-02-28  Anders Carlsson  <andersca@apple.com>
 
         Add the notion of an allowed connection to SessionStorageNamespace
index e59028d..493125b 100644 (file)
@@ -227,6 +227,7 @@ struct WKViewInterpretKeyEventsParameters {
     NSSize _intrinsicContentSize;
     BOOL _expandsToFitContentViaAutoLayout;
     BOOL _isWindowOccluded;
+    BOOL _windowOcclusionDetectionEnabled;
 }
 
 @end
@@ -2262,6 +2263,9 @@ static void drawPageBackground(CGContextRef context, WebPageProxy* page, const I
 - (void)_enableWindowOcclusionNotifications
 {
 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+    if (![self windowOcclusionDetectionEnabled])
+        return;
+
     NSWindow *window = [self window];
     if (!window)
         return;
@@ -2320,7 +2324,7 @@ static void windowBecameOccluded(uint32_t, void* data, uint32_t dataLength, void
     Vector<WKView *>& allViews = [WKView _allViews];
     for (size_t i = 0, size = allViews.size(); i < size; ++i) {
         WKView *view = allViews[i];
-        if ([[view window] windowNumber] == windowID)
+        if ([[view window] windowNumber] == windowID && [view windowOcclusionDetectionEnabled])
             [view _setIsWindowOccluded:YES];
     }
 }
@@ -3133,6 +3137,7 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path)
     _data->_expandsToFitContentViaAutoLayout = NO;
 
     _data->_intrinsicContentSize = NSMakeSize(NSViewNoInstrinsicMetric, NSViewNoInstrinsicMetric);
+    _data->_windowOcclusionDetectionEnabled = YES;
 
     [self _registerDraggedTypes];
 
@@ -3321,6 +3326,22 @@ static NSString *pathWithUniqueFilenameForPath(NSString *path)
     return _data->_viewInWindowChangesDeferredCount;
 }
 
+- (BOOL)windowOcclusionDetectionEnabled
+{
+    return _data->_windowOcclusionDetectionEnabled;
+}
+
+- (void)setWindowOcclusionDetectionEnabled:(BOOL)flag
+{
+    if (_data->_windowOcclusionDetectionEnabled == flag)
+        return;
+    _data->_windowOcclusionDetectionEnabled = flag;
+    if (flag)
+        [self _enableWindowOcclusionNotifications];
+    else
+        [self _disableWindowOcclusionNotifications];
+}
+
 @end
 
 @implementation WKResponderChainSink
index f63dade..705b59d 100644 (file)
@@ -59,4 +59,7 @@
 - (void)endDeferringViewInWindowChanges;
 - (BOOL)isDeferringViewInWindowChanges;
 
+- (BOOL)windowOcclusionDetectionEnabled;
+- (void)setWindowOcclusionDetectionEnabled:(BOOL)flag;
+
 @end