void nsViewManager::WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint) { if (!IsRefreshDriverPaintingEnabled() && aWidget && mContext) { // If an ancestor widget was hidden and then shown, we could // have a delayed resize to handle. for (nsViewManager *vm = this; vm; vm = vm->mRootView->GetParent() ? vm->mRootView->GetParent()->GetViewManager() : nullptr) { if (vm->mDelayedResize != nsSize(NSCOORD_NONE, NSCOORD_NONE) && vm->mRootView->IsEffectivelyVisible() && mPresShell && mPresShell->IsVisible()) { vm->FlushDelayedResize(true); vm->InvalidateView(vm->mRootView); } } // Flush things like reflows by calling WillPaint on observer presShells. nsRefPtr<nsViewManager> rootVM = RootViewManager(); rootVM->CallWillPaintOnObservers(aWillSendDidPaint); // Flush view widget geometry updates and invalidations. rootVM->ProcessPendingUpdates(); } if (aWidget && IsRefreshDriverPaintingEnabled()) { nsView* view = nsView::GetViewFor(aWidget); if (view && view->ForcedRepaint()) { ProcessPendingUpdates(); // Re-get the view pointer here since the ProcessPendingUpdates might have // destroyed it during CallWillPaintOnObservers. view = nsView::GetViewFor(aWidget); if (view) { view->SetForcedRepaint(false); } } } nsCOMPtr<nsIPresShell> shell = mPresShell; if (shell) { shell->WillPaintWindow(aWillSendDidPaint); } }
void nsViewManager::WillPaintWindow(nsIWidget* aWidget, bool aWillSendDidPaint) { if (aWidget) { nsView* view = nsView::GetViewFor(aWidget); if (view && view->ForcedRepaint()) { ProcessPendingUpdates(); // Re-get the view pointer here since the ProcessPendingUpdates might have // destroyed it during CallWillPaintOnObservers. view = nsView::GetViewFor(aWidget); if (view) { view->SetForcedRepaint(false); } } } nsCOMPtr<nsIPresShell> shell = mPresShell; if (shell) { shell->WillPaintWindow(aWillSendDidPaint); } }
/** aRegion is given in device coordinates!! aContext may be null, in which case layers should be used for rendering. */ void nsViewManager::Refresh(nsView *aView, const nsIntRegion& aRegion, bool aWillSendDidPaint) { NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager"); // damageRegion is the damaged area, in twips, relative to the view origin nsRegion damageRegion = aRegion.ToAppUnits(AppUnitsPerDevPixel()); // move region from widget coordinates into view coordinates damageRegion.MoveBy(-aView->ViewToWidgetOffset()); if (damageRegion.IsEmpty()) { #ifdef DEBUG_roc nsRect viewRect = aView->GetDimensions(); nsRect damageRect = damageRegion.GetBounds(); printf("XXX Damage rectangle (%d,%d,%d,%d) does not intersect the widget's view (%d,%d,%d,%d)!\n", damageRect.x, damageRect.y, damageRect.width, damageRect.height, viewRect.x, viewRect.y, viewRect.width, viewRect.height); #endif return; } nsIWidget *widget = aView->GetWidget(); if (!widget) { return; } if (aView->ForcedRepaint() && IsRefreshDriverPaintingEnabled()) { ProcessPendingUpdates(); aView->SetForcedRepaint(false); } NS_ASSERTION(!IsPainting(), "recursive painting not permitted"); if (IsPainting()) { RootViewManager()->mRecursiveRefreshPending = true; return; } { nsAutoScriptBlocker scriptBlocker; SetPainting(true); NS_ASSERTION(GetDisplayRootFor(aView) == aView, "Widgets that we paint must all be display roots"); if (mPresShell) { #ifdef DEBUG_INVALIDATIONS printf("--COMPOSITE-- %p\n", mPresShell); #endif if (IsRefreshDriverPaintingEnabled()) { mPresShell->Paint(aView, damageRegion, nsIPresShell::PaintType_Composite, false); } else { mPresShell->Paint(aView, damageRegion, nsIPresShell::PaintType_Full, aWillSendDidPaint); } #ifdef DEBUG_INVALIDATIONS printf("--ENDCOMPOSITE--\n"); #endif mozilla::StartupTimeline::RecordOnce(mozilla::StartupTimeline::FIRST_PAINT); } SetPainting(false); } if (RootViewManager()->mRecursiveRefreshPending) { RootViewManager()->mRecursiveRefreshPending = false; InvalidateAllViews(); } }