- Revision
- 181866
- Author
- [email protected]
- Date
- 2015-03-23 13:42:03 -0700 (Mon, 23 Mar 2015)
Log Message
REGRESSION (Yosemite): WKView visibility notifications are messed up
https://bugs.webkit.org/show_bug.cgi?id=142945
Reviewed by Tim Horton.
As these notifications cannot be used by NSView subclasses, create a separate
object for observing them.
Source/WebKit/mac:
* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):
(-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):
(-[WebView addWindowObserversForWindow:]):
(-[WebView removeWindowObservers]):
(-[WebView viewWillMoveToWindow:]): Make sure that observers are removed even
if -[WebView close] is called manually.
* WebView/WebViewData.h:
* WebView/WebViewData.mm:
(-[WebWindowVisibilityObserver initWithView:]):
(-[WebWindowVisibilityObserver startObserving:]):
(-[WebWindowVisibilityObserver stopObserving:]):
(-[WebWindowVisibilityObserver _windowVisibilityChanged:]):
Source/WebKit2:
* UIProcess/API/mac/WKView.mm:
(-[WKWindowVisibilityObserver initWithView:]):
(-[WKWindowVisibilityObserver startObserving:]):
(-[WKWindowVisibilityObserver stopObserving:]):
(-[WKWindowVisibilityObserver _windowDidOrderOnScreen:]):
(-[WKWindowVisibilityObserver _windowDidOrderOffScreen:]):
(-[WKView addWindowObserversForWindow:]):
(-[WKView removeWindowObservers]): Also, don't try to remove NSWindowWillOrderOffScreenNotification,
which we never start to observe.
(-[WKView initWithFrame:processPool:configuration:webView:]):
* UIProcess/API/mac/WKViewInternal.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit/mac/ChangeLog (181865 => 181866)
--- trunk/Source/WebKit/mac/ChangeLog 2015-03-23 20:35:17 UTC (rev 181865)
+++ trunk/Source/WebKit/mac/ChangeLog 2015-03-23 20:42:03 UTC (rev 181866)
@@ -1,3 +1,27 @@
+2015-03-23 Alexey Proskuryakov <[email protected]>
+
+ REGRESSION (Yosemite): WKView visibility notifications are messed up
+ https://bugs.webkit.org/show_bug.cgi?id=142945
+
+ Reviewed by Tim Horton.
+
+ As these notifications cannot be used by NSView subclasses, create a separate
+ object for observing them.
+
+ * WebView/WebView.mm:
+ (-[WebView _commonInitializationWithFrameName:groupName:]):
+ (-[WebView initSimpleHTMLDocumentWithStyle:frame:preferences:groupName:]):
+ (-[WebView addWindowObserversForWindow:]):
+ (-[WebView removeWindowObservers]):
+ (-[WebView viewWillMoveToWindow:]): Make sure that observers are removed even
+ if -[WebView close] is called manually.
+ * WebView/WebViewData.h:
+ * WebView/WebViewData.mm:
+ (-[WebWindowVisibilityObserver initWithView:]):
+ (-[WebWindowVisibilityObserver startObserving:]):
+ (-[WebWindowVisibilityObserver stopObserving:]):
+ (-[WebWindowVisibilityObserver _windowVisibilityChanged:]):
+
2015-03-23 Tim Horton <[email protected]>
Add a share item to the link action menu
Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (181865 => 181866)
--- trunk/Source/WebKit/mac/WebView/WebView.mm 2015-03-23 20:35:17 UTC (rev 181865)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm 2015-03-23 20:42:03 UTC (rev 181866)
@@ -879,6 +879,10 @@
#endif
_private->includesFlattenedCompositingLayersWhenDrawingToBitmap = YES;
+#if PLATFORM(MAC)
+ _private->windowVisibilityObserver = adoptNS([[WebWindowVisibilityObserver alloc] initWithView:self]);
+#endif
+
NSRect f = [self frame];
WebFrameView *frameView = [[WebFrameView alloc] initWithFrame: NSMakeRect(0,0,f.size.width,f.size.height)];
[frameView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
@@ -1173,7 +1177,7 @@
_private->mainFrameDocumentReady = NO;
_private->drawsBackground = YES;
_private->backgroundColor = CGColorRetain(cachedCGColor(Color::white, ColorSpaceDeviceRGB));
-
+
WebFrameView *frameView = nil;
frameView = [[WebFrameView alloc] initWithFrame: CGRectMake(0,0,frame.size.width,frame.size.height)];
[frameView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
@@ -5186,10 +5190,7 @@
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];
+ [_private->windowVisibilityObserver startObserving:window];
}
}
@@ -5213,10 +5214,7 @@
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];
+ [_private->windowVisibilityObserver stopObserving:window];
}
}
@@ -5225,9 +5223,9 @@
// Don't do anything if the WebView isn't initialized.
// This happens when decoding a WebView in a nib.
// FIXME: What sets up the observer of NSWindowWillCloseNotification in this case?
- if (!_private || _private->closed)
+ if (!_private)
return;
-
+
if ([self window] && [self window] != [self hostWindow])
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowWillCloseNotification object:[self window]];
@@ -5239,7 +5237,7 @@
// and over, so do them when we move into a window.
[window setAcceptsMouseMovedEvents:YES];
WKSetNSWindowShouldPostEventNotifications(window, YES);
- } else {
+ } else if (!_private->closed) {
_private->page->setCanStartMedia(false);
_private->page->setIsInWindow(false);
}
Modified: trunk/Source/WebKit/mac/WebView/WebViewData.h (181865 => 181866)
--- trunk/Source/WebKit/mac/WebView/WebViewData.h 2015-03-23 20:35:17 UTC (rev 181865)
+++ trunk/Source/WebKit/mac/WebView/WebViewData.h 2015-03-23 20:42:03 UTC (rev 181866)
@@ -84,6 +84,10 @@
class WebMediaPlaybackTargetPicker;
#endif
+#if PLATFORM(MAC)
+@class WebWindowVisibilityObserver;
+#endif
+
extern BOOL applicationIsTerminating;
extern int pluginDatabaseClientCount;
@@ -125,6 +129,15 @@
WebViewLayerFlushScheduler m_layerFlushScheduler;
};
+@interface WebWindowVisibilityObserver : NSObject {
+ WebView *_view;
+}
+
+- (instancetype)initWithView:(WebView *)view;
+- (void)startObserving:(NSWindow *)window;
+- (void)stopObserving:(NSWindow *)window;
+@end
+
// FIXME: This should be renamed to WebViewData.
@interface WebViewPrivate : NSObject {
@public
@@ -159,6 +172,7 @@
#endif // __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
std::unique_ptr<WebCore::TextIndicatorWindow> textIndicatorWindow;
BOOL hasInitializedLookupObserver;
+ RetainPtr<WebWindowVisibilityObserver> windowVisibilityObserver;
#endif // PLATFORM(MAC)
BOOL shouldMaintainInactiveSelection;
Modified: trunk/Source/WebKit/mac/WebView/WebViewData.mm (181865 => 181866)
--- trunk/Source/WebKit/mac/WebView/WebViewData.mm 2015-03-23 20:35:17 UTC (rev 181865)
+++ trunk/Source/WebKit/mac/WebView/WebViewData.mm 2015-03-23 20:42:03 UTC (rev 181866)
@@ -77,6 +77,44 @@
{
}
+#if PLATFORM(MAC)
+
+@implementation WebWindowVisibilityObserver
+
+- (instancetype)initWithView:(WebView *)view
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _view = view;
+ return self;
+}
+
+- (void)startObserving:(NSWindow *)window
+{
+ // An NSView derived object such as WebView cannot observe these notifications, because NSView itself observes them.
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowVisibilityChanged:)
+ name:@"NSWindowDidOrderOffScreenNotification" object:window];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowVisibilityChanged:)
+ name:@"_NSWindowDidBecomeVisible" object:window];
+}
+
+- (void)stopObserving:(NSWindow *)window
+{
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSWindowDidOrderOffScreenNotification" object:window];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:@"_NSWindowDidBecomeVisible" object:window];
+}
+
+- (void)_windowVisibilityChanged:(NSNotification *)notification
+{
+ [_view _windowVisibilityChanged:notification];
+}
+
+@end
+
+#endif // PLATFORM(MAC)
+
@implementation WebViewPrivate
+ (void)initialize
Modified: trunk/Source/WebKit2/ChangeLog (181865 => 181866)
--- trunk/Source/WebKit2/ChangeLog 2015-03-23 20:35:17 UTC (rev 181865)
+++ trunk/Source/WebKit2/ChangeLog 2015-03-23 20:42:03 UTC (rev 181866)
@@ -1,3 +1,25 @@
+2015-03-23 Alexey Proskuryakov <[email protected]>
+
+ REGRESSION (Yosemite): WKView visibility notifications are messed up
+ https://bugs.webkit.org/show_bug.cgi?id=142945
+
+ Reviewed by Tim Horton.
+
+ As these notifications cannot be used by NSView subclasses, create a separate
+ object for observing them.
+
+ * UIProcess/API/mac/WKView.mm:
+ (-[WKWindowVisibilityObserver initWithView:]):
+ (-[WKWindowVisibilityObserver startObserving:]):
+ (-[WKWindowVisibilityObserver stopObserving:]):
+ (-[WKWindowVisibilityObserver _windowDidOrderOnScreen:]):
+ (-[WKWindowVisibilityObserver _windowDidOrderOffScreen:]):
+ (-[WKView addWindowObserversForWindow:]):
+ (-[WKView removeWindowObservers]): Also, don't try to remove NSWindowWillOrderOffScreenNotification,
+ which we never start to observe.
+ (-[WKView initWithFrame:processPool:configuration:webView:]):
+ * UIProcess/API/mac/WKViewInternal.h:
+
2015-03-23 Anders Carlsson <[email protected]>
Make platform/mac-wk2/plugins/destroy-during-async-npp-new.html work again.
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm (181865 => 181866)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2015-03-23 20:35:17 UTC (rev 181865)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm 2015-03-23 20:42:03 UTC (rev 181866)
@@ -170,6 +170,8 @@
};
#endif
+@class WKWindowVisibilityObserver;
+
@interface WKViewData : NSObject {
@public
std::unique_ptr<PageClientImpl> _pageClient;
@@ -252,6 +254,8 @@
BOOL _useContentPreparationRectForVisibleRect;
BOOL _windowOcclusionDetectionEnabled;
+ RetainPtr<WKWindowVisibilityObserver> _windowVisibilityObserver;
+
std::unique_ptr<ViewGestureController> _gestureController;
BOOL _allowsMagnification;
BOOL _ignoresNonWheelEvents;
@@ -283,6 +287,54 @@
@implementation WKViewData
@end
+@interface WKWindowVisibilityObserver : NSObject {
+ WKView *_view;
+}
+
+- (instancetype)initWithView:(WKView *)view;
+- (void)startObserving:(NSWindow *)window;
+- (void)stopObserving:(NSWindow *)window;
+@end
+
+@implementation WKWindowVisibilityObserver
+
+- (instancetype)initWithView:(WKView *)view
+{
+ self = [super init];
+ if (!self)
+ return nil;
+
+ _view = view;
+ return self;
+}
+
+- (void)startObserving:(NSWindow *)window
+{
+ // An NSView derived object such as WKView cannot observe these notifications, because NSView itself observes them.
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidOrderOffScreen:)
+ name:@"NSWindowDidOrderOffScreenNotification" object:window];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidOrderOnScreen:)
+ name:@"_NSWindowDidBecomeVisible" object:window];
+}
+
+- (void)stopObserving:(NSWindow *)window
+{
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSWindowDidOrderOffScreenNotification" object:window];
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:@"_NSWindowDidBecomeVisible" object:window];
+}
+
+- (void)_windowDidOrderOnScreen:(NSNotification *)notification
+{
+ [_view _windowDidOrderOnScreen:notification];
+}
+
+- (void)_windowDidOrderOffScreen:(NSNotification *)notification
+{
+ [_view _windowDidOrderOffScreen:notification];
+}
+
+@end
+
@interface WKResponderChainSink : NSResponder {
NSResponder *_lastResponderInChain;
bool _didReceiveUnhandledCommand;
@@ -2546,10 +2598,6 @@
name:NSWindowDidMoveNotification object:window];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidResize:)
name:NSWindowDidResizeNotification object:window];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidOrderOffScreen:)
- name:@"NSWindowDidOrderOffScreenNotification" object:window];
- [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidOrderOnScreen:)
- name:@"_NSWindowDidBecomeVisible" object:window];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidChangeBackingProperties:)
name:NSWindowDidChangeBackingPropertiesNotification object:window];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidChangeScreen:)
@@ -2566,6 +2614,7 @@
[window addObserver:self forKeyPath:@"contentLayoutRect" options:NSKeyValueObservingOptionInitial context:keyValueObservingContext];
[window addObserver:self forKeyPath:@"titlebarAppearsTransparent" options:NSKeyValueObservingOptionInitial context:keyValueObservingContext];
#endif
+ [_data->_windowVisibilityObserver startObserving:window];
}
}
@@ -2581,9 +2630,6 @@
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidDeminiaturizeNotification object:window];
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidMoveNotification object:window];
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidResizeNotification object:window];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSWindowWillOrderOffScreenNotification" object:window];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:@"NSWindowDidOrderOffScreenNotification" object:window];
- [[NSNotificationCenter defaultCenter] removeObserver:self name:@"_NSWindowDidBecomeVisible" object:window];
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidChangeBackingPropertiesNotification object:window];
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSWindowDidChangeScreenNotification object:window];
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"_NSWindowDidChangeContentsHostedInLayerSurfaceNotification" object:window];
@@ -2593,6 +2639,7 @@
[window removeObserver:self forKeyPath:@"contentLayoutRect" context:keyValueObservingContext];
[window removeObserver:self forKeyPath:@"titlebarAppearsTransparent" context:keyValueObservingContext];
#endif
+ [_data->_windowVisibilityObserver stopObserving:window];
}
- (void)viewWillMoveToWindow:(NSWindow *)window
@@ -3696,10 +3743,12 @@
_data->_useContentPreparationRectForVisibleRect = NO;
_data->_windowOcclusionDetectionEnabled = YES;
+ _data->_windowVisibilityObserver = adoptNS([[WKWindowVisibilityObserver alloc] initWithView:self]);
+
_data->_intrinsicContentSize = NSMakeSize(NSViewNoInstrinsicMetric, NSViewNoInstrinsicMetric);
_data->_needsViewFrameInWindowCoordinates = _data->_page->preferences().pluginsEnabled();
-
+
[self _registerDraggedTypes];
self.wantsLayer = YES;
Modified: trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h (181865 => 181866)
--- trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h 2015-03-23 20:35:17 UTC (rev 181865)
+++ trunk/Source/WebKit2/UIProcess/API/mac/WKViewInternal.h 2015-03-23 20:42:03 UTC (rev 181866)
@@ -129,6 +129,9 @@
- (void)_reparentLayerTreeInThumbnailView;
#endif
+- (void)_windowDidOrderOnScreen:(NSNotification *)notification;
+- (void)_windowDidOrderOffScreen:(NSNotification *)notification;
+
// FullScreen
@property (readonly) BOOL _hasFullScreenWindowController;