зеркало из https://github.com/mozilla/pjs.git
Part of fix to allow background on BODY element to be inherited. b=47127 r=pierre
This commit is contained in:
Родитель
cb53425bce
Коммит
4cf78ca378
|
@ -566,7 +566,8 @@ BodyFixupRule::MapStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aP
|
|||
canvasStyleColor->mBackgroundXPosition = styleColor->mBackgroundXPosition;
|
||||
canvasStyleColor->mBackgroundYPosition = styleColor->mBackgroundYPosition;
|
||||
canvasStyleColor->mBackgroundImage = styleColor->mBackgroundImage;
|
||||
canvasStyleColor->mBackgroundFlags = styleColor->mBackgroundFlags;
|
||||
canvasStyleColor->mBackgroundFlags = (styleColor->mBackgroundFlags & ~NS_STYLE_BG_PROPAGATED_TO_PARENT);
|
||||
canvasStyleColor->mBackgroundFlags |= NS_STYLE_BG_PROPAGATED_FROM_CHILD;
|
||||
|
||||
bFixedBackground =
|
||||
canvasStyleColor->mBackgroundAttachment == NS_STYLE_BG_ATTACHMENT_FIXED ? PR_TRUE : PR_FALSE;
|
||||
|
@ -579,7 +580,14 @@ BodyFixupRule::MapStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aP
|
|||
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
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
|
|
|
@ -2032,11 +2032,23 @@ MapDeclarationColorInto(nsICSSDeclaration* aDeclaration,
|
|||
if (eCSSUnit_Inherit == ourColor->mBackColor.GetUnit()) { // do inherit first, so SetColor doesn't do it
|
||||
const nsStyleColor* inheritColor = parentColor;
|
||||
if (inheritColor->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_TO_PARENT) {
|
||||
// walk up the contexts until we get to a context that does not have its
|
||||
// background propagated to its parent (or a context that has had its background
|
||||
// propagated from its child)
|
||||
if (nsnull != aParentContext) {
|
||||
nsIStyleContext* grandParentContext = aParentContext->GetParent();
|
||||
if (nsnull != grandParentContext) {
|
||||
inheritColor = (const nsStyleColor*)grandParentContext->GetStyleData(eStyleStruct_Color);
|
||||
}
|
||||
nsCOMPtr<nsIStyleContext> higherContext = getter_AddRefs(aParentContext->GetParent());
|
||||
do {
|
||||
if (higherContext) {
|
||||
inheritColor = (const nsStyleColor*)higherContext->GetStyleData(eStyleStruct_Color);
|
||||
if (inheritColor &&
|
||||
(!(inheritColor->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_TO_PARENT)) ||
|
||||
(inheritColor->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_FROM_CHILD)) {
|
||||
// done walking up the higher contexts
|
||||
break;
|
||||
}
|
||||
higherContext = getter_AddRefs(higherContext->GetParent());
|
||||
}
|
||||
} while (higherContext);
|
||||
}
|
||||
}
|
||||
color->mBackgroundColor = inheritColor->mBackgroundColor;
|
||||
|
|
|
@ -2072,8 +2072,10 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
|
|||
{
|
||||
NS_ASSERTION(aForFrame, "Frame is expected to be provided to PaintBackground");
|
||||
|
||||
PRBool transparentBG = NS_STYLE_BG_COLOR_TRANSPARENT ==
|
||||
(aColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT);
|
||||
// consider it transparent if transparent is set, or if it is propagated to the parent
|
||||
PRBool transparentBG =
|
||||
(NS_STYLE_BG_COLOR_TRANSPARENT == (aColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)) ||
|
||||
(aColor.mBackgroundFlags & NS_STYLE_BG_PROPAGATED_TO_PARENT);
|
||||
float percent;
|
||||
nsStyleCoord bordStyleRadius[4];
|
||||
PRInt16 borderRadii[4],i;
|
||||
|
@ -2208,7 +2210,6 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
|
|||
if (scrollFrame) {
|
||||
nsCOMPtr<nsIScrollableFrame> scrollableFrame ( do_QueryInterface(scrollFrame) );
|
||||
if ( scrollableFrame ) {
|
||||
|
||||
scrollableFrame->GetScrolledFrame(aPresContext, scrolledFrame);
|
||||
if (scrolledFrame) {
|
||||
nsRect rect;
|
||||
|
@ -2231,8 +2232,8 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
|
|||
NS_RELEASE(presShell);
|
||||
rootFrame->GetView(aPresContext, (nsIView**)&viewportView);
|
||||
|
||||
NS_ASSERTION(viewportView, "no viewport view");
|
||||
viewportView->GetDimensions(&viewportArea.width, &viewportArea.height);
|
||||
NS_ASSERTION(viewportView, "no viewport view");
|
||||
viewportView->GetDimensions(&viewportArea.width, &viewportArea.height);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2477,30 +2478,28 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
|
|||
// See if there's a background color specified. The background color
|
||||
// is rendered over the 'border' 'padding' and 'content' areas
|
||||
if (!transparentBG) {
|
||||
// get the radius for our border
|
||||
aSpacing.mBorderRadius.GetTop(bordStyleRadius[0]); //topleft
|
||||
aSpacing.mBorderRadius.GetRight(bordStyleRadius[1]); //topright
|
||||
aSpacing.mBorderRadius.GetBottom(bordStyleRadius[2]); //bottomright
|
||||
aSpacing.mBorderRadius.GetLeft(bordStyleRadius[3]); //bottomleft
|
||||
|
||||
|
||||
// get the radius for our border
|
||||
aSpacing.mBorderRadius.GetTop(bordStyleRadius[0]); //topleft
|
||||
aSpacing.mBorderRadius.GetRight(bordStyleRadius[1]); //topright
|
||||
aSpacing.mBorderRadius.GetBottom(bordStyleRadius[2]); //bottomright
|
||||
aSpacing.mBorderRadius.GetLeft(bordStyleRadius[3]); //bottomleft
|
||||
|
||||
for(i=0;i<4;i++) {
|
||||
borderRadii[i] = 0;
|
||||
switch ( bordStyleRadius[i].GetUnit()) {
|
||||
case eStyleUnit_Inherit:
|
||||
break;
|
||||
case eStyleUnit_Percent:
|
||||
percent = bordStyleRadius[i].GetPercentValue();
|
||||
borderRadii[i] = (nscoord)(percent * aBorderArea.width);
|
||||
break;
|
||||
case eStyleUnit_Coord:
|
||||
borderRadii[i] = bordStyleRadius[i].GetCoordValue();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
for(i=0;i<4;i++) {
|
||||
borderRadii[i] = 0;
|
||||
switch ( bordStyleRadius[i].GetUnit()) {
|
||||
case eStyleUnit_Inherit:
|
||||
break;
|
||||
case eStyleUnit_Percent:
|
||||
percent = bordStyleRadius[i].GetPercentValue();
|
||||
borderRadii[i] = (nscoord)(percent * aBorderArea.width);
|
||||
break;
|
||||
case eStyleUnit_Coord:
|
||||
borderRadii[i] = bordStyleRadius[i].GetCoordValue();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// rounded version of the border
|
||||
|
@ -2515,7 +2514,6 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
|
|||
aRenderingContext.FillRect(aBorderArea);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
|
|
|
@ -566,7 +566,8 @@ BodyFixupRule::MapStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aP
|
|||
canvasStyleColor->mBackgroundXPosition = styleColor->mBackgroundXPosition;
|
||||
canvasStyleColor->mBackgroundYPosition = styleColor->mBackgroundYPosition;
|
||||
canvasStyleColor->mBackgroundImage = styleColor->mBackgroundImage;
|
||||
canvasStyleColor->mBackgroundFlags = styleColor->mBackgroundFlags;
|
||||
canvasStyleColor->mBackgroundFlags = (styleColor->mBackgroundFlags & ~NS_STYLE_BG_PROPAGATED_TO_PARENT);
|
||||
canvasStyleColor->mBackgroundFlags |= NS_STYLE_BG_PROPAGATED_FROM_CHILD;
|
||||
|
||||
bFixedBackground =
|
||||
canvasStyleColor->mBackgroundAttachment == NS_STYLE_BG_ATTACHMENT_FIXED ? PR_TRUE : PR_FALSE;
|
||||
|
@ -579,7 +580,14 @@ BodyFixupRule::MapStyleInto(nsIMutableStyleContext* aContext, nsIPresContext* aP
|
|||
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
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPresShell> presShell;
|
||||
|
|
|
@ -2072,8 +2072,10 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
|
|||
{
|
||||
NS_ASSERTION(aForFrame, "Frame is expected to be provided to PaintBackground");
|
||||
|
||||
PRBool transparentBG = NS_STYLE_BG_COLOR_TRANSPARENT ==
|
||||
(aColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT);
|
||||
// consider it transparent if transparent is set, or if it is propagated to the parent
|
||||
PRBool transparentBG =
|
||||
(NS_STYLE_BG_COLOR_TRANSPARENT == (aColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)) ||
|
||||
(aColor.mBackgroundFlags & NS_STYLE_BG_PROPAGATED_TO_PARENT);
|
||||
float percent;
|
||||
nsStyleCoord bordStyleRadius[4];
|
||||
PRInt16 borderRadii[4],i;
|
||||
|
@ -2208,7 +2210,6 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
|
|||
if (scrollFrame) {
|
||||
nsCOMPtr<nsIScrollableFrame> scrollableFrame ( do_QueryInterface(scrollFrame) );
|
||||
if ( scrollableFrame ) {
|
||||
|
||||
scrollableFrame->GetScrolledFrame(aPresContext, scrolledFrame);
|
||||
if (scrolledFrame) {
|
||||
nsRect rect;
|
||||
|
@ -2231,8 +2232,8 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
|
|||
NS_RELEASE(presShell);
|
||||
rootFrame->GetView(aPresContext, (nsIView**)&viewportView);
|
||||
|
||||
NS_ASSERTION(viewportView, "no viewport view");
|
||||
viewportView->GetDimensions(&viewportArea.width, &viewportArea.height);
|
||||
NS_ASSERTION(viewportView, "no viewport view");
|
||||
viewportView->GetDimensions(&viewportArea.width, &viewportArea.height);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2477,30 +2478,28 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
|
|||
// See if there's a background color specified. The background color
|
||||
// is rendered over the 'border' 'padding' and 'content' areas
|
||||
if (!transparentBG) {
|
||||
// get the radius for our border
|
||||
aSpacing.mBorderRadius.GetTop(bordStyleRadius[0]); //topleft
|
||||
aSpacing.mBorderRadius.GetRight(bordStyleRadius[1]); //topright
|
||||
aSpacing.mBorderRadius.GetBottom(bordStyleRadius[2]); //bottomright
|
||||
aSpacing.mBorderRadius.GetLeft(bordStyleRadius[3]); //bottomleft
|
||||
|
||||
|
||||
// get the radius for our border
|
||||
aSpacing.mBorderRadius.GetTop(bordStyleRadius[0]); //topleft
|
||||
aSpacing.mBorderRadius.GetRight(bordStyleRadius[1]); //topright
|
||||
aSpacing.mBorderRadius.GetBottom(bordStyleRadius[2]); //bottomright
|
||||
aSpacing.mBorderRadius.GetLeft(bordStyleRadius[3]); //bottomleft
|
||||
|
||||
for(i=0;i<4;i++) {
|
||||
borderRadii[i] = 0;
|
||||
switch ( bordStyleRadius[i].GetUnit()) {
|
||||
case eStyleUnit_Inherit:
|
||||
break;
|
||||
case eStyleUnit_Percent:
|
||||
percent = bordStyleRadius[i].GetPercentValue();
|
||||
borderRadii[i] = (nscoord)(percent * aBorderArea.width);
|
||||
break;
|
||||
case eStyleUnit_Coord:
|
||||
borderRadii[i] = bordStyleRadius[i].GetCoordValue();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
for(i=0;i<4;i++) {
|
||||
borderRadii[i] = 0;
|
||||
switch ( bordStyleRadius[i].GetUnit()) {
|
||||
case eStyleUnit_Inherit:
|
||||
break;
|
||||
case eStyleUnit_Percent:
|
||||
percent = bordStyleRadius[i].GetPercentValue();
|
||||
borderRadii[i] = (nscoord)(percent * aBorderArea.width);
|
||||
break;
|
||||
case eStyleUnit_Coord:
|
||||
borderRadii[i] = bordStyleRadius[i].GetCoordValue();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// rounded version of the border
|
||||
|
@ -2515,7 +2514,6 @@ nsCSSRendering::PaintBackground(nsIPresContext* aPresContext,
|
|||
aRenderingContext.FillRect(aBorderArea);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
|
|
|
@ -2032,11 +2032,23 @@ MapDeclarationColorInto(nsICSSDeclaration* aDeclaration,
|
|||
if (eCSSUnit_Inherit == ourColor->mBackColor.GetUnit()) { // do inherit first, so SetColor doesn't do it
|
||||
const nsStyleColor* inheritColor = parentColor;
|
||||
if (inheritColor->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_TO_PARENT) {
|
||||
// walk up the contexts until we get to a context that does not have its
|
||||
// background propagated to its parent (or a context that has had its background
|
||||
// propagated from its child)
|
||||
if (nsnull != aParentContext) {
|
||||
nsIStyleContext* grandParentContext = aParentContext->GetParent();
|
||||
if (nsnull != grandParentContext) {
|
||||
inheritColor = (const nsStyleColor*)grandParentContext->GetStyleData(eStyleStruct_Color);
|
||||
}
|
||||
nsCOMPtr<nsIStyleContext> higherContext = getter_AddRefs(aParentContext->GetParent());
|
||||
do {
|
||||
if (higherContext) {
|
||||
inheritColor = (const nsStyleColor*)higherContext->GetStyleData(eStyleStruct_Color);
|
||||
if (inheritColor &&
|
||||
(!(inheritColor->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_TO_PARENT)) ||
|
||||
(inheritColor->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_FROM_CHILD)) {
|
||||
// done walking up the higher contexts
|
||||
break;
|
||||
}
|
||||
higherContext = getter_AddRefs(higherContext->GetParent());
|
||||
}
|
||||
} while (higherContext);
|
||||
}
|
||||
}
|
||||
color->mBackgroundColor = inheritColor->mBackgroundColor;
|
||||
|
|
|
@ -2032,11 +2032,23 @@ MapDeclarationColorInto(nsICSSDeclaration* aDeclaration,
|
|||
if (eCSSUnit_Inherit == ourColor->mBackColor.GetUnit()) { // do inherit first, so SetColor doesn't do it
|
||||
const nsStyleColor* inheritColor = parentColor;
|
||||
if (inheritColor->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_TO_PARENT) {
|
||||
// walk up the contexts until we get to a context that does not have its
|
||||
// background propagated to its parent (or a context that has had its background
|
||||
// propagated from its child)
|
||||
if (nsnull != aParentContext) {
|
||||
nsIStyleContext* grandParentContext = aParentContext->GetParent();
|
||||
if (nsnull != grandParentContext) {
|
||||
inheritColor = (const nsStyleColor*)grandParentContext->GetStyleData(eStyleStruct_Color);
|
||||
}
|
||||
nsCOMPtr<nsIStyleContext> higherContext = getter_AddRefs(aParentContext->GetParent());
|
||||
do {
|
||||
if (higherContext) {
|
||||
inheritColor = (const nsStyleColor*)higherContext->GetStyleData(eStyleStruct_Color);
|
||||
if (inheritColor &&
|
||||
(!(inheritColor->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_TO_PARENT)) ||
|
||||
(inheritColor->mBackgroundFlags & NS_STYLE_BG_PROPAGATED_FROM_CHILD)) {
|
||||
// done walking up the higher contexts
|
||||
break;
|
||||
}
|
||||
higherContext = getter_AddRefs(higherContext->GetParent());
|
||||
}
|
||||
} while (higherContext);
|
||||
}
|
||||
}
|
||||
color->mBackgroundColor = inheritColor->mBackgroundColor;
|
||||
|
|
Загрузка…
Ссылка в новой задаче