From dd5ffceab5ebdb93b160adddfa828320b317d9d0 Mon Sep 17 00:00:00 2001 From: "attinasi%netscape.com" Date: Wed, 17 May 2000 01:44:49 +0000 Subject: [PATCH] Fixed a problem where background color could not be cleared once set. b=9151 r=rickg --- .../html/content/src/nsHTMLBodyElement.cpp | 59 +++++++++++++------ layout/html/content/src/nsHTMLBodyElement.cpp | 59 +++++++++++++------ 2 files changed, 82 insertions(+), 36 deletions(-) diff --git a/content/html/content/src/nsHTMLBodyElement.cpp b/content/html/content/src/nsHTMLBodyElement.cpp index c093d521153e..994dd2150a0f 100644 --- a/content/html/content/src/nsHTMLBodyElement.cpp +++ b/content/html/content/src/nsHTMLBodyElement.cpp @@ -507,8 +507,10 @@ BodyFixupRule::MapStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aP // XXX do any other body processing here nsCOMPtr parentContext; + nsCOMPtr canvasContext; parentContext = getter_AddRefs(aContext->GetParent()); - + canvasContext = getter_AddRefs(parentContext->GetParent()); + const nsStyleColor* parentStyleColor; const nsStyleColor* styleColor; styleColor = (const nsStyleColor*)aContext->GetStyleData(eStyleStruct_Color); @@ -520,28 +522,49 @@ BodyFixupRule::MapStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aP // for the BODY element // See if the BODY has a background specified + // or if the HTML element was previously propagated from its child (the BODY) + // + // XXX - I think we should be doing this *always*, to cover the cases where the + // XXX - background is going to and from transparent... work is needed to handle + // XXX - different settings on the HTML and BODY simoultaneously, however. if ((!styleColor->BackgroundIsTransparent()) || (parentStyleColor->BackgroundIsTransparent() || (NS_STYLE_BG_PROPAGATED_FROM_CHILD == (parentStyleColor->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_FROM_CHILD))) ) { - // Have the parent (initial containing block) use the BODY's background - nsStyleColor* mutableStyleColor; - mutableStyleColor = (nsStyleColor*)parentContext->GetMutableStyleData(eStyleStruct_Color); - mutableStyleColor->mBackgroundAttachment = styleColor->mBackgroundAttachment; - mutableStyleColor->mBackgroundFlags = styleColor->mBackgroundFlags | NS_STYLE_BG_PROPAGATED_FROM_CHILD; - mutableStyleColor->mBackgroundRepeat = styleColor->mBackgroundRepeat; - mutableStyleColor->mBackgroundColor = styleColor->mBackgroundColor; - mutableStyleColor->mBackgroundXPosition = styleColor->mBackgroundXPosition; - mutableStyleColor->mBackgroundYPosition = styleColor->mBackgroundYPosition; - mutableStyleColor->mBackgroundImage = styleColor->mBackgroundImage; + // We have three frames that have to get along here: + // - the BODY is the one the bg values are set on + // - the HTML element is the body's parent + // - the Canvas is the HTML element's frame's parent, and the frame that actually paints the bg + // So, we bubble the bg values up from BODY -> HTML -> Canvas, setting the propagation flags as we go - // Reset the BODY's background to transparent - mutableStyleColor = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color); - mutableStyleColor->mBackgroundFlags = NS_STYLE_BG_COLOR_TRANSPARENT | - NS_STYLE_BG_IMAGE_NONE | - NS_STYLE_BG_PROPAGATED_TO_PARENT; - mutableStyleColor->mBackgroundImage.SetLength(0); - mutableStyleColor->mBackgroundAttachment = NS_STYLE_BG_ATTACHMENT_SCROLL; + nsStyleColor* canvasStyleColor; + nsStyleColor* htmlStyleColor; + nsStyleColor* bodyStyleColor; + bodyStyleColor = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color); + htmlStyleColor = (nsStyleColor*)parentContext->GetMutableStyleData(eStyleStruct_Color); + canvasStyleColor = (nsStyleColor*)canvasContext->GetMutableStyleData(eStyleStruct_Color); + + // set the canvas bg values from the body + canvasStyleColor->mBackgroundAttachment = styleColor->mBackgroundAttachment; + canvasStyleColor->mBackgroundRepeat = styleColor->mBackgroundRepeat; + canvasStyleColor->mBackgroundColor = styleColor->mBackgroundColor; + canvasStyleColor->mBackgroundXPosition = styleColor->mBackgroundXPosition; + canvasStyleColor->mBackgroundYPosition = styleColor->mBackgroundYPosition; + canvasStyleColor->mBackgroundImage = styleColor->mBackgroundImage; + + // Reset the BODY's and HTML's background to transparent and propagated-to-parent + bodyStyleColor = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color); + bodyStyleColor->mBackgroundFlags = NS_STYLE_BG_COLOR_TRANSPARENT | + NS_STYLE_BG_IMAGE_NONE | + NS_STYLE_BG_PROPAGATED_TO_PARENT; + bodyStyleColor->mBackgroundImage.SetLength(0); + bodyStyleColor->mBackgroundAttachment = NS_STYLE_BG_ATTACHMENT_SCROLL; + + htmlStyleColor->mBackgroundFlags = NS_STYLE_BG_COLOR_TRANSPARENT | + NS_STYLE_BG_IMAGE_NONE | + NS_STYLE_BG_PROPAGATED_TO_PARENT; + htmlStyleColor->mBackgroundImage.SetLength(0); + htmlStyleColor->mBackgroundAttachment = NS_STYLE_BG_ATTACHMENT_SCROLL; } nsCOMPtr presShell; diff --git a/layout/html/content/src/nsHTMLBodyElement.cpp b/layout/html/content/src/nsHTMLBodyElement.cpp index c093d521153e..994dd2150a0f 100644 --- a/layout/html/content/src/nsHTMLBodyElement.cpp +++ b/layout/html/content/src/nsHTMLBodyElement.cpp @@ -507,8 +507,10 @@ BodyFixupRule::MapStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aP // XXX do any other body processing here nsCOMPtr parentContext; + nsCOMPtr canvasContext; parentContext = getter_AddRefs(aContext->GetParent()); - + canvasContext = getter_AddRefs(parentContext->GetParent()); + const nsStyleColor* parentStyleColor; const nsStyleColor* styleColor; styleColor = (const nsStyleColor*)aContext->GetStyleData(eStyleStruct_Color); @@ -520,28 +522,49 @@ BodyFixupRule::MapStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aP // for the BODY element // See if the BODY has a background specified + // or if the HTML element was previously propagated from its child (the BODY) + // + // XXX - I think we should be doing this *always*, to cover the cases where the + // XXX - background is going to and from transparent... work is needed to handle + // XXX - different settings on the HTML and BODY simoultaneously, however. if ((!styleColor->BackgroundIsTransparent()) || (parentStyleColor->BackgroundIsTransparent() || (NS_STYLE_BG_PROPAGATED_FROM_CHILD == (parentStyleColor->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_FROM_CHILD))) ) { - // Have the parent (initial containing block) use the BODY's background - nsStyleColor* mutableStyleColor; - mutableStyleColor = (nsStyleColor*)parentContext->GetMutableStyleData(eStyleStruct_Color); - mutableStyleColor->mBackgroundAttachment = styleColor->mBackgroundAttachment; - mutableStyleColor->mBackgroundFlags = styleColor->mBackgroundFlags | NS_STYLE_BG_PROPAGATED_FROM_CHILD; - mutableStyleColor->mBackgroundRepeat = styleColor->mBackgroundRepeat; - mutableStyleColor->mBackgroundColor = styleColor->mBackgroundColor; - mutableStyleColor->mBackgroundXPosition = styleColor->mBackgroundXPosition; - mutableStyleColor->mBackgroundYPosition = styleColor->mBackgroundYPosition; - mutableStyleColor->mBackgroundImage = styleColor->mBackgroundImage; + // We have three frames that have to get along here: + // - the BODY is the one the bg values are set on + // - the HTML element is the body's parent + // - the Canvas is the HTML element's frame's parent, and the frame that actually paints the bg + // So, we bubble the bg values up from BODY -> HTML -> Canvas, setting the propagation flags as we go - // Reset the BODY's background to transparent - mutableStyleColor = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color); - mutableStyleColor->mBackgroundFlags = NS_STYLE_BG_COLOR_TRANSPARENT | - NS_STYLE_BG_IMAGE_NONE | - NS_STYLE_BG_PROPAGATED_TO_PARENT; - mutableStyleColor->mBackgroundImage.SetLength(0); - mutableStyleColor->mBackgroundAttachment = NS_STYLE_BG_ATTACHMENT_SCROLL; + nsStyleColor* canvasStyleColor; + nsStyleColor* htmlStyleColor; + nsStyleColor* bodyStyleColor; + bodyStyleColor = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color); + htmlStyleColor = (nsStyleColor*)parentContext->GetMutableStyleData(eStyleStruct_Color); + canvasStyleColor = (nsStyleColor*)canvasContext->GetMutableStyleData(eStyleStruct_Color); + + // set the canvas bg values from the body + canvasStyleColor->mBackgroundAttachment = styleColor->mBackgroundAttachment; + canvasStyleColor->mBackgroundRepeat = styleColor->mBackgroundRepeat; + canvasStyleColor->mBackgroundColor = styleColor->mBackgroundColor; + canvasStyleColor->mBackgroundXPosition = styleColor->mBackgroundXPosition; + canvasStyleColor->mBackgroundYPosition = styleColor->mBackgroundYPosition; + canvasStyleColor->mBackgroundImage = styleColor->mBackgroundImage; + + // Reset the BODY's and HTML's background to transparent and propagated-to-parent + bodyStyleColor = (nsStyleColor*)aContext->GetMutableStyleData(eStyleStruct_Color); + bodyStyleColor->mBackgroundFlags = NS_STYLE_BG_COLOR_TRANSPARENT | + NS_STYLE_BG_IMAGE_NONE | + NS_STYLE_BG_PROPAGATED_TO_PARENT; + bodyStyleColor->mBackgroundImage.SetLength(0); + bodyStyleColor->mBackgroundAttachment = NS_STYLE_BG_ATTACHMENT_SCROLL; + + htmlStyleColor->mBackgroundFlags = NS_STYLE_BG_COLOR_TRANSPARENT | + NS_STYLE_BG_IMAGE_NONE | + NS_STYLE_BG_PROPAGATED_TO_PARENT; + htmlStyleColor->mBackgroundImage.SetLength(0); + htmlStyleColor->mBackgroundAttachment = NS_STYLE_BG_ATTACHMENT_SCROLL; } nsCOMPtr presShell;