From 614583e8229a7c1e72de8ac0793e40e0000ad7aa Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Fri, 31 May 2002 03:20:23 +0000 Subject: [PATCH] Bug 50623. Don't forget background styles inherited from the initial context. This has the effect of making FRAME/IFRAME documents transparent by default. Also, make FRAME/IFRAME elements paint any background styles set on them. r=dbaron,sr=waterson git-svn-id: svn://10.0.0.236/trunk@122398 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/src/nsRuleNode.cpp | 10 ++++++---- mozilla/layout/generic/nsFrameFrame.cpp | 17 ++++++----------- mozilla/layout/html/document/src/html.css | 2 -- .../layout/html/document/src/nsFrameFrame.cpp | 17 ++++++----------- mozilla/layout/style/html.css | 2 -- mozilla/layout/style/nsRuleNode.cpp | 10 ++++++---- 6 files changed, 24 insertions(+), 34 deletions(-) diff --git a/mozilla/content/base/src/nsRuleNode.cpp b/mozilla/content/base/src/nsRuleNode.cpp index 659eb84a446..249b8dd0c23 100644 --- a/mozilla/content/base/src/nsRuleNode.cpp +++ b/mozilla/content/base/src/nsRuleNode.cpp @@ -3124,12 +3124,14 @@ nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct, const nsCSSStruct parentBG = NS_STATIC_CAST(const nsStyleBackground*, parentContext->GetStyleData(eStyleStruct_Background)); PRBool inherited = aInherited; + // save parentFlags in case bg == parentBG and we clobber them later + PRUint8 parentFlags = parentBG->mBackgroundFlags; // background-color: color, string, enum (flags), inherit if (eCSSUnit_Inherit == colorData.mBackColor.GetUnit()) { // do inherit first, so SetColor doesn't do it bg->mBackgroundColor = parentBG->mBackgroundColor; bg->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT; - bg->mBackgroundFlags |= (parentBG->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT); + bg->mBackgroundFlags |= (parentFlags & NS_STYLE_BG_COLOR_TRANSPARENT); inherited = PR_TRUE; } else if (SetColor(colorData.mBackColor, parentBG->mBackgroundColor, @@ -3154,7 +3156,7 @@ nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct, const nsCSSStruct inherited = PR_TRUE; bg->mBackgroundImage = parentBG->mBackgroundImage; bg->mBackgroundFlags &= ~NS_STYLE_BG_IMAGE_NONE; - bg->mBackgroundFlags |= (parentBG->mBackgroundFlags & NS_STYLE_BG_IMAGE_NONE); + bg->mBackgroundFlags |= (parentFlags & NS_STYLE_BG_IMAGE_NONE); } // background-repeat: enum, inherit @@ -3196,7 +3198,7 @@ nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct, const nsCSSStruct inherited = PR_TRUE; bg->mBackgroundXPosition = parentBG->mBackgroundXPosition; bg->mBackgroundFlags &= ~(NS_STYLE_BG_X_POSITION_LENGTH | NS_STYLE_BG_X_POSITION_PERCENT); - bg->mBackgroundFlags |= (parentBG->mBackgroundFlags & (NS_STYLE_BG_X_POSITION_LENGTH | NS_STYLE_BG_X_POSITION_PERCENT)); + bg->mBackgroundFlags |= (parentFlags & (NS_STYLE_BG_X_POSITION_LENGTH | NS_STYLE_BG_X_POSITION_PERCENT)); } if (eCSSUnit_Percent == colorData.mBackPositionY.GetUnit()) { @@ -3219,7 +3221,7 @@ nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct, const nsCSSStruct inherited = PR_TRUE; bg->mBackgroundYPosition = parentBG->mBackgroundYPosition; bg->mBackgroundFlags &= ~(NS_STYLE_BG_Y_POSITION_LENGTH | NS_STYLE_BG_Y_POSITION_PERCENT); - bg->mBackgroundFlags |= (parentBG->mBackgroundFlags & (NS_STYLE_BG_Y_POSITION_LENGTH | NS_STYLE_BG_Y_POSITION_PERCENT)); + bg->mBackgroundFlags |= (parentFlags & (NS_STYLE_BG_Y_POSITION_LENGTH | NS_STYLE_BG_Y_POSITION_PERCENT)); } if (inherited) diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index d7294b5fa55..912f2be7810 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -220,6 +220,10 @@ public: nsFramePaintLayer aWhichLayer, PRUint32 aFlags); + // Make sure we never think this frame is opaque because it has + // a background set; we won't be painting it in most cases + virtual PRBool CanPaintBackground() { return PR_FALSE; } + /** * @see nsIFrame::Reflow */ @@ -460,17 +464,8 @@ nsHTMLFrameOuterFrame::Paint(nsIPresContext* aPresContext, } //printf("outer paint %X (%d,%d,%d,%d) \n", this, aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height); - nsIFrame* firstChild = mFrames.FirstChild(); - if (nsnull != firstChild) { - firstChild->Paint(aPresContext, aRenderingContext, aDirtyRect, - aWhichLayer); - } - if (IsInline()) { - return nsHTMLContainerFrame::Paint(aPresContext, aRenderingContext, - aDirtyRect, aWhichLayer); - } else { - return NS_OK; - } + return nsHTMLContainerFrame::Paint(aPresContext, aRenderingContext, + aDirtyRect, aWhichLayer); } #ifdef DEBUG diff --git a/mozilla/layout/html/document/src/html.css b/mozilla/layout/html/document/src/html.css index c2444703903..5bb870678b6 100644 --- a/mozilla/layout/html/document/src/html.css +++ b/mozilla/layout/html/document/src/html.css @@ -440,12 +440,10 @@ frameset { } frame { - background-color: transparent ! important; /* (b=49779) */ -moz-user-focus: normal; } iframe { - background-color: transparent ! important; /* (b=49779) */ border: 2px inset; -moz-user-focus: normal; } diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index d7294b5fa55..912f2be7810 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -220,6 +220,10 @@ public: nsFramePaintLayer aWhichLayer, PRUint32 aFlags); + // Make sure we never think this frame is opaque because it has + // a background set; we won't be painting it in most cases + virtual PRBool CanPaintBackground() { return PR_FALSE; } + /** * @see nsIFrame::Reflow */ @@ -460,17 +464,8 @@ nsHTMLFrameOuterFrame::Paint(nsIPresContext* aPresContext, } //printf("outer paint %X (%d,%d,%d,%d) \n", this, aDirtyRect.x, aDirtyRect.y, aDirtyRect.width, aDirtyRect.height); - nsIFrame* firstChild = mFrames.FirstChild(); - if (nsnull != firstChild) { - firstChild->Paint(aPresContext, aRenderingContext, aDirtyRect, - aWhichLayer); - } - if (IsInline()) { - return nsHTMLContainerFrame::Paint(aPresContext, aRenderingContext, - aDirtyRect, aWhichLayer); - } else { - return NS_OK; - } + return nsHTMLContainerFrame::Paint(aPresContext, aRenderingContext, + aDirtyRect, aWhichLayer); } #ifdef DEBUG diff --git a/mozilla/layout/style/html.css b/mozilla/layout/style/html.css index c2444703903..5bb870678b6 100644 --- a/mozilla/layout/style/html.css +++ b/mozilla/layout/style/html.css @@ -440,12 +440,10 @@ frameset { } frame { - background-color: transparent ! important; /* (b=49779) */ -moz-user-focus: normal; } iframe { - background-color: transparent ! important; /* (b=49779) */ border: 2px inset; -moz-user-focus: normal; } diff --git a/mozilla/layout/style/nsRuleNode.cpp b/mozilla/layout/style/nsRuleNode.cpp index 659eb84a446..249b8dd0c23 100644 --- a/mozilla/layout/style/nsRuleNode.cpp +++ b/mozilla/layout/style/nsRuleNode.cpp @@ -3124,12 +3124,14 @@ nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct, const nsCSSStruct parentBG = NS_STATIC_CAST(const nsStyleBackground*, parentContext->GetStyleData(eStyleStruct_Background)); PRBool inherited = aInherited; + // save parentFlags in case bg == parentBG and we clobber them later + PRUint8 parentFlags = parentBG->mBackgroundFlags; // background-color: color, string, enum (flags), inherit if (eCSSUnit_Inherit == colorData.mBackColor.GetUnit()) { // do inherit first, so SetColor doesn't do it bg->mBackgroundColor = parentBG->mBackgroundColor; bg->mBackgroundFlags &= ~NS_STYLE_BG_COLOR_TRANSPARENT; - bg->mBackgroundFlags |= (parentBG->mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT); + bg->mBackgroundFlags |= (parentFlags & NS_STYLE_BG_COLOR_TRANSPARENT); inherited = PR_TRUE; } else if (SetColor(colorData.mBackColor, parentBG->mBackgroundColor, @@ -3154,7 +3156,7 @@ nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct, const nsCSSStruct inherited = PR_TRUE; bg->mBackgroundImage = parentBG->mBackgroundImage; bg->mBackgroundFlags &= ~NS_STYLE_BG_IMAGE_NONE; - bg->mBackgroundFlags |= (parentBG->mBackgroundFlags & NS_STYLE_BG_IMAGE_NONE); + bg->mBackgroundFlags |= (parentFlags & NS_STYLE_BG_IMAGE_NONE); } // background-repeat: enum, inherit @@ -3196,7 +3198,7 @@ nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct, const nsCSSStruct inherited = PR_TRUE; bg->mBackgroundXPosition = parentBG->mBackgroundXPosition; bg->mBackgroundFlags &= ~(NS_STYLE_BG_X_POSITION_LENGTH | NS_STYLE_BG_X_POSITION_PERCENT); - bg->mBackgroundFlags |= (parentBG->mBackgroundFlags & (NS_STYLE_BG_X_POSITION_LENGTH | NS_STYLE_BG_X_POSITION_PERCENT)); + bg->mBackgroundFlags |= (parentFlags & (NS_STYLE_BG_X_POSITION_LENGTH | NS_STYLE_BG_X_POSITION_PERCENT)); } if (eCSSUnit_Percent == colorData.mBackPositionY.GetUnit()) { @@ -3219,7 +3221,7 @@ nsRuleNode::ComputeBackgroundData(nsStyleStruct* aStartStruct, const nsCSSStruct inherited = PR_TRUE; bg->mBackgroundYPosition = parentBG->mBackgroundYPosition; bg->mBackgroundFlags &= ~(NS_STYLE_BG_Y_POSITION_LENGTH | NS_STYLE_BG_Y_POSITION_PERCENT); - bg->mBackgroundFlags |= (parentBG->mBackgroundFlags & (NS_STYLE_BG_Y_POSITION_LENGTH | NS_STYLE_BG_Y_POSITION_PERCENT)); + bg->mBackgroundFlags |= (parentFlags & (NS_STYLE_BG_Y_POSITION_LENGTH | NS_STYLE_BG_Y_POSITION_PERCENT)); } if (inherited)