use scaledpixels to convert from CSS pixels to realword pixels bug=307367 r/sr=roc

This commit is contained in:
bmlk%gmx.de 2006-01-21 09:54:07 +00:00
parent 6c6b9013a4
commit ef5d2c73ea
8 changed files with 55 additions and 68 deletions

View File

@ -307,22 +307,22 @@ nsTableCellFrame::DecorateForSelection(nsPresContext* aPresContext,
GetColor(nsILookAndFeel::eColor_TextSelectBackground,
bordercolor);
}
PRInt16 t2p = (PRInt16) aPresContext->PixelsToTwips();
if ((mRect.width >(3*t2p)) && (mRect.height > (3*t2p)))
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
if ((mRect.width >(3*p2t)) && (mRect.height > (3*p2t)))
{
//compare bordercolor to ((nsStyleColor *)myColor)->mBackgroundColor)
bordercolor = EnsureDifferentColors(bordercolor, aStyleColor->mBackgroundColor);
//outerrounded
aRenderingContext.SetColor(bordercolor);
aRenderingContext.DrawLine(t2p, 0, mRect.width, 0);
aRenderingContext.DrawLine(0, t2p, 0, mRect.height);
aRenderingContext.DrawLine(t2p, mRect.height, mRect.width, mRect.height);
aRenderingContext.DrawLine(mRect.width, t2p, mRect.width, mRect.height);
aRenderingContext.DrawLine(p2t, 0, mRect.width, 0);
aRenderingContext.DrawLine(0, p2t, 0, mRect.height);
aRenderingContext.DrawLine(p2t, mRect.height, mRect.width, mRect.height);
aRenderingContext.DrawLine(mRect.width, p2t, mRect.width, mRect.height);
//middle
aRenderingContext.DrawRect(t2p, t2p, mRect.width-t2p, mRect.height-t2p);
aRenderingContext.DrawRect(p2t, p2t, mRect.width-p2t, mRect.height-p2t);
//shading
aRenderingContext.DrawLine(2*t2p, mRect.height-2*t2p, mRect.width-t2p, mRect.height- (2*t2p));
aRenderingContext.DrawLine(mRect.width - (2*t2p), 2*t2p, mRect.width - (2*t2p), mRect.height-t2p);
aRenderingContext.DrawLine(2*p2t, mRect.height-2*p2t, mRect.width-p2t, mRect.height- (2*p2t));
aRenderingContext.DrawLine(mRect.width - (2*p2t), 2*p2t, mRect.width - (2*p2t), mRect.height-p2t);
}
}
}
@ -579,9 +579,7 @@ void nsTableCellFrame::VerticallyAlignChild(const nsHTMLReflowState& aReflowStat
case NS_STYLE_VERTICAL_ALIGN_MIDDLE:
// Align the middle of the child frame with the middle of the content area,
kidYTop = (height - childHeight - bottomInset + topInset) / 2;
kidYTop = nsTableFrame::RoundToPixel(kidYTop,
presContext->ScaledPixelsToTwips(),
eAlwaysRoundDown);
kidYTop = nsTableFrame::RoundToPixel(kidYTop, p2t, eAlwaysRoundDown);
}
// if the content is larger than the cell height align from top
kidYTop = PR_MAX(0, kidYTop);
@ -720,7 +718,7 @@ NS_METHOD nsTableCellFrame::Reflow(nsPresContext* aPresContext,
#if defined DEBUG_TABLE_REFLOW_TIMING
nsTableFrame::DebugReflow(this, (nsHTMLReflowState&)aReflowState);
#endif
float p2t = aPresContext->ScaledPixelsToTwips();
GET_PIXELS_TO_TWIPS(aPresContext, p2t);
// work around pixel rounding errors, round down to ensure we don't exceed the avail height in
nscoord availHeight = aReflowState.availableHeight;
@ -1277,7 +1275,7 @@ nsBCTableCellFrame::SetBorderWidth(PRUint8 aSide,
nsBCTableCellFrame::GetSelfOverflow(nsRect& aOverflowArea)
{
nsMargin halfBorder;
float p2t = GetPresContext()->PixelsToTwips();
GET_PIXELS_TO_TWIPS(GetPresContext(), p2t);
halfBorder.top = BC_BORDER_TOP_HALF_COORD(p2t, mTopBorder);
halfBorder.right = BC_BORDER_RIGHT_HALF_COORD(p2t, mRightBorder);
halfBorder.bottom = BC_BORDER_BOTTOM_HALF_COORD(p2t, mBottomBorder);

View File

@ -3474,7 +3474,6 @@ nsTableFrame::CalcDesiredHeight(const nsHTMLReflowState& aReflowState, nsHTMLRef
static
void ResizeCells(nsTableFrame& aTableFrame,
nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState)
{
nsAutoVoidArray rowGroups;
@ -3498,7 +3497,7 @@ void ResizeCells(nsTableFrame& aTableFrame,
groupDesiredSize.height);
nsTableRowFrame* rowFrame = rgFrame->GetFirstRow();
while (rowFrame) {
rowFrame->DidResize(aPresContext, aReflowState);
rowFrame->DidResize(aReflowState);
rgFrame->ConsiderChildOverflow(groupDesiredSize.mOverflowArea, rowFrame);
rowFrame = rowFrame->GetNextRow();
}
@ -3517,9 +3516,8 @@ void
nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
nscoord aAmount)
{
nsPresContext *presContext = GetPresContext();
float p2t;
p2t = presContext->PixelsToTwips();
GET_PIXELS_TO_TWIPS(GetPresContext(), p2t);
nscoord cellSpacingY = GetCellSpacingY();
@ -3556,7 +3554,7 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
yEndRG += rowRect.height + cellSpacingY;
amountUsed += amountForRow;
amountUsedByRG += amountForRow;
//rowFrame->DidResize(aPresContext, aReflowState);
//rowFrame->DidResize(aReflowState);
nsTableFrame::RePositionViews(rowFrame);
}
}
@ -3585,7 +3583,7 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
}
if (amountUsed >= aAmount) {
ResizeCells(*this, presContext, aReflowState);
ResizeCells(*this, aReflowState);
return;
}
@ -3661,7 +3659,7 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
amountUsed += amountForRow;
amountUsedByRG += amountForRow;
NS_ASSERTION((amountUsed <= aAmount), "invalid row allocation");
//rowFrame->DidResize(aPresContext, aReflowState);
//rowFrame->DidResize(aReflowState);
nsTableFrame::RePositionViews(rowFrame);
}
else {
@ -3690,7 +3688,7 @@ nsTableFrame::DistributeHeightToRows(const nsHTMLReflowState& aReflowState,
yOriginRG = yEndRG;
}
ResizeCells(*this, presContext, aReflowState);
ResizeCells(*this, aReflowState);
}
static void
@ -4144,8 +4142,7 @@ nsTableFrame::CalcBorderBoxWidth(const nsHTMLReflowState& aState)
width = PR_MAX(width, 0);
if (NS_UNCONSTRAINEDSIZE != width) {
float p2t;
p2t = GetPresContext()->PixelsToTwips();
GET_PIXELS_TO_TWIPS(GetPresContext(), p2t);
width = RoundToPixel(width, p2t, eRoundUpIfHalfOrMore);
}

View File

@ -907,8 +907,7 @@ nsTableOuterFrame::BalanceLeftRightCaption(PRUint8 aCaptionSide,
}
nsresult
nsTableOuterFrame::GetCaptionOrigin(nsPresContext* aPresContext,
PRUint32 aCaptionSide,
nsTableOuterFrame::GetCaptionOrigin(PRUint32 aCaptionSide,
const nsSize& aContainBlockSize,
const nsSize& aInnerSize,
const nsMargin& aInnerMargin,
@ -923,7 +922,7 @@ nsTableOuterFrame::GetCaptionOrigin(nsPresContext* aPresContext,
}
if (!mCaptionFrame) return NS_OK;
float p2t = aPresContext->ScaledPixelsToTwips();
GET_PIXELS_TO_TWIPS(GetPresContext(), p2t);
switch(aCaptionSide) {
case NS_SIDE_BOTTOM: {
@ -1019,8 +1018,7 @@ nsTableOuterFrame::GetCaptionOrigin(nsPresContext* aPresContext,
}
nsresult
nsTableOuterFrame::GetInnerOrigin(nsPresContext* aPresContext,
PRUint32 aCaptionSide,
nsTableOuterFrame::GetInnerOrigin(PRUint32 aCaptionSide,
const nsSize& aContainBlockSize,
const nsSize& aCaptionSize,
const nsMargin& aCaptionMargin,
@ -1034,7 +1032,7 @@ nsTableOuterFrame::GetInnerOrigin(nsPresContext* aPresContext,
return NS_OK;
}
float p2t = aPresContext->ScaledPixelsToTwips();
GET_PIXELS_TO_TWIPS(GetPresContext(), p2t);
nscoord minCapWidth = aCaptionSize.width;
if (NS_AUTOMARGIN != aCaptionMargin.left)
@ -1481,13 +1479,13 @@ nsTableOuterFrame::IR_TargetIsCaptionFrame(nsPresContext* aPresContext
OuterReflowChild(aPresContext, mInnerTableFrame, aOuterRS, innerMet, availTableWidth, innerSize,
innerMargin, innerMarginNoAuto, innerPadding, eReflowReason_Resize, aStatus);
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
GetInnerOrigin(captionSide, containSize, captionSize,
captionMargin, innerSize, innerMargin, innerOrigin);
rv = FinishReflowChild(mInnerTableFrame, aPresContext, nsnull, innerMet,
innerOrigin.x, innerOrigin.y, 0);
if (NS_FAILED(rv)) return rv;
GetCaptionOrigin(aPresContext, captionSide, containSize, innerSize,
GetCaptionOrigin(captionSide, containSize, innerSize,
innerMargin, captionSize, captionMargin, captionOrigin);
}
else {
@ -1495,9 +1493,9 @@ nsTableOuterFrame::IR_TargetIsCaptionFrame(nsPresContext* aPresContext
nsSize innerSize = mInnerTableFrame->GetSize();
GetMarginPadding(aPresContext, aOuterRS, mInnerTableFrame, aOuterRS.availableWidth, innerMargin,
innerMarginNoAuto, innerPadding);
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
GetInnerOrigin(captionSide, containSize, captionSize,
captionMargin, innerSize, innerMargin, innerOrigin);
GetCaptionOrigin(aPresContext, captionSide, containSize, innerSize,
GetCaptionOrigin(captionSide, containSize, innerSize,
innerMargin, captionSize, captionMargin, captionOrigin);
MoveFrameTo(mInnerTableFrame, innerOrigin.x, innerOrigin.y);
}
@ -1553,7 +1551,7 @@ nsTableOuterFrame::IR_ReflowDirty(nsPresContext* aPresContext,
GetMarginPadding(aPresContext, aReflowState, mInnerTableFrame, aReflowState.availableWidth, innerMargin,
innerMarginNoAuto, innerPadding);
nsSize containSize = GetContainingBlockSize(aReflowState);
GetInnerOrigin(aPresContext, NO_SIDE, containSize, nsSize(0,0),
GetInnerOrigin(NO_SIDE, containSize, nsSize(0,0),
nsMargin(0,0,0,0), innerSize, innerMargin, innerOrigin);
MoveFrameTo(mInnerTableFrame, innerOrigin.x, innerOrigin.y);
@ -1680,12 +1678,12 @@ nsTableOuterFrame::IR_InnerTableReflow(nsPresContext* aPresContext,
ignorePadding, reflowReason, capStatus);
if (NS_FAILED(rv)) return rv;
GetCaptionOrigin(aPresContext, captionSide, containSize, innerSize,
GetCaptionOrigin(captionSide, containSize, innerSize,
innerMargin, captionSize, captionMargin, captionOrigin);
FinishReflowChild(mCaptionFrame, aPresContext, nsnull, captionMet,
captionOrigin.x, captionOrigin.y, 0);
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
GetInnerOrigin(captionSide, containSize, captionSize,
captionMargin, innerSize, innerMargin, innerOrigin);
}
else {
@ -1694,9 +1692,9 @@ nsTableOuterFrame::IR_InnerTableReflow(nsPresContext* aPresContext,
nsMargin captionPadding;
GetMarginPadding(aPresContext, aOuterRS, mCaptionFrame, aOuterRS.availableWidth, captionMargin,
captionMarginNoAuto, captionPadding);
GetCaptionOrigin(aPresContext, captionSide, containSize, innerSize,
GetCaptionOrigin(captionSide, containSize, innerSize,
innerMargin, captionSize, captionMargin, captionOrigin);
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
GetInnerOrigin(captionSide, containSize, captionSize,
captionMargin, innerSize, innerMargin, innerOrigin);
MoveFrameTo(mCaptionFrame, captionOrigin.x, captionOrigin.y);
}
@ -1708,7 +1706,7 @@ nsTableOuterFrame::IR_InnerTableReflow(nsPresContext* aPresContext,
}
}
else {
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
GetInnerOrigin(captionSide, containSize, captionSize,
captionMargin, innerSize, innerMargin, innerOrigin);
}
@ -1781,7 +1779,7 @@ nsTableOuterFrame::IR_CaptionInserted(nsPresContext* aPresContext,
innerPadding, eReflowReason_Resize, aStatus);
if (NS_FAILED(rv)) return rv;
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
GetInnerOrigin(captionSide, containSize, captionSize,
captionMargin, innerSize, innerMargin, innerOrigin);
rv = FinishReflowChild(mInnerTableFrame, aPresContext, nsnull, innerMet,
innerOrigin.x, innerOrigin.y, 0);
@ -1789,7 +1787,7 @@ nsTableOuterFrame::IR_CaptionInserted(nsPresContext* aPresContext,
aDesiredSize.mMaxElementWidth = innerMet.mMaxElementWidth;
}
if (NS_FAILED(rv)) return rv;
GetCaptionOrigin(aPresContext, captionSide, containSize, innerSize,
GetCaptionOrigin(captionSide, containSize, innerSize,
innerMargin, captionSize, captionMargin, captionOrigin);
}
else {
@ -1797,9 +1795,9 @@ nsTableOuterFrame::IR_CaptionInserted(nsPresContext* aPresContext,
nsSize innerSize = mInnerTableFrame->GetSize();
GetMarginPadding(aPresContext, aOuterRS, mInnerTableFrame, aOuterRS.availableWidth, innerMargin,
innerMarginNoAuto, innerPadding);
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
GetInnerOrigin(captionSide, containSize, captionSize,
captionMargin, innerSize, innerMargin, innerOrigin);
GetCaptionOrigin(aPresContext, captionSide, containSize, innerSize,
GetCaptionOrigin(captionSide, containSize, innerSize,
innerMargin, captionSize, captionMargin, captionOrigin);
MoveFrameTo(mInnerTableFrame, innerOrigin.x, innerOrigin.y);
}
@ -1975,18 +1973,18 @@ NS_METHOD nsTableOuterFrame::Reflow(nsPresContext* aPresContext,
nsPoint captionOrigin;
GetCaptionOrigin(aPresContext, captionSide, containSize, innerSize,
GetCaptionOrigin(captionSide, containSize, innerSize,
innerMargin, captionSize, captionMargin, captionOrigin);
FinishReflowChild(mCaptionFrame, aPresContext, nsnull, captionMet,
captionOrigin.x, captionOrigin.y, 0);
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
GetInnerOrigin(captionSide, containSize, captionSize,
captionMargin, innerSize, innerMargin, innerOrigin);
// XXX If the height is constrained then we need to check whether the inner table still fits...
}
else {
GetInnerOrigin(aPresContext, captionSide, containSize, captionSize,
GetInnerOrigin(captionSide, containSize, captionSize,
captionMargin, innerSize, innerMargin, innerOrigin);
}

View File

@ -320,8 +320,7 @@ protected:
nscoord& aInnerWidth,
nscoord& aCaptionWidth);
NS_IMETHOD GetCaptionOrigin(nsPresContext* aPresContext,
PRUint32 aCaptionSide,
NS_IMETHOD GetCaptionOrigin(PRUint32 aCaptionSide,
const nsSize& aContainBlockSize,
const nsSize& aInnerSize,
const nsMargin& aInnerMargin,
@ -329,8 +328,7 @@ protected:
nsMargin& aCaptionMargin,
nsPoint& aOrigin);
NS_IMETHOD GetInnerOrigin(nsPresContext* aPresContext,
PRUint32 aCaptionSide,
NS_IMETHOD GetInnerOrigin(PRUint32 aCaptionSide,
const nsSize& aContainBlockSize,
const nsSize& aCaptionSize,
const nsMargin& aCaptionMargin,

View File

@ -344,8 +344,7 @@ nsTableRowFrame::GetFirstCell()
* Post-reflow hook. This is where the table row does its post-processing
*/
void
nsTableRowFrame::DidResize(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState)
nsTableRowFrame::DidResize(const nsHTMLReflowState& aReflowState)
{
// Resize and re-align the cell frames based on our row height
nsTableFrame* tableFrame;
@ -394,7 +393,7 @@ nsTableRowFrame::DidResize(nsPresContext* aPresContext,
}
FinishAndStoreOverflow(&desiredSize);
if (HasView()) {
nsContainerFrame::SyncFrameViewAfterReflow(aPresContext, this, GetView(), &desiredSize.mOverflowArea, 0);
nsContainerFrame::SyncFrameViewAfterReflow(GetPresContext(), this, GetView(), &desiredSize.mOverflowArea, 0);
}
// Let our base class do the usual work
}

View File

@ -123,8 +123,7 @@ public:
const nsHTMLReflowState& aReflowState,
nsReflowStatus& aStatus);
void DidResize(nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState);
void DidResize(const nsHTMLReflowState& aReflowState);
/**
* Get the "type" of the frame

View File

@ -470,8 +470,7 @@ UpdateHeights(RowInfo& aRowInfo,
}
void
nsTableRowGroupFrame::DidResizeRows(nsPresContext& aPresContext,
const nsHTMLReflowState& aReflowState,
nsTableRowGroupFrame::DidResizeRows(const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aDesiredSize,
nsTableRowFrame* aStartRowFrameIn)
{
@ -485,7 +484,7 @@ nsTableRowGroupFrame::DidResizeRows(nsPresContext& aPresContext,
aDesiredSize.mOverflowArea = nsRect(0, 0, 0, 0);
}
for (rowFrame = startRowFrame, rowIndex = 0; rowFrame; rowFrame = rowFrame->GetNextRow(), rowIndex++) {
rowFrame->DidResize(&aPresContext, aReflowState);
rowFrame->DidResize(aReflowState);
ConsiderChildOverflow(aDesiredSize.mOverflowArea, rowFrame);
}
}
@ -521,8 +520,8 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext,
// all table cells have the same top and bottom margins, namely cellSpacingY
nscoord cellSpacingY = tableFrame->GetCellSpacingY();
float p2t;
p2t = aPresContext->PixelsToTwips();
GET_TWIPS_TO_PIXELS(aPresContext, p2t);
PRInt32 numEffCols = tableFrame->GetEffectiveColCount();
// find the nearest row index at or before aStartRowFrameIn that isn't spanned into.
@ -797,7 +796,7 @@ nsTableRowGroupFrame::CalculateRowHeights(nsPresContext* aPresContext,
CacheRowHeightsForPrinting(aPresContext, GetFirstRow());
}
DidResizeRows(*aPresContext, aReflowState, aDesiredSize, startRowFrame);
DidResizeRows(aReflowState, aDesiredSize, startRowFrame);
aDesiredSize.height = rowGroupHeight; // Adjust our desired size
delete [] rowInfo; // cleanup
@ -1033,7 +1032,7 @@ nsTableRowGroupFrame::SplitRowGroup(nsPresContext* aPresContext,
if (NS_FAILED(rv)) return rv;
rowFrame->SetSize(nsSize(rowMetrics.width, rowMetrics.height));
rowFrame->DidReflow(aPresContext, nsnull, NS_FRAME_REFLOW_FINISHED);
rowFrame->DidResize(aPresContext, aReflowState);
rowFrame->DidResize(aReflowState);
if (NS_FRAME_IS_NOT_COMPLETE(aStatus)) {
// The row frame is incomplete and all of the rowspan 1 cells' block frames split
@ -1251,7 +1250,7 @@ nsTableRowGroupFrame::Reflow(nsPresContext* aPresContext,
// but we need to correctly calculate the row group height and we can't if there
// are row spans unless we do this step
if (aReflowState.mFlags.mSpecialHeightReflow) {
DidResizeRows(*aPresContext, aReflowState, aDesiredSize);
DidResizeRows(aReflowState, aDesiredSize);
if (isPaginated) {
CacheRowHeightsForPrinting(aPresContext, GetFirstRow());
}
@ -1660,7 +1659,7 @@ nsTableRowGroupFrame::IR_TargetIsChild(nsPresContext* aPresContext,
aDesiredSize.height = GetLastRowSibling(mFrames.FirstChild())->GetRect().YMost();
} else {
// Inform the row of its new height.
((nsTableRowFrame*)aNextFrame)->DidResize(aPresContext, aReflowState.reflowState);
((nsTableRowFrame*)aNextFrame)->DidResize(aReflowState.reflowState);
// the overflow area may have changed inflate the overflow area
if (aReflowState.tableFrame->IsAutoHeight()) {
// Because other cells in the row may need to be aligned differently,

View File

@ -272,8 +272,7 @@ protected:
const nsHTMLReflowState& aReflowState,
nsTableRowFrame* aStartRowFrameIn = nsnull);
void DidResizeRows(nsPresContext& aPresContext,
const nsHTMLReflowState& aReflowState,
void DidResizeRows(const nsHTMLReflowState& aReflowState,
nsHTMLReflowMetrics& aDesiredSize,
nsTableRowFrame* aStartRowFrameIn = nsnull);