Title: [102605] trunk/Source/WebKit/mac
Revision
102605
Author
m...@apple.com
Date
2011-12-12 10:48:43 -0800 (Mon, 12 Dec 2011)

Log Message

<rdar://problem/10328474> Text highlight changes to gray selection color when menu extra is shown

Reviewed by John Sullivan.

* WebView/WebView.mm:
(-[WebView _updateActiveState]): Changed to use -[NSWindow _hasKeyAppearance] instead
of -isKeyWindow. The former also returns YES when a menu extra is open.
(-[WebView addWindowObserversForWindow:]): Removed code to observe
NSWindowDidBecomeKeyNotification and NSWindowDidResignKeyNotification.
(-[WebView removeWindowObservers]): Removed code to stop observing the above.
(-[WebView _windowChangedKeyState]): Overridden this to call _updateActiveState.
This is called when the result of -_hasKeyAppearance changes.
(-[WebView _windowWillOrderOnScreen:]): Removed call to _updateActiveState,
previously needed for popovers, because _windowChangedKeyState is invoked
at the right time for them.
(-[WebView _windowWillOrderOffScreen:]): Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebKit/mac/ChangeLog (102604 => 102605)


--- trunk/Source/WebKit/mac/ChangeLog	2011-12-12 18:44:10 UTC (rev 102604)
+++ trunk/Source/WebKit/mac/ChangeLog	2011-12-12 18:48:43 UTC (rev 102605)
@@ -1,3 +1,22 @@
+2011-12-12  Dan Bernstein  <m...@apple.com>
+
+        <rdar://problem/10328474> Text highlight changes to gray selection color when menu extra is shown
+
+        Reviewed by John Sullivan.
+
+        * WebView/WebView.mm:
+        (-[WebView _updateActiveState]): Changed to use -[NSWindow _hasKeyAppearance] instead
+        of -isKeyWindow. The former also returns YES when a menu extra is open.
+        (-[WebView addWindowObserversForWindow:]): Removed code to observe
+        NSWindowDidBecomeKeyNotification and NSWindowDidResignKeyNotification.
+        (-[WebView removeWindowObservers]): Removed code to stop observing the above.
+        (-[WebView _windowChangedKeyState]): Overridden this to call _updateActiveState.
+        This is called when the result of -_hasKeyAppearance changes.
+        (-[WebView _windowWillOrderOnScreen:]): Removed call to _updateActiveState,
+        previously needed for popovers, because _windowChangedKeyState is invoked
+        at the right time for them.
+        (-[WebView _windowWillOrderOffScreen:]): Ditto.
+
 2011-12-07  Mark Rowe  <mr...@apple.com>
 
         Fix the 32-bit build.

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (102604 => 102605)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2011-12-12 18:44:10 UTC (rev 102604)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2011-12-12 18:48:43 UTC (rev 102605)
@@ -206,10 +206,11 @@
 - (BOOL)_shouldAutoscrollForDraggingInfo:(id)dragInfo;
 @end
 
-@interface NSWindow (WebNSWindowDetails) 
+@interface NSWindow (WebNSWindowDetails)
 - (id)_oldFirstResponderBeforeBecoming;
 - (void)_enableScreenUpdatesIfNeeded;
 - (BOOL)_wrapsCarbonWindow;
+- (BOOL)_hasKeyAppearance;
 @end
 
 using namespace WebCore;
@@ -2508,7 +2509,7 @@
 - (void)_updateActiveState
 {
     if (_private && _private->page)
-        _private->page->focusController()->setActive([[self window] isKeyWindow]);
+        _private->page->focusController()->setActive([[self window] _hasKeyAppearance]);
 }
 
 static PassOwnPtr<Vector<String> > toStringVector(NSArray* patterns)
@@ -3348,10 +3349,6 @@
 - (void)addWindowObserversForWindow:(NSWindow *)window
 {
     if (window) {
-        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidBecomeKey:)
-            name:NSWindowDidBecomeKeyNotification object:nil];
-        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowDidResignKey:)
-            name:NSWindowDidResignKeyNotification object:nil];
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowWillOrderOnScreen:)
             name:WKWindowWillOrderOnScreenNotification() object:window];
         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_windowWillOrderOffScreen:)
@@ -3368,10 +3365,6 @@
     NSWindow *window = [self window];
     if (window) {
         [[NSNotificationCenter defaultCenter] removeObserver:self
-            name:NSWindowDidBecomeKeyNotification object:nil];
-        [[NSNotificationCenter defaultCenter] removeObserver:self
-            name:NSWindowDidResignKeyNotification object:nil];
-        [[NSNotificationCenter defaultCenter] removeObserver:self
             name:WKWindowWillOrderOnScreenNotification() object:window];
         [[NSNotificationCenter defaultCenter] removeObserver:self
             name:WKWindowWillOrderOffScreenNotification() object:window];
@@ -3437,27 +3430,13 @@
         _private->page->windowScreenDidChange((PlatformDisplayID)[[[[[self window] screen] deviceDescription] objectForKey:@"NSScreenNumber"] intValue]);
 }
 
-- (void)_windowDidBecomeKey:(NSNotification *)notification
+- (void)_windowChangedKeyState
 {
-    NSWindow *keyWindow = [notification object];
-    if (keyWindow == [self window] || keyWindow == [[self window] attachedSheet])
-        [self _updateActiveState];
+    [self _updateActiveState];
 }
 
-- (void)_windowDidResignKey:(NSNotification *)notification
-{
-    NSWindow *formerKeyWindow = [notification object];
-    if (formerKeyWindow == [self window] || formerKeyWindow == [[self window] attachedSheet])
-        [self _updateActiveState];
-}
-
 - (void)_windowWillOrderOnScreen:(NSNotification *)notification
 {
-    // Update the active state here so WebViews in NSPopovers get the active state.
-    // This is needed because the normal NSWindowDidBecomeKeyNotification is not fired
-    // for NSPopover windows since they share key with their parent window.
-    [self _updateActiveState];
-
     if (![self shouldUpdateWhileOffscreen])
         [self setNeedsDisplay:YES];
 
@@ -3475,11 +3454,6 @@
 
 - (void)_windowWillOrderOffScreen:(NSNotification *)notification
 {
-    // Update the active state here so WebViews in NSPopovers get the inactive state.
-    // This is needed because the normal NSWindowDidResignKeyNotification is not fired
-    // for NSPopover windows since they share key with their parent window.
-    [self _updateActiveState];
-    
     if (_private && _private->page)
         _private->page->suspendScriptedAnimations();    
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to