WebCore:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Jul 2006 15:19:13 +0000 (15:19 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Jul 2006 15:19:13 +0000 (15:19 +0000)
        Reviewed by John Sullivan.

        - manual test for http://bugzilla.opendarwin.org/show_bug.cgi?id=9984
          ASSERTION FAILURE: _private->mouseDownEvent != nil
          (WebKit/WebView/WebHTMLView.m:4863 -[WebHTMLView(WebInternal) _delegateDragSourceActionMask])

        * manual-tests/subview-click-assertion.html: Added.

WebKit:

        Reviewed by John Sullivan.

         - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=9984
          ASSERTION FAILURE: _private->mouseDownEvent != nil
          (WebKit/WebView/WebHTMLView.m:4863 -[WebHTMLView(WebInternal) _delegateDragSourceActionMask])

        * WebView/WebHTMLView.m:
        (-[WebHTMLView _setMouseDownEvent:]): Moved into the WebHTMLViewFileInternal category and changed
        to accept nil.
        (-[WebHTMLView _startDraggingImage:at:operation:event:sourceIsDHTML:DHTMLWroteData:]):
        Copy the hit HTMLView's mouse down event to the top HTMLView.
        (-[WebHTMLView acceptsFirstMouse:]): Added a call to _setMouseDownEvent:nil before returning.
        (-[WebHTMLView shouldDelayWindowOrderingForEvent:]): Added a call to _setMouseDownEvent:nil
        before returning.
        (-[WebHTMLView mouseUp:]): Added a call to _setMouseDownEvent:nil to clear the event set in
        mouseDown: (and used during dragging).
        (-[WebHTMLView _delegateDragSourceActionMask]): Copy the hit HTMLView's mouse down event to
        the top HTMLView.

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

WebCore/ChangeLog
WebCore/manual-tests/drag-image-to-address-bar.html [new file with mode: 0644]
WebCore/manual-tests/subview-click-assertion.html [new file with mode: 0644]
WebKit/ChangeLog
WebKit/WebView/WebHTMLView.m

index dbbb483385c53779b59a5cd32859c234182b9f41..d08d3c440b4c4a1a3992c86c04d8dd30cce46515 100644 (file)
@@ -1,3 +1,13 @@
+2006-07-29  Mitz Pettel  <opendarwin.org@mitzpettel.com>
+
+        Reviewed by John Sullivan.
+
+        - manual test for http://bugzilla.opendarwin.org/show_bug.cgi?id=9984
+          ASSERTION FAILURE: _private->mouseDownEvent != nil
+          (WebKit/WebView/WebHTMLView.m:4863 -[WebHTMLView(WebInternal) _delegateDragSourceActionMask])
+
+        * manual-tests/subview-click-assertion.html: Added.
+
 2006-07-29  Andrew Wellington  <proton@wiretapped.net>
 
         Reviewed by Darin.
diff --git a/WebCore/manual-tests/drag-image-to-address-bar.html b/WebCore/manual-tests/drag-image-to-address-bar.html
new file mode 100644 (file)
index 0000000..daf8517
--- /dev/null
@@ -0,0 +1,24 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+        "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+</head>
+<body>
+<p><b>BUG ID:</b> <a href="http://bugzilla.opendarwin.org/show_bug.cgi?id=9952">Bugzilla bug 9952</a> REGRESSION: Repro crash when dragging an image from the window to the address bar</p>
+
+<p id="test" style="background-color:skyblue; padding:3px;"><b>STEPS TO TEST:</b> 
+Drag the image from below to the address bar, then click on the image.
+</p>
+
+<p id="success" style="background-color:palegreen; padding:3px;"><b>TEST PASS:</b> 
+No crash.
+</p>
+
+<p id="failure" style="background-color:#FF3300; padding:3px;"><b>TEST FAIL:</b>  
+Safari will crash when you drop the image onto the address bar or when you click it.
+</p>
+
+<img src="resources/webkit-background.png"><br><iframe></iframe>
+
+</body>
+</html>
diff --git a/WebCore/manual-tests/subview-click-assertion.html b/WebCore/manual-tests/subview-click-assertion.html
new file mode 100644 (file)
index 0000000..26677a1
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+        "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="en">
+<head>
+</head>
+<body>
+<p><b>BUG ID:</b> <a href="http://bugzilla.opendarwin.org/show_bug.cgi?id=9984">Bugzilla bug 9984</a> ASSERTION FAILURE: _private->mouseDownEvent != nil (WebKit/WebView/WebHTMLView.m:4863 -[WebHTMLView(WebInternal) _delegateDragSourceActionMask])</p>
+
+<p id="test" style="background-color:skyblue; padding:3px;"><b>STEPS TO TEST:</b> 
+Open this test in a new Safari window. In the new window, click once on the text &ldquo;Click me&rdquo;. Do not click
+anywhere else in the window before clicking the text.
+</p>
+
+<p id="success" style="background-color:palegreen; padding:3px;"><b>TEST PASS:</b> 
+The text will be deselected.
+</p>
+
+<p id="failure" style="background-color:#FF3300; padding:3px;"><b>TEST FAIL:</b>  
+An assertion failure will occur.
+</p>
+
+<iframe id="frame"></iframe>
+<script>
+    var win = window['frame'];
+    var doc = win.document;
+    doc.write("<p id='target'>Click me</p>");
+    var target = doc.getElementById('target');
+    win.getSelection().setBaseAndExtent(target, 0, target, 1);
+</script>
+
+</body>
+</html>
index b959e0b04b9a99d2419a83b3fc40329881b91795..ed5ad5958707289dfc9ea69a59e7f4346f04f9a7 100644 (file)
@@ -1,3 +1,24 @@
+2006-07-29  Mitz Pettel  <opendarwin.org@mitzpettel.com>
+
+        Reviewed by John Sullivan.
+
+         - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=9984
+          ASSERTION FAILURE: _private->mouseDownEvent != nil
+          (WebKit/WebView/WebHTMLView.m:4863 -[WebHTMLView(WebInternal) _delegateDragSourceActionMask])
+
+        * WebView/WebHTMLView.m:
+        (-[WebHTMLView _setMouseDownEvent:]): Moved into the WebHTMLViewFileInternal category and changed
+        to accept nil.
+        (-[WebHTMLView _startDraggingImage:at:operation:event:sourceIsDHTML:DHTMLWroteData:]):
+        Copy the hit HTMLView's mouse down event to the top HTMLView.
+        (-[WebHTMLView acceptsFirstMouse:]): Added a call to _setMouseDownEvent:nil before returning.
+        (-[WebHTMLView shouldDelayWindowOrderingForEvent:]): Added a call to _setMouseDownEvent:nil
+        before returning.
+        (-[WebHTMLView mouseUp:]): Added a call to _setMouseDownEvent:nil to clear the event set in
+        mouseDown: (and used during dragging).
+        (-[WebHTMLView _delegateDragSourceActionMask]): Copy the hit HTMLView's mouse down event to
+        the top HTMLView.
+
 2006-07-28  Timothy Hatcher  <timothy@apple.com>
 
         Reviewed by John.
index 3a9f3c7524190a788aa78e09e2d63d745f706875..47d2de8b83a875df7e959cb150d0da24c72a5422 100644 (file)
@@ -199,6 +199,7 @@ void *_NSSoftLinkingGetFrameworkFuncPtr(NSString *inUmbrellaFrameworkName,
 - (void)_writeSelectionWithPasteboardTypes:(NSArray *)types toPasteboard:(NSPasteboard *)pasteboard cachedAttributedString:(NSAttributedString *)attributedString;
 - (DOMRange *)_documentRange;
 - (WebFrameBridge *)_bridge;
+- (void)_setMouseDownEvent:(NSEvent *)event;
 @end
 
 @interface WebHTMLView (WebForwardDeclaration) // FIXME: Put this in a normal category and stop doing the forward declaration trick.
@@ -694,6 +695,33 @@ void *_NSSoftLinkingGetFrameworkFuncPtr(NSString *inUmbrellaFrameworkName,
     }
 }
 
+- (void)_setMouseDownEvent:(NSEvent *)event
+{
+    ASSERT(!event || [event type] == NSLeftMouseDown || [event type] == NSRightMouseDown || [event type] == NSOtherMouseDown);
+
+    if (event == _private->mouseDownEvent)
+        return;
+
+    [event retain];
+    [_private->mouseDownEvent release];
+    _private->mouseDownEvent = event;
+
+    [_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.
+    if (event) {
+        NSResponder *firstResponder = [[self window] firstResponder];
+        if ([firstResponder isKindOfClass:[NSTextView class]])
+            _private->firstResponderTextViewAtMouseDownTime = [firstResponder retain];
+        else
+            _private->firstResponderTextViewAtMouseDownTime = nil;
+    } else
+        _private->firstResponderTextViewAtMouseDownTime = nil;
+}
+
 @end
 
 @implementation WebHTMLView (WebPrivate)
@@ -1272,8 +1300,12 @@ static WebHTMLView *lastHitView = nil;
 - (BOOL)_startDraggingImage:(NSImage *)wcDragImage at:(NSPoint)wcDragLoc operation:(NSDragOperation)op event:(NSEvent *)mouseDraggedEvent sourceIsDHTML:(BOOL)srcIsDHTML DHTMLWroteData:(BOOL)dhtmlWroteData
 {
     WebHTMLView *topHTMLView = [self _topHTMLView];
-    if (self != topHTMLView)
-        return [topHTMLView _startDraggingImage:wcDragImage at:wcDragLoc operation:op event:mouseDraggedEvent sourceIsDHTML:srcIsDHTML DHTMLWroteData:dhtmlWroteData];
+    if (self != topHTMLView) {
+        [topHTMLView _setMouseDownEvent:_private->mouseDownEvent];
+        BOOL result = [topHTMLView _startDraggingImage:wcDragImage at:wcDragLoc operation:op event:mouseDraggedEvent sourceIsDHTML:srcIsDHTML DHTMLWroteData:dhtmlWroteData];
+        [topHTMLView _setMouseDownEvent:nil];
+        return result;
+    }
 
     NSPoint mouseDownPoint = [self convertPoint:[_private->mouseDownEvent locationInWindow] fromView:nil];
     NSDictionary *element = [self elementAtPoint:mouseDownPoint allowShadowContent:YES];
@@ -2694,46 +2726,22 @@ static WebHTMLView *lastHitView = nil;
     return [[[self elementAtPoint:point allowShadowContent:YES] objectForKey:WebElementIsSelectedKey] boolValue];
 }
 
-- (void)_setMouseDownEvent:(NSEvent *)event
-{
-    ASSERT([event type] == NSLeftMouseDown || [event type] == NSRightMouseDown || [event type] == NSOtherMouseDown);
-
-    if (event == _private->mouseDownEvent) {
-        return;
-    }
-
-    [event retain];
-    [_private->mouseDownEvent release];
-    _private->mouseDownEvent = event;
-
-    [_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
 {
     NSView *hitView = [self _hitViewForEvent:event];
     WebHTMLView *hitHTMLView = [hitView isKindOfClass:[self class]] ? (WebHTMLView *)hitView : nil;
-    [hitHTMLView _setMouseDownEvent:event];
     
     if ([[self _webView] _dashboardBehavior:WebDashboardBehaviorAlwaysAcceptsFirstMouse])
         return YES;
     
     if (hitHTMLView != nil) {
+        [hitHTMLView _setMouseDownEvent:event];
         [[hitHTMLView _bridge] setActivationEventNumber:[event eventNumber]];
-        return [hitHTMLView _isSelectionEvent:event] ? [[hitHTMLView _bridge] eventMayStartDrag:event] : NO;
-    } else {
+        BOOL result = [hitHTMLView _isSelectionEvent:event] ? [[hitHTMLView _bridge] eventMayStartDrag:event] : NO;
+        [hitHTMLView _setMouseDownEvent:nil];
+        return result;
+    } else
         return [hitView acceptsFirstMouse:event];
-    }
 }
 
 - (BOOL)shouldDelayWindowOrderingForEvent:(NSEvent *)event
@@ -2742,10 +2750,11 @@ static WebHTMLView *lastHitView = nil;
     WebHTMLView *hitHTMLView = [hitView isKindOfClass:[self class]] ? (WebHTMLView *)hitView : nil;
     if (hitHTMLView != nil) {
         [hitHTMLView _setMouseDownEvent:event];
-        return [hitHTMLView _isSelectionEvent:event] ? [[hitHTMLView _bridge] eventMayStartDrag:event] : NO;
-    } else {
+        BOOL result = [hitHTMLView _isSelectionEvent:event] ? [[hitHTMLView _bridge] eventMayStartDrag:event] : NO;
+        [hitHTMLView _setMouseDownEvent:nil];
+        return result;
+    } else
         return [hitView shouldDelayWindowOrderingForEvent:event];
-    }
 }
 
 - (void)mouseDown:(NSEvent *)event
@@ -2901,6 +2910,8 @@ done:
 
 - (void)mouseUp:(NSEvent *)event
 {
+    [self _setMouseDownEvent:nil];
+
     NSInputManager *currentInputManager = [NSInputManager currentInputManager];
     if ([currentInputManager wantsToHandleMouseEvents] && [currentInputManager handleMouseEvent:event])
         return;
@@ -4868,11 +4879,15 @@ static DOMRange *unionDOMRanges(DOMRange *a, DOMRange *b)
 
 - (unsigned)_delegateDragSourceActionMask
 {
+    ASSERT(_private->mouseDownEvent != nil);
     WebHTMLView *topHTMLView = [self _topHTMLView];
-    if (self != topHTMLView)
-        return [topHTMLView _delegateDragSourceActionMask];
+    if (self != topHTMLView) {
+        [topHTMLView _setMouseDownEvent:_private->mouseDownEvent];
+        unsigned result = [topHTMLView _delegateDragSourceActionMask];
+        [topHTMLView _setMouseDownEvent:nil];
+        return result;
+    }
 
-    ASSERT(_private->mouseDownEvent != nil);
     WebView *webView = [self _webView];
     NSPoint point = [webView convertPoint:[_private->mouseDownEvent locationInWindow] fromView:nil];
     _private->dragSourceActionMask = [[webView _UIDelegateForwarder] webView:webView dragSourceActionMaskForPoint:point];