From 9c95f04cf85f8b4432d96cb701427547bc1d8f69 Mon Sep 17 00:00:00 2001 From: "attinasi%netscape.com" Date: Mon, 9 Apr 2001 23:13:31 +0000 Subject: [PATCH] Fixed some bad code that was updating list position incorrectly when going from outside to inside. b=59086, r=karnaze@netscape.com sr=waterson@netscape.com git-svn-id: svn://10.0.0.236/trunk@91792 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsBlockFrame.cpp | 31 ++++++++++++++++--- mozilla/layout/generic/nsBlockReflowState.cpp | 31 ++++++++++++++++--- mozilla/layout/generic/nsBlockReflowState.h | 31 ++++++++++++++++--- mozilla/layout/html/base/src/nsBlockFrame.cpp | 31 ++++++++++++++++--- .../html/base/src/nsBlockReflowState.cpp | 31 ++++++++++++++++--- .../layout/html/base/src/nsBlockReflowState.h | 31 ++++++++++++++++--- 6 files changed, 156 insertions(+), 30 deletions(-) diff --git a/mozilla/layout/generic/nsBlockFrame.cpp b/mozilla/layout/generic/nsBlockFrame.cpp index e6cbfa9a67e..7f5997d4c3a 100644 --- a/mozilla/layout/generic/nsBlockFrame.cpp +++ b/mozilla/layout/generic/nsBlockFrame.cpp @@ -2511,12 +2511,33 @@ nsBlockFrame::UpdateBulletPosition(nsBlockReflowState& aState) if (mBullet && HaveOutsideBullet()) { // We now have an inside bullet, but used to have an outside // bullet. Adjust the frame line list - nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE); - if (!line) { - return NS_ERROR_OUT_OF_MEMORY; + if (mLines) { + // if we have a line already, then move the bullet to the front of the + // first line + nsIFrame* child = nsnull; + +#ifdef DEBUG + // bullet should not have any siblings if it was an outside bullet + nsIFrame* next = nsnull; + mBullet->GetNextSibling(&next); + NS_ASSERTION(!next, "outside bullet should not have siblings"); +#endif + // move bullet to front and chain the previous frames, and update the line count + child = mLines->mFirstChild; + mLines->mFirstChild = mBullet; + mBullet->SetNextSibling(child); + PRInt32 count = mLines->GetChildCount(); + mLines->SetChildCount(count+1); + // dirty it here in case the caller does not + mLines->MarkDirty(); + } else { + // no prior lines, just create a new line for the bullet + nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE); + if (!line) { + return NS_ERROR_OUT_OF_MEMORY; + } + mLines = line; } - line->mNext = mLines; - mLines = line; } mState &= ~NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET; } diff --git a/mozilla/layout/generic/nsBlockReflowState.cpp b/mozilla/layout/generic/nsBlockReflowState.cpp index e6cbfa9a67e..7f5997d4c3a 100644 --- a/mozilla/layout/generic/nsBlockReflowState.cpp +++ b/mozilla/layout/generic/nsBlockReflowState.cpp @@ -2511,12 +2511,33 @@ nsBlockFrame::UpdateBulletPosition(nsBlockReflowState& aState) if (mBullet && HaveOutsideBullet()) { // We now have an inside bullet, but used to have an outside // bullet. Adjust the frame line list - nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE); - if (!line) { - return NS_ERROR_OUT_OF_MEMORY; + if (mLines) { + // if we have a line already, then move the bullet to the front of the + // first line + nsIFrame* child = nsnull; + +#ifdef DEBUG + // bullet should not have any siblings if it was an outside bullet + nsIFrame* next = nsnull; + mBullet->GetNextSibling(&next); + NS_ASSERTION(!next, "outside bullet should not have siblings"); +#endif + // move bullet to front and chain the previous frames, and update the line count + child = mLines->mFirstChild; + mLines->mFirstChild = mBullet; + mBullet->SetNextSibling(child); + PRInt32 count = mLines->GetChildCount(); + mLines->SetChildCount(count+1); + // dirty it here in case the caller does not + mLines->MarkDirty(); + } else { + // no prior lines, just create a new line for the bullet + nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE); + if (!line) { + return NS_ERROR_OUT_OF_MEMORY; + } + mLines = line; } - line->mNext = mLines; - mLines = line; } mState &= ~NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET; } diff --git a/mozilla/layout/generic/nsBlockReflowState.h b/mozilla/layout/generic/nsBlockReflowState.h index e6cbfa9a67e..7f5997d4c3a 100644 --- a/mozilla/layout/generic/nsBlockReflowState.h +++ b/mozilla/layout/generic/nsBlockReflowState.h @@ -2511,12 +2511,33 @@ nsBlockFrame::UpdateBulletPosition(nsBlockReflowState& aState) if (mBullet && HaveOutsideBullet()) { // We now have an inside bullet, but used to have an outside // bullet. Adjust the frame line list - nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE); - if (!line) { - return NS_ERROR_OUT_OF_MEMORY; + if (mLines) { + // if we have a line already, then move the bullet to the front of the + // first line + nsIFrame* child = nsnull; + +#ifdef DEBUG + // bullet should not have any siblings if it was an outside bullet + nsIFrame* next = nsnull; + mBullet->GetNextSibling(&next); + NS_ASSERTION(!next, "outside bullet should not have siblings"); +#endif + // move bullet to front and chain the previous frames, and update the line count + child = mLines->mFirstChild; + mLines->mFirstChild = mBullet; + mBullet->SetNextSibling(child); + PRInt32 count = mLines->GetChildCount(); + mLines->SetChildCount(count+1); + // dirty it here in case the caller does not + mLines->MarkDirty(); + } else { + // no prior lines, just create a new line for the bullet + nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE); + if (!line) { + return NS_ERROR_OUT_OF_MEMORY; + } + mLines = line; } - line->mNext = mLines; - mLines = line; } mState &= ~NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET; } diff --git a/mozilla/layout/html/base/src/nsBlockFrame.cpp b/mozilla/layout/html/base/src/nsBlockFrame.cpp index e6cbfa9a67e..7f5997d4c3a 100644 --- a/mozilla/layout/html/base/src/nsBlockFrame.cpp +++ b/mozilla/layout/html/base/src/nsBlockFrame.cpp @@ -2511,12 +2511,33 @@ nsBlockFrame::UpdateBulletPosition(nsBlockReflowState& aState) if (mBullet && HaveOutsideBullet()) { // We now have an inside bullet, but used to have an outside // bullet. Adjust the frame line list - nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE); - if (!line) { - return NS_ERROR_OUT_OF_MEMORY; + if (mLines) { + // if we have a line already, then move the bullet to the front of the + // first line + nsIFrame* child = nsnull; + +#ifdef DEBUG + // bullet should not have any siblings if it was an outside bullet + nsIFrame* next = nsnull; + mBullet->GetNextSibling(&next); + NS_ASSERTION(!next, "outside bullet should not have siblings"); +#endif + // move bullet to front and chain the previous frames, and update the line count + child = mLines->mFirstChild; + mLines->mFirstChild = mBullet; + mBullet->SetNextSibling(child); + PRInt32 count = mLines->GetChildCount(); + mLines->SetChildCount(count+1); + // dirty it here in case the caller does not + mLines->MarkDirty(); + } else { + // no prior lines, just create a new line for the bullet + nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE); + if (!line) { + return NS_ERROR_OUT_OF_MEMORY; + } + mLines = line; } - line->mNext = mLines; - mLines = line; } mState &= ~NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET; } diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.cpp b/mozilla/layout/html/base/src/nsBlockReflowState.cpp index e6cbfa9a67e..7f5997d4c3a 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.cpp +++ b/mozilla/layout/html/base/src/nsBlockReflowState.cpp @@ -2511,12 +2511,33 @@ nsBlockFrame::UpdateBulletPosition(nsBlockReflowState& aState) if (mBullet && HaveOutsideBullet()) { // We now have an inside bullet, but used to have an outside // bullet. Adjust the frame line list - nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE); - if (!line) { - return NS_ERROR_OUT_OF_MEMORY; + if (mLines) { + // if we have a line already, then move the bullet to the front of the + // first line + nsIFrame* child = nsnull; + +#ifdef DEBUG + // bullet should not have any siblings if it was an outside bullet + nsIFrame* next = nsnull; + mBullet->GetNextSibling(&next); + NS_ASSERTION(!next, "outside bullet should not have siblings"); +#endif + // move bullet to front and chain the previous frames, and update the line count + child = mLines->mFirstChild; + mLines->mFirstChild = mBullet; + mBullet->SetNextSibling(child); + PRInt32 count = mLines->GetChildCount(); + mLines->SetChildCount(count+1); + // dirty it here in case the caller does not + mLines->MarkDirty(); + } else { + // no prior lines, just create a new line for the bullet + nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE); + if (!line) { + return NS_ERROR_OUT_OF_MEMORY; + } + mLines = line; } - line->mNext = mLines; - mLines = line; } mState &= ~NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET; } diff --git a/mozilla/layout/html/base/src/nsBlockReflowState.h b/mozilla/layout/html/base/src/nsBlockReflowState.h index e6cbfa9a67e..7f5997d4c3a 100644 --- a/mozilla/layout/html/base/src/nsBlockReflowState.h +++ b/mozilla/layout/html/base/src/nsBlockReflowState.h @@ -2511,12 +2511,33 @@ nsBlockFrame::UpdateBulletPosition(nsBlockReflowState& aState) if (mBullet && HaveOutsideBullet()) { // We now have an inside bullet, but used to have an outside // bullet. Adjust the frame line list - nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE); - if (!line) { - return NS_ERROR_OUT_OF_MEMORY; + if (mLines) { + // if we have a line already, then move the bullet to the front of the + // first line + nsIFrame* child = nsnull; + +#ifdef DEBUG + // bullet should not have any siblings if it was an outside bullet + nsIFrame* next = nsnull; + mBullet->GetNextSibling(&next); + NS_ASSERTION(!next, "outside bullet should not have siblings"); +#endif + // move bullet to front and chain the previous frames, and update the line count + child = mLines->mFirstChild; + mLines->mFirstChild = mBullet; + mBullet->SetNextSibling(child); + PRInt32 count = mLines->GetChildCount(); + mLines->SetChildCount(count+1); + // dirty it here in case the caller does not + mLines->MarkDirty(); + } else { + // no prior lines, just create a new line for the bullet + nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE); + if (!line) { + return NS_ERROR_OUT_OF_MEMORY; + } + mLines = line; } - line->mNext = mLines; - mLines = line; } mState &= ~NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET; }