WebCore:
authorsullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Jul 2006 01:07:47 +0000 (01:07 +0000)
committersullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Jul 2006 01:07:47 +0000 (01:07 +0000)
        Reviewed by Maciej

        - WebCore part of fix for:
        <rdar://problem/4557386> REGRESSION (419.3-521.19): repro Safari world leak involving
        closing tabs after clicking in a web page

        * bridge/mac/WebCoreFrameBridge.h:
        (-[WebCoreFrameBridge textViewWasFirstResponderAtMouseDownTime:])
        renamed to be more specific (formerly wasFirstResponderAtMouseDownTime:)
        * bridge/mac/FrameMac.mm:
        (WebCore::FrameMac::passMouseDownEventToWidget):
        updated for name change

WebKit:

        Reviewed by Maciej

        - WebKit part of fix for:
        <rdar://problem/4557386> REGRESSION (419.3-521.19): repro Safari world leak involving
        closing tabs after clicking in a web page

        * WebCoreSupport/WebFrameBridge.m:
        (-[WebFrameBridge textViewWasFirstResponderAtMouseDownTime:]):
        renamed to be more specific (formerly wasFirstResponderAtMouseDownTime:)

        * WebView/WebHTMLViewInternal.h:
        * WebView/WebHTMLView.m:
        (-[WebTextCompleteController dealloc]):
        updated for name change
        (-[NSArray _setMouseDownEvent:]):
        Now only retains the first responder if it's a textView, since that's the only case that the only client
        actually cares about. This avoids a reference cycle caused by retaining self. This is the only substantive
        part of the patch; all the rest is just renaming for clarity, and comments.
        (-[NSArray mouseDown:]):
        updated for name change
        (-[WebHTMLView _textViewWasFirstResponderAtMouseDownTime:]):
        renamed to be more specific (formerly _wasFirstResponderAtMouseDownTime:)

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

WebCore/ChangeLog
WebCore/bridge/mac/FrameMac.mm
WebCore/bridge/mac/WebCoreFrameBridge.h
WebKit/ChangeLog
WebKit/WebCoreSupport/WebFrameBridge.m
WebKit/WebView/WebHTMLView.m
WebKit/WebView/WebHTMLViewInternal.h

index 9c74a600cfe31a35e657cc61c4d1628eb9198281..fdf06eecc0048c246ec698dfb677cb315c747896 100644 (file)
@@ -1,3 +1,18 @@
+2006-07-20  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Maciej
+
+        - WebCore part of fix for:
+        <rdar://problem/4557386> REGRESSION (419.3-521.19): repro Safari world leak involving 
+        closing tabs after clicking in a web page
+        
+        * bridge/mac/WebCoreFrameBridge.h:
+        (-[WebCoreFrameBridge textViewWasFirstResponderAtMouseDownTime:])
+        renamed to be more specific (formerly wasFirstResponderAtMouseDownTime:)
+        * bridge/mac/FrameMac.mm:
+        (WebCore::FrameMac::passMouseDownEventToWidget):
+        updated for name change
+
 2006-07-19  Alexey Proskuryakov  <ap@nypop.com>
 
         Reviewed by Darin.
index 82ed4b269a5f776014d599042287542b2ecffb3c..291a0016c713566cea1a8e0ffd30668747c428c6 100644 (file)
@@ -1461,7 +1461,11 @@ bool FrameMac::passMouseDownEventToWidget(Widget* widget)
         // In the case where we just became first responder, we should send the mouseDown:
         // to the NSTextField, not the NSTextField's editor. This code makes sure that happens.
         // If we don't do this, we see a flash of selected text when clicking in a text field.
-        if (![_bridge wasFirstResponderAtMouseDownTime:view] && [view isKindOfClass:[NSTextView class]]) {
+        // FIXME: This is the only caller of textViewWasFirstResponderAtMouseDownTime. When we
+        // eliminate all use of NSTextField/NSTextView in form fields we can eliminate this code,
+        // and textViewWasFirstResponderAtMouseDownTime:, and the instance variable WebHTMLView
+        // keeps solely to support textViewWasFirstResponderAtMouseDownTime:.
+        if ([view isKindOfClass:[NSTextView class]] && ![_bridge textViewWasFirstResponderAtMouseDownTime:(NSTextView *)view]) {
             NSView *superview = view;
             while (superview != nodeView) {
                 superview = [superview superview];
index fe8c17c226df0a2440e560d5fe1817d34ebb149f..399e46c86a04e8dfe63f9fd7995c1ad309152419 100644 (file)
@@ -550,7 +550,7 @@ typedef enum {
 - (void)makeFirstResponder:(NSResponder *)responder;
 - (void)willMakeFirstResponderForNodeFocus;
 
-- (BOOL)wasFirstResponderAtMouseDownTime:(NSResponder *)responder;
+- (BOOL)textViewWasFirstResponderAtMouseDownTime:(NSTextView *)textView;
 
 - (void)closeWindowSoon;
 
index f2931eda2fb8903539ddd1399a9ea273ca2bcdc3..db7ac66302a31a36fc59f4b1615b3d2ee2933986 100644 (file)
@@ -1,3 +1,28 @@
+2006-07-20  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Maciej
+
+        - WebKit part of fix for:
+        <rdar://problem/4557386> REGRESSION (419.3-521.19): repro Safari world leak involving 
+        closing tabs after clicking in a web page
+
+        * WebCoreSupport/WebFrameBridge.m:
+        (-[WebFrameBridge textViewWasFirstResponderAtMouseDownTime:]):
+        renamed to be more specific (formerly wasFirstResponderAtMouseDownTime:)        
+        
+        * WebView/WebHTMLViewInternal.h:
+        * WebView/WebHTMLView.m:
+        (-[WebTextCompleteController dealloc]):
+        updated for name change
+        (-[NSArray _setMouseDownEvent:]):
+        Now only retains the first responder if it's a textView, since that's the only case that the only client
+        actually cares about. This avoids a reference cycle caused by retaining self. This is the only substantive
+        part of the patch; all the rest is just renaming for clarity, and comments.
+        (-[NSArray mouseDown:]):
+        updated for name change
+        (-[WebHTMLView _textViewWasFirstResponderAtMouseDownTime:]):
+        renamed to be more specific (formerly _wasFirstResponderAtMouseDownTime:)        
+
 2006-07-19  Tim Omernick  <timo@apple.com>
 
         Reviewed by Darin.
index f4f1b7a6d03753031db0c5ebd0f9fafb9097fa7c..96510683a71241245dded9eceef8cbf18eb73358 100644 (file)
@@ -342,7 +342,7 @@ NSString *WebPluginContainerKey =   @"WebPluginContainer";
 }
 
 
-- (BOOL)wasFirstResponderAtMouseDownTime:(NSResponder *)responder;
+- (BOOL)textViewWasFirstResponderAtMouseDownTime:(NSTextView *)textView;
 {
     ASSERT(_frame != nil);
     NSView *documentView = [[_frame frameView] documentView];
@@ -350,7 +350,7 @@ NSString *WebPluginContainerKey =   @"WebPluginContainer";
         return NO;
     }
     WebHTMLView *webHTMLView = (WebHTMLView *)documentView;
-    return [webHTMLView _wasFirstResponderAtMouseDownTime:responder];
+    return [webHTMLView _textViewWasFirstResponderAtMouseDownTime:textView];
 }
 
 - (void)closeWindowSoon
index 81a57ef58e23e2387d26c91accaa3bff5ec244d0..fc23f8ab06c6940887cd6900ed34b3a2470088da 100644 (file)
@@ -256,7 +256,7 @@ void *_NSSoftLinkingGetFrameworkFuncPtr(NSString *inUmbrellaFrameworkName,
     [pluginController release];
     [toolTip release];
     [compController release];
-    [firstResponderAtMouseDownTime release];
+    [firstResponderTextViewAtMouseDownTime release];
     [dataSource release];
     [highlighters release];
 
@@ -2703,8 +2703,17 @@ static WebHTMLView *lastHitView = nil;
     [_private->mouseDownEvent release];
     _private->mouseDownEvent = event;
 
-    [_private->firstResponderAtMouseDownTime release];
-    _private->firstResponderAtMouseDownTime = [[[self window] firstResponder] retain];
+    [_private->firstResponderTextViewAtMouseDownTime release];
+    
+    // The only code that checks this ivar only cares about NSTextViews. The code used to be more general,
+    // but it caused reference cycles leading to world leaks (see 4557386). We should be able to eliminate
+    // firstResponderTextViewAtMouseDownTime entirely when all the form controls are native widgets, because 
+    // the only caller (in WebCore) will be unnecessary.
+    NSResponder *firstResponder = [[self window] firstResponder];
+    if ([firstResponder isKindOfClass:[NSTextView class]])
+        _private->firstResponderTextViewAtMouseDownTime = [firstResponder retain];
+    else
+        _private->firstResponderTextViewAtMouseDownTime = nil;
 }
 
 - (BOOL)acceptsFirstMouse:(NSEvent *)event
@@ -2765,8 +2774,8 @@ static WebHTMLView *lastHitView = nil;
     }
 
 done:
-    [_private->firstResponderAtMouseDownTime release];
-    _private->firstResponderAtMouseDownTime = nil;
+    [_private->firstResponderTextViewAtMouseDownTime release];
+    _private->firstResponderTextViewAtMouseDownTime = nil;
 
     _private->handlingMouseDownEvent = NO;
     
@@ -4893,9 +4902,9 @@ static DOMRange *unionDOMRanges(DOMRange *a, DOMRange *b)
     [[self _bridge] smartInsertForString:pasteString replacingRange:rangeToReplace beforeString:beforeString afterString:afterString];
 }
 
-- (BOOL)_wasFirstResponderAtMouseDownTime:(NSResponder *)responder
+- (BOOL)_textViewWasFirstResponderAtMouseDownTime:(NSTextView *)textView
 {
-    return responder == _private->firstResponderAtMouseDownTime;
+    return textView == _private->firstResponderTextViewAtMouseDownTime;
 }
 
 - (void)_pauseNullEventsForAllNetscapePlugins
index 041a1abef8bbb9d0a5a18f789be2943ab6070f75..7046ee0ce69586e5782b6281311394b8590025a5 100644 (file)
@@ -89,7 +89,7 @@
     
     BOOL transparentBackground;
 
-    NSResponder *firstResponderAtMouseDownTime;
+    NSTextView *firstResponderTextViewAtMouseDownTime;
     
     WebDataSource *dataSource;
 }
 - (void)_updateFontPanel;
 - (unsigned int)_delegateDragSourceActionMask;
 - (BOOL)_canSmartCopyOrDelete;
-- (BOOL)_wasFirstResponderAtMouseDownTime:(NSResponder *)responder;
+- (BOOL)_textViewWasFirstResponderAtMouseDownTime:(NSTextView *)textView;
 - (void)_pauseNullEventsForAllNetscapePlugins;
 - (void)_resumeNullEventsForAllNetscapePlugins;
 - (void)_willMakeFirstResponderForNodeFocus;