コード例 #1
0
/**
   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;
    }

    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
            mPresShell->Paint(aView, damageRegion,
                              nsIPresShell::PAINT_COMPOSITE |
                              (aWillSendDidPaint ? nsIPresShell::PAINT_WILL_SEND_DID_PAINT : 0));
#ifdef DEBUG_INVALIDATIONS
            printf("--ENDCOMPOSITE--\n");
#endif
            mozilla::StartupTimeline::RecordOnce(mozilla::StartupTimeline::FIRST_PAINT);
        }

        SetPainting(false);
    }

    if (RootViewManager()->mRecursiveRefreshPending) {
        RootViewManager()->mRecursiveRefreshPending = false;
        InvalidateAllViews();
    }
}
コード例 #2
0
void nsViewManager::ProcessPendingUpdatesForView(nsView* aView,
        bool aFlushDirtyRegion)
{
    NS_ASSERTION(IsRootVM(), "Updates will be missed");

    // Protect against a null-view.
    if (!aView) {
        return;
    }

    if (aView->HasWidget()) {
        aView->ResetWidgetBounds(false, true);
    }

    // process pending updates in child view.
    for (nsView* childView = aView->GetFirstChild(); childView;
            childView = childView->GetNextSibling()) {
        ProcessPendingUpdatesForView(childView, aFlushDirtyRegion);
    }

    // Push out updates after we've processed the children; ensures that
    // damage is applied based on the final widget geometry
    if (aFlushDirtyRegion) {
        nsIWidget *widget = aView->GetWidget();
        if (widget && widget->NeedsPaint()) {
            // 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);
                }
            }

            NS_ASSERTION(aView->HasWidget(), "Must have a widget!");

#ifdef DEBUG_INVALIDATIONS
            printf("---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n", mPresShell, aView, widget);
#endif
            nsAutoScriptBlocker scriptBlocker;
            NS_ASSERTION(aView->HasWidget(), "Must have a widget!");
            aView->GetWidget()->WillPaint();
            SetPainting(true);
            mPresShell->Paint(aView, nsRegion(),
                              nsIPresShell::PAINT_LAYERS |
                              nsIPresShell::PAINT_WILL_SEND_DID_PAINT);
#ifdef DEBUG_INVALIDATIONS
            printf("---- PAINT END ----\n");
#endif
            aView->SetForcedRepaint(false);
            SetPainting(false);
        }
        FlushDirtyRegionToWidget(aView);
    }
}
コード例 #3
0
ファイル: nsViewManager.cpp プロジェクト: mozilla/pjs
bool nsViewManager::ProcessPendingUpdatesForView(nsView* aView,
                                                 bool aFlushDirtyRegion)
{
  NS_ASSERTION(IsRootVM(), "Updates will be missed");

  // Protect against a null-view.
  if (!aView) {
    return false;
  }

  if (aView->HasWidget()) {
    aView->ResetWidgetBounds(false, true);
  }

  // process pending updates in child view.
  bool skipped = false;
  for (nsView* childView = aView->GetFirstChild(); childView;
       childView = childView->GetNextSibling()) {
    skipped |= ProcessPendingUpdatesForView(childView, aFlushDirtyRegion);
  }

  // Push out updates after we've processed the children; ensures that
  // damage is applied based on the final widget geometry
  if (aFlushDirtyRegion) {
    nsIWidget *widget = aView->GetWidget();
    if (widget && widget->NeedsPaint()) {
      if (aView->PendingRefresh() && aView->SkippedPaints() < 5) {
        aView->SkippedPaint();
        skipped = true;
      } else {
        aView->ClearSkippedPaints();
        aView->SetPendingRefresh(false);
        widget->SetNeedsPaint(false);
        SetPainting(true);
#ifdef DEBUG_INVALIDATIONS
        printf("---- PAINT START ----PresShell(%p), nsView(%p), nsIWidget(%p)\n", mPresShell, aView, widget);
#endif
        nsAutoScriptBlocker scriptBlocker;
        mPresShell->Paint(aView, nsRegion(), nsIPresShell::PaintType_NoComposite, false);
#ifdef DEBUG_INVALIDATIONS
        printf("---- PAINT END ----\n");
#endif
        SetPainting(false);
      }
    }
    FlushDirtyRegionToWidget(aView);
  }
  return skipped;
}