Fix bug 201607: crash on some sites because the base widget's Destroy method would get called, and then we tried to draw the NSView. Fix is to remove the NSView from the view hierarchy earlier. r=pink

Fix bug 170112: shift-scroll should scroll up. Fix is to set the key modifiers in the event. r=brade.
This commit is contained in:
sfraser%netscape.com 2004-02-24 03:40:27 +00:00
Родитель 9d1096ef32
Коммит 2c35239a76
2 изменённых файлов: 34 добавлений и 18 удалений

Просмотреть файл

@ -261,6 +261,7 @@ protected:
// override to create different kinds of child views. Autoreleases, so
// caller must retain.
virtual NSView* CreateCocoaView() ;
void TearDownView();
// Find a quickdraw port in which to draw (needed by GFX until it
// is converted to Cocoa). This MUST be overridden if CreateCocoaView()

Просмотреть файл

@ -273,20 +273,7 @@ nsChildView::nsChildView() : nsBaseWidget()
//-------------------------------------------------------------------------
nsChildView::~nsChildView()
{
if ( mView ) {
NSWindow* win = [mView window];
NSResponder* responder = [win firstResponder];
// We're being unhooked from the view hierarchy, don't leave our view
// or a child view as the window first responder.
if (responder && [responder isKindOfClass:[NSView class]] &&
[(NSView*)responder isDescendantOf:mView])
[win makeFirstResponder: [mView superview]];
[mView removeFromSuperviewWithoutNeedingDisplay];
[mView release];
}
TearDownView(); // should have already been done from Destroy
NS_IF_RELEASE(mTempRenderingContext);
NS_IF_RELEASE(mFontMetrics);
@ -408,11 +395,33 @@ nsresult nsChildView::StandardCreate(nsIWidget *aParent,
// our |ChildView| object. Autoreleases, so caller must retain.
//
NSView*
nsChildView::CreateCocoaView ( )
nsChildView::CreateCocoaView( )
{
return [[[ChildView alloc] initWithGeckoChild:this eventSink:nsnull] autorelease];
}
//-------------------------------------------------------------------------
//
//
//-------------------------------------------------------------------------
void nsChildView::TearDownView()
{
if (mView)
{
NSWindow* win = [mView window];
NSResponder* responder = [win firstResponder];
// We're being unhooked from the view hierarchy, don't leave our view
// or a child view as the window first responder.
if (responder && [responder isKindOfClass:[NSView class]] &&
[(NSView*)responder isDescendantOf:mView])
[win makeFirstResponder: [mView superview]];
[mView removeFromSuperviewWithoutNeedingDisplay];
[mView release];
mView = nil;
}
}
//-------------------------------------------------------------------------
//
@ -475,6 +484,8 @@ NS_IMETHODIMP nsChildView::Destroy()
ReportDestroyEvent(); // beard: this seems to cause the window to be deleted. moved all release code to destructor.
mParentWidget = nil;
TearDownView();
return NS_OK;
}
@ -2929,9 +2940,13 @@ static void ConvertCocoaKeyEventToMacEvent(NSEvent* cocoaEvent, EventRecord& mac
{
// dispatch keypress event with char instead of textEvent
nsKeyEvent geckoEvent(NS_KEY_PRESS, mGeckoChild);
geckoEvent.time = PR_IntervalNow();
geckoEvent.charCode = bufPtr[0]; // gecko expects OS-translated unicode
geckoEvent.isChar = PR_TRUE;
geckoEvent.time = PR_IntervalNow();
geckoEvent.charCode = bufPtr[0]; // gecko expects OS-translated unicode
geckoEvent.isChar = PR_TRUE;
geckoEvent.isShift = ([mCurEvent modifierFlags] & NSShiftKeyMask) != 0;
geckoEvent.isControl = ([mCurEvent modifierFlags] & NSControlKeyMask) != 0;
geckoEvent.isAlt = ([mCurEvent modifierFlags] & NSAlternateKeyMask) != 0;
geckoEvent.isMeta = ([mCurEvent modifierFlags] & NSCommandKeyMask) != 0;
// plugins need a native autokey event here, but only if this is a repeat event
EventRecord macEvent;