Bug 494667. Don't apply optimization to shrink drawn background area to exclude solid borders, if we're not going to draw those borders (e.g. in tables with collapsing borders). r+sr=dbaron,a=beltzner

This commit is contained in:
Robert O'Callahan 2009-05-28 17:01:42 +12:00
parent f1db574761
commit 5843f756df
19 changed files with 111 additions and 27 deletions

View File

@ -1326,7 +1326,7 @@ nsCSSRendering::PaintBackground(nsPresContext* aPresContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
PRBool aUsePrintSettings,
PRUint32 aFlags,
nsRect* aBGClipRect)
{
NS_PRECONDITION(aForFrame,
@ -1353,8 +1353,8 @@ nsCSSRendering::PaintBackground(nsPresContext* aPresContext,
PaintBackgroundWithSC(aPresContext, aRenderingContext, aForFrame,
aDirtyRect, aBorderArea, *color,
*aForFrame->GetStyleBorder(),
aUsePrintSettings, aBGClipRect);
*aForFrame->GetStyleBorder(), aFlags,
aBGClipRect);
}
static PRBool
@ -1504,7 +1504,7 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext,
const nsRect& aBorderArea,
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
PRBool aUsePrintSettings,
PRUint32 aFlags,
nsRect* aBGClipRect)
{
NS_PRECONDITION(aForFrame,
@ -1530,8 +1530,8 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext,
// background colors.
PRBool drawBackgroundImage = PR_TRUE;
PRBool drawBackgroundColor = PR_TRUE;
if (aUsePrintSettings) {
PRBool usePrintSettings = aForFrame->HonorPrintBackgroundSettings();
if (usePrintSettings) {
drawBackgroundImage = aPresContext->GetBackgroundImageDraw();
drawBackgroundColor = aPresContext->GetBackgroundColorDraw();
}
@ -1612,7 +1612,8 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext,
// The background-color is drawn based on the bottom
// background-clip.
currentBackgroundClip = aColor.BottomLayer().mClip;
isSolidBorder = IsSolidBorder(aBorder);
isSolidBorder =
(aFlags & PAINT_WILL_PAINT_BORDER) && IsSolidBorder(aBorder);
if (isSolidBorder)
currentBackgroundClip = NS_STYLE_BG_CLIP_PADDING;
SetupBackgroundClip(ctx, currentBackgroundClip, aForFrame,
@ -1697,7 +1698,7 @@ nsCSSRendering::PaintBackgroundWithSC(nsPresContext* aPresContext,
if (!dirtyRectGfx.IsEmpty()) {
PaintBackgroundLayer(aPresContext, aRenderingContext, aForFrame,
dirtyRect, aBorderArea, bgClipArea, aColor,
layer, aBorder, aUsePrintSettings);
layer, aBorder, usePrintSettings);
}
}
}

View File

@ -174,12 +174,19 @@ struct nsCSSRendering {
* Both aDirtyRect and aBorderArea are in the local coordinate space
* of aForFrame
*/
enum {
/**
* When this flag is passed, the element's nsDisplayBorder will be
* painted immediately on top of this background.
*/
PAINT_WILL_PAINT_BORDER = 0x01
};
static void PaintBackground(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
nsIFrame* aForFrame,
const nsRect& aDirtyRect,
const nsRect& aBorderArea,
PRBool aUsePrintSettings,
PRUint32 aFlags,
nsRect* aBGClipRect = nsnull);
/**
@ -194,7 +201,7 @@ struct nsCSSRendering {
const nsRect& aBorderArea,
const nsStyleBackground& aColor,
const nsStyleBorder& aBorder,
PRBool aUsePrintSettings = PR_FALSE,
PRUint32 aFlags,
nsRect* aBGClipRect = nsnull);
/**

View File

@ -622,9 +622,15 @@ void
nsDisplayBackground::Paint(nsDisplayListBuilder* aBuilder,
nsIRenderingContext* aCtx, const nsRect& aDirtyRect) {
nsPoint offset = aBuilder->ToReferenceFrame(mFrame);
PRUint32 flags = 0;
nsDisplayItem* nextItem = GetAbove();
if (nextItem && nextItem->GetUnderlyingFrame() == mFrame &&
nextItem->GetType() == TYPE_BORDER) {
flags |= nsCSSRendering::PAINT_WILL_PAINT_BORDER;
}
nsCSSRendering::PaintBackground(mFrame->PresContext(), *aCtx, mFrame,
aDirtyRect, nsRect(offset, mFrame->GetSize()),
mFrame->HonorPrintBackgroundSettings());
flags);
}
nsRect

View File

@ -395,7 +395,8 @@ public:
TYPE_SVG_EFFECTS,
#endif
TYPE_WRAPLIST,
TYPE_TRANSFORM
TYPE_TRANSFORM,
TYPE_BORDER
};
struct HitTestState {
@ -1001,6 +1002,7 @@ public:
}
#endif
virtual Type GetType() { return TYPE_BORDER; }
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx,
const nsRect& aDirtyRect);
virtual PRBool OptimizeVisibility(nsDisplayListBuilder* aBuilder, nsRegion* aVisibleRegion);

View File

@ -269,7 +269,7 @@ nsButtonFrameRenderer::PaintBorderAndBackground(nsPresContext* aPresContext,
const nsStyleBorder* border = context->GetStyleBorder();
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, mFrame,
aDirtyRect, buttonRect, PR_FALSE);
aDirtyRect, buttonRect, 0);
nsCSSRendering::PaintBoxShadowInner(aPresContext, aRenderingContext,
mFrame, buttonRect, aDirtyRect);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, mFrame,

View File

@ -279,7 +279,7 @@ nsFieldSetFrame::PaintBorderBackground(nsIRenderingContext& aRenderingContext,
nsRect rect(aPt.x, aPt.y + yoff, mRect.width, mRect.height - yoff);
nsCSSRendering::PaintBackground(presContext, aRenderingContext, this,
aDirtyRect, rect, PR_TRUE);
aDirtyRect, rect, 0);
nsCSSRendering::PaintBoxShadowInner(presContext, aRenderingContext,
this, rect, aDirtyRect);

View File

@ -116,6 +116,8 @@ public:
}
#endif
virtual PRBool HonorPrintBackgroundSettings() { return PR_FALSE; }
// nsIFormControlFrame
void SetFocus(PRBool aOn, PRBool aRepaint);
virtual nsresult SetFormProperty(nsIAtom* aName, const nsAString& aValue);

View File

@ -433,8 +433,7 @@ public:
nsCSSRendering::PaintBackground(mFrame->PresContext(), *aCtx, mFrame,
aDirtyRect,
nsRect(offset, mFrame->GetSize()),
mFrame->HonorPrintBackgroundSettings(),
&bgClipRect);
0, &bgClipRect);
}
NS_DISPLAY_DECL_NAME("CanvasBackground")

View File

@ -576,7 +576,7 @@ nsPageFrame::PaintPageContent(nsIRenderingContext& aRenderingContext,
nsRect backgroundRect = nsRect(nsPoint(0, 0), pageContentFrame->GetSize());
nsCSSRendering::PaintBackground(PresContext(), aRenderingContext, this,
rect, backgroundRect, PR_TRUE);
rect, backgroundRect, 0);
nsLayoutUtils::PaintFrame(&aRenderingContext, pageContentFrame,
nsRegion(rect), NS_RGBA(0,0,0,0));

View File

@ -1934,7 +1934,7 @@ void nsDisplayMathMLCharBackground::Paint(nsDisplayListBuilder* aBuilder,
nsRect rect(mRect + aBuilder->ToReferenceFrame(mFrame));
nsCSSRendering::PaintBackgroundWithSC(mFrame->PresContext(), *aCtx, mFrame,
aDirtyRect, rect, *backg, *border,
PR_TRUE);
0);
}
class nsDisplayMathMLCharForeground : public nsDisplayItem {

View File

@ -0,0 +1,6 @@
<!DOCTYPE HTML>
<html>
<body>
<div style="width:200px; height:200px; background:lime;"></div>
</body>
</html>

View File

@ -0,0 +1,25 @@
<!DOCTYPE HTML>
<html>
<head>
<style>
table {
border-collapse: collapse;
background-color: red;
}
td, th {
background-color: lime;
width:100px;
height:100px;
}
td {
border-top: 4px solid lime;
}
</style>
</head>
<body>
<table cellpadding="0">
<tr><th colspan="2"></th></tr>
<tr><th></th><td></td>
</table>
</body>
</html>

View File

@ -0,0 +1,6 @@
<!DOCTYPE HTML>
<html>
<body>
<div style="width:212px; height:204px; background:lime;"></div>
</body>
</html>

View File

@ -0,0 +1,26 @@
<!DOCTYPE HTML>
<html>
<head>
<style>
table {
border-collapse: collapse;
background-color: red;
}
td, th {
background-color: lime;
width:100px;
height:100px;
border:4px solid lime;
}
td {
border-top:hidden;
}
</style>
</head>
<body>
<table cellpadding="0">
<tr><th colspan="2"></th></tr>
<tr><th></th><td></td>
</table>
</body>
</html>

View File

@ -1240,3 +1240,5 @@ fails-if(MOZ_WIDGET_TOOLKIT!="cocoa") == 488692-1.html 488692-1-ref.html # needs
== 490173-2.html 490173-2-ref.html
== 491323-1.xul 491323-1-ref.xul
== 493968-1.html 493968-1-ref.html
== 494667-1.html 494667-1-ref.html
== 494667-2.html 494667-2-ref.html

View File

@ -365,7 +365,7 @@ nsTableCellFrame::PaintBackground(nsIRenderingContext& aRenderingContext,
{
nsRect rect(aPt, GetSize());
nsCSSRendering::PaintBackground(PresContext(), aRenderingContext, this,
aDirtyRect, rect, PR_TRUE);
aDirtyRect, rect, 0);
}
// Called by nsTablePainter
@ -1210,5 +1210,5 @@ nsBCTableCellFrame::PaintBackground(nsIRenderingContext& aRenderingContext,
nsCSSRendering::PaintBackgroundWithSC(PresContext(), aRenderingContext, this,
aDirtyRect, rect,
*GetStyleBackground(), myBorder,
PR_TRUE, nsnull);
0, nsnull);
}

View File

@ -326,7 +326,7 @@ TableBackgroundPainter::PaintTableFrame(nsTableFrame* aTableFrame,
tableData.mRect + mRenderPt,
*tableData.mBackground,
*tableData.mBorder,
PR_TRUE);
0);
}
tableData.Destroy(mPresContext);
return NS_OK;
@ -631,7 +631,7 @@ TableBackgroundPainter::PaintCell(nsTableCellFrame* aCell,
mCols[colIndex].mColGroup->mRect + mRenderPt,
*mCols[colIndex].mColGroup->mBackground,
*mCols[colIndex].mColGroup->mBorder,
PR_TRUE, &mCellRect);
0, &mCellRect);
}
//Paint column background
@ -641,7 +641,7 @@ TableBackgroundPainter::PaintCell(nsTableCellFrame* aCell,
mCols[colIndex].mCol.mRect + mRenderPt,
*mCols[colIndex].mCol.mBackground,
*mCols[colIndex].mCol.mBorder,
PR_TRUE, &mCellRect);
0, &mCellRect);
}
//Paint row group background
@ -650,7 +650,7 @@ TableBackgroundPainter::PaintCell(nsTableCellFrame* aCell,
mRowGroup.mFrame, mDirtyRect,
mRowGroup.mRect + mRenderPt,
*mRowGroup.mBackground, *mRowGroup.mBorder,
PR_TRUE, &mCellRect);
0, &mCellRect);
}
//Paint row background
@ -659,7 +659,7 @@ TableBackgroundPainter::PaintCell(nsTableCellFrame* aCell,
mRow.mFrame, mDirtyRect,
mRow.mRect + mRenderPt,
*mRow.mBackground, *mRow.mBorder,
PR_TRUE, &mCellRect);
0, &mCellRect);
}
//Paint cell background in border-collapse unless we're just passing

View File

@ -60,6 +60,8 @@ public:
}
#endif
virtual PRBool HonorPrintBackgroundSettings() { return PR_FALSE; }
void PaintBorderBackground(nsIRenderingContext& aRenderingContext,
nsPoint aPt, const nsRect& aDirtyRect);
@ -173,7 +175,7 @@ nsGroupBoxFrame::PaintBorderBackground(nsIRenderingContext& aRenderingContext,
groupRect += aPt;
nsCSSRendering::PaintBackground(presContext, aRenderingContext, this,
aDirtyRect, rect, PR_FALSE);
aDirtyRect, rect, 0);
if (groupBox) {

View File

@ -3910,7 +3910,7 @@ nsTreeBodyFrame::PaintBackgroundLayer(nsStyleContext* aStyleContext,
nsCSSRendering::PaintBackgroundWithSC(aPresContext, aRenderingContext,
this, aDirtyRect, aRect,
*myColor, *myBorder, PR_TRUE);
*myColor, *myBorder, 0);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, aRect, *myBorder, mStyleContext);