Bug 1237902 (part 2) - Pass a DrawTarget to DrawTableBorderSegment(). r=roc.

And to several functions above it in the callgraph, ones that no longer need an
nsRenderingContext.
This commit is contained in:
Nicholas Nethercote 2016-01-07 20:20:06 -08:00
parent 61beecdc3b
commit 7a83b373b0
4 changed files with 46 additions and 52 deletions

View File

@ -3868,7 +3868,7 @@ GetDashInfo(nscoord aBorderLength,
}
void
nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
uint8_t aBorderStyle,
nscolor aBorderColor,
const nsStyleBackground* aBGColor,
@ -3891,8 +3891,6 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
aEndBevelOffset = 0;
}
DrawTarget& drawTarget = *aContext.GetDrawTarget();
switch (aBorderStyle) {
case NS_STYLE_BORDER_STYLE_NONE:
case NS_STYLE_BORDER_STYLE_HIDDEN:
@ -3915,36 +3913,36 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
GetDashInfo(aBorder.width, dashLength, twipsPerPixel, numDashSpaces,
startDashLength, endDashLength);
nsRect rect(aBorder.x, aBorder.y, startDashLength, aBorder.height);
DrawSolidBorderSegment(drawTarget, rect, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, rect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel);
rect.x += startDashLength + dashLength;
rect.width = aBorder.width
- (startDashLength + endDashLength + dashLength);
DrawDashedSegment(drawTarget, rect, dashLength, aBorderColor,
DrawDashedSegment(aDrawTarget, rect, dashLength, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel, horizontal);
rect.x += rect.width;
rect.width = endDashLength;
DrawSolidBorderSegment(drawTarget, rect, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, rect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel);
}
else {
GetDashInfo(aBorder.height, dashLength, twipsPerPixel, numDashSpaces,
startDashLength, endDashLength);
nsRect rect(aBorder.x, aBorder.y, aBorder.width, startDashLength);
DrawSolidBorderSegment(drawTarget, rect, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, rect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel);
rect.y += rect.height + dashLength;
rect.height = aBorder.height
- (startDashLength + endDashLength + dashLength);
DrawDashedSegment(drawTarget, rect, dashLength, aBorderColor,
DrawDashedSegment(aDrawTarget, rect, dashLength, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel, horizontal);
rect.y += rect.height;
rect.height = endDashLength;
DrawSolidBorderSegment(drawTarget, rect, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, rect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel);
}
}
@ -3956,7 +3954,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if ((horizontal && (twipsPerPixel >= aBorder.height)) ||
(!horizontal && (twipsPerPixel >= aBorder.width))) {
// a one pixel border
DrawSolidBorderSegment(drawTarget, aBorder, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, aBorder, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aStartBevelSide, aStartBevelOffset,
aEndBevelSide, aEndBevelOffset);
@ -3984,7 +3982,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_TOP == aEndBevelSide) {
rect.width -= endBevel;
}
DrawSolidBorderSegment(drawTarget, rect, bevelColor,
DrawSolidBorderSegment(aDrawTarget, rect, bevelColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
@ -3999,7 +3997,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_LEFT == aEndBevelSide) {
rect.height -= endBevel;
}
DrawSolidBorderSegment(drawTarget, rect, bevelColor,
DrawSolidBorderSegment(aDrawTarget, rect, bevelColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
@ -4021,7 +4019,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_BOTTOM == aEndBevelSide) {
rect.width -= endBevel;
}
DrawSolidBorderSegment(drawTarget, rect, bevelColor,
DrawSolidBorderSegment(aDrawTarget, rect, bevelColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
@ -4036,7 +4034,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_RIGHT == aEndBevelSide) {
rect.height -= endBevel;
}
DrawSolidBorderSegment(drawTarget, rect, bevelColor,
DrawSolidBorderSegment(aDrawTarget, rect, bevelColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
@ -4065,7 +4063,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_TOP == aEndBevelSide) {
topRect.width -= aEndBevelOffset - endBevel;
}
DrawSolidBorderSegment(drawTarget, topRect, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, topRect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
@ -4080,7 +4078,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_BOTTOM == aEndBevelSide) {
bottomRect.width -= aEndBevelOffset - endBevel;
}
DrawSolidBorderSegment(drawTarget, bottomRect, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, bottomRect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
@ -4096,7 +4094,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_LEFT == aEndBevelSide) {
leftRect.height -= aEndBevelOffset - endBevel;
}
DrawSolidBorderSegment(drawTarget, leftRect, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, leftRect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
@ -4110,7 +4108,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
if (NS_SIDE_RIGHT == aEndBevelSide) {
rightRect.height -= aEndBevelOffset - endBevel;
}
DrawSolidBorderSegment(drawTarget, rightRect, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, rightRect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
@ -4120,7 +4118,7 @@ nsCSSRendering::DrawTableBorderSegment(nsRenderingContext& aContext,
// else fall through to solid
MOZ_FALLTHROUGH;
case NS_STYLE_BORDER_STYLE_SOLID:
DrawSolidBorderSegment(drawTarget, aBorder, aBorderColor,
DrawSolidBorderSegment(aDrawTarget, aBorder, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel, aStartBevelSide,
aStartBevelOffset, aEndBevelSide, aEndBevelOffset);
break;

View File

@ -644,8 +644,8 @@ struct nsCSSRendering {
// Draw a border segment in the table collapsing border model without
// beveling corners
static void DrawTableBorderSegment(nsRenderingContext& aContext,
uint8_t aBorderStyle,
static void DrawTableBorderSegment(DrawTarget& aDrawTarget,
uint8_t aBorderStyle,
nscolor aBorderColor,
const nsStyleBackground* aBGColor,
const nsRect& aBorderRect,

View File

@ -1417,7 +1417,7 @@ nsTableFrame::PaintTableBorderBackground(nsDisplayListBuilder* aBuilder,
gfxContextMatrixAutoSaveRestore autoSR(ctx);
ctx->SetMatrix(ctx->CurrentMatrix().Translate(devPixelOffset));
PaintBCBorders(aRenderingContext, aDirtyRect - aPt);
PaintBCBorders(*aRenderingContext.GetDrawTarget(), aDirtyRect - aPt);
}
}
@ -6230,7 +6230,7 @@ struct BCBlockDirSeg
void Paint(BCPaintBorderIterator& aIter,
nsRenderingContext& aRenderingContext,
DrawTarget& aDrawTarget,
BCPixelSize aInlineSegBSize);
void AdvanceOffsetB();
void IncludeCurrentBorder(BCPaintBorderIterator& aIter);
@ -6280,8 +6280,7 @@ struct BCInlineDirSeg
BCPixelSize aIStartSegISize);
void AdvanceOffsetI();
void IncludeCurrentBorder(BCPaintBorderIterator& aIter);
void Paint(BCPaintBorderIterator& aIter,
nsRenderingContext& aRenderingContext);
void Paint(BCPaintBorderIterator& aIter, DrawTarget& aDrawTarget);
nscoord mOffsetI; // i-offset with respect to the table edge
nscoord mOffsetB; // b-offset with respect to the table edge
@ -6325,8 +6324,8 @@ public:
bool SetDamageArea(const nsRect& aDamageRect);
void First();
void Next();
void AccumulateOrPaintInlineDirSegment(nsRenderingContext& aRenderingContext);
void AccumulateOrPaintBlockDirSegment(nsRenderingContext& aRenderingContext);
void AccumulateOrPaintInlineDirSegment(DrawTarget& aDrawTarget);
void AccumulateOrPaintBlockDirSegment(DrawTarget& aDrawTarget);
void ResetVerInfo();
void StoreColumnWidth(int32_t aIndex);
bool BlockDirSegmentOwnsCorner();
@ -6952,14 +6951,14 @@ BCBlockDirSeg::GetBEndCorner(BCPaintBorderIterator& aIter,
/**
* Paint the block-dir segment
* @param aIter - iterator containing the structural information
* @param aRenderingContext - the rendering context
* @param aInlineSegBSize - the width of the inline-dir segment joining the corner
* at the start
* @param aIter - iterator containing the structural information
* @param aDrawTarget - the draw target
* @param aInlineSegBSize - the width of the inline-dir segment joining the
* corner at the start
*/
void
BCBlockDirSeg::Paint(BCPaintBorderIterator& aIter,
nsRenderingContext& aRenderingContext,
DrawTarget& aDrawTarget,
BCPixelSize aInlineSegBSize)
{
// get the border style, color and paint the segment
@ -7065,7 +7064,7 @@ BCBlockDirSeg::Paint(BCPaintBorderIterator& aIter,
Swap(startBevelSide, endBevelSide);
Swap(startBevelOffset, endBevelOffset);
}
nsCSSRendering::DrawTableBorderSegment(aRenderingContext, style, color,
nsCSSRendering::DrawTableBorderSegment(aDrawTarget, style, color,
aIter.mTableBgColor, physicalRect,
appUnitsPerDevPixel,
nsPresContext::AppUnitsPerCSSPixel(),
@ -7167,12 +7166,11 @@ BCInlineDirSeg::GetIEndCorner(BCPaintBorderIterator& aIter,
/**
* Paint the inline-dir segment
* @param aIter - iterator containing the structural information
* @param aRenderingContext - the rendering context
* @param aIter - iterator containing the structural information
* @param aDrawTarget - the draw target
*/
void
BCInlineDirSeg::Paint(BCPaintBorderIterator& aIter,
nsRenderingContext& aRenderingContext)
BCInlineDirSeg::Paint(BCPaintBorderIterator& aIter, DrawTarget& aDrawTarget)
{
// get the border style, color and paint the segment
LogicalSide side =
@ -7270,7 +7268,7 @@ BCInlineDirSeg::Paint(BCPaintBorderIterator& aIter,
Swap(startBevelSide, endBevelSide);
Swap(startBevelOffset, endBevelOffset);
}
nsCSSRendering::DrawTableBorderSegment(aRenderingContext, style, color,
nsCSSRendering::DrawTableBorderSegment(aDrawTarget, style, color,
aIter.mTableBgColor, physicalRect,
appUnitsPerDevPixel,
nsPresContext::AppUnitsPerCSSPixel(),
@ -7329,10 +7327,10 @@ BCPaintBorderIterator::BlockDirSegmentOwnsCorner()
/**
* Paint if necessary an inline-dir segment, otherwise accumulate it
* @param aRenderingContext - the rendering context
* @param aDrawTarget - the draw target
*/
void
BCPaintBorderIterator::AccumulateOrPaintInlineDirSegment(nsRenderingContext& aRenderingContext)
BCPaintBorderIterator::AccumulateOrPaintInlineDirSegment(DrawTarget& aDrawTarget)
{
int32_t relColIndex = GetRelativeColIndex();
@ -7365,7 +7363,7 @@ BCPaintBorderIterator::AccumulateOrPaintInlineDirSegment(nsRenderingContext& aRe
if (mInlineSeg.mLength > 0) {
mInlineSeg.GetIEndCorner(*this, iStartSegISize);
if (mInlineSeg.mWidth > 0) {
mInlineSeg.Paint(*this, aRenderingContext);
mInlineSeg.Paint(*this, aDrawTarget);
}
mInlineSeg.AdvanceOffsetI();
}
@ -7377,10 +7375,10 @@ BCPaintBorderIterator::AccumulateOrPaintInlineDirSegment(nsRenderingContext& aRe
}
/**
* Paint if necessary a block-dir segment, otherwise accumulate it
* @param aRenderingContext - the rendering context
* @param aDrawTarget - the draw target
*/
void
BCPaintBorderIterator::AccumulateOrPaintBlockDirSegment(nsRenderingContext& aRenderingContext)
BCPaintBorderIterator::AccumulateOrPaintBlockDirSegment(DrawTarget& aDrawTarget)
{
BCBorderOwner borderOwner = eCellOwner;
BCBorderOwner ignoreBorderOwner;
@ -7407,7 +7405,7 @@ BCPaintBorderIterator::AccumulateOrPaintBlockDirSegment(nsRenderingContext& aRen
if (blockDirSeg.mLength > 0) {
blockDirSeg.GetBEndCorner(*this, inlineSegBSize);
if (blockDirSeg.mWidth > 0) {
blockDirSeg.Paint(*this, aRenderingContext, inlineSegBSize);
blockDirSeg.Paint(*this, aDrawTarget, inlineSegBSize);
}
blockDirSeg.AdvanceOffsetB();
}
@ -7435,12 +7433,11 @@ BCPaintBorderIterator::ResetVerInfo()
/**
* Method to paint BCBorders, this does not use currently display lists although
* it will do this in future
* @param aRenderingContext - the rendering context
* @param aDirtyRect - inside this rectangle the BC Borders will redrawn
* @param aDrawTarget - the rendering context
* @param aDirtyRect - inside this rectangle the BC Borders will redrawn
*/
void
nsTableFrame::PaintBCBorders(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect)
nsTableFrame::PaintBCBorders(DrawTarget& aDrawTarget, const nsRect& aDirtyRect)
{
// We first transfer the aDirtyRect into cellmap coordinates to compute which
// cell borders need to be painted
@ -7459,7 +7456,7 @@ nsTableFrame::PaintBCBorders(nsRenderingContext& aRenderingContext,
// this we the now active segment with the current border. These
// segments are stored in mBlockDirInfo to be used on the next row
for (iter.First(); !iter.mAtEnd; iter.Next()) {
iter.AccumulateOrPaintBlockDirSegment(aRenderingContext);
iter.AccumulateOrPaintBlockDirSegment(aDrawTarget);
}
// Next, paint all of the inline-dir border segments from bStart to bEnd reuse
@ -7467,7 +7464,7 @@ nsTableFrame::PaintBCBorders(nsRenderingContext& aRenderingContext,
// corner calculations
iter.Reset();
for (iter.First(); !iter.mAtEnd; iter.Next()) {
iter.AccumulateOrPaintInlineDirSegment(aRenderingContext);
iter.AccumulateOrPaintInlineDirSegment(aDrawTarget);
}
}

View File

@ -312,8 +312,7 @@ public:
void AddBCDamageArea(const mozilla::TableArea& aValue);
bool BCRecalcNeeded(nsStyleContext* aOldStyleContext,
nsStyleContext* aNewStyleContext);
void PaintBCBorders(nsRenderingContext& aRenderingContext,
const nsRect& aDirtyRect);
void PaintBCBorders(DrawTarget& aDrawTarget, const nsRect& aDirtyRect);
virtual void MarkIntrinsicISizesDirty() override;
// For border-collapse tables, the caller must not add padding and