From 9c077b6eb71b620b2a3fd8c556809c798d28bffa Mon Sep 17 00:00:00 2001 From: "kipp%netscape.com" Date: Tue, 27 Apr 1999 22:12:37 +0000 Subject: [PATCH] Support first letter reflow git-svn-id: svn://10.0.0.236/trunk@29550 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsInlineFrame.cpp | 32 +++++++++++++++---- .../layout/html/base/src/nsInlineFrame.cpp | 32 +++++++++++++++---- 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/mozilla/layout/generic/nsInlineFrame.cpp b/mozilla/layout/generic/nsInlineFrame.cpp index a44a89dacf0..605bfc7dcfc 100644 --- a/mozilla/layout/generic/nsInlineFrame.cpp +++ b/mozilla/layout/generic/nsInlineFrame.cpp @@ -1359,11 +1359,18 @@ nsInlineFrame::ReflowInlineFrames(nsIPresContext* aPresContext, nsIFrame* frame = mFrames.FirstChild(); PRBool done = PR_FALSE; while (nsnull != frame) { + PRBool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK(); rv = ReflowInlineFrame(aPresContext, aReflowState, irs, frame, aStatus); - if (NS_FAILED(rv) || (NS_FRAME_COMPLETE != aStatus)) { + if (NS_FAILED(rv)) { done = PR_TRUE; break; } + if (NS_FRAME_COMPLETE != aStatus) { + if (!reflowingFirstLetter || NS_INLINE_IS_BREAK(aStatus)) { + done = PR_TRUE; + break; + } + } irs.mPrevFrame = frame; frame->GetNextSibling(&frame); } @@ -1371,6 +1378,7 @@ nsInlineFrame::ReflowInlineFrames(nsIPresContext* aPresContext, // Attempt to pull frames from our next-in-flow until we can't if (!done && (nsnull != mNextInFlow)) { while (!done) { + PRBool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK(); PRBool isComplete; frame = PullInlineFrame(aPresContext, irs, &isComplete); if (nsnull == frame) { @@ -1380,10 +1388,16 @@ nsInlineFrame::ReflowInlineFrames(nsIPresContext* aPresContext, break; } rv = ReflowInlineFrame(aPresContext, aReflowState, irs, frame, aStatus); - if (NS_FAILED(rv) || (NS_FRAME_COMPLETE != aStatus)) { + if (NS_FAILED(rv)) { done = PR_TRUE; break; } + if (NS_FRAME_COMPLETE != aStatus) { + if (!reflowingFirstLetter || NS_INLINE_IS_BREAK(aStatus)) { + done = PR_TRUE; + break; + } + } irs.mPrevFrame = frame; } } @@ -1515,6 +1529,7 @@ nsInlineFrame::ReflowInlineFrame(nsIPresContext* aPresContext, } nsLineLayout* lineLayout = aReflowState.lineLayout; + PRBool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK(); nsresult rv = lineLayout->ReflowFrame(aFrame, &irs.mNextRCFrame, aStatus); if (NS_FAILED(rv)) { return rv; @@ -1570,10 +1585,12 @@ nsInlineFrame::ReflowInlineFrame(nsIPresContext* aPresContext, if (NS_FAILED(rv)) { return rv; } - nsIFrame* nextFrame; - aFrame->GetNextSibling(&nextFrame); - if (nsnull != nextFrame) { - PushFrames(aPresContext, nextFrame, aFrame); + if (!reflowingFirstLetter) { + nsIFrame* nextFrame; + aFrame->GetNextSibling(&nextFrame); + if (nsnull != nextFrame) { + PushFrames(aPresContext, nextFrame, aFrame); + } } } return rv; @@ -1849,7 +1866,7 @@ NS_IMETHODIMP nsFirstLineFrame::GetFrameType(nsIAtom** aType) const { NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer"); - *aType = nsHTMLAtoms::lineFrame; + *aType = nsLayoutAtoms::lineFrame; NS_ADDREF(*aType); return NS_OK; } @@ -2060,6 +2077,7 @@ nsFirstLineFrame::Reflow(nsIPresContext& aPresContext, irs.mPrevFrame = nsnull; } else { +// XXX do this in the Init method instead // For continuations, we need to check and see if our style // context is right. If its the same as the first-in-flow, then // we need to fix it up (that way :first-line style doesn't leak diff --git a/mozilla/layout/html/base/src/nsInlineFrame.cpp b/mozilla/layout/html/base/src/nsInlineFrame.cpp index a44a89dacf0..605bfc7dcfc 100644 --- a/mozilla/layout/html/base/src/nsInlineFrame.cpp +++ b/mozilla/layout/html/base/src/nsInlineFrame.cpp @@ -1359,11 +1359,18 @@ nsInlineFrame::ReflowInlineFrames(nsIPresContext* aPresContext, nsIFrame* frame = mFrames.FirstChild(); PRBool done = PR_FALSE; while (nsnull != frame) { + PRBool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK(); rv = ReflowInlineFrame(aPresContext, aReflowState, irs, frame, aStatus); - if (NS_FAILED(rv) || (NS_FRAME_COMPLETE != aStatus)) { + if (NS_FAILED(rv)) { done = PR_TRUE; break; } + if (NS_FRAME_COMPLETE != aStatus) { + if (!reflowingFirstLetter || NS_INLINE_IS_BREAK(aStatus)) { + done = PR_TRUE; + break; + } + } irs.mPrevFrame = frame; frame->GetNextSibling(&frame); } @@ -1371,6 +1378,7 @@ nsInlineFrame::ReflowInlineFrames(nsIPresContext* aPresContext, // Attempt to pull frames from our next-in-flow until we can't if (!done && (nsnull != mNextInFlow)) { while (!done) { + PRBool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK(); PRBool isComplete; frame = PullInlineFrame(aPresContext, irs, &isComplete); if (nsnull == frame) { @@ -1380,10 +1388,16 @@ nsInlineFrame::ReflowInlineFrames(nsIPresContext* aPresContext, break; } rv = ReflowInlineFrame(aPresContext, aReflowState, irs, frame, aStatus); - if (NS_FAILED(rv) || (NS_FRAME_COMPLETE != aStatus)) { + if (NS_FAILED(rv)) { done = PR_TRUE; break; } + if (NS_FRAME_COMPLETE != aStatus) { + if (!reflowingFirstLetter || NS_INLINE_IS_BREAK(aStatus)) { + done = PR_TRUE; + break; + } + } irs.mPrevFrame = frame; } } @@ -1515,6 +1529,7 @@ nsInlineFrame::ReflowInlineFrame(nsIPresContext* aPresContext, } nsLineLayout* lineLayout = aReflowState.lineLayout; + PRBool reflowingFirstLetter = lineLayout->GetFirstLetterStyleOK(); nsresult rv = lineLayout->ReflowFrame(aFrame, &irs.mNextRCFrame, aStatus); if (NS_FAILED(rv)) { return rv; @@ -1570,10 +1585,12 @@ nsInlineFrame::ReflowInlineFrame(nsIPresContext* aPresContext, if (NS_FAILED(rv)) { return rv; } - nsIFrame* nextFrame; - aFrame->GetNextSibling(&nextFrame); - if (nsnull != nextFrame) { - PushFrames(aPresContext, nextFrame, aFrame); + if (!reflowingFirstLetter) { + nsIFrame* nextFrame; + aFrame->GetNextSibling(&nextFrame); + if (nsnull != nextFrame) { + PushFrames(aPresContext, nextFrame, aFrame); + } } } return rv; @@ -1849,7 +1866,7 @@ NS_IMETHODIMP nsFirstLineFrame::GetFrameType(nsIAtom** aType) const { NS_PRECONDITION(nsnull != aType, "null OUT parameter pointer"); - *aType = nsHTMLAtoms::lineFrame; + *aType = nsLayoutAtoms::lineFrame; NS_ADDREF(*aType); return NS_OK; } @@ -2060,6 +2077,7 @@ nsFirstLineFrame::Reflow(nsIPresContext& aPresContext, irs.mPrevFrame = nsnull; } else { +// XXX do this in the Init method instead // For continuations, we need to check and see if our style // context is right. If its the same as the first-in-flow, then // we need to fix it up (that way :first-line style doesn't leak