[webkit-changes] cvs commit: WebKit/WebView.subproj WebTextView.m
John
sullivan at opensource.apple.com
Mon Sep 26 12:07:01 PDT 2005
sullivan 05/09/26 12:07:00
Modified: . ChangeLog
WebView.subproj WebTextView.m
Log:
Reviewed by Tim Omernick.
- fixed <rdar://problem/4118126> Drag-and-drop text with text containing a colon causes a crash
There were two problems here. One is that dragging and dropping text within the same WebTextView
should have done nothing rather than try to navigate. The other is that navigating while processing
the end of the drag would dealloc the drag-initiating WebTextView, leading to a crash. Fixing the
former doesn't fix all cases of the latter, since dropping onto (e.g.) Safari's location field
could cause a navigation during the drag. So these two issues needed to be fixed separately.
* WebView.subproj/WebTextView.m:
(-[WebTextView dragSelectionWithEvent:offset:slideBack:]):
Before drag, retain self, and tell WebView that the drag is self-initiated. After drag, do the
opposite. This is the same approach as WebImageView, but it can all be contained in one method
here due to NSTextView's dragging API, which wraps up some of the drag-machinery guts.
Revision Changes Path
1.3333 +18 -0 WebKit/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebKit/ChangeLog,v
retrieving revision 1.3332
retrieving revision 1.3333
diff -u -r1.3332 -r1.3333
--- ChangeLog 24 Sep 2005 13:36:50 -0000 1.3332
+++ ChangeLog 26 Sep 2005 19:06:57 -0000 1.3333
@@ -1,3 +1,21 @@
+2005-09-26 John Sullivan <sullivan at apple.com>
+
+ Reviewed by Tim Omernick.
+
+ - fixed <rdar://problem/4118126> Drag-and-drop text with text containing a colon causes a crash
+
+ There were two problems here. One is that dragging and dropping text within the same WebTextView
+ should have done nothing rather than try to navigate. The other is that navigating while processing
+ the end of the drag would dealloc the drag-initiating WebTextView, leading to a crash. Fixing the
+ former doesn't fix all cases of the latter, since dropping onto (e.g.) Safari's location field
+ could cause a navigation during the drag. So these two issues needed to be fixed separately.
+
+ * WebView.subproj/WebTextView.m:
+ (-[WebTextView dragSelectionWithEvent:offset:slideBack:]):
+ Before drag, retain self, and tell WebView that the drag is self-initiated. After drag, do the
+ opposite. This is the same approach as WebImageView, but it can all be contained in one method
+ here due to NSTextView's dragging API, which wraps up some of the drag-machinery guts.
+
2005-09-24 Mitz Pettel <opendarwin.org at mitzpettel.com>
Reviewed and landed by Darin.
1.63 +19 -0 WebKit/WebView.subproj/WebTextView.m
Index: WebTextView.m
===================================================================
RCS file: /cvs/root/WebKit/WebView.subproj/WebTextView.m,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- WebTextView.m 20 Sep 2005 22:31:06 -0000 1.62
+++ WebTextView.m 26 Sep 2005 19:07:00 -0000 1.63
@@ -338,6 +338,25 @@
return [self _elementAtWindowPoint:[self convertPoint:point toView:nil]];
}
+- (BOOL)dragSelectionWithEvent:(NSEvent *)event offset:(NSSize)mouseOffset slideBack:(BOOL)slideBack
+{
+ // Mark webview as initiating the drag so dropping the text back on this webview never tries to navigate.
+ WebView *webView = [self _web_parentWebView];
+ [webView _setInitiatedDrag:YES];
+
+ // The last reference can be lost during the drag if it causes a navigation (e.g. dropping in Safari location
+ // field). This can mess up the dragging machinery (radar 4118126), so retain here and release at end of drag.
+ [self retain];
+
+ BOOL result = [super dragSelectionWithEvent:event offset:mouseOffset slideBack:slideBack];
+
+ // When the call to super finishes, the drag is either aborted or completed. We must clean up in either case.
+ [webView _setInitiatedDrag:NO];
+ [self release];
+
+ return result;
+}
+
- (NSMenu *)menuForEvent:(NSEvent *)event
{
WebView *webView = [self _web_parentWebView];
More information about the webkit-changes
mailing list