From ba00a8035a3531b78ebeee981994a9355332dcd7 Mon Sep 17 00:00:00 2001 From: "pavlov%pavlov.net" Date: Thu, 9 Nov 2006 22:58:11 +0000 Subject: [PATCH] bug 360013. draw using the region rather than the union rect. r=josh sr=vlad git-svn-id: svn://10.0.0.236/trunk@215063 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/widget/src/cocoa/nsChildView.h | 2 +- mozilla/widget/src/cocoa/nsChildView.mm | 40 +++++++++++++++---------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/mozilla/widget/src/cocoa/nsChildView.h b/mozilla/widget/src/cocoa/nsChildView.h index 30b6c63c9b3..7ac1f18958a 100644 --- a/mozilla/widget/src/cocoa/nsChildView.h +++ b/mozilla/widget/src/cocoa/nsChildView.h @@ -246,7 +246,7 @@ public: #ifndef MOZ_CAIRO_GFX virtual void StartDraw(nsIRenderingContext* aRenderingContext = nsnull); virtual void EndDraw(); - void UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext); + void UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext, nsIRegion *aRegion); #endif NS_IMETHOD Update(); diff --git a/mozilla/widget/src/cocoa/nsChildView.mm b/mozilla/widget/src/cocoa/nsChildView.mm index 53f48fcafca..72c40d4cd68 100644 --- a/mozilla/widget/src/cocoa/nsChildView.mm +++ b/mozilla/widget/src/cocoa/nsChildView.mm @@ -58,10 +58,16 @@ #include "nsIScrollableView.h" #include "nsIInterfaceRequestor.h" #include "nsIServiceManager.h" +#include "nsGfxCIID.h" + +#include "nsMacResources.h" + #include "nsDragService.h" #import "nsCursorManager.h" #import "nsWindowMap.h" +static NS_DEFINE_CID(kRegionCID, NS_REGION_CID); + #ifdef MOZ_CAIRO_GFX #include "gfxContext.h" #include "gfxQuartzSurface.h" @@ -1410,7 +1416,7 @@ NS_IMETHODIMP nsChildView::Update() // because the display system will take care of that for us. // void -nsChildView::UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext) +nsChildView::UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext, nsIRegion *aRegion) { if (! mVisible) return; @@ -1427,6 +1433,7 @@ nsChildView::UpdateWidget(nsRect& aRect, nsIRenderingContext* aContext) nsPaintEvent paintEvent(PR_TRUE, NS_PAINT, this); paintEvent.renderingContext = aContext; // nsPaintEvent paintEvent.rect = &aRect; + paintEvent.region = aRegion; // offscreen drawing is pointless. if (paintEvent.rect->x < 0) @@ -2517,11 +2524,6 @@ NSEvent* globalDragEvent = nil; nsRefPtr targetContext = new gfxContext(targetSurface); -#if 0 - targetContext->Rectangle(gfxRect(aRect.origin.x, aRect.origin.y, - aRect.size.width, aRect.size.height)); - targetContext->Clip(); -#else const NSRect *rects; int count, i; [self getRectsBeingDrawn:&rects count:&count]; @@ -2530,7 +2532,6 @@ NSEvent* globalDragEvent = nil; rects[i].size.width, rects[i].size.height)); } targetContext->Clip(); -#endif nsCOMPtr rc; mGeckoChild->GetDeviceContext()->CreateRenderingContextInstance(*getter_AddRefs(rc)); @@ -2573,16 +2574,25 @@ NSEvent* globalDragEvent = nil; #endif #else - // tell gecko to paint. - const NSRect *rects; - int count, i; - [self getRectsBeingDrawn:&rects count:&count]; - for (i = 0; i < count; ++i) { + + nsCOMPtr rgn(do_CreateInstance(kRegionCID)); + if (rgn) { + rgn->Init(); + nsRect r; - NSRectToGeckoRect(rects[i], r); - nsCOMPtr rendContext = getter_AddRefs(mGeckoChild->GetRenderingContext()); - mGeckoChild->UpdateWidget(r, rendContext); + const NSRect *rects; + int count, i; + [self getRectsBeingDrawn:&rects count:&count]; + for (i = 0; i < count; ++i) { + NSRectToGeckoRect(rects[i], r); + rgn->Union(r.x, r.y, r.width, r.height); + } } + + nsRect fullRect; + NSRectToGeckoRect(aRect, fullRect); + nsCOMPtr rendContext = getter_AddRefs(mGeckoChild->GetRenderingContext()); + mGeckoChild->UpdateWidget(fullRect, rendContext, rgn); #endif }