delay invalidates if we're in the middle of painting. fixes scrambling during

loads (sr=pink, r=sfraser, bug 294415)
This commit is contained in:
pinkerton%aol.net 2005-06-16 12:49:43 +00:00
Родитель 698b140d97
Коммит d35af1bfd4
4 изменённых файлов: 126 добавлений и 61 удалений

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

@ -62,5 +62,10 @@ class nsIWidget;
- (NSWindow*) getNativeWindow;
- (void) setNativeWindow: (NSWindow*)aWindow;
// calls setNeedsDisplay, with the rect in inRectValue if supplied.
// Allows callers to do a delayed invalidate using
// -performSelector:withObject:afterDelay:
- (void)setNeedsDisplayWithValue:(NSValue*)inRectValue;
@end

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

@ -72,9 +72,6 @@
// category of NSView methods to quiet warnings
@interface NSView(ChildViewExtensions)
- (NSWindow*)getNativeWindow;
- (NSMenu*)getContextMenu;
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3
- (void)getRectsBeingDrawn:(const NSRect **)rects count:(int *)count;
- (BOOL)needsToDrawRect:(NSRect)aRect;
@ -1287,6 +1284,12 @@ NS_IMETHODIMP nsChildView::Invalidate(PRBool aIsSynchronous)
if (aIsSynchronous)
[mView display];
else if ([NSView focusView])
{
// if a view is focussed (i.e. being drawn), then postpone the invalidate so that we
// don't lose it.
[mView performSelector:@selector(setNeedsDisplayWithValue:) withObject:nil afterDelay:0];
}
else
[mView setNeedsDisplay:YES];
@ -1308,6 +1311,12 @@ NS_IMETHODIMP nsChildView::Invalidate(const nsRect &aRect, PRBool aIsSynchronous
if (aIsSynchronous)
[mView displayRect:r];
else if ([NSView focusView])
{
// if a view is focussed (i.e. being drawn), then postpone the invalidate so that we
// don't lose it.
[mView performSelector:@selector(setNeedsDisplayWithValue:) withObject:[NSValue valueWithRect:r] afterDelay:0];
}
else
[mView setNeedsDisplayInRect:r];
@ -2189,25 +2198,6 @@ nsChildView::Idle()
@implementation ChildView
-(NSMenu*)menuForEvent:(NSEvent*)theEvent
{
// Fire the context menu event into Gecko.
nsMouseEvent geckoEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal);
[self convert:theEvent message:NS_CONTEXTMENU toGeckoEvent:&geckoEvent];
// send event into Gecko by going directly to the
// the widget.
mGeckoChild->DispatchMouseEvent(geckoEvent);
// Go up our view chain to fetch the correct menu to return.
return [self getContextMenu];
}
-(NSMenu*)getContextMenu
{
return [[self superview] getContextMenu];
}
//
// initWithGeckoChild:eventSink:
//
@ -2215,8 +2205,8 @@ nsChildView::Idle()
//
- (id)initWithGeckoChild:(nsChildView*)inChild eventSink:(nsIEventSink*)inSink
{
[super init];
if ((self = [super init]))
{
mGeckoChild = inChild;
mEventSink = inSink;
mIsPluginView = NO;
@ -2235,10 +2225,35 @@ nsChildView::Idle()
mSelectedRange.location = NSNotFound;
mSelectedRange.length = 0;
mInComposition = NO;
}
return self;
}
- (void)dealloc
{
[super dealloc]; // this sets the current port to _savePort
SetPort(NULL); // this is safe on OS X; it will set the port to
// an empty fallback port.
}
//
// -widget
// mozView method
//
// return our gecko child view widget. Note this does not AddRef.
//
- (nsIWidget*) widget
{
return NS_STATIC_CAST(nsIWidget*, mGeckoChild);
}
//
// -getNativeWindow
// mozView method
//
// get the window that this view is associated with
//
- (NSWindow*)getNativeWindow
{
NSWindow* currWin = [self window];
@ -2248,17 +2263,35 @@ nsChildView::Idle()
return mWindow;
}
//
// -setNativeWindow:
// mozView method
//
// set the NSWindow that this view is associated with (even when not in the view
// hierarchy).
//
- (void)setNativeWindow:(NSWindow*)aWindow
{
mWindow = aWindow;
}
- (void) dealloc
//
// -setNeedsDisplayWithValue:
//
//
- (void)setNeedsDisplayWithValue:(NSValue*)inRectValue
{
[super dealloc]; // this sets the current port to _savePort
SetPort(NULL); // this is safe on OS X; it will set the port to
// an empty fallback port.
if (inRectValue)
{
NSRect theRect = [inRectValue rectValue];
[self setNeedsDisplayInRect:theRect];
}
else
{
[self setNeedsDisplay:YES];
}
}
- (NSString*)description
{
@ -2517,7 +2550,7 @@ nsChildView::Idle()
RgnHandle updateRgn = ::NewRgn();
RectRgn(updateRgn, &updateRect);
::QDFlushPortBuffer((OpaqueGrafPtr *)[self qdPort], updateRgn);
::QDFlushPortBuffer((CGrafPtr)[self qdPort], updateRgn);
::DisposeRgn(updateRgn);
}
@ -2814,6 +2847,25 @@ const PRInt32 kNumLines = 4;
mGeckoChild->DispatchWindowEvent(geckoEvent);
}
-(NSMenu*)menuForEvent:(NSEvent*)theEvent
{
// Fire the context menu event into Gecko.
nsMouseEvent geckoEvent(PR_TRUE, 0, nsnull, nsMouseEvent::eReal);
[self convert:theEvent message:NS_CONTEXTMENU toGeckoEvent:&geckoEvent];
// send event into Gecko by going directly to the
// the widget.
mGeckoChild->DispatchMouseEvent(geckoEvent);
// Go up our view chain to fetch the correct menu to return.
return [self getContextMenu];
}
-(NSMenu*)getContextMenu
{
return [[self superview] getContextMenu];
}
//
// -convert:message:toGeckoEvent:
//
@ -2850,16 +2902,6 @@ const PRInt32 kNumLines = 4;
}
//
// -widget
//
// return our gecko child view widget. Note this does not AddRef.
//
- (nsIWidget*) widget
{
return NS_STATIC_CAST(nsIWidget*, mGeckoChild);
}
static PRBool ConvertUnicodeToCharCode(PRUnichar inUniChar, unsigned char* outChar)
{
UnicodeToTextInfo converterInfo;

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

@ -43,6 +43,7 @@
#include "nsChildView.h"
#include <Controls.h>
#include "nsIContent.h"
#import "mozView.h"
class nsIScrollbarMediator;

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

@ -596,6 +596,23 @@ nsNativeScrollbar::IsEnabled(PRBool *aState)
return NS_STATIC_CAST(nsIWidget*, mGeckoChild);
}
//
// -setNeedsDisplayWithValue:
//
// call -setNeedsDisplay or setNeedsDisplayInRect:
//
- (void)setNeedsDisplayWithValue:(NSValue*)inRectValue
{
if (inRectValue)
{
NSRect theRect = [inRectValue rectValue];
[self setNeedsDisplayInRect:theRect];
}
else
{
[self setNeedsDisplay:YES];
}
}
//
// -mouseMoved