summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorjoepeck@webkit.org <joepeck@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>2013-01-28 22:38:26 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-08 17:35:16 +0200
commit412ec5284b300668101a1db137e08a729008d164 (patch)
treebe76826e8200e642448c585bad98fc74e60486d9 /Source
parent0dd9e57645d192fca388abe8f04e93ca7bef6ad6 (diff)
downloadqtwebkit-412ec5284b300668101a1db137e08a729008d164.tar.gz
[Mac] Update PageVisibilityState when WebView is hidden / visible
https://bugs.webkit.org/show_bug.cgi?id=107509 Source/WebKit/mac: Reviewed by NOBODY (OOPS!). * WebView/WebView.mm: * WebView/WebViewPrivate.h: (-[WebView _commonInitializationWithFrameName:groupName:]): Set the initial visibility of the page. (-[WebView addWindowObserversForWindow:]): (-[WebView removeWindowObservers]): (-[WebView _isViewVisible]): (-[WebView _updateVisibilityState]): (-[WebView viewDidMoveToWindow]): (-[WebView _windowVisibilityChanged:]): Update visibility state in the same ways WK2 does. This involves listening for some new NSWindow delegates. Tools: Add a test that PageVisibility of WK1 WebViews and WK2 WKViews automatically changes between hidden and visible as the view is added and removed from window, or when it is in a window that changes visibility, for instance by minimizing / deminimizing. Reviewed by NOBODY (OOPS!). * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * TestWebKitAPI/Tests/mac/PageVisibilityStateWithWindowChanges.html: Added. * TestWebKitAPI/Tests/mac/PageVisibilityStateWithWindowChanges.mm: Added. (-[PageVisibilityStateDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:]): (runJavaScriptAlert): (PageVisibilityStateWithWindowChanges): (TestWebKitAPI::PageVisibilityStateWithWindowChanges::initializeView): (TestWebKitAPI::PageVisibilityStateWithWindowChanges::deinitializeView): (TestWebKitAPI::PageVisibilityStateWithWindowChanges::runTest): (TestWebKitAPI::TEST_F): Test visibility state of a page in a WebView/WKView with different window states. * TestWebKitAPI/mac/WebKitAgnosticTest.h: * TestWebKitAPI/mac/WebKitAgnosticTest.mm: (TestWebKitAPI::WebKitAgnosticTest::deinitializeView): (TestWebKitAPI::WebKitAgnosticTest::runWebKit1Test): (TestWebKitAPI::WebKitAgnosticTest::runWebKit2Test): Add a WK1 and WK2 deinitializeView to balance initializeView. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@141011 268f45cc-cd09-0410-ab3c-d52691b4dbfc Change-Id: Ie9ef191e55f69ee32b01a0e7220820be038ac8a4 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Source')
-rw-r--r--Source/WebKit/mac/WebView/WebView.mm46
-rw-r--r--Source/WebKit/mac/WebView/WebViewPrivate.h7
2 files changed, 49 insertions, 4 deletions
diff --git a/Source/WebKit/mac/WebView/WebView.mm b/Source/WebKit/mac/WebView/WebView.mm
index d270eaed3..fe445618f 100644
--- a/Source/WebKit/mac/WebView/WebView.mm
+++ b/Source/WebKit/mac/WebView/WebView.mm
@@ -835,6 +835,8 @@ static bool shouldRespectPriorityInCSSAttributeSetters()
[self _registerDraggedTypes];
+ [self _setVisibilityState:([self _isViewVisible] ? WebPageVisibilityStateVisible : WebPageVisibilityStateHidden) isInitialState:YES];
+
WebPreferences *prefs = [self preferences];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesChangedNotification:)
name:WebPreferencesChangedInternalNotification object:prefs];
@@ -2641,11 +2643,31 @@ static inline IMP getMethod(id o, SEL s)
SecurityPolicy::removeOriginAccessWhitelistEntry(*SecurityOrigin::createFromString(sourceOrigin), destinationProtocol, destinationHost, allowDestinationSubdomains);
}
-+(void)_resetOriginAccessWhitelists
++ (void)_resetOriginAccessWhitelists
{
SecurityPolicy::resetOriginAccessWhitelists();
}
+- (BOOL)_isViewVisible
+{
+ if (![self window])
+ return false;
+
+ if (![[self window] isVisible])
+ return false;
+
+ if ([self isHiddenOrHasHiddenAncestor])
+ return false;
+
+ return true;
+}
+
+- (void)_updateVisibilityState
+{
+ if (_private && _private->page)
+ [self _setVisibilityState:([self _isViewVisible] ? WebPageVisibilityStateVisible : WebPageVisibilityStateHidden) isInitialState:NO];
+}
+
- (void)_updateActiveState
{
if (_private && _private->page)
@@ -3561,6 +3583,14 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
name:windowDidChangeBackingPropertiesNotification object:window];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidChangeScreen:)
name:NSWindowDidChangeScreenNotification object:window];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowVisibilityChanged:)
+ name:NSWindowDidMiniaturizeNotification object:window];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowVisibilityChanged:)
+ name:NSWindowDidDeminiaturizeNotification object:window];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowVisibilityChanged:)
+ name:@"NSWindowDidOrderOffScreenNotification" object:window];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowVisibilityChanged:)
+ name:@"_NSWindowDidBecomeVisible" object:window];
}
}
@@ -3576,6 +3606,14 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
name:windowDidChangeBackingPropertiesNotification object:window];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:NSWindowDidChangeScreenNotification object:window];
+ [[NSNotificationCenter defaultCenter] removeObserver:self
+ name:NSWindowDidMiniaturizeNotification object:window];
+ [[NSNotificationCenter defaultCenter] removeObserver:self
+ name:NSWindowDidDeminiaturizeNotification object:window];
+ [[NSNotificationCenter defaultCenter] removeObserver:self
+ name:@"NSWindowDidOrderOffScreenNotification" object:window];
+ [[NSNotificationCenter defaultCenter] removeObserver:self
+ name:@"_NSWindowDidBecomeVisible" object:window];
}
}
@@ -3626,6 +3664,7 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
_private->page->setDeviceScaleFactor([self _deviceScaleFactor]);
[self _updateActiveState];
+ [self _updateVisibilityState];
}
- (void)doWindowDidChangeScreen
@@ -3666,6 +3705,11 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
}
}
+- (void)_windowVisibilityChanged:(NSNotification *)notification
+{
+ [self _updateVisibilityState];
+}
+
- (void)_windowWillClose:(NSNotification *)notification
{
if ([self shouldCloseWithWindow] && ([self window] == [self hostWindow] || ([self window] && ![self hostWindow]) || (![self window] && [self hostWindow])))
diff --git a/Source/WebKit/mac/WebView/WebViewPrivate.h b/Source/WebKit/mac/WebView/WebViewPrivate.h
index 49bdcd0cb..a4c85f943 100644
--- a/Source/WebKit/mac/WebView/WebViewPrivate.h
+++ b/Source/WebKit/mac/WebView/WebViewPrivate.h
@@ -322,6 +322,10 @@ Could be worth adding to the API.
// Indicates if the WebView is in the midst of a user gesture.
- (BOOL)_isProcessingUserGesture;
+// Determining and updating page visibility state.
+- (BOOL)_isViewVisible;
+- (void)_updateVisibilityState;
+
// SPI for DumpRenderTree
- (void)_updateActiveState;
@@ -648,9 +652,6 @@ Could be worth adding to the API.
*/
+ (void)_setHTTPPipeliningEnabled:(BOOL)enabled;
-// SPI for DumpRenderTree
-- (void)_setVisibilityState:(int)visibilityState isInitialState:(BOOL)isInitialState;
-
@end
@interface WebView (WebViewPrintingPrivate)