From a134288b35826c5c9c08ba86f43f3d85335f23e9 Mon Sep 17 00:00:00 2001 From: "kipp%netscape.com" Date: Sat, 17 Oct 1998 01:05:58 +0000 Subject: [PATCH] Compute text indent for the first frame in the first line of a body frame --- layout/html/base/src/nsInlineReflow.cpp | 33 ++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/layout/html/base/src/nsInlineReflow.cpp b/layout/html/base/src/nsInlineReflow.cpp index 5c28e9b5cd43..a88b91bc43fd 100644 --- a/layout/html/base/src/nsInlineReflow.cpp +++ b/layout/html/base/src/nsInlineReflow.cpp @@ -337,7 +337,38 @@ void nsInlineReflow::ApplyTopLeftMargins() { PerFrameData* pfd = mFrameData; - pfd->mBounds.x = mX; + + // If this is the first frame of a block, and its the first line of + // a block then see if the text-indent property amounts to anything. + nscoord indent = 0; + if (mOuterIsBlock && + (0 == mLineLayout.GetLineNumber()) && + (0 == mFrameNum)) { + const nsStyleText* text; + mOuterFrame->GetStyleData(eStyleStruct_Text, (const nsStyleStruct*&) text); + nsStyleUnit unit = text->mTextIndent.GetUnit(); + if (eStyleUnit_Coord == unit) { + indent = text->mTextIndent.GetCoordValue(); + } + else if (eStyleUnit_Percent == unit) { + nscoord width; + if (mOuterReflowState.HaveConstrainedWidth()) { + width = mOuterReflowState.minWidth; + } + else if (NS_UNCONSTRAINEDSIZE == mOuterReflowState.maxSize.width) { + // We are unconstrained only when a table cell is reflowing + // the block. Therefore don't bother with the indent until + // the next reflow. + width = 0; + } + else { + width = mOuterReflowState.maxSize.width; + } + indent = nscoord(text->mTextIndent.GetPercentValue() * width); + } + } + + pfd->mBounds.x = mX + indent; pfd->mBounds.y = mTopEdge; // Compute left margin