From c0f3d7c52d0fbc1a818216632feb1a70c2f0e026 Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Sat, 24 Feb 2001 20:37:06 +0000 Subject: [PATCH] Fix for bug 67478. Fix for BodyFixupRule so that if both the BODY and HTML elements have a transparent background, we make sure to give the canvas the default background (chosen by the PresShell). r=kmcclusk, sr=attinasi git-svn-id: svn://10.0.0.236/trunk@87917 18797224-902f-48f8-a5cc-f745e15eee43 --- .../html/content/src/nsHTMLBodyElement.cpp | 42 +++++++++++++------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp index 92545ef9225..3baec59744d 100644 --- a/mozilla/content/html/content/src/nsHTMLBodyElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLBodyElement.cpp @@ -51,6 +51,7 @@ #include "nsIStyleSet.h" #include "nsISizeOfHandler.h" #include "nsIView.h" +#include "nsLayoutAtoms.h" //---------------------------------------------------------------------- @@ -498,6 +499,9 @@ BodyFixupRule::MapStyleInto(nsIMutableStyleContext* aContext, // get the context data for the BODY, HTML element, and CANVAS nsCOMPtr parentContext; nsCOMPtr canvasContext; + // this is used below to hold the default canvas style. Since we may need the color data + // until the end of this function, we declare the nsCOMPtr here. + nsCOMPtr recalculatedCanvasStyle; parentContext = dont_AddRef(aContext->GetParent()); if (parentContext){ @@ -542,8 +546,19 @@ BodyFixupRule::MapStyleInto(nsIMutableStyleContext* aContext, // otherwise we use the BODY's background if (!(htmlStyleColor->BackgroundIsTransparent())) { styleColor = htmlStyleColor; - } else { + } else if (!(bodyStyleColor->BackgroundIsTransparent())) { styleColor = bodyStyleColor; + } else { + PRBool isPaginated = PR_FALSE; + aPresContext->IsPaginated(&isPaginated); + nsIAtom* rootPseudo = isPaginated ? nsLayoutAtoms::pageSequencePseudo : nsLayoutAtoms::canvasPseudo; + + nsCOMPtr canvasParentStyle = getter_AddRefs(canvasContext->GetParent()); + aPresContext->ResolvePseudoStyleContextFor(nsnull, rootPseudo, canvasParentStyle, + PR_TRUE, // IMPORTANT don't share; otherwise things go wrong + getter_AddRefs(recalculatedCanvasStyle)); + + styleColor = (nsStyleColor*)recalculatedCanvasStyle->GetStyleData(eStyleStruct_Color); } // set the canvas bg values @@ -559,17 +574,20 @@ BodyFixupRule::MapStyleInto(nsIMutableStyleContext* aContext, bFixedBackground = canvasStyleColor->mBackgroundAttachment == NS_STYLE_BG_ATTACHMENT_FIXED ? PR_TRUE : PR_FALSE; - // reset the background values for the context that was propogated - styleColor->mBackgroundImage.SetLength(0); - styleColor->mBackgroundAttachment = NS_STYLE_BG_ATTACHMENT_SCROLL; - styleColor->mBackgroundFlags = NS_STYLE_BG_COLOR_TRANSPARENT | - NS_STYLE_BG_IMAGE_NONE | - NS_STYLE_BG_PROPAGATED_TO_PARENT; - // NOTE: if this was the BODY then this flag is somewhat erroneous - // as it was propogated to the GRANDPARENT! We patch this next by - // marking the HTML's background as propagated too, so we can walk - // up the chain of contexts that have to propagation bit set (see - // nsCSSStyleRule.cpp MapDeclarationColorInto) + // only reset the background values if we used something other than the default canvas style + if (styleColor == htmlStyleColor || styleColor == bodyStyleColor) { + // reset the background values for the context that was propogated + styleColor->mBackgroundImage.SetLength(0); + styleColor->mBackgroundAttachment = NS_STYLE_BG_ATTACHMENT_SCROLL; + styleColor->mBackgroundFlags = NS_STYLE_BG_COLOR_TRANSPARENT | + NS_STYLE_BG_IMAGE_NONE | + NS_STYLE_BG_PROPAGATED_TO_PARENT; + // NOTE: if this was the BODY then this flag is somewhat erroneous + // as it was propogated to the GRANDPARENT! We patch this next by + // marking the HTML's background as propagated too, so we can walk + // up the chain of contexts that have to propagation bit set (see + // nsCSSStyleRule.cpp MapDeclarationColorInto) + } if (styleColor == bodyStyleColor) { htmlStyleColor->mBackgroundFlags |= NS_STYLE_BG_PROPAGATED_TO_PARENT;