Added methods to support word breaking
git-svn-id: svn://10.0.0.236/trunk@12508 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -100,6 +100,64 @@ nsLineLayout::AddText(nsIFrame* aTextFrame)
|
||||
return NS_OK;/* XXX */
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
nsLineLayout::FindNextText(nsIFrame* aFrame)
|
||||
{
|
||||
// Only the first-in-flows are present in the text run list so
|
||||
// backup from the argument frame to its first-in-flow.
|
||||
for (;;) {
|
||||
nsIFrame* prevInFlow;
|
||||
aFrame->GetPrevInFlow(prevInFlow);
|
||||
if (nsnull == prevInFlow) {
|
||||
break;
|
||||
}
|
||||
aFrame = prevInFlow;
|
||||
}
|
||||
|
||||
// Now look for the frame that follows aFrame's first-in-flow
|
||||
nsTextRun* run = mReflowTextRuns;
|
||||
while (nsnull != run) {
|
||||
PRInt32 ix = run->mArray.IndexOf(aFrame);
|
||||
if (ix >= 0) {
|
||||
if (ix < run->mArray.Count() - 1) {
|
||||
return (nsIFrame*) run->mArray[ix + 1];
|
||||
}
|
||||
}
|
||||
run = run->mNext;
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsLineLayout::IsNextWordFrame(nsIFrame* aFrame)
|
||||
{
|
||||
if (0 != mWordFrames.Count()) {
|
||||
nsIFrame* next = (nsIFrame*) mWordFrames[0];
|
||||
return next == aFrame;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsLineLayout::IsLastWordFrame(nsIFrame* aFrame)
|
||||
{
|
||||
PRInt32 n = mWordFrames.Count();
|
||||
if (0 != n) {
|
||||
nsIFrame* next = (nsIFrame*) mWordFrames[0];
|
||||
return (next == aFrame) && (1 == n);
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
nsLineLayout::ForgetWordFrame(nsIFrame* aFrame)
|
||||
{
|
||||
NS_ASSERTION((void*)aFrame == mWordFrames[0], "forget-word-frame");
|
||||
if (0 != mWordFrames.Count()) {
|
||||
mWordFrames.RemoveElementAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX move this somewhere else!!!
|
||||
PRBool
|
||||
nsLineLayout::TreatFrameAsBlock(const nsStyleDisplay* aDisplay,
|
||||
|
||||
@@ -75,6 +75,7 @@ public:
|
||||
#ifdef NS_DEBUG
|
||||
mPlacedFrames.Clear();
|
||||
#endif
|
||||
ForgetWordFrames();
|
||||
}
|
||||
|
||||
// Add to the placed-frame count
|
||||
@@ -116,8 +117,6 @@ public:
|
||||
void UpdateInlines(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
|
||||
PRBool aPlacedLeftFloater);
|
||||
|
||||
// --------------------------------------------------
|
||||
|
||||
// Reset the text-run information in preparation for a FindTextRuns
|
||||
void ResetTextRuns();
|
||||
|
||||
@@ -133,6 +132,30 @@ public:
|
||||
// FindTextRuns. The internal text-run state is reset.
|
||||
nsTextRun* TakeTextRuns();
|
||||
|
||||
void SetReflowTextRuns(nsTextRun* aTextRuns) {
|
||||
mReflowTextRuns = aTextRuns;
|
||||
}
|
||||
|
||||
nsIFrame* FindNextText(nsIFrame* aFrame);
|
||||
|
||||
void RecordWordFrame(nsIFrame* aWordFrame) {
|
||||
mWordFrames.AppendElement(aWordFrame);
|
||||
}
|
||||
|
||||
void ForgetWordFrames() {
|
||||
mWordFrames.Clear();
|
||||
}
|
||||
|
||||
PRBool IsNextWordFrame(nsIFrame* aFrame);
|
||||
|
||||
PRBool InNonBreakingUnit() {
|
||||
return 0 != mWordFrames.Count();
|
||||
}
|
||||
|
||||
PRBool IsLastWordFrame(nsIFrame* aFrame);
|
||||
|
||||
void ForgetWordFrame(nsIFrame* aFrame);
|
||||
|
||||
PRInt32 GetColumn() {
|
||||
return mColumn;
|
||||
}
|
||||
@@ -145,18 +168,19 @@ public:
|
||||
mLineNumber++;
|
||||
}
|
||||
|
||||
void AddFloater(nsPlaceholderFrame* aFrame);
|
||||
|
||||
static PRBool TreatFrameAsBlock(const nsStyleDisplay* aDisplay,
|
||||
const nsStylePosition* aPosition);
|
||||
|
||||
// --------------------------------------------------
|
||||
|
||||
void AddFloater(nsPlaceholderFrame* aFrame);
|
||||
|
||||
nsIPresContext& mPresContext;
|
||||
nsISpaceManager* mSpaceManager;
|
||||
nsBlockReflowState* mBlockReflowState;
|
||||
|
||||
PRBool mListPositionOutside;
|
||||
PRInt32 mLineNumber;
|
||||
// nscoord mLeftEdge;
|
||||
PRInt32 mColumn;
|
||||
|
||||
//XXX temporary?
|
||||
@@ -176,6 +200,8 @@ protected:
|
||||
nsVoidArray mPlacedFrames;
|
||||
#endif
|
||||
|
||||
nsVoidArray mWordFrames;
|
||||
|
||||
nsVoidArray mInlineStack;
|
||||
|
||||
// These slots are used during FindTextRuns
|
||||
|
||||
@@ -100,6 +100,64 @@ nsLineLayout::AddText(nsIFrame* aTextFrame)
|
||||
return NS_OK;/* XXX */
|
||||
}
|
||||
|
||||
nsIFrame*
|
||||
nsLineLayout::FindNextText(nsIFrame* aFrame)
|
||||
{
|
||||
// Only the first-in-flows are present in the text run list so
|
||||
// backup from the argument frame to its first-in-flow.
|
||||
for (;;) {
|
||||
nsIFrame* prevInFlow;
|
||||
aFrame->GetPrevInFlow(prevInFlow);
|
||||
if (nsnull == prevInFlow) {
|
||||
break;
|
||||
}
|
||||
aFrame = prevInFlow;
|
||||
}
|
||||
|
||||
// Now look for the frame that follows aFrame's first-in-flow
|
||||
nsTextRun* run = mReflowTextRuns;
|
||||
while (nsnull != run) {
|
||||
PRInt32 ix = run->mArray.IndexOf(aFrame);
|
||||
if (ix >= 0) {
|
||||
if (ix < run->mArray.Count() - 1) {
|
||||
return (nsIFrame*) run->mArray[ix + 1];
|
||||
}
|
||||
}
|
||||
run = run->mNext;
|
||||
}
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsLineLayout::IsNextWordFrame(nsIFrame* aFrame)
|
||||
{
|
||||
if (0 != mWordFrames.Count()) {
|
||||
nsIFrame* next = (nsIFrame*) mWordFrames[0];
|
||||
return next == aFrame;
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsLineLayout::IsLastWordFrame(nsIFrame* aFrame)
|
||||
{
|
||||
PRInt32 n = mWordFrames.Count();
|
||||
if (0 != n) {
|
||||
nsIFrame* next = (nsIFrame*) mWordFrames[0];
|
||||
return (next == aFrame) && (1 == n);
|
||||
}
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
nsLineLayout::ForgetWordFrame(nsIFrame* aFrame)
|
||||
{
|
||||
NS_ASSERTION((void*)aFrame == mWordFrames[0], "forget-word-frame");
|
||||
if (0 != mWordFrames.Count()) {
|
||||
mWordFrames.RemoveElementAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX move this somewhere else!!!
|
||||
PRBool
|
||||
nsLineLayout::TreatFrameAsBlock(const nsStyleDisplay* aDisplay,
|
||||
|
||||
@@ -75,6 +75,7 @@ public:
|
||||
#ifdef NS_DEBUG
|
||||
mPlacedFrames.Clear();
|
||||
#endif
|
||||
ForgetWordFrames();
|
||||
}
|
||||
|
||||
// Add to the placed-frame count
|
||||
@@ -116,8 +117,6 @@ public:
|
||||
void UpdateInlines(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
|
||||
PRBool aPlacedLeftFloater);
|
||||
|
||||
// --------------------------------------------------
|
||||
|
||||
// Reset the text-run information in preparation for a FindTextRuns
|
||||
void ResetTextRuns();
|
||||
|
||||
@@ -133,6 +132,30 @@ public:
|
||||
// FindTextRuns. The internal text-run state is reset.
|
||||
nsTextRun* TakeTextRuns();
|
||||
|
||||
void SetReflowTextRuns(nsTextRun* aTextRuns) {
|
||||
mReflowTextRuns = aTextRuns;
|
||||
}
|
||||
|
||||
nsIFrame* FindNextText(nsIFrame* aFrame);
|
||||
|
||||
void RecordWordFrame(nsIFrame* aWordFrame) {
|
||||
mWordFrames.AppendElement(aWordFrame);
|
||||
}
|
||||
|
||||
void ForgetWordFrames() {
|
||||
mWordFrames.Clear();
|
||||
}
|
||||
|
||||
PRBool IsNextWordFrame(nsIFrame* aFrame);
|
||||
|
||||
PRBool InNonBreakingUnit() {
|
||||
return 0 != mWordFrames.Count();
|
||||
}
|
||||
|
||||
PRBool IsLastWordFrame(nsIFrame* aFrame);
|
||||
|
||||
void ForgetWordFrame(nsIFrame* aFrame);
|
||||
|
||||
PRInt32 GetColumn() {
|
||||
return mColumn;
|
||||
}
|
||||
@@ -145,18 +168,19 @@ public:
|
||||
mLineNumber++;
|
||||
}
|
||||
|
||||
void AddFloater(nsPlaceholderFrame* aFrame);
|
||||
|
||||
static PRBool TreatFrameAsBlock(const nsStyleDisplay* aDisplay,
|
||||
const nsStylePosition* aPosition);
|
||||
|
||||
// --------------------------------------------------
|
||||
|
||||
void AddFloater(nsPlaceholderFrame* aFrame);
|
||||
|
||||
nsIPresContext& mPresContext;
|
||||
nsISpaceManager* mSpaceManager;
|
||||
nsBlockReflowState* mBlockReflowState;
|
||||
|
||||
PRBool mListPositionOutside;
|
||||
PRInt32 mLineNumber;
|
||||
// nscoord mLeftEdge;
|
||||
PRInt32 mColumn;
|
||||
|
||||
//XXX temporary?
|
||||
@@ -176,6 +200,8 @@ protected:
|
||||
nsVoidArray mPlacedFrames;
|
||||
#endif
|
||||
|
||||
nsVoidArray mWordFrames;
|
||||
|
||||
nsVoidArray mInlineStack;
|
||||
|
||||
// These slots are used during FindTextRuns
|
||||
|
||||
Reference in New Issue
Block a user