From 7e23bbba0b8b0d181af73455fa6bd904a5b6cb1e Mon Sep 17 00:00:00 2001 From: "mats.palmgren%bredband.net" Date: Mon, 29 Aug 2005 04:39:31 +0000 Subject: [PATCH] Don't go below BODY in search for a background color (Print only bug). b=294836 r+sr=bzbarsky --- layout/base/nsCSSRendering.cpp | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/layout/base/nsCSSRendering.cpp b/layout/base/nsCSSRendering.cpp index 295f069d9fe1..6e58eea57ed9 100644 --- a/layout/base/nsCSSRendering.cpp +++ b/layout/base/nsCSSRendering.cpp @@ -21,6 +21,7 @@ * the Initial Developer. All Rights Reserved. * * Contributor(s): + * Mats Palmgren * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -2576,32 +2577,20 @@ FindCanvasBackground(nsPresContext* aPresContext, nsIFrame *firstChild = aForFrame->GetFirstChild(nsnull); if (firstChild) { const nsStyleBackground* result = firstChild->GetStyleBackground(); - - // for printing and print preview.. this should be a pageContentFrame - nsStyleContext* parentContext; + nsIFrame* topFrame = aForFrame; if (firstChild->GetType() == nsLayoutAtoms::pageContentFrame) { - // we have to find the background style ourselves.. since the - // pageContentframe does not have content - while(firstChild){ - for (nsIFrame* kidFrame = firstChild; nsnull != kidFrame; ) { - parentContext = kidFrame->GetStyleContext(); - result = parentContext->GetStyleBackground(); - if (!result->IsTransparent()) { - *aBackground = kidFrame->GetStyleBackground(); - return PR_TRUE; - } else { - kidFrame = kidFrame->GetNextSibling(); - } - } - firstChild = firstChild->GetFirstChild(nsnull); - } - return PR_FALSE; // nothing found for this + topFrame = firstChild->GetFirstChild(nsnull); + NS_ASSERTION(topFrame, + "nsPageContentFrame is missing a normal flow child"); + NS_ASSERTION(topFrame->GetContent(), + "nsPageContentFrame child without content"); + result = topFrame->GetStyleBackground(); } // Check if we need to do propagation from BODY rather than HTML. if (result->IsTransparent()) { - nsIContent* content = aForFrame->GetContent(); + nsIContent* content = topFrame->GetContent(); if (content) { // Use |GetOwnerDoc| so it works during destruction. nsIDocument* document = content->GetOwnerDoc();