Bug 895096 - Part 1: Round border-collapsed table borders to device pixels rather than CSS pixels, as for other borders, and store them (as BCPixelSize) as device pixels rather than CSS pixels. r=dbaron

MozReview-Commit-ID: 3yqj8gAAGYv
This commit is contained in:
Ya-Chieh Wu 2017-09-12 19:48:00 -04:00
Родитель 084e79f16c
Коммит ce1be4b4eb
11 изменённых файлов: 136 добавлений и 113 удалений

Просмотреть файл

@ -3473,17 +3473,16 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
nscolor aBGColor,
const nsRect& aBorder,
int32_t aAppUnitsPerDevPixel,
int32_t aAppUnitsPerCSSPixel,
mozilla::Side aStartBevelSide,
nscoord aStartBevelOffset,
mozilla::Side aEndBevelSide,
nscoord aEndBevelOffset)
{
bool horizontal = ((eSideTop == aStartBevelSide) || (eSideBottom == aStartBevelSide));
nscoord twipsPerPixel = NSIntPixelsToAppUnits(1, aAppUnitsPerCSSPixel);
nscoord oneDevPixel = NSIntPixelsToAppUnits(1, aAppUnitsPerDevPixel);
uint8_t ridgeGroove = NS_STYLE_BORDER_STYLE_RIDGE;
if ((twipsPerPixel >= aBorder.width) || (twipsPerPixel >= aBorder.height) ||
if ((oneDevPixel >= aBorder.width) || (oneDevPixel >= aBorder.height) ||
(NS_STYLE_BORDER_STYLE_DASHED == aBorderStyle) || (NS_STYLE_BORDER_STYLE_DOTTED == aBorderStyle)) {
// no beveling for 1 pixel border, dash or dot
aStartBevelOffset = 0;
@ -3503,46 +3502,48 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
dashLength *= (horizontal) ? aBorder.height : aBorder.width;
// make the min dash length for the ends 1/2 the dash length
nscoord minDashLength = (NS_STYLE_BORDER_STYLE_DASHED == aBorderStyle)
? RoundFloatToPixel(((float)dashLength) / 2.0f, twipsPerPixel) : dashLength;
minDashLength = std::max(minDashLength, twipsPerPixel);
? RoundFloatToPixel(((float)dashLength) / 2.0f,
aAppUnitsPerDevPixel)
: dashLength;
minDashLength = std::max(minDashLength, oneDevPixel);
nscoord numDashSpaces = 0;
nscoord startDashLength = minDashLength;
nscoord endDashLength = minDashLength;
if (horizontal) {
GetDashInfo(aBorder.width, dashLength, twipsPerPixel, numDashSpaces,
startDashLength, endDashLength);
GetDashInfo(aBorder.width, dashLength, aAppUnitsPerDevPixel,
numDashSpaces, startDashLength, endDashLength);
nsRect rect(aBorder.x, aBorder.y, startDashLength, aBorder.height);
DrawSolidBorderSegment(aDrawTarget, rect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel);
aAppUnitsPerDevPixel, oneDevPixel);
rect.x += startDashLength + dashLength;
rect.width = aBorder.width
- (startDashLength + endDashLength + dashLength);
DrawDashedSegment(aDrawTarget, rect, dashLength, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel, horizontal);
aAppUnitsPerDevPixel, oneDevPixel, horizontal);
rect.x += rect.width;
rect.width = endDashLength;
DrawSolidBorderSegment(aDrawTarget, rect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel);
aAppUnitsPerDevPixel, oneDevPixel);
}
else {
GetDashInfo(aBorder.height, dashLength, twipsPerPixel, numDashSpaces,
startDashLength, endDashLength);
GetDashInfo(aBorder.height, dashLength, aAppUnitsPerDevPixel,
numDashSpaces, startDashLength, endDashLength);
nsRect rect(aBorder.x, aBorder.y, aBorder.width, startDashLength);
DrawSolidBorderSegment(aDrawTarget, rect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel);
aAppUnitsPerDevPixel, oneDevPixel);
rect.y += rect.height + dashLength;
rect.height = aBorder.height
- (startDashLength + endDashLength + dashLength);
DrawDashedSegment(aDrawTarget, rect, dashLength, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel, horizontal);
aAppUnitsPerDevPixel, oneDevPixel, horizontal);
rect.y += rect.height;
rect.height = endDashLength;
DrawSolidBorderSegment(aDrawTarget, rect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel);
aAppUnitsPerDevPixel, oneDevPixel);
}
}
break;
@ -3550,19 +3551,21 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
ridgeGroove = NS_STYLE_BORDER_STYLE_GROOVE; // and fall through to ridge
MOZ_FALLTHROUGH;
case NS_STYLE_BORDER_STYLE_RIDGE:
if ((horizontal && (twipsPerPixel >= aBorder.height)) ||
(!horizontal && (twipsPerPixel >= aBorder.width))) {
if ((horizontal && (oneDevPixel >= aBorder.height)) ||
(!horizontal && (oneDevPixel >= aBorder.width))) {
// a one pixel border
DrawSolidBorderSegment(aDrawTarget, aBorder, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aAppUnitsPerDevPixel, oneDevPixel,
aStartBevelSide, aStartBevelOffset,
aEndBevelSide, aEndBevelOffset);
}
else {
nscoord startBevel = (aStartBevelOffset > 0)
? RoundFloatToPixel(0.5f * (float)aStartBevelOffset, twipsPerPixel, true) : 0;
? RoundFloatToPixel(0.5f * (float)aStartBevelOffset,
aAppUnitsPerDevPixel, true) : 0;
nscoord endBevel = (aEndBevelOffset > 0)
? RoundFloatToPixel(0.5f * (float)aEndBevelOffset, twipsPerPixel, true) : 0;
? RoundFloatToPixel(0.5f * (float)aEndBevelOffset,
aAppUnitsPerDevPixel, true) : 0;
mozilla::Side ridgeGrooveSide = (horizontal) ? eSideTop : eSideLeft;
// FIXME: In theory, this should use the visited-dependent
// background color, but I don't care.
@ -3571,7 +3574,8 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
nsRect rect(aBorder);
nscoord half;
if (horizontal) { // top, bottom
half = RoundFloatToPixel(0.5f * (float)aBorder.height, twipsPerPixel);
half = RoundFloatToPixel(0.5f * (float)aBorder.height,
aAppUnitsPerDevPixel);
rect.height = half;
if (eSideTop == aStartBevelSide) {
rect.x += startBevel;
@ -3581,12 +3585,13 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
rect.width -= endBevel;
}
DrawSolidBorderSegment(aDrawTarget, rect, bevelColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aAppUnitsPerDevPixel, oneDevPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
}
else { // left, right
half = RoundFloatToPixel(0.5f * (float)aBorder.width, twipsPerPixel);
half = RoundFloatToPixel(0.5f * (float)aBorder.width,
aAppUnitsPerDevPixel);
rect.width = half;
if (eSideLeft == aStartBevelSide) {
rect.y += startBevel;
@ -3596,7 +3601,7 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
rect.height -= endBevel;
}
DrawSolidBorderSegment(aDrawTarget, rect, bevelColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aAppUnitsPerDevPixel, oneDevPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
}
@ -3618,7 +3623,7 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
rect.width -= endBevel;
}
DrawSolidBorderSegment(aDrawTarget, rect, bevelColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aAppUnitsPerDevPixel, oneDevPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
}
@ -3633,7 +3638,7 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
rect.height -= endBevel;
}
DrawSolidBorderSegment(aDrawTarget, rect, bevelColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aAppUnitsPerDevPixel, oneDevPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
}
@ -3643,14 +3648,20 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
// We can only do "double" borders if the thickness of the border
// is more than 2px. Otherwise, we fall through to painting a
// solid border.
if ((aBorder.width > 2*twipsPerPixel || horizontal) &&
(aBorder.height > 2*twipsPerPixel || !horizontal)) {
if ((aBorder.width > 2 * oneDevPixel || horizontal) &&
(aBorder.height > 2 * oneDevPixel || !horizontal)) {
nscoord startBevel = (aStartBevelOffset > 0)
? RoundFloatToPixel(0.333333f * (float)aStartBevelOffset, twipsPerPixel) : 0;
? RoundFloatToPixel(0.333333f *
(float)aStartBevelOffset,
aAppUnitsPerDevPixel) : 0;
nscoord endBevel = (aEndBevelOffset > 0)
? RoundFloatToPixel(0.333333f * (float)aEndBevelOffset, twipsPerPixel) : 0;
? RoundFloatToPixel(0.333333f *
(float)aEndBevelOffset,
aAppUnitsPerDevPixel) : 0;
if (horizontal) { // top, bottom
nscoord thirdHeight = RoundFloatToPixel(0.333333f * (float)aBorder.height, twipsPerPixel);
nscoord thirdHeight = RoundFloatToPixel(0.333333f *
(float)aBorder.height,
aAppUnitsPerDevPixel);
// draw the top line or rect
nsRect topRect(aBorder.x, aBorder.y, aBorder.width, thirdHeight);
@ -3662,7 +3673,7 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
topRect.width -= aEndBevelOffset - endBevel;
}
DrawSolidBorderSegment(aDrawTarget, topRect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aAppUnitsPerDevPixel, oneDevPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
@ -3677,12 +3688,13 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
bottomRect.width -= aEndBevelOffset - endBevel;
}
DrawSolidBorderSegment(aDrawTarget, bottomRect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aAppUnitsPerDevPixel, oneDevPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
}
else { // left, right
nscoord thirdWidth = RoundFloatToPixel(0.333333f * (float)aBorder.width, twipsPerPixel);
nscoord thirdWidth = RoundFloatToPixel(0.333333f * (float)aBorder.width,
aAppUnitsPerDevPixel);
nsRect leftRect(aBorder.x, aBorder.y, thirdWidth, aBorder.height);
if (eSideLeft == aStartBevelSide) {
@ -3693,7 +3705,7 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
leftRect.height -= aEndBevelOffset - endBevel;
}
DrawSolidBorderSegment(aDrawTarget, leftRect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aAppUnitsPerDevPixel, oneDevPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
@ -3707,7 +3719,7 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
rightRect.height -= aEndBevelOffset - endBevel;
}
DrawSolidBorderSegment(aDrawTarget, rightRect, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel,
aAppUnitsPerDevPixel, oneDevPixel,
aStartBevelSide, startBevel, aEndBevelSide,
endBevel);
}
@ -3717,7 +3729,7 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget,
MOZ_FALLTHROUGH;
case NS_STYLE_BORDER_STYLE_SOLID:
DrawSolidBorderSegment(aDrawTarget, aBorder, aBorderColor,
aAppUnitsPerDevPixel, twipsPerPixel, aStartBevelSide,
aAppUnitsPerDevPixel, oneDevPixel, aStartBevelSide,
aStartBevelOffset, aEndBevelSide, aEndBevelOffset);
break;
case NS_STYLE_BORDER_STYLE_OUTSET:

Просмотреть файл

@ -550,7 +550,6 @@ struct nsCSSRendering {
nscolor aBGColor,
const nsRect& aBorderRect,
int32_t aAppUnitsPerDevPixel,
int32_t aAppUnitsPerCSSPixel,
mozilla::Side aStartBevelSide = mozilla::eSideTop,
nscoord aStartBevelOffset = 0,
mozilla::Side aEndBevelSide = mozilla::eSideTop,

Просмотреть файл

@ -144,6 +144,7 @@ enum BCBorderOwner
eAjaCellOwner = 10 // cell to the top or to the left
};
// BCPixelSize is in device pixels.
typedef uint16_t BCPixelSize;
// These are the max sizes that are stored. If they are exceeded, then the max is stored and

Просмотреть файл

@ -1142,12 +1142,12 @@ nsBCTableCellFrame::GetFrameName(nsAString& aResult) const
LogicalMargin
nsBCTableCellFrame::GetBorderWidth(WritingMode aWM) const
{
int32_t pixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
int32_t d2a = PresContext()->AppUnitsPerDevPixel();
return LogicalMargin(aWM,
BC_BORDER_END_HALF_COORD(pixelsToTwips, mBStartBorder),
BC_BORDER_START_HALF_COORD(pixelsToTwips, mIEndBorder),
BC_BORDER_START_HALF_COORD(pixelsToTwips, mBEndBorder),
BC_BORDER_END_HALF_COORD(pixelsToTwips, mIStartBorder));
BC_BORDER_END_HALF_COORD(d2a, mBStartBorder),
BC_BORDER_START_HALF_COORD(d2a, mIEndBorder),
BC_BORDER_START_HALF_COORD(d2a, mBEndBorder),
BC_BORDER_END_HALF_COORD(d2a, mIStartBorder));
}
BCPixelSize
@ -1187,12 +1187,12 @@ nsBCTableCellFrame::SetBorderWidth(LogicalSide aSide, BCPixelSize aValue)
nsBCTableCellFrame::GetBorderOverflow()
{
WritingMode wm = GetWritingMode();
int32_t p2t = nsPresContext::AppUnitsPerCSSPixel();
int32_t d2a = PresContext()->AppUnitsPerDevPixel();
LogicalMargin halfBorder(wm,
BC_BORDER_START_HALF_COORD(p2t, mBStartBorder),
BC_BORDER_END_HALF_COORD(p2t, mIEndBorder),
BC_BORDER_END_HALF_COORD(p2t, mBEndBorder),
BC_BORDER_START_HALF_COORD(p2t, mIStartBorder));
BC_BORDER_START_HALF_COORD(d2a, mBStartBorder),
BC_BORDER_END_HALF_COORD(d2a, mIEndBorder),
BC_BORDER_END_HALF_COORD(d2a, mBEndBorder),
BC_BORDER_START_HALF_COORD(d2a, mIStartBorder));
return halfBorder.GetPhysicalMargin(wm);
}

Просмотреть файл

@ -327,14 +327,14 @@ inline nscoord
nsTableColFrame::GetContinuousBCBorderWidth(mozilla::WritingMode aWM,
mozilla::LogicalMargin& aBorder)
{
int32_t aPixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
aBorder.BStart(aWM) = BC_BORDER_END_HALF_COORD(aPixelsToTwips,
int32_t d2a = PresContext()->AppUnitsPerDevPixel();
aBorder.BStart(aWM) = BC_BORDER_END_HALF_COORD(d2a,
mBStartContBorderWidth);
aBorder.IEnd(aWM) = BC_BORDER_START_HALF_COORD(aPixelsToTwips,
aBorder.IEnd(aWM) = BC_BORDER_START_HALF_COORD(d2a,
mIEndContBorderWidth);
aBorder.BEnd(aWM) = BC_BORDER_START_HALF_COORD(aPixelsToTwips,
aBorder.BEnd(aWM) = BC_BORDER_START_HALF_COORD(d2a,
mBEndContBorderWidth);
return BC_BORDER_END_HALF_COORD(aPixelsToTwips, mIEndContBorderWidth);
return BC_BORDER_END_HALF_COORD(d2a, mIEndContBorderWidth);
}
#endif

Просмотреть файл

@ -444,13 +444,13 @@ void nsTableColGroupFrame::SetContinuousBCBorderWidth(LogicalSide aForSide,
void nsTableColGroupFrame::GetContinuousBCBorderWidth(WritingMode aWM,
LogicalMargin& aBorder)
{
int32_t aPixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
int32_t d2a = PresContext()->AppUnitsPerDevPixel();
nsTableColFrame* col = GetTableFrame()->
GetColFrame(mStartColIndex + mColCount - 1);
col->GetContinuousBCBorderWidth(aWM, aBorder);
aBorder.BStart(aWM) = BC_BORDER_END_HALF_COORD(aPixelsToTwips,
aBorder.BStart(aWM) = BC_BORDER_END_HALF_COORD(d2a,
mBStartContBorderWidth);
aBorder.BEnd(aWM) = BC_BORDER_START_HALF_COORD(aPixelsToTwips,
aBorder.BEnd(aWM) = BC_BORDER_START_HALF_COORD(d2a,
mBEndContBorderWidth);
}

Просмотреть файл

@ -2925,15 +2925,14 @@ nsTableFrame::GetOuterBCBorder(const WritingMode aWM) const
if (NeedToCalcBCBorders()) {
const_cast<nsTableFrame*>(this)->CalcBCBorders();
}
int32_t p2t = nsPresContext::AppUnitsPerCSSPixel();
int32_t d2a = PresContext()->AppUnitsPerDevPixel();
BCPropertyData* propData = GetBCProperty();
if (propData) {
return LogicalMargin(aWM,
BC_BORDER_START_HALF_COORD(p2t, propData->mBStartBorderWidth),
BC_BORDER_END_HALF_COORD(p2t, propData->mIEndBorderWidth),
BC_BORDER_END_HALF_COORD(p2t, propData->mBEndBorderWidth),
BC_BORDER_START_HALF_COORD(p2t, propData->mIStartBorderWidth));
BC_BORDER_START_HALF_COORD(d2a, propData->mBStartBorderWidth),
BC_BORDER_END_HALF_COORD(d2a, propData->mIEndBorderWidth),
BC_BORDER_END_HALF_COORD(d2a, propData->mBEndBorderWidth),
BC_BORDER_START_HALF_COORD(d2a, propData->mIStartBorderWidth));
}
return LogicalMargin(aWM);
}
@ -2945,14 +2944,14 @@ nsTableFrame::GetIncludedOuterBCBorder(const WritingMode aWM) const
const_cast<nsTableFrame*>(this)->CalcBCBorders();
}
int32_t p2t = nsPresContext::AppUnitsPerCSSPixel();
int32_t d2a = PresContext()->AppUnitsPerDevPixel();
BCPropertyData* propData = GetBCProperty();
if (propData) {
return LogicalMargin(aWM,
BC_BORDER_START_HALF_COORD(p2t, propData->mBStartBorderWidth),
BC_BORDER_END_HALF_COORD(p2t, propData->mIEndCellBorderWidth),
BC_BORDER_END_HALF_COORD(p2t, propData->mBEndBorderWidth),
BC_BORDER_START_HALF_COORD(p2t, propData->mIStartCellBorderWidth));
BC_BORDER_START_HALF_COORD(d2a, propData->mBStartBorderWidth),
BC_BORDER_END_HALF_COORD(d2a, propData->mIEndCellBorderWidth),
BC_BORDER_END_HALF_COORD(d2a, propData->mBEndBorderWidth),
BC_BORDER_START_HALF_COORD(d2a, propData->mIStartCellBorderWidth));
}
return LogicalMargin(aWM);
}
@ -5056,7 +5055,7 @@ GetColorAndStyle(const nsIFrame* aFrame,
if (aWidth) {
nscoord width = styleData->GetComputedBorderWidth(physicalSide);
*aWidth = nsPresContext::AppUnitsToIntCSSPixels(width);
*aWidth = aFrame->PresContext()->AppUnitsToDevPixels(width);
}
}
@ -6824,6 +6823,7 @@ BCPaintBorderIterator::SetDamageArea(const nsRect& aDirtyRect)
bool haveIntersect = false;
// find startRowIndex, endRowIndex
nscoord rowB = mInitialOffsetB;
nsPresContext* presContext = mTable->PresContext();
for (uint32_t rgIdx = 0; rgIdx < mRowGroups.Length() && !done; rgIdx++) {
nsTableRowGroupFrame* rgFrame = mRowGroups[rgIdx];
for (nsTableRowFrame* rowFrame = rgFrame->GetFirstRow(); rowFrame;
@ -6832,8 +6832,10 @@ BCPaintBorderIterator::SetDamageArea(const nsRect& aDirtyRect)
nscoord rowBSize = rowFrame->BSize(mTableWM);
if (haveIntersect) {
// conservatively estimate the half border widths outside the row
nscoord borderHalf = mTable->GetPrevInFlow() ? 0 : nsPresContext::
CSSPixelsToAppUnits(rowFrame->GetBStartBCBorderWidth() + 1);
nscoord borderHalf = mTable->GetPrevInFlow() ? 0 :
presContext->DevPixelsToAppUnits(
rowFrame->GetBStartBCBorderWidth() + 1);
if (dirtyRect.BEnd(mTableWM) >= rowB - borderHalf) {
nsTableRowFrame* fifRow =
static_cast<nsTableRowFrame*>(rowFrame->FirstInFlow());
@ -6843,8 +6845,9 @@ BCPaintBorderIterator::SetDamageArea(const nsRect& aDirtyRect)
}
else {
// conservatively estimate the half border widths outside the row
nscoord borderHalf = mTable->GetNextInFlow() ? 0 : nsPresContext::
CSSPixelsToAppUnits(rowFrame->GetBEndBCBorderWidth() + 1);
nscoord borderHalf = mTable->GetNextInFlow() ? 0 :
presContext->DevPixelsToAppUnits(
rowFrame->GetBEndBCBorderWidth() + 1);
if (rowB + rowBSize + borderHalf >= dirtyRect.BStart(mTableWM)) {
mStartRg = rgFrame;
mStartRow = rowFrame;
@ -6888,8 +6891,8 @@ BCPaintBorderIterator::SetDamageArea(const nsRect& aDirtyRect)
nscoord colISize = colFrame->ISize(mTableWM);
if (haveIntersect) {
// conservatively estimate the iStart half border width outside the col
nscoord iStartBorderHalf = nsPresContext::
CSSPixelsToAppUnits(colFrame->GetIStartBorderWidth() + 1);
nscoord iStartBorderHalf = presContext->DevPixelsToAppUnits(
colFrame->GetIStartBorderWidth() + 1);
if (dirtyRect.IEnd(mTableWM) >= x - iStartBorderHalf) {
endColIndex = colIdx;
}
@ -6897,8 +6900,8 @@ BCPaintBorderIterator::SetDamageArea(const nsRect& aDirtyRect)
}
else {
// conservatively estimate the iEnd half border width outside the col
nscoord iEndBorderHalf = nsPresContext::
CSSPixelsToAppUnits(colFrame->GetIEndBorderWidth() + 1);
nscoord iEndBorderHalf = presContext->DevPixelsToAppUnits(
colFrame->GetIEndBorderWidth() + 1);
if (x + colISize + iEndBorderHalf >= dirtyRect.IStart(mTableWM)) {
startColIndex = endColIndex = colIdx;
haveIntersect = true;
@ -7137,7 +7140,8 @@ BCPaintBorderIterator::Next()
* @return - offset in twips
*/
static nscoord
CalcVerCornerOffset(LogicalSide aCornerOwnerSide,
CalcVerCornerOffset(nsPresContext* aPresContext,
LogicalSide aCornerOwnerSide,
BCPixelSize aCornerSubWidth,
BCPixelSize aHorWidth,
bool aIsStartOfSeg,
@ -7164,7 +7168,7 @@ CalcVerCornerOffset(LogicalSide aCornerOwnerSide,
offset = (aIsStartOfSeg) ? smallHalf : -largeHalf;
}
}
return nsPresContext::CSSPixelsToAppUnits(offset);
return aPresContext->DevPixelsToAppUnits(offset);
}
/** Compute the horizontal offset of a horizontal border segment
@ -7176,7 +7180,8 @@ CalcVerCornerOffset(LogicalSide aCornerOwnerSide,
* @return - offset in twips
*/
static nscoord
CalcHorCornerOffset(LogicalSide aCornerOwnerSide,
CalcHorCornerOffset(nsPresContext* aPresContext,
LogicalSide aCornerOwnerSide,
BCPixelSize aCornerSubWidth,
BCPixelSize aVerWidth,
bool aIsStartOfSeg,
@ -7203,7 +7208,7 @@ CalcHorCornerOffset(LogicalSide aCornerOwnerSide,
offset = (aIsStartOfSeg) ? smallHalf : -largeHalf;
}
}
return nsPresContext::CSSPixelsToAppUnits(offset);
return aPresContext->DevPixelsToAppUnits(offset);
}
BCBlockDirSeg::BCBlockDirSeg()
@ -7237,12 +7242,14 @@ BCBlockDirSeg::Start(BCPaintBorderIterator& aIter,
bool bStartBevel = (aBlockSegISize > 0) ? bevel : false;
BCPixelSize maxInlineSegBSize = std::max(aIter.mPrevInlineSegBSize, aInlineSegBSize);
nscoord offset = CalcVerCornerOffset(ownerSide, cornerSubWidth,
nsPresContext* presContext = aIter.mTable->PresContext();
nscoord offset = CalcVerCornerOffset(presContext,
ownerSide, cornerSubWidth,
maxInlineSegBSize, true,
bStartBevel);
mBStartBevelOffset = bStartBevel ?
nsPresContext::CSSPixelsToAppUnits(maxInlineSegBSize): 0;
presContext->DevPixelsToAppUnits(maxInlineSegBSize): 0;
// XXX this assumes that only corners where 2 segments join can be beveled
mBStartBevelSide = (aInlineSegBSize > 0) ? eLogicalSideIEnd : eLogicalSideIStart;
mOffsetB += offset;
@ -7299,7 +7306,8 @@ BCBlockDirSeg::GetBEndCorner(BCPaintBorderIterator& aIter,
}
mIsBEndBevel = (mWidth > 0) ? bevel : false;
mBEndInlineSegBSize = std::max(aIter.mPrevInlineSegBSize, aInlineSegBSize);
mBEndOffset = CalcVerCornerOffset(ownerSide, cornerSubWidth,
mBEndOffset = CalcVerCornerOffset(aIter.mTable->PresContext(),
ownerSide, cornerSubWidth,
mBEndInlineSegBSize,
false, mIsBEndBevel);
mLength += mBEndOffset;
@ -7324,7 +7332,8 @@ BCBlockDirSeg::BuildBorderParameters(BCPaintBorderIterator& aIter,
// All the tables frames have the same presContext, so we just use any one
// that exists here:
result.mAppUnitsPerDevPixel = col->PresContext()->AppUnitsPerDevPixel();
nsPresContext* presContext = aIter.mTable->PresContext();
result.mAppUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
switch (mOwner) {
case eTableOwner:
@ -7380,11 +7389,11 @@ BCBlockDirSeg::BuildBorderParameters(BCPaintBorderIterator& aIter,
BCPixelSize smallHalf, largeHalf;
DivideBCBorderSize(mWidth, smallHalf, largeHalf);
LogicalRect segRect(aIter.mTableWM,
mOffsetI - nsPresContext::CSSPixelsToAppUnits(largeHalf),
mOffsetI - presContext->DevPixelsToAppUnits(largeHalf),
mOffsetB,
nsPresContext::CSSPixelsToAppUnits(mWidth), mLength);
presContext->DevPixelsToAppUnits(mWidth), mLength);
nscoord bEndBevelOffset = (mIsBEndBevel) ?
nsPresContext::CSSPixelsToAppUnits(mBEndInlineSegBSize) : 0;
presContext->DevPixelsToAppUnits(mBEndInlineSegBSize) : 0;
LogicalSide bEndBevelSide =
(aInlineSegBSize > 0) ? eLogicalSideIEnd : eLogicalSideIStart;
@ -7438,7 +7447,6 @@ BCBlockDirSeg::Paint(BCPaintBorderIterator& aIter,
nsCSSRendering::DrawTableBorderSegment(aDrawTarget, param->mBorderStyle, param->mBorderColor,
param->mBGColor, param->mBorderRect,
param->mAppUnitsPerDevPixel,
nsPresContext::AppUnitsPerCSSPixel(),
param->mStartBevelSide, param->mStartBevelOffset,
param->mEndBevelSide, param->mEndBevelOffset);
}
@ -7533,7 +7541,8 @@ BCInlineDirSeg::Start(BCPaintBorderIterator& aIter,
int32_t relColIndex = aIter.GetRelativeColIndex();
nscoord maxBlockSegISize = std::max(aIter.mBlockDirInfo[relColIndex].mWidth,
aBEndBlockSegISize);
nscoord offset = CalcHorCornerOffset(cornerOwnerSide, cornerSubWidth,
nscoord offset = CalcHorCornerOffset(aIter.mTable->PresContext(),
cornerOwnerSide, cornerSubWidth,
maxBlockSegISize, true, iStartBevel);
mIStartBevelOffset = (iStartBevel && (aInlineSegBSize > 0)) ? maxBlockSegISize : 0;
// XXX this assumes that only corners where 2 segments join can be beveled
@ -7567,11 +7576,12 @@ BCInlineDirSeg::GetIEndCorner(BCPaintBorderIterator& aIter,
int32_t relColIndex = aIter.GetRelativeColIndex();
nscoord verWidth = std::max(aIter.mBlockDirInfo[relColIndex].mWidth,
aIStartSegISize);
mEndOffset = CalcHorCornerOffset(ownerSide, cornerSubWidth, verWidth,
false, mIsIEndBevel);
nsPresContext* presContext = aIter.mTable->PresContext();
mEndOffset = CalcHorCornerOffset(presContext, ownerSide, cornerSubWidth,
verWidth, false, mIsIEndBevel);
mLength += mEndOffset;
mIEndBevelOffset = (mIsIEndBevel) ?
nsPresContext::CSSPixelsToAppUnits(verWidth) : 0;
presContext->DevPixelsToAppUnits(verWidth) : 0;
mIEndBevelSide = (aIStartSegISize > 0) ? eLogicalSideBEnd : eLogicalSideBStart;
}
@ -7591,7 +7601,8 @@ BCInlineDirSeg::BuildBorderParameters(BCPaintBorderIterator& aIter)
// All the tables frames have the same presContext, so we just use any one
// that exists here:
result.mAppUnitsPerDevPixel = row->PresContext()->AppUnitsPerDevPixel();
nsPresContext* presContext = aIter.mTable->PresContext();
result.mAppUnitsPerDevPixel = presContext->AppUnitsPerDevPixel();
result.mBorderStyle = NS_STYLE_BORDER_STYLE_SOLID;
result.mBorderColor = 0xFFFFFFFF;
@ -7649,16 +7660,16 @@ BCInlineDirSeg::BuildBorderParameters(BCPaintBorderIterator& aIter)
BCPixelSize smallHalf, largeHalf;
DivideBCBorderSize(mWidth, smallHalf, largeHalf);
LogicalRect segRect(aIter.mTableWM, mOffsetI,
mOffsetB - nsPresContext::CSSPixelsToAppUnits(largeHalf),
mOffsetB - presContext->DevPixelsToAppUnits(largeHalf),
mLength,
nsPresContext::CSSPixelsToAppUnits(mWidth));
presContext->DevPixelsToAppUnits(mWidth));
// Convert logical to physical sides/coordinates for DrawTableBorderSegment.
result.mBorderRect = segRect.GetPhysicalRect(aIter.mTableWM, aIter.mTable->GetSize());
result.mStartBevelSide = aIter.mTableWM.PhysicalSide(mIStartBevelSide);
result.mEndBevelSide = aIter.mTableWM.PhysicalSide(mIEndBevelSide);
result.mStartBevelOffset =
nsPresContext::CSSPixelsToAppUnits(mIStartBevelOffset);
presContext->DevPixelsToAppUnits(mIStartBevelOffset);
result.mEndBevelOffset = mIEndBevelOffset;
// With inline-RTL directionality, the 'start' and 'end' of the inline-dir
// border segment need to be swapped because DrawTableBorderSegment will
@ -7696,7 +7707,6 @@ BCInlineDirSeg::Paint(BCPaintBorderIterator& aIter, DrawTarget& aDrawTarget)
nsCSSRendering::DrawTableBorderSegment(aDrawTarget, param->mBorderStyle, param->mBorderColor,
param->mBGColor, param->mBorderRect,
param->mAppUnitsPerDevPixel,
nsPresContext::AppUnitsPerCSSPixel(),
param->mStartBevelSide, param->mStartBevelOffset,
param->mEndBevelSide, param->mEndBevelOffset);
}

Просмотреть файл

@ -1028,8 +1028,8 @@ inline void nsTableFrame::SetHasBCBorders(bool aValue)
inline nscoord
nsTableFrame::GetContinuousIStartBCBorderWidth() const
{
int32_t aPixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
return BC_BORDER_END_HALF_COORD(aPixelsToTwips, mBits.mIStartContBCBorder);
int32_t d2a = PresContext()->AppUnitsPerDevPixel();
return BC_BORDER_END_HALF_COORD(d2a, mBits.mIStartContBCBorder);
}
inline void nsTableFrame::SetContinuousIStartBCBorderWidth(nscoord aValue)

Просмотреть файл

@ -424,21 +424,22 @@ inline void nsTableRowFrame::SetHasUnpaginatedBSize(bool aValue)
inline mozilla::LogicalMargin
nsTableRowFrame::GetBCBorderWidth(mozilla::WritingMode aWM)
{
nsPresContext* presContext = PresContext();
return mozilla::LogicalMargin(
aWM, nsPresContext::CSSPixelsToAppUnits(mBStartBorderWidth), 0,
nsPresContext::CSSPixelsToAppUnits(mBEndBorderWidth), 0);
aWM, presContext->DevPixelsToAppUnits(mBStartBorderWidth), 0,
presContext->DevPixelsToAppUnits(mBEndBorderWidth), 0);
}
inline void
nsTableRowFrame::GetContinuousBCBorderWidth(mozilla::WritingMode aWM,
mozilla::LogicalMargin& aBorder)
{
int32_t aPixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
aBorder.IEnd(aWM) = BC_BORDER_START_HALF_COORD(aPixelsToTwips,
int32_t d2a = PresContext()->AppUnitsPerDevPixel();
aBorder.IEnd(aWM) = BC_BORDER_START_HALF_COORD(d2a,
mIStartContBorderWidth);
aBorder.BStart(aWM) = BC_BORDER_END_HALF_COORD(aPixelsToTwips,
aBorder.BStart(aWM) = BC_BORDER_END_HALF_COORD(d2a,
mBStartContBorderWidth);
aBorder.IStart(aWM) = BC_BORDER_END_HALF_COORD(aPixelsToTwips,
aBorder.IStart(aWM) = BC_BORDER_END_HALF_COORD(d2a,
mIEndContBorderWidth);
}

Просмотреть файл

@ -1684,10 +1684,10 @@ nsTableRowGroupFrame::GetBCBorderWidth(WritingMode aWM)
lastRowFrame = rowFrame;
}
if (firstRowFrame) {
border.BStart(aWM) = nsPresContext::
CSSPixelsToAppUnits(firstRowFrame->GetBStartBCBorderWidth());
border.BEnd(aWM) = nsPresContext::
CSSPixelsToAppUnits(lastRowFrame->GetBEndBCBorderWidth());
border.BStart(aWM) = PresContext()->DevPixelsToAppUnits(
firstRowFrame->GetBStartBCBorderWidth());
border.BEnd(aWM) = PresContext()->DevPixelsToAppUnits(
lastRowFrame->GetBEndBCBorderWidth());
}
return border;
}

Просмотреть файл

@ -450,12 +450,12 @@ inline void
nsTableRowGroupFrame::GetContinuousBCBorderWidth(mozilla::WritingMode aWM,
mozilla::LogicalMargin& aBorder)
{
int32_t aPixelsToTwips = nsPresContext::AppUnitsPerCSSPixel();
aBorder.IEnd(aWM) = BC_BORDER_START_HALF_COORD(aPixelsToTwips,
int32_t d2a = PresContext()->AppUnitsPerDevPixel();
aBorder.IEnd(aWM) = BC_BORDER_START_HALF_COORD(d2a,
mIEndContBorderWidth);
aBorder.BEnd(aWM) = BC_BORDER_START_HALF_COORD(aPixelsToTwips,
aBorder.BEnd(aWM) = BC_BORDER_START_HALF_COORD(d2a,
mBEndContBorderWidth);
aBorder.IStart(aWM) = BC_BORDER_END_HALF_COORD(aPixelsToTwips,
aBorder.IStart(aWM) = BC_BORDER_END_HALF_COORD(d2a,
mIStartContBorderWidth);
}
#endif