Text caret disappears in Mail after returning from another application
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Apr 2014 20:24:13 +0000 (20:24 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 24 Apr 2014 20:24:13 +0000 (20:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=132111

Reviewed by Darin Adler.

The bug was caused by our SPI _windowChangedKeyState not getting called upon deminiaturization.

Fixed the bug by using the standard NSWindowDidBecomeKeyNotification and NSWindowDidResignKeyNotification
notifications as done in WebKit2 since they DO get called upon deminiaturization.

* WebView/WebView.mm:
(-[WebView addWindowObserversForWindow:]):
(-[WebView removeWindowObservers]):
(-[WebView _windowKeyStateChanged:]):
(-[WebView _windowChangedKeyState]): Deleted.

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

Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebView.mm

index 4871a71..a9a2052 100644 (file)
@@ -1,3 +1,21 @@
+2014-04-24  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Text caret disappears in Mail after returning from another application
+        https://bugs.webkit.org/show_bug.cgi?id=132111
+
+        Reviewed by Darin Adler.
+
+        The bug was caused by our SPI _windowChangedKeyState not getting called upon deminiaturization.
+
+        Fixed the bug by using the standard NSWindowDidBecomeKeyNotification and NSWindowDidResignKeyNotification
+        notifications as done in WebKit2 since they DO get called upon deminiaturization.
+
+        * WebView/WebView.mm:
+        (-[WebView addWindowObserversForWindow:]):
+        (-[WebView removeWindowObservers]):
+        (-[WebView _windowKeyStateChanged:]):
+        (-[WebView _windowChangedKeyState]): Deleted.
+
 2014-04-24  Myles C. Maxfield  <mmaxfield@apple.com>
 
         FontCache::fontCache() never returns nullptr so it can be made to return a reference instead
index f6023a4..1b5413e 100644 (file)
 - (NSView *)_hitTest:(NSPoint *)aPoint dragTypes:(NSSet *)types;
 - (void)_autoscrollForDraggingInfo:(id)dragInfo timeDelta:(NSTimeInterval)repeatDelta;
 - (BOOL)_shouldAutoscrollForDraggingInfo:(id)dragInfo;
-- (void)_windowChangedKeyState;
 @end
 
 @interface NSWindow (WebNSWindowDetails)
@@ -5227,6 +5226,10 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
 - (void)addWindowObserversForWindow:(NSWindow *)window
 {
     if (window) {
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowKeyStateChanged:)
+            name:NSWindowDidBecomeKeyNotification object:window];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowKeyStateChanged:)
+            name:NSWindowDidResignKeyNotification object:window];
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowWillOrderOnScreen:)
             name:WKWindowWillOrderOnScreenNotification() object:window];
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowWillOrderOffScreen:)
@@ -5251,6 +5254,10 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
     NSWindow *window = [self window];
     if (window) {
         [[NSNotificationCenter defaultCenter] removeObserver:self
+            name:NSWindowDidBecomeKeyNotification object:window];
+        [[NSNotificationCenter defaultCenter] removeObserver:self
+            name:NSWindowDidResignKeyNotification object:window];
+        [[NSNotificationCenter defaultCenter] removeObserver:self
             name:WKWindowWillOrderOnScreenNotification() object:window];
         [[NSNotificationCenter defaultCenter] removeObserver:self
             name:WKWindowWillOrderOffScreenNotification() object:window];
@@ -5337,11 +5344,9 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
         _private->page->chrome().windowScreenDidChange((PlatformDisplayID)[[[[[self window] screen] deviceDescription] objectForKey:@"NSScreenNumber"] intValue]);
 }
 
-- (void)_windowChangedKeyState
+- (void)windowKeyStateChanged:(NSNotification *)notification
 {
     [self _updateActiveState];
-
-    [super _windowChangedKeyState];
 }
 
 - (void)_windowWillOrderOnScreen:(NSNotification *)notification