Title: [157968] trunk/Source/WebKit2
- Revision
- 157968
- Author
- [email protected]
- Date
- 2013-10-24 17:43:54 -0700 (Thu, 24 Oct 2013)
Log 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.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (157967 => 157968)
--- trunk/Source/WebKit2/ChangeLog 2013-10-25 00:42:04 UTC (rev 157967)
+++ trunk/Source/WebKit2/ChangeLog 2013-10-25 00:43:54 UTC (rev 157968)
@@ -1,5 +1,35 @@
2013-10-24 Gavin Barraclough <[email protected]>
+ 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.
+
+2013-10-24 Gavin Barraclough <[email protected]>
+
SetIsVisible message should be sent to WebPage
https://bugs.webkit.org/show_bug.cgi?id=123296
Modified: trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm (157967 => 157968)
--- trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm 2013-10-25 00:42:04 UTC (rev 157967)
+++ trunk/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm 2013-10-25 00:43:54 UTC (rev 157968)
@@ -38,6 +38,7 @@
#import "WKAPICast.h"
#import "WKStringCF.h"
#import "WKViewInternal.h"
+#import "WKViewPrivate.h"
#import "StringUtilities.h"
#import "WebColorPickerMac.h"
#import "WebContextMenuProxyMac.h"
@@ -201,8 +202,10 @@
if ([m_wkView isHiddenOrHasHiddenAncestor])
return false;
- if ([m_wkView _isWindowOccluded])
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
+ if ([m_wkView windowOcclusionDetectionEnabled] && ([[m_wkView window] occlusionState] & NSWindowOcclusionStateVisible) != NSWindowOcclusionStateVisible)
return false;
+#endif
return true;
}
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (157967 => 157968)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2013-10-25 00:42:04 UTC (rev 157967)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2013-10-25 00:43:54 UTC (rev 157968)
@@ -146,10 +146,6 @@
- (void)_postFakeMouseMovedEventForFlagsChangedEvent:(NSEvent *)flagsChangedEvent;
- (void)_setDrawingAreaSize:(NSSize)size;
- (void)_setPluginComplexTextInputState:(PluginComplexTextInputState)pluginComplexTextInputState;
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
-- (void)_setIsWindowOccluded:(BOOL)isWindowOccluded;
-#endif
@end
@interface WKViewData : NSObject {
@@ -237,11 +233,7 @@
BOOL _clipsToVisibleRect;
NSRect _contentPreparationRect;
BOOL _useContentPreparationRectForVisibleRect;
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
- BOOL _isWindowOccluded;
BOOL _windowOcclusionDetectionEnabled;
-#endif
}
@end
@@ -1941,10 +1933,6 @@
// update the active state first and then make it visible. If the view is about to be hidden, we hide it first and then
// update the active state.
if ([self window]) {
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
- if (_data->_windowOcclusionDetectionEnabled)
- [self _setIsWindowOccluded:([[self window] occlusionState] & NSWindowOcclusionStateVisible) != NSWindowOcclusionStateVisible];
-#endif
_data->_windowHasValidBackingStore = NO;
[self doWindowDidChangeScreen];
[self _updateWindowVisibility];
@@ -2071,10 +2059,7 @@
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
- (void)_windowDidChangeOcclusionState:(NSNotification *)notification
{
- if (!_data->_windowOcclusionDetectionEnabled)
- return;
-
- [self _setIsWindowOccluded:([self.window occlusionState] & NSWindowOcclusionStateVisible) != NSWindowOcclusionStateVisible];
+ _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
}
#endif
@@ -2259,17 +2244,6 @@
}
#endif
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
-- (void)_setIsWindowOccluded:(BOOL)isWindowOccluded
-{
- if (_data->_isWindowOccluded == isWindowOccluded)
- return;
-
- _data->_isWindowOccluded = isWindowOccluded;
- _data->_page->viewStateDidChange(WebPageProxy::ViewIsVisible);
-}
-#endif
-
@end
@implementation WKView (Internal)
@@ -2918,15 +2892,6 @@
return _data->_page->suppressVisibilityUpdates();
}
-- (BOOL)_isWindowOccluded
-{
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
- return _data->_isWindowOccluded;
-#else
- return NO;
-#endif
-}
-
@end
@implementation WKView (Private)
@@ -2982,14 +2947,10 @@
_data->_ignoringMouseDraggedEvents = NO;
_data->_clipsToVisibleRect = NO;
_data->_useContentPreparationRectForVisibleRect = NO;
+ _data->_windowOcclusionDetectionEnabled = YES;
_data->_intrinsicContentSize = NSMakeSize(NSViewNoInstrinsicMetric, NSViewNoInstrinsicMetric);
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
- _data->_isWindowOccluded = NO;
- _data->_windowOcclusionDetectionEnabled = YES;
-#endif
-
_data->_needsViewFrameInWindowCoordinates = _data->_page->pageGroup()->preferences()->pluginsEnabled();
_data->_frameOrigin = NSZeroPoint;
_data->_contentAnchor = WKContentAnchorTopLeft;
@@ -3252,32 +3213,12 @@
- (BOOL)windowOcclusionDetectionEnabled
{
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
return _data->_windowOcclusionDetectionEnabled;
-#else
- return NO;
-#endif
}
- (void)setWindowOcclusionDetectionEnabled:(BOOL)flag
{
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
- if (_data->_windowOcclusionDetectionEnabled == flag)
- return;
-
_data->_windowOcclusionDetectionEnabled = flag;
-
- if (flag) {
- // When enabling window occlusion detection, update the view's current occluded state
- // immediately, as the notification only fires when it changes.
- if (self.window)
- [self _setIsWindowOccluded:([self.window occlusionState] & NSWindowOcclusionStateVisible) != NSWindowOcclusionStateVisible];
- } else {
- // When disabling window occlusion detection, force the view to think it is not occluded,
- // as it may already be occluded at the time of calling.
- [self _setIsWindowOccluded:NO];
- }
-#endif
}
- (void)setContentAnchor:(WKContentAnchor)contentAnchor
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h (157967 => 157968)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h 2013-10-25 00:42:04 UTC (rev 157967)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h 2013-10-25 00:43:54 UTC (rev 157968)
@@ -96,6 +96,4 @@
- (void)_setSuppressVisibilityUpdates:(BOOL)suppressVisibilityUpdates;
- (BOOL)_suppressVisibilityUpdates;
-- (BOOL)_isWindowOccluded;
-
@end
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes