WebKit/mac:
authoradele@apple.com <adele@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Feb 2009 01:15:38 +0000 (01:15 +0000)
committeradele@apple.com <adele@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Feb 2009 01:15:38 +0000 (01:15 +0000)
2009-02-26  Adele Peterson  <adele@apple.com>

        Reviewed by Geoff Garen.

        Fix for <rdar://problem/6618166>
        https://bugs.webkit.org/show_bug.cgi?id=24216
        (REGRESSION r36919) Safari 4 Beta causes MSN Messenger's text entry field to lose focus after entering a message

        During a series of firstResponder changes, at some point while the WebHTMLView was losing first responder status,
        we incorrectly marked the page as active, and then when the WebHTMLView became first responder again, setActive did nothing.
        This change restores behavior from before r36919 to check if the WebHTMLView is in the middle of losing first responder when calling setActive.

        In addition to updating editing/selection/designmode-no-caret.html results, I also made sure the test cases that were
        fixed in r36919 and r38570 are still fixed.

        * WebView/WebHTMLView.mm:
        (-[WebHTMLView resignFirstResponder]): Keep track if we're in the process of resigning first responder.
        (-[WebHTMLView _isResigningFirstResponder]): Added.
        * WebView/WebHTMLViewInternal.h:
        * WebView/WebView.mm: (-[WebView _updateFocusedAndActiveStateForFrame:]): Don't set the page to be active
        if the document view is currently resigning first responder.

LayoutTests:

2009-02-26  Adele Peterson  <adele@apple.com>

        Reviewed by Geoff Garen.

        Updating results for <rdar://problem/6618166>
        https://bugs.webkit.org/show_bug.cgi?id=24216
        (REGRESSION r36919) Safari 4 Beta causes MSN Messenger's text entry field to lose focus after entering a message

        We changed these results shortly after r36919, but the original result is actually correct.
        The test's text indicates that we expect a caret to be placed in this case.

        * platform/mac/editing/selection/designmode-no-caret-expected.checksum:
        * platform/mac/editing/selection/designmode-no-caret-expected.png:
        * platform/mac/editing/selection/designmode-no-caret-expected.txt:

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/editing/selection/designmode-no-caret-expected.checksum
LayoutTests/platform/mac/editing/selection/designmode-no-caret-expected.png
LayoutTests/platform/mac/editing/selection/designmode-no-caret-expected.txt
WebKit/mac/ChangeLog
WebKit/mac/WebView/WebHTMLView.mm
WebKit/mac/WebView/WebHTMLViewInternal.h
WebKit/mac/WebView/WebView.mm

index 77baad9..86cdede 100644 (file)
@@ -1,3 +1,18 @@
+2009-02-26  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Geoff Garen.
+
+        Updating results for <rdar://problem/6618166>
+        https://bugs.webkit.org/show_bug.cgi?id=24216
+        (REGRESSION r36919) Safari 4 Beta causes MSN Messenger's text entry field to lose focus after entering a message
+
+        We changed these results shortly after r36919, but the original result is actually correct.
+        The test's text indicates that we expect a caret to be placed in this case.
+
+        * platform/mac/editing/selection/designmode-no-caret-expected.checksum:
+        * platform/mac/editing/selection/designmode-no-caret-expected.png:
+        * platform/mac/editing/selection/designmode-no-caret-expected.txt:
+
 2009-02-26  David Hyatt  <hyatt@apple.com>
 
         Reviewed by Sam Weinig
index d688d2b..784671b 100644 (file)
Binary files a/LayoutTests/platform/mac/editing/selection/designmode-no-caret-expected.png and b/LayoutTests/platform/mac/editing/selection/designmode-no-caret-expected.png differ
index d67bee3..2ae9c7f 100644 (file)
@@ -1,3 +1,6 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of HTML > #document to 2 of HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
 layer at (0,0) size 800x600
   RenderView at (0,0) size 800x600
 layer at (0,0) size 800x600
@@ -9,3 +12,4 @@ layer at (0,0) size 800x600
         text run at (118,18) width 187: "We do this as a convenience. "
         text run at (305,18) width 479: "Right now, we only do this convenience when a document's frame becomes"
         text run at (0,36) width 378: "first responder or when a document's window becomes key."
+caret: position 1 of child 0 {#text} of child 1 {BODY} of child 0 {HTML} of document
index 23ebd3c..5ca4e42 100644 (file)
@@ -1,3 +1,25 @@
+2009-02-26  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Geoff Garen.
+
+        Fix for <rdar://problem/6618166>
+        https://bugs.webkit.org/show_bug.cgi?id=24216
+        (REGRESSION r36919) Safari 4 Beta causes MSN Messenger's text entry field to lose focus after entering a message
+
+        During a series of firstResponder changes, at some point while the WebHTMLView was losing first responder status,
+        we incorrectly marked the page as active, and then when the WebHTMLView became first responder again, setActive did nothing.
+        This change restores behavior from before r36919 to check if the WebHTMLView is in the middle of losing first responder when calling setActive.
+
+        In addition to updating editing/selection/designmode-no-caret.html results, I also made sure the test cases that were 
+        fixed in r36919 and r38570 are still fixed.
+
+        * WebView/WebHTMLView.mm:
+        (-[WebHTMLView resignFirstResponder]): Keep track if we're in the process of resigning first responder.
+        (-[WebHTMLView _isResigningFirstResponder]): Added.
+        * WebView/WebHTMLViewInternal.h:
+        * WebView/WebView.mm: (-[WebView _updateFocusedAndActiveStateForFrame:]): Don't set the page to be active
+        if the document view is currently resigning first responder.
+
 2009-02-25  Anders Carlsson  <andersca@apple.com>
 
         Reviewed by Kevin Decker.
index 963bd66..aa0094c 100644 (file)
@@ -381,6 +381,7 @@ struct WebHTMLViewInterpretKeyEventsParameters {
     BOOL observingMouseMovedNotifications;
     BOOL observingSuperviewNotifications;
     BOOL observingWindowNotifications;
+    BOOL resigningFirstResponder;
     
     id savedSubviews;
     BOOL subviewsSetAside;
@@ -3441,6 +3442,7 @@ noPromisedData:
 {
     BOOL resign = [super resignFirstResponder];
     if (resign) {
+        _private->resigningFirstResponder = YES;
         [_private->compController endRevertingChange:NO moveLeft:NO];
         if (![self maintainsInactiveSelection]) { 
             [self deselectAll];
@@ -3448,6 +3450,7 @@ noPromisedData:
                 [self clearFocus];
         }
         [self _updateFocusedAndActiveState];
+        _private->resigningFirstResponder = NO;
     }
     return resign;
 }
@@ -5030,6 +5033,11 @@ static CGPoint coreGraphicsScreenPointForAppKitScreenPoint(NSPoint point)
     [[self _pluginController] destroyAllPlugins];
 }
 
+- (BOOL)_isResigningFirstResponder
+{
+    return _private->resigningFirstResponder;
+}
+
 #if USE(ACCELERATED_COMPOSITING)
 - (void)attachRootLayer:(CALayer*)layer
 {
index a984a2c..a32df02 100644 (file)
@@ -58,6 +58,7 @@ namespace WebCore {
 - (void)setPromisedDragTIFFDataSource:(WebCore::CachedImage*)source;
 - (void)_web_layoutIfNeededRecursive;
 - (void)_destroyAllWebPlugins;
+- (BOOL)_isResigningFirstResponder;
 
 #if USE(ACCELERATED_COMPOSITING)
 - (void)attachRootLayer:(CALayer*)layer;
index f7e4bfa..68588ce 100644 (file)
@@ -2632,10 +2632,14 @@ static bool needsWebViewInitThreadWorkaround()
     BOOL windowIsKey = [window isKeyWindow];
     BOOL windowOrSheetIsKey = windowIsKey || [[window attachedSheet] isKeyWindow];
 
-    NSResponder *firstResponder = [window firstResponder]; 
+    WebFrameView *mainFrameView = [[self mainFrame] frameView];
+    id <WebDocumentView> documentView = [mainFrameView documentView];
+    BOOL documentViewIsResigningFirstResponder = [documentView isKindOfClass:[WebHTMLView class]] && [(WebHTMLView *)documentView _isResigningFirstResponder];
+        
+    NSResponder *firstResponder = [window firstResponder];
     if ([firstResponder isKindOfClass:[NSView class]] 
-        && [(NSView*)firstResponder isDescendantOf:[[self mainFrame] frameView]])
-        page->focusController()->setActive(windowIsKey);
+        && [(NSView *)firstResponder isDescendantOf:mainFrameView])
+        page->focusController()->setActive(windowIsKey && !documentViewIsResigningFirstResponder);
 
     Frame* focusedFrame = page->focusController()->focusedOrMainFrame();
     frame->selection()->setFocused(frame == focusedFrame && windowOrSheetIsKey);