Bug 517804 - Flush reflows and invalidations during viewWillDraw. r=roc, r=josh

This commit is contained in:
Markus Stange 2009-09-21 18:29:59 +12:00
parent b161efc0ae
commit 133f044207
3 changed files with 24 additions and 10 deletions

View File

@ -893,6 +893,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
break;
}
case NS_WILL_PAINT:
case NS_PAINT:
{
nsPaintEvent *event = static_cast<nsPaintEvent*>(aEvent);
@ -905,16 +906,18 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
// The rect is in device units, and it's in the coordinate space of its
// associated window.
nsCOMPtr<nsIRegion> region = event->region;
if (!region) {
if (NS_FAILED(CreateRegion(getter_AddRefs(region))))
break;
if (aEvent->message == NS_PAINT) {
if (!region) {
if (NS_FAILED(CreateRegion(getter_AddRefs(region))))
break;
const nsIntRect& damrect = *event->rect;
region->SetTo(damrect.x, damrect.y, damrect.width, damrect.height);
const nsIntRect& damrect = *event->rect;
region->SetTo(damrect.x, damrect.y, damrect.width, damrect.height);
}
if (region->IsEmpty())
break;
}
if (region->IsEmpty())
break;
// Refresh the view
if (IsRefreshEnabled()) {
@ -985,12 +988,12 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent,
rootVM->ProcessPendingUpdates(mRootView, PR_FALSE);
}
if (view) {
if (view && aEvent->message == NS_PAINT) {
Refresh(view, event->renderingContext, region,
NS_VMREFRESH_DOUBLE_BUFFER);
}
}
} else {
} else if (aEvent->message == NS_PAINT) {
// since we got an NS_PAINT event, we need to
// draw something so we don't get blank areas,
// unless there's no widget or it's transparent.

View File

@ -162,6 +162,8 @@ class nsHashKey;
#define NS_DEACTIVATE (NS_WINDOW_START + 8)
// top-level window z-level change request
#define NS_SETZLEVEL (NS_WINDOW_START + 9)
// Widget will need to be painted
#define NS_WILL_PAINT (NS_WINDOW_START + 29)
// Widget needs to be repainted
#define NS_PAINT (NS_WINDOW_START + 30)
// Key is pressed within a window

View File

@ -2739,6 +2739,15 @@ static const PRInt32 sShadowInvalidationInterval = 100;
NS_OBJC_END_TRY_ABORT_BLOCK;
}
- (void)viewWillDraw
{
if (!mGeckoChild)
return;
nsPaintEvent paintEvent(PR_TRUE, NS_WILL_PAINT, mGeckoChild);
mGeckoChild->DispatchWindowEvent(paintEvent);
}
// Allows us to turn off setting up the clip region
// before each drawRect. We already clip within gecko.
- (BOOL)wantsDefaultClipping