Commit dd237c40 authored by adele's avatar adele
Browse files

WebCore:

        Fix by Darin, reviewed by me.

        Fix for <rdar://problem/5171145> Safari crashed closing tab in NSInputContext updateInputContexts

        * platform/mac/WidgetMac.mm:
        (WebCore::safeRemoveFromSuperview): Added. If the view is the window's first responder, then 
         set the window's first responder to nil so we don't leave the window pointing to a view that's no longer in it.
        (WebCore::Widget::setFocus): Don't attempt to focus the view if it has no window.
        (WebCore::Widget::removeFromSuperview): Call safeRemoveFromSuperview.
        (WebCore::Widget::afterMouseDown): ditto.

WebKit:

        Fix by Darin, reviewed by me.

        Fix for <rdar://problem/5171145> Safari crashed closing tab in NSInputContext updateInputContexts

        * WebView/WebFrameView.mm: (-[WebFrameView _setDocumentView:]): If the old view is the first responder,
        then set the window's first responder to nil so we don't leave the window pointing to a view that's no longer in it.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@21632 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b3baea79
2007-05-21 Adele Peterson <adele@apple.com>
Fix by Darin, reviewed by me.
Fix for <rdar://problem/5171145> Safari crashed closing tab in NSInputContext updateInputContexts
* platform/mac/WidgetMac.mm:
(WebCore::safeRemoveFromSuperview): Added. If the view is the window's first responder, then
set the window's first responder to nil so we don't leave the window pointing to a view that's no longer in it.
(WebCore::Widget::setFocus): Don't attempt to focus the view if it has no window.
(WebCore::Widget::removeFromSuperview): Call safeRemoveFromSuperview.
(WebCore::Widget::afterMouseDown): ditto.
2007-05-21 David Hyatt <hyatt@apple.com>
 
Make a line gutter backdrop so that tiny view source docs don't look
......@@ -51,6 +51,18 @@ public:
bool removeFromSuperviewSoon;
};
static void safeRemoveFromSuperview(NSView *view)
{
// If the the view is the first responder, then set the window's first responder to nil so
// we don't leave the window pointing to a view that's no longer in it.
NSWindow *window = [view window];
NSResponder *firstResponder = [window firstResponder];
if ([firstResponder isKindOfClass:[NSView class]] && [(NSView *)firstResponder isDescendantOf:view])
[window makeFirstResponder:nil];
[view removeFromSuperview];
}
Widget::Widget() : data(new WidgetPrivate)
{
data->view = nil;
......@@ -120,7 +132,7 @@ void Widget::setFocus()
if (firstResponder && firstResponder == view)
return;
if (![view superview] || ![view acceptsFirstResponder])
if (![view window] || ![view superview] || ![view acceptsFirstResponder])
return;
NSResponder *oldFirstResponder = [bridge firstResponder];
......@@ -264,7 +276,7 @@ void Widget::removeFromSuperview()
else {
data->removeFromSuperviewSoon = false;
BEGIN_BLOCK_OBJC_EXCEPTIONS;
[getOuterView() removeFromSuperview];
safeRemoveFromSuperview(getOuterView());
END_BLOCK_OBJC_EXCEPTIONS;
}
}
......@@ -282,7 +294,7 @@ void Widget::afterMouseDown(NSView *view, Widget* widget)
{
if (!widget) {
BEGIN_BLOCK_OBJC_EXCEPTIONS;
[view removeFromSuperview];
safeRemoveFromSuperview(view);
END_BLOCK_OBJC_EXCEPTIONS;
} else {
ASSERT(widget->data->mustStayInWindow);
......
2007-05-21 Adele Peterson <adele@apple.com>
Fix by Darin, reviewed by me.
Fix for <rdar://problem/5171145> Safari crashed closing tab in NSInputContext updateInputContexts
* WebView/WebFrameView.mm: (-[WebFrameView _setDocumentView:]): If the old view is the first responder,
then set the window's first responder to nil so we don't leave the window pointing to a view that's no longer in it.
2007-05-21 Brady Eidson <beidson@apple.com>
 
Making the importance of my last change more clear
......
......@@ -165,6 +165,13 @@ enum {
// tree, so must do this before setDocumentView:.
[sv setDocumentCursor:[NSCursor arrowCursor]];
// If the old view is the first responder, then set the window's first responder to nil so
// we don't leave the window pointing to a view that's no longer in it.
NSWindow *window = [sv window];
NSResponder *firstResponder = [window firstResponder];
if ([firstResponder isKindOfClass:[NSView class]] && [(NSView *)firstResponder isDescendantOf:[sv documentView]])
[window makeFirstResponder:nil];
[sv setDocumentView:view];
[sv setSuppressLayout:NO];
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment