From 507be0258ed74923583c183693796083d682aa55 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Mon, 11 Apr 2011 08:41:18 -0700 Subject: [PATCH] Bug 598854. We no longer have cases where the view to paint is not a displayroot, so remove the code that handles that. r=tnikkel --- layout/base/nsPresShell.cpp | 63 ++++++++--------------------------- view/public/nsIViewObserver.h | 7 ++-- view/src/nsViewManager.cpp | 15 ++------- 3 files changed, 19 insertions(+), 66 deletions(-) diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 789c376f288c..c6a62928bc04 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -843,8 +843,7 @@ public: //nsIViewObserver interface - NS_IMETHOD Paint(nsIView* aDisplayRoot, - nsIView* aViewToPaint, + NS_IMETHOD Paint(nsIView* aViewToPaint, nsIWidget* aWidget, const nsRegion& aDirtyRegion, const nsIntRegion& aIntDirtyRegion, @@ -5877,9 +5876,6 @@ nscolor PresShell::ComputeBackstopColor(nsIView* aDisplayRoot) } struct PaintParams { - nsIFrame* mFrame; - nsPoint mOffsetToWidget; - const nsRegion* mDirtyRegion; nscolor mBackgroundColor; }; @@ -5957,33 +5953,16 @@ static void DrawThebesLayer(ThebesLayer* aLayer, void* aCallbackData) { PaintParams* params = static_cast(aCallbackData); - nsIFrame* frame = params->mFrame; - if (frame) { - // We're drawing into a child window. - nsIDeviceContext* devCtx = frame->PresContext()->DeviceContext(); - nsCOMPtr rc; - nsresult rv = devCtx->CreateRenderingContextInstance(*getter_AddRefs(rc)); - if (NS_SUCCEEDED(rv)) { - rc->Init(devCtx, aContext); - nsIRenderingContext::AutoPushTranslation - push(rc, params->mOffsetToWidget.x, params->mOffsetToWidget.y); - nsLayoutUtils::PaintFrame(rc, frame, *params->mDirtyRegion, - params->mBackgroundColor, - nsLayoutUtils::PAINT_WIDGET_LAYERS); - } - } else { - aContext->NewPath(); - aContext->SetColor(gfxRGBA(params->mBackgroundColor)); - nsIntRect dirtyRect = aRegionToDraw.GetBounds(); - aContext->Rectangle( - gfxRect(dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height)); - aContext->Fill(); - } + aContext->NewPath(); + aContext->SetColor(gfxRGBA(params->mBackgroundColor)); + nsIntRect dirtyRect = aRegionToDraw.GetBounds(); + aContext->Rectangle( + gfxRect(dirtyRect.x, dirtyRect.y, dirtyRect.width, dirtyRect.height)); + aContext->Fill(); } NS_IMETHODIMP -PresShell::Paint(nsIView* aDisplayRoot, - nsIView* aViewToPaint, +PresShell::Paint(nsIView* aViewToPaint, nsIWidget* aWidgetToPaint, const nsRegion& aDirtyRegion, const nsIntRegion& aIntDirtyRegion, @@ -6002,7 +5981,6 @@ PresShell::Paint(nsIView* aDisplayRoot, #endif NS_ASSERTION(!mIsDestroying, "painting a destroyed PresShell"); - NS_ASSERTION(aDisplayRoot, "null view"); NS_ASSERTION(aViewToPaint, "null view"); NS_ASSERTION(aWidgetToPaint, "Can't paint without a widget"); @@ -6010,7 +5988,7 @@ PresShell::Paint(nsIView* aDisplayRoot, AUTO_LAYOUT_PHASE_ENTRY_POINT(presContext, Paint); nsIFrame* frame = aPaintDefaultBackground - ? nsnull : static_cast(aDisplayRoot->GetClientData()); + ? nsnull : static_cast(aViewToPaint->GetClientData()); bool isRetainingManager; LayerManager* layerManager = @@ -6041,9 +6019,9 @@ PresShell::Paint(nsIView* aDisplayRoot, frame->ClearPresShellsFromLastPaint(); } - nscolor bgcolor = ComputeBackstopColor(aDisplayRoot); + nscolor bgcolor = ComputeBackstopColor(aViewToPaint); - if (frame && aViewToPaint == aDisplayRoot) { + if (frame) { // Defer invalidates that are triggered during painting, and discard // invalidates of areas that are already being repainted. // The layer system can trigger invalidates during painting @@ -6063,30 +6041,15 @@ PresShell::Paint(nsIView* aDisplayRoot, return NS_OK; } - if (frame) { - // Defer invalidates that are triggered during painting, and discard - // invalidates of areas that are already being repainted. - frame->BeginDeferringInvalidatesForDisplayRoot(aDirtyRegion); - } - nsRefPtr root = layerManager->CreateThebesLayer(); if (root) { root->SetVisibleRegion(aIntDirtyRegion); layerManager->SetRoot(root); } - if (!frame) { - bgcolor = NS_ComposeColors(bgcolor, mCanvasBackgroundColor); - } - PaintParams params = - { frame, - aDisplayRoot->GetOffsetToWidget(aWidgetToPaint), - &aDirtyRegion, - bgcolor }; + bgcolor = NS_ComposeColors(bgcolor, mCanvasBackgroundColor); + PaintParams params = { bgcolor }; layerManager->EndTransaction(DrawThebesLayer, ¶ms); - if (frame) { - frame->EndDeferringInvalidatesForDisplayRoot(); - } presContext->NotifyDidPaintForSubtree(); return NS_OK; } diff --git a/view/public/nsIViewObserver.h b/view/public/nsIViewObserver.h index 04a01a71ec7b..d7d4159d63bf 100644 --- a/view/public/nsIViewObserver.h +++ b/view/public/nsIViewObserver.h @@ -47,8 +47,8 @@ class nsIRenderingContext; class nsGUIEvent; #define NS_IVIEWOBSERVER_IID \ - { 0xc8ba5804, 0x2459, 0x4b62, \ - { 0xa4, 0x15, 0x02, 0x84, 0x1a, 0xd7, 0x93, 0xa7 } } + { 0xdc283a18, 0x61cb, 0x468c, \ + { 0x8d, 0xb8, 0x9b, 0x81, 0xf7, 0xc9, 0x33, 0x25 } } class nsIViewObserver : public nsISupports { @@ -76,8 +76,7 @@ public: * which is to paint some default background color over the dirty region. * @return error status */ - NS_IMETHOD Paint(nsIView* aDisplayRoot, - nsIView* aViewToPaint, + NS_IMETHOD Paint(nsIView* aViewToPaint, nsIWidget* aWidgetToPaint, const nsRegion& aDirtyRegion, const nsIntRegion& aIntDirtyRegion, diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index c297302f978d..d63021efe2da 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -441,20 +441,11 @@ void nsViewManager::RenderViews(nsView *aView, nsIWidget *aWidget, PRBool aPaintDefaultBackground, PRBool aWillSendDidPaint) { - nsView* displayRoot = GetDisplayRootFor(aView); - // Make sure we call Paint from the view manager that owns displayRoot. - // (Bug 485275) - nsViewManager* displayRootVM = displayRoot->GetViewManager(); - if (displayRootVM && displayRootVM != this) { - displayRootVM-> - RenderViews(aView, aWidget, aRegion, aIntRegion, aPaintDefaultBackground, - aWillSendDidPaint); - return; - } + NS_ASSERTION(GetDisplayRootFor(aView) == aView, + "Widgets that we paint must all be display roots"); if (mObserver) { - nsRegion region = ConvertRegionBetweenViews(aRegion, aView, displayRoot); - mObserver->Paint(displayRoot, aView, aWidget, region, aIntRegion, + mObserver->Paint(aView, aWidget, aRegion, aIntRegion, aPaintDefaultBackground, aWillSendDidPaint); if (!gFirstPaintTimestamp) gFirstPaintTimestamp = PR_Now();