From b3521097f826c3d6626392aee6b964218964d494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A3o=20Gottwald?= Date: Sat, 18 Apr 2009 10:53:27 +0200 Subject: [PATCH] Backout bug 485275 (changeset 996c11579453) because of test failures --- layout/base/nsCSSRendering.cpp | 4 +++- layout/base/nsDisplayList.cpp | 31 +++----------------------- layout/base/nsDisplayList.h | 39 --------------------------------- layout/base/nsIPresShell.h | 11 +++------- layout/base/nsLayoutUtils.cpp | 34 +++++++++++++++++++++++++--- layout/base/nsPresShell.cpp | 25 ++++++++------------- layout/generic/nsFrameFrame.cpp | 37 +++---------------------------- 7 files changed, 52 insertions(+), 129 deletions(-) diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 594ff956f6ea..940104c2fc54 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -982,7 +982,9 @@ nsCSSRendering::FindRootFrame(nsIFrame* aForFrame) * * |FindBackground| returns true if a background should be painted, and * the resulting style context to use for the background information - * will be filled in to |aBackground|. + * will be filled in to |aBackground|. It fills in a boolean indicating + * whether the frame is the canvas frame, because PaintBackground must + * propagate that frame's background color to the view manager. */ const nsStyleBackground* nsCSSRendering::FindRootFrameBackground(nsIFrame* aForFrame) diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index f1dc6c30175e..56dc1a8f0d69 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -171,8 +171,6 @@ nsDisplayListBuilder::EnterPresShell(nsIFrame* aReferenceFrame, state->mCaretFrame = nsnull; state->mFirstFrameMarkedForDisplay = mFramesMarkedForDisplay.Length(); - state->mPresShell->UpdateCanvasBackground(); - if (!mBuildCaret) return; @@ -194,7 +192,8 @@ nsDisplayListBuilder::EnterPresShell(nsIFrame* aReferenceFrame, void nsDisplayListBuilder::LeavePresShell(nsIFrame* aReferenceFrame, - const nsRect& aDirtyRect) { + const nsRect& aDirtyRect) +{ if (CurrentPresShellState()->mPresShell != aReferenceFrame->PresContext()->PresShell()) { // Must have not allocated a state for this presshell, presumably due // to OOM. @@ -255,7 +254,7 @@ nsDisplayItem::OptimizeVisibility(nsDisplayListBuilder* aBuilder, if (isMoving) { // The display list should include items for both the before and after // states (see nsLayoutUtils::ComputeRepaintRegionForCopy. So the - // only area we want to cover is the area that was opaque in the + // only area we want to cover is the the area that was opaque in the // before state and in the after state. opaqueArea.IntersectRect(bounds - aBuilder->GetMoveDelta(), bounds); } @@ -492,30 +491,6 @@ void nsDisplayList::Sort(nsDisplayListBuilder* aBuilder, ::Sort(this, Count(), aCmp, aClosure); } -void nsDisplaySolidColor::Paint(nsDisplayListBuilder* aBuilder, - nsIRenderingContext* aCtx, const nsRect& aDirtyRect) { - nsRect dirty; - dirty.IntersectRect(GetBounds(aBuilder), aDirtyRect); - aCtx->SetColor(mColor); - aCtx->FillRect(dirty); -} - -// Even though we aren't supposed to, we need to override this because -// we have no frame. -PRBool -nsDisplaySolidColor::OptimizeVisibility(nsDisplayListBuilder* aBuilder, - nsRegion* aVisibleRegion) { - // Do what nsDisplayItem::OptimizeVisibility would do but without a frame. - if (!aVisibleRegion->Intersects(mBounds)) - return PR_FALSE; - - if (IsOpaque(aBuilder)) { - aVisibleRegion->SimpleSubtract(mBounds); - } - - return PR_TRUE; -} - PRBool nsDisplayBackground::IsOpaque(nsDisplayListBuilder* aBuilder) { // theme background overrides any other background diff --git a/layout/base/nsDisplayList.h b/layout/base/nsDisplayList.h index ae237e7d2fc0..10248be3fef3 100644 --- a/layout/base/nsDisplayList.h +++ b/layout/base/nsDisplayList.h @@ -1007,45 +1007,6 @@ public: NS_DISPLAY_DECL_NAME("Border") }; -/** - * A simple display item that just renders a solid color across a frame or - * specified bounds. Used in cases where we can't draw the frame tree but - * we want to draw something to avoid an ugly flash of white when - * navigating between pages. Also used as a bottom item to ensure that - * something is painted everywhere. - */ -class nsDisplaySolidColor : public nsDisplayItem { -public: - nsDisplaySolidColor(const nsRect& aBounds, nscolor aColor) - : nsDisplayItem(nsnull), mBounds(aBounds), mColor(aColor) { - MOZ_COUNT_CTOR(nsDisplaySolidColor); - } -#ifdef NS_BUILD_REFCNT_LOGGING - virtual ~nsDisplaySolidColor() { - MOZ_COUNT_DTOR(nsDisplaySolidColor); - } -#endif - - virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder) { return mBounds; } - - virtual PRBool IsOpaque(nsDisplayListBuilder* aBuilder) { - return (NS_GET_A(mColor) == 255); - } - - virtual PRBool IsUniform(nsDisplayListBuilder* aBuilder) { return PR_TRUE; } - - virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx, - const nsRect& aDirtyRect); - - virtual PRBool OptimizeVisibility(nsDisplayListBuilder* aBuilder, - nsRegion* aVisibleRegion); - - NS_DISPLAY_DECL_NAME("SolidColor") -private: - nsRect mBounds; - nscolor mColor; -}; - /** * The standard display item to paint the CSS background of a frame. */ diff --git a/layout/base/nsIPresShell.h b/layout/base/nsIPresShell.h index 75e500e4dc6e..f730eb88473a 100644 --- a/layout/base/nsIPresShell.h +++ b/layout/base/nsIPresShell.h @@ -101,10 +101,10 @@ class nsPIDOMEventTarget; typedef short SelectionType; typedef PRUint32 nsFrameState; -// fa1bf801-9fb6-4d19-8d33-698e9961fc10 +// fa7f090d-b19a-4ef8-9552-82992a3b4a83 #define NS_IPRESSHELL_IID \ -{ 0xfa1bf801, 0x9fb6, 0x4d19, \ - { 0x8d, 0x33, 0x69, 0x8e, 0x99, 0x61, 0xfc, 0x10 } } +{ 0xfa7f090d, 0xb19a, 0x4ef8, \ + { 0x95, 0x52, 0x82, 0x99, 0x2a, 0x3b, 0x4a, 0x83 } } // Constants for ScrollContentIntoView() function #define NS_PRESSHELL_SCROLL_TOP 0 @@ -793,11 +793,6 @@ public: void SetCanvasBackground(nscolor aColor) { mCanvasBackgroundColor = aColor; } nscolor GetCanvasBackground() { return mCanvasBackgroundColor; } - /* Use the current frame tree (if it exists) to update the background - * color of the most recent canvas. - */ - virtual void UpdateCanvasBackground() = 0; - protected: // IMPORTANT: The ownership implicit in the following member variables // has been explicitly checked. If you add any members to this class, diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 34c2fd7d3610..2e47c189e23c 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -940,6 +940,36 @@ nsLayoutUtils::GetFrameForPoint(nsIFrame* aFrame, nsPoint aPt, return result; } +/** + * A simple display item that just renders a solid color across the entire + * visible area. + */ +class nsDisplaySolidColor : public nsDisplayItem { +public: + nsDisplaySolidColor(nsIFrame* aFrame, nscolor aColor) + : nsDisplayItem(aFrame), mColor(aColor) { + MOZ_COUNT_CTOR(nsDisplaySolidColor); + } +#ifdef NS_BUILD_REFCNT_LOGGING + virtual ~nsDisplaySolidColor() { + MOZ_COUNT_DTOR(nsDisplaySolidColor); + } +#endif + + virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx, + const nsRect& aDirtyRect); + NS_DISPLAY_DECL_NAME("SolidColor") +private: + nscolor mColor; +}; + +void nsDisplaySolidColor::Paint(nsDisplayListBuilder* aBuilder, + nsIRenderingContext* aCtx, const nsRect& aDirtyRect) +{ + aCtx->SetColor(mColor); + aCtx->FillRect(aDirtyRect); +} + /** * Remove all leaf display items that are not for descendants of * aBuilder->GetReferenceFrame() from aList, and move all nsDisplayClip @@ -1077,9 +1107,7 @@ nsLayoutUtils::PaintFrame(nsIRenderingContext* aRenderingContext, nsIFrame* aFra // document (at least!) so this will be removed by the optimizer. In some // cases we might not have a root frame, so this will prevent garbage // from being drawn. - rv = list.AppendNewToBottom(new (&builder) nsDisplaySolidColor( - nsRect(builder.ToReferenceFrame(aFrame), aFrame->GetSize()), - aBackground)); + rv = list.AppendNewToBottom(new (&builder) nsDisplaySolidColor(aFrame, aBackground)); NS_ENSURE_SUCCESS(rv, rv); } diff --git a/layout/base/nsPresShell.cpp b/layout/base/nsPresShell.cpp index 7c797c8c1f96..55efe99ee05f 100644 --- a/layout/base/nsPresShell.cpp +++ b/layout/base/nsPresShell.cpp @@ -1130,8 +1130,6 @@ public: NS_IMETHOD DisableNonTestMouseEvents(PRBool aDisable); - virtual void UpdateCanvasBackground(); - protected: virtual ~PresShell(); @@ -5521,19 +5519,6 @@ PresShell::RenderSelection(nsISelection* aSelection, aScreenRect); } -void PresShell::UpdateCanvasBackground() -{ - // If we have a frame tree and it has style information that - // specifies the background color of the canvas, update our local - // cache of that color. - nsIFrame* rootFrame = FrameConstructor()->GetRootElementStyleFrame(); - if (rootFrame) { - const nsStyleBackground* bgStyle = - nsCSSRendering::FindRootFrameBackground(rootFrame); - mCanvasBackgroundColor = bgStyle->mBackgroundColor; - } -} - NS_IMETHODIMP PresShell::Paint(nsIView* aView, nsIRenderingContext* aRenderingContext, @@ -5544,7 +5529,15 @@ PresShell::Paint(nsIView* aView, NS_ASSERTION(!mIsDestroying, "painting a destroyed PresShell"); NS_ASSERTION(aView, "null view"); - UpdateCanvasBackground(); + // If we have a frame tree and it has style information that + // specifies the background color of the canvas, update our local + // cache of that color. + nsIFrame* rootFrame = FrameConstructor()->GetRootElementStyleFrame(); + if (rootFrame) { + const nsStyleBackground* bgStyle = + nsCSSRendering::FindRootFrameBackground(rootFrame); + mCanvasBackgroundColor = bgStyle->mBackgroundColor; + } // Compute the backstop color for the view. nscolor bgcolor; diff --git a/layout/generic/nsFrameFrame.cpp b/layout/generic/nsFrameFrame.cpp index b408cf75ff2d..ad291a5a84dd 100644 --- a/layout/generic/nsFrameFrame.cpp +++ b/layout/generic/nsFrameFrame.cpp @@ -321,41 +321,10 @@ nsSubDocumentFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, nsIView* subdocView = mInnerView->GetFirstChild(); if (!subdocView) return NS_OK; - - // Get the PresShell so we can check if painting is suppressed - // on the subdocument. We use this roundabout way in case we - // don't have a frame tree. - if (!mFrameLoader) - return NS_OK; - nsCOMPtr docShell; - mFrameLoader->GetDocShell(getter_AddRefs(docShell)); - if (!docShell) - return NS_OK; - nsCOMPtr presShell; - docShell->GetPresShell(getter_AddRefs(presShell)); - if (!presShell) - return NS_OK; - - PRBool suppressed = PR_TRUE; - presShell->IsPaintingSuppressed(&suppressed); - nsIFrame* f = static_cast(subdocView->GetClientData()); - - if (!f || suppressed) { - // If we don't have a frame or painting of the PresShell is suppressed, - // try to draw the default background color. (Bug 485275) - - // Get the bounds of subdocView relative to the reference frame. - nsRect shellBounds = subdocView->GetBounds() + - mInnerView->GetPosition() + - GetOffsetTo(aBuilder->ReferenceFrame()); - rv = aLists.Content()->AppendNewToBottom( - new (aBuilder) nsDisplaySolidColor( - shellBounds, - presShell->GetCanvasBackground())); - return rv; - } - + if (!f) + return NS_OK; + nsRect dirty = aDirtyRect - f->GetOffsetTo(this); aBuilder->EnterPresShell(f, dirty);