From a620ddc4169300380897452b9c89f1e75eb32698 Mon Sep 17 00:00:00 2001 From: Phil Ringnalda Date: Fri, 27 Jan 2012 20:31:29 -0800 Subject: [PATCH] Back out eb80ab6ee07b (bug 721627) and 06d02e7132b2 (bug 721294) for orange and red --- layout/base/FrameLayerBuilder.cpp | 4 +-- layout/base/nsIPresShell.h | 14 ++------- layout/base/nsPresShell.cpp | 13 ++++---- layout/base/nsPresShell.h | 2 +- layout/generic/nsImageFrame.cpp | 16 ++++++---- layout/generic/nsImageFrame.h | 3 +- view/src/nsViewManager.cpp | 50 ++++++++++++++++++++----------- view/src/nsViewManager.h | 10 +++++-- 8 files changed, 67 insertions(+), 45 deletions(-) diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index 5b60d01b18d..5e279c767f9 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -219,7 +219,7 @@ protected: * supports being optimized to an ImageLayer (TYPE_RASTER only) returns * an ImageContainer for the image. */ - already_AddRefed CanOptimizeImageLayer(LayerManager* aManager); + nsRefPtr CanOptimizeImageLayer(LayerManager* aManager); /** * The region of visible content in the layer, relative to the @@ -968,7 +968,7 @@ ContainerState::FindOpaqueBackgroundColorFor(PRInt32 aThebesLayerIndex) return NS_RGBA(0,0,0,0); } -already_AddRefed +nsRefPtr ContainerState::ThebesLayerData::CanOptimizeImageLayer(LayerManager* aManager) { if (!mImage || !mImageClip.mRoundedClipRects.IsEmpty()) { diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index f5ad57b9da8..c13f99b04da 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -143,8 +143,8 @@ typedef struct CapturingContentInfo { } CapturingContentInfo; #define NS_IPRESSHELL_IID \ - { 0x87acd089, 0x8da7, 0x4438, \ - { 0xa5, 0xcd, 0x90, 0x1e, 0x5d, 0x8f, 0xd8, 0x19 } } +{ 0x3ab5b116, 0x2d73, 0x431c, \ + { 0x9a, 0x4b, 0x6c, 0x91, 0x9e, 0x42, 0x45, 0xc3 } } // Constants for ScrollContentIntoView() function #define NS_PRESSHELL_SCROLL_TOP 0 @@ -1145,21 +1145,13 @@ public: virtual void Paint(nsIView* aViewToPaint, nsIWidget* aWidget, const nsRegion& aDirtyRegion, const nsIntRegion& aIntDirtyRegion, - bool aWillSendDidPaint) = 0; + bool aPaintDefaultBackground, bool aWillSendDidPaint) = 0; virtual nsresult HandleEvent(nsIFrame* aFrame, nsGUIEvent* aEvent, bool aDontRetargetEvents, nsEventStatus* aEventStatus) = 0; virtual bool ShouldIgnoreInvalidation() = 0; - /** - * Notify that the NS_WILL_PAINT event was received. Fires on every - * visible presshell in the document tree. - */ virtual void WillPaint(bool aWillSendDidPaint) = 0; - /** - * Notify that the NS_DID_PAINT event was received. Only fires on the - * root pres shell. - */ virtual void DidPaint() = 0; virtual void ScheduleViewManagerFlush() = 0; virtual void ClearMouseCaptureOnView(nsIView* aView) = 0; diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 783a529b706..4c606aa1dab 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -5427,6 +5427,7 @@ PresShell::Paint(nsIView* aViewToPaint, nsIWidget* aWidgetToPaint, const nsRegion& aDirtyRegion, const nsIntRegion& aIntDirtyRegion, + bool aPaintDefaultBackground, bool aWillSendDidPaint) { #ifdef NS_FUNCTION_TIMER @@ -5448,7 +5449,7 @@ PresShell::Paint(nsIView* aViewToPaint, nsPresContext* presContext = GetPresContext(); AUTO_LAYOUT_PHASE_ENTRY_POINT(presContext, Paint); - nsIFrame* frame = aViewToPaint->GetFrame(); + nsIFrame* frame = aPaintDefaultBackground ? nsnull : aViewToPaint->GetFrame(); bool isRetainingManager; LayerManager* layerManager = @@ -5487,6 +5488,9 @@ PresShell::Paint(nsIView* aViewToPaint, frame->BeginDeferringInvalidatesForDisplayRoot(aDirtyRegion); // We can paint directly into the widget using its layer manager. + // When we get rid of child widgets, this will be the only path we + // need. (aPaintDefaultBackground will never be needed since the + // chrome can always paint a default background.) nsLayoutUtils::PaintFrame(nsnull, frame, aDirtyRegion, bgcolor, nsLayoutUtils::PAINT_WIDGET_LAYERS | nsLayoutUtils::PAINT_EXISTING_TRANSACTION); @@ -7204,11 +7208,10 @@ PresShell::DidPaint() return; } - NS_ASSERTION(mPresContext->IsRoot(), "Should only call DidPaint on root presshells"); - nsRootPresContext* rootPresContext = mPresContext->GetRootPresContext(); - // This should only be called on root presshells, but maybe if a document - // tree is torn down we might not be a root presshell... + if (!rootPresContext) { + return; + } if (rootPresContext == mPresContext) { rootPresContext->UpdatePluginGeometry(); } diff --git a/layout/base/nsPresShell.h b/layout/base/nsPresShell.h index cc271570da7..7f57156e8f0 100644 --- a/layout/base/nsPresShell.h +++ b/layout/base/nsPresShell.h @@ -316,7 +316,7 @@ public: virtual void Paint(nsIView* aViewToPaint, nsIWidget* aWidget, const nsRegion& aDirtyRegion, const nsIntRegion& aIntDirtyRegion, - bool aWillSendDidPaint); + bool aPaintDefaultBackground, bool aWillSendDidPaint); virtual nsresult HandleEvent(nsIFrame* aFrame, nsGUIEvent* aEvent, bool aDontRetargetEvents, diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 6f64fbe0256..fcdb0ad5d33 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -1210,13 +1210,19 @@ nsDisplayImage::Paint(nsDisplayListBuilder* aBuilder, : (PRUint32) imgIContainer::FLAG_NONE); } -already_AddRefed +nsCOMPtr +nsDisplayImage::GetImage() +{ + return mImage; +} + +nsRefPtr nsDisplayImage::GetContainer(LayerManager* aManager) { - nsRefPtr container; - nsresult rv = mImage->GetImageContainer(aManager, getter_AddRefs(container)); - NS_ENSURE_SUCCESS(rv, nsnull); - return container.forget(); + ImageContainer* container; + nsresult rv = mImage->GetImageContainer(aManager, &container); + NS_ENSURE_SUCCESS(rv, NULL); + return container; } void diff --git a/layout/generic/nsImageFrame.h b/layout/generic/nsImageFrame.h index 369468a796a..caba3ba0501 100644 --- a/layout/generic/nsImageFrame.h +++ b/layout/generic/nsImageFrame.h @@ -386,12 +386,13 @@ public: } virtual void Paint(nsDisplayListBuilder* aBuilder, nsRenderingContext* aCtx); + nsCOMPtr GetImage(); /** * Returns an ImageContainer for this image if the image type * supports it (TYPE_RASTER only). */ - already_AddRefed GetContainer(LayerManager* aManager); + nsRefPtr GetContainer(LayerManager* aManager); /** * Configure an ImageLayer for this display item. diff --git a/view/src/nsViewManager.cpp b/view/src/nsViewManager.cpp index 0075e757f8c..b793eb815d1 100644 --- a/view/src/nsViewManager.cpp +++ b/view/src/nsViewManager.cpp @@ -337,8 +337,7 @@ nsIView* nsIViewManager::GetDisplayRootFor(nsIView* aView) rendering. */ void nsViewManager::Refresh(nsView *aView, nsIWidget *aWidget, - const nsIntRegion& aRegion, - bool aWillSendDidPaint) + const nsIntRegion& aRegion) { NS_ASSERTION(aView == nsView::GetViewFor(aWidget), "view widget mismatch"); NS_ASSERTION(aView->GetViewManager() == this, "wrong view manager"); @@ -369,14 +368,7 @@ void nsViewManager::Refresh(nsView *aView, nsIWidget *aWidget, nsAutoScriptBlocker scriptBlocker; SetPainting(true); - NS_ASSERTION(GetDisplayRootFor(aView) == aView, - "Widgets that we paint must all be display roots"); - - if (mPresShell) { - mPresShell->Paint(aView, aWidget, damageRegion, aRegion, - aWillSendDidPaint); - mozilla::StartupTimeline::RecordOnce(mozilla::StartupTimeline::FIRST_PAINT); - } + RenderViews(aView, aWidget, damageRegion, aRegion, false, false); SetPainting(false); } @@ -387,6 +379,23 @@ void nsViewManager::Refresh(nsView *aView, nsIWidget *aWidget, } } +// aRC and aRegion are in view coordinates +void nsViewManager::RenderViews(nsView *aView, nsIWidget *aWidget, + const nsRegion& aRegion, + const nsIntRegion& aIntRegion, + bool aPaintDefaultBackground, + bool aWillSendDidPaint) +{ + NS_ASSERTION(GetDisplayRootFor(aView) == aView, + "Widgets that we paint must all be display roots"); + + if (mPresShell) { + mPresShell->Paint(aView, aWidget, aRegion, aIntRegion, + aPaintDefaultBackground, aWillSendDidPaint); + mozilla::StartupTimeline::RecordOnce(mozilla::StartupTimeline::FIRST_PAINT); + } +} + void nsViewManager::ProcessPendingUpdatesForView(nsView* aView, bool aFlushDirtyRegion) { @@ -810,14 +819,14 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, break; // Paint. - Refresh(view, event->widget, event->region, event->willSendDidPaint); + Refresh(view, event->widget, event->region); break; } case NS_DID_PAINT: { nsRefPtr rootVM = RootViewManager(); - rootVM->CallDidPaintOnObserver(); + rootVM->CallDidPaintOnObservers(); break; } @@ -1388,14 +1397,21 @@ nsViewManager::CallWillPaintOnObservers(bool aWillSendDidPaint) } void -nsViewManager::CallDidPaintOnObserver() +nsViewManager::CallDidPaintOnObservers() { NS_PRECONDITION(IsRootVM(), "Must be root VM for this to be called!"); - if (mRootView && mRootView->IsEffectivelyVisible()) { - nsCOMPtr shell = GetPresShell(); - if (shell) { - shell->DidPaint(); + PRInt32 index; + for (index = 0; index < mVMCount; index++) { + nsViewManager* vm = (nsViewManager*)gViewManagers->ElementAt(index); + if (vm->RootViewManager() == this) { + // One of our kids. + if (vm->mRootView && vm->mRootView->IsEffectivelyVisible()) { + nsCOMPtr shell = vm->GetPresShell(); + if (shell) { + shell->DidPaint(); + } + } } } } diff --git a/view/src/nsViewManager.h b/view/src/nsViewManager.h index 19279ee945a..a66f545cfd4 100644 --- a/view/src/nsViewManager.h +++ b/view/src/nsViewManager.h @@ -153,7 +153,7 @@ private: * Call WillPaint() on all view observers under this vm root. */ void CallWillPaintOnObservers(bool aWillSendDidPaint); - void CallDidPaintOnObserver(); + void CallDidPaintOnObservers(); void ReparentChildWidgets(nsIView* aView, nsIWidget *aNewWidget); void ReparentWidgets(nsIView* aView, nsIView *aParent); void InvalidateWidgetArea(nsView *aWidgetView, const nsRegion &aDamagedRegion); @@ -161,8 +161,12 @@ private: void InvalidateViews(nsView *aView); // aView is the view for aWidget and aRegion is relative to aWidget. - void Refresh(nsView *aView, nsIWidget *aWidget, const nsIntRegion& aRegion, - bool aWillSendDidPaint); + void Refresh(nsView *aView, nsIWidget *aWidget, const nsIntRegion& aRegion); + // aRootView is the view for aWidget, aRegion is relative to aRootView, and + // aIntRegion is relative to aWidget. + void RenderViews(nsView *aRootView, nsIWidget *aWidget, + const nsRegion& aRegion, const nsIntRegion& aIntRegion, + bool aPaintDefaultBackground, bool aWillSendDidPaint); void InvalidateRectDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut); void InvalidateHorizontalBandDifference(nsView *aView, const nsRect& aRect, const nsRect& aCutOut,