Fix for printing crash when bulleted items have no bullet and we assume they do. Added assertion to help find the cause of the problem, and checks for null to prevent the crash. b=70730 r=dcone sr=waterson

This commit is contained in:
attinasi@netscape.com
2001-03-07 00:38:45 +00:00
parent 9b73ac9193
commit fa42e93e4f
8 changed files with 28 additions and 24 deletions

View File

@@ -1223,7 +1223,7 @@ nsBlockFrame::Destroy(nsIPresContext* aPresContext)
mAbsoluteContainer.DestroyFrames(this, aPresContext); mAbsoluteContainer.DestroyFrames(this, aPresContext);
// Outside bullets are not in our child-list so check for them here // Outside bullets are not in our child-list so check for them here
// and delete them when present. // and delete them when present.
if (HaveOutsideBullet()) { if (mBullet) {
mBullet->Destroy(aPresContext); mBullet->Destroy(aPresContext);
mBullet = nsnull; mBullet = nsnull;
} }
@@ -2480,7 +2480,7 @@ nsBlockFrame::UpdateBulletPosition(nsBlockReflowState& aState)
const nsStyleList* styleList; const nsStyleList* styleList;
GetStyleData(eStyleStruct_List, (const nsStyleStruct*&) styleList); GetStyleData(eStyleStruct_List, (const nsStyleStruct*&) styleList);
if (NS_STYLE_LIST_STYLE_POSITION_INSIDE == styleList->mListStylePosition) { if (NS_STYLE_LIST_STYLE_POSITION_INSIDE == styleList->mListStylePosition) {
if (HaveOutsideBullet()) { if (mBullet && HaveOutsideBullet()) {
// We now have an inside bullet, but used to have an outside // We now have an inside bullet, but used to have an outside
// bullet. Adjust the frame line list // bullet. Adjust the frame line list
nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE); nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE);
@@ -4061,7 +4061,7 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState,
// rare case: an empty first line followed by a second line that // rare case: an empty first line followed by a second line that
// contains a block (example: <LI>\n<P>... ). This is where // contains a block (example: <LI>\n<P>... ). This is where
// the second case can happen. // the second case can happen.
if (HaveOutsideBullet() && if (mBullet && HaveOutsideBullet() &&
((aLine == mLines) || ((aLine == mLines) ||
((0 == mLines->mBounds.height) && (aLine == mLines->mNext)))) { ((0 == mLines->mBounds.height) && (aLine == mLines->mNext)))) {
// Reflow the bullet // Reflow the bullet
@@ -4683,7 +4683,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
// case is happening then the worst that will happen is that the // case is happening then the worst that will happen is that the
// bullet frame will be reflowed twice. // bullet frame will be reflowed twice.
PRBool addedBullet = PR_FALSE; PRBool addedBullet = PR_FALSE;
if (HaveOutsideBullet() && (aLine == mLines) && if (mBullet && HaveOutsideBullet() && (aLine == mLines) &&
(!aLineLayout.IsZeroHeight() || !aLine->mNext)) { (!aLineLayout.IsZeroHeight() || !aLine->mNext)) {
nsHTMLReflowMetrics metrics(nsnull); nsHTMLReflowMetrics metrics(nsnull);
ReflowBullet(aState, metrics); ReflowBullet(aState, metrics);

View File

@@ -172,6 +172,8 @@ protected:
} }
PRBool HaveOutsideBullet() const { PRBool HaveOutsideBullet() const {
NS_ASSERTION((mState & NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET) ? nsnull!=mBullet : nsnull==mBullet,
"HaveOutsideBullet flag and mBullet are out of synch");
return 0 != (mState & NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET); return 0 != (mState & NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET);
} }

View File

@@ -1223,7 +1223,7 @@ nsBlockFrame::Destroy(nsIPresContext* aPresContext)
mAbsoluteContainer.DestroyFrames(this, aPresContext); mAbsoluteContainer.DestroyFrames(this, aPresContext);
// Outside bullets are not in our child-list so check for them here // Outside bullets are not in our child-list so check for them here
// and delete them when present. // and delete them when present.
if (HaveOutsideBullet()) { if (mBullet) {
mBullet->Destroy(aPresContext); mBullet->Destroy(aPresContext);
mBullet = nsnull; mBullet = nsnull;
} }
@@ -2480,7 +2480,7 @@ nsBlockFrame::UpdateBulletPosition(nsBlockReflowState& aState)
const nsStyleList* styleList; const nsStyleList* styleList;
GetStyleData(eStyleStruct_List, (const nsStyleStruct*&) styleList); GetStyleData(eStyleStruct_List, (const nsStyleStruct*&) styleList);
if (NS_STYLE_LIST_STYLE_POSITION_INSIDE == styleList->mListStylePosition) { if (NS_STYLE_LIST_STYLE_POSITION_INSIDE == styleList->mListStylePosition) {
if (HaveOutsideBullet()) { if (mBullet && HaveOutsideBullet()) {
// We now have an inside bullet, but used to have an outside // We now have an inside bullet, but used to have an outside
// bullet. Adjust the frame line list // bullet. Adjust the frame line list
nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE); nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE);
@@ -4061,7 +4061,7 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState,
// rare case: an empty first line followed by a second line that // rare case: an empty first line followed by a second line that
// contains a block (example: <LI>\n<P>... ). This is where // contains a block (example: <LI>\n<P>... ). This is where
// the second case can happen. // the second case can happen.
if (HaveOutsideBullet() && if (mBullet && HaveOutsideBullet() &&
((aLine == mLines) || ((aLine == mLines) ||
((0 == mLines->mBounds.height) && (aLine == mLines->mNext)))) { ((0 == mLines->mBounds.height) && (aLine == mLines->mNext)))) {
// Reflow the bullet // Reflow the bullet
@@ -4683,7 +4683,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
// case is happening then the worst that will happen is that the // case is happening then the worst that will happen is that the
// bullet frame will be reflowed twice. // bullet frame will be reflowed twice.
PRBool addedBullet = PR_FALSE; PRBool addedBullet = PR_FALSE;
if (HaveOutsideBullet() && (aLine == mLines) && if (mBullet && HaveOutsideBullet() && (aLine == mLines) &&
(!aLineLayout.IsZeroHeight() || !aLine->mNext)) { (!aLineLayout.IsZeroHeight() || !aLine->mNext)) {
nsHTMLReflowMetrics metrics(nsnull); nsHTMLReflowMetrics metrics(nsnull);
ReflowBullet(aState, metrics); ReflowBullet(aState, metrics);

View File

@@ -1223,7 +1223,7 @@ nsBlockFrame::Destroy(nsIPresContext* aPresContext)
mAbsoluteContainer.DestroyFrames(this, aPresContext); mAbsoluteContainer.DestroyFrames(this, aPresContext);
// Outside bullets are not in our child-list so check for them here // Outside bullets are not in our child-list so check for them here
// and delete them when present. // and delete them when present.
if (HaveOutsideBullet()) { if (mBullet) {
mBullet->Destroy(aPresContext); mBullet->Destroy(aPresContext);
mBullet = nsnull; mBullet = nsnull;
} }
@@ -2480,7 +2480,7 @@ nsBlockFrame::UpdateBulletPosition(nsBlockReflowState& aState)
const nsStyleList* styleList; const nsStyleList* styleList;
GetStyleData(eStyleStruct_List, (const nsStyleStruct*&) styleList); GetStyleData(eStyleStruct_List, (const nsStyleStruct*&) styleList);
if (NS_STYLE_LIST_STYLE_POSITION_INSIDE == styleList->mListStylePosition) { if (NS_STYLE_LIST_STYLE_POSITION_INSIDE == styleList->mListStylePosition) {
if (HaveOutsideBullet()) { if (mBullet && HaveOutsideBullet()) {
// We now have an inside bullet, but used to have an outside // We now have an inside bullet, but used to have an outside
// bullet. Adjust the frame line list // bullet. Adjust the frame line list
nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE); nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE);
@@ -4061,7 +4061,7 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState,
// rare case: an empty first line followed by a second line that // rare case: an empty first line followed by a second line that
// contains a block (example: <LI>\n<P>... ). This is where // contains a block (example: <LI>\n<P>... ). This is where
// the second case can happen. // the second case can happen.
if (HaveOutsideBullet() && if (mBullet && HaveOutsideBullet() &&
((aLine == mLines) || ((aLine == mLines) ||
((0 == mLines->mBounds.height) && (aLine == mLines->mNext)))) { ((0 == mLines->mBounds.height) && (aLine == mLines->mNext)))) {
// Reflow the bullet // Reflow the bullet
@@ -4683,7 +4683,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
// case is happening then the worst that will happen is that the // case is happening then the worst that will happen is that the
// bullet frame will be reflowed twice. // bullet frame will be reflowed twice.
PRBool addedBullet = PR_FALSE; PRBool addedBullet = PR_FALSE;
if (HaveOutsideBullet() && (aLine == mLines) && if (mBullet && HaveOutsideBullet() && (aLine == mLines) &&
(!aLineLayout.IsZeroHeight() || !aLine->mNext)) { (!aLineLayout.IsZeroHeight() || !aLine->mNext)) {
nsHTMLReflowMetrics metrics(nsnull); nsHTMLReflowMetrics metrics(nsnull);
ReflowBullet(aState, metrics); ReflowBullet(aState, metrics);

View File

@@ -1223,7 +1223,7 @@ nsBlockFrame::Destroy(nsIPresContext* aPresContext)
mAbsoluteContainer.DestroyFrames(this, aPresContext); mAbsoluteContainer.DestroyFrames(this, aPresContext);
// Outside bullets are not in our child-list so check for them here // Outside bullets are not in our child-list so check for them here
// and delete them when present. // and delete them when present.
if (HaveOutsideBullet()) { if (mBullet) {
mBullet->Destroy(aPresContext); mBullet->Destroy(aPresContext);
mBullet = nsnull; mBullet = nsnull;
} }
@@ -2480,7 +2480,7 @@ nsBlockFrame::UpdateBulletPosition(nsBlockReflowState& aState)
const nsStyleList* styleList; const nsStyleList* styleList;
GetStyleData(eStyleStruct_List, (const nsStyleStruct*&) styleList); GetStyleData(eStyleStruct_List, (const nsStyleStruct*&) styleList);
if (NS_STYLE_LIST_STYLE_POSITION_INSIDE == styleList->mListStylePosition) { if (NS_STYLE_LIST_STYLE_POSITION_INSIDE == styleList->mListStylePosition) {
if (HaveOutsideBullet()) { if (mBullet && HaveOutsideBullet()) {
// We now have an inside bullet, but used to have an outside // We now have an inside bullet, but used to have an outside
// bullet. Adjust the frame line list // bullet. Adjust the frame line list
nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE); nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE);
@@ -4061,7 +4061,7 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState,
// rare case: an empty first line followed by a second line that // rare case: an empty first line followed by a second line that
// contains a block (example: <LI>\n<P>... ). This is where // contains a block (example: <LI>\n<P>... ). This is where
// the second case can happen. // the second case can happen.
if (HaveOutsideBullet() && if (mBullet && HaveOutsideBullet() &&
((aLine == mLines) || ((aLine == mLines) ||
((0 == mLines->mBounds.height) && (aLine == mLines->mNext)))) { ((0 == mLines->mBounds.height) && (aLine == mLines->mNext)))) {
// Reflow the bullet // Reflow the bullet
@@ -4683,7 +4683,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
// case is happening then the worst that will happen is that the // case is happening then the worst that will happen is that the
// bullet frame will be reflowed twice. // bullet frame will be reflowed twice.
PRBool addedBullet = PR_FALSE; PRBool addedBullet = PR_FALSE;
if (HaveOutsideBullet() && (aLine == mLines) && if (mBullet && HaveOutsideBullet() && (aLine == mLines) &&
(!aLineLayout.IsZeroHeight() || !aLine->mNext)) { (!aLineLayout.IsZeroHeight() || !aLine->mNext)) {
nsHTMLReflowMetrics metrics(nsnull); nsHTMLReflowMetrics metrics(nsnull);
ReflowBullet(aState, metrics); ReflowBullet(aState, metrics);

View File

@@ -172,6 +172,8 @@ protected:
} }
PRBool HaveOutsideBullet() const { PRBool HaveOutsideBullet() const {
NS_ASSERTION((mState & NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET) ? nsnull!=mBullet : nsnull==mBullet,
"HaveOutsideBullet flag and mBullet are out of synch");
return 0 != (mState & NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET); return 0 != (mState & NS_BLOCK_FRAME_HAS_OUTSIDE_BULLET);
} }

View File

@@ -1223,7 +1223,7 @@ nsBlockFrame::Destroy(nsIPresContext* aPresContext)
mAbsoluteContainer.DestroyFrames(this, aPresContext); mAbsoluteContainer.DestroyFrames(this, aPresContext);
// Outside bullets are not in our child-list so check for them here // Outside bullets are not in our child-list so check for them here
// and delete them when present. // and delete them when present.
if (HaveOutsideBullet()) { if (mBullet) {
mBullet->Destroy(aPresContext); mBullet->Destroy(aPresContext);
mBullet = nsnull; mBullet = nsnull;
} }
@@ -2480,7 +2480,7 @@ nsBlockFrame::UpdateBulletPosition(nsBlockReflowState& aState)
const nsStyleList* styleList; const nsStyleList* styleList;
GetStyleData(eStyleStruct_List, (const nsStyleStruct*&) styleList); GetStyleData(eStyleStruct_List, (const nsStyleStruct*&) styleList);
if (NS_STYLE_LIST_STYLE_POSITION_INSIDE == styleList->mListStylePosition) { if (NS_STYLE_LIST_STYLE_POSITION_INSIDE == styleList->mListStylePosition) {
if (HaveOutsideBullet()) { if (mBullet && HaveOutsideBullet()) {
// We now have an inside bullet, but used to have an outside // We now have an inside bullet, but used to have an outside
// bullet. Adjust the frame line list // bullet. Adjust the frame line list
nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE); nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE);
@@ -4061,7 +4061,7 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState,
// rare case: an empty first line followed by a second line that // rare case: an empty first line followed by a second line that
// contains a block (example: <LI>\n<P>... ). This is where // contains a block (example: <LI>\n<P>... ). This is where
// the second case can happen. // the second case can happen.
if (HaveOutsideBullet() && if (mBullet && HaveOutsideBullet() &&
((aLine == mLines) || ((aLine == mLines) ||
((0 == mLines->mBounds.height) && (aLine == mLines->mNext)))) { ((0 == mLines->mBounds.height) && (aLine == mLines->mNext)))) {
// Reflow the bullet // Reflow the bullet
@@ -4683,7 +4683,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
// case is happening then the worst that will happen is that the // case is happening then the worst that will happen is that the
// bullet frame will be reflowed twice. // bullet frame will be reflowed twice.
PRBool addedBullet = PR_FALSE; PRBool addedBullet = PR_FALSE;
if (HaveOutsideBullet() && (aLine == mLines) && if (mBullet && HaveOutsideBullet() && (aLine == mLines) &&
(!aLineLayout.IsZeroHeight() || !aLine->mNext)) { (!aLineLayout.IsZeroHeight() || !aLine->mNext)) {
nsHTMLReflowMetrics metrics(nsnull); nsHTMLReflowMetrics metrics(nsnull);
ReflowBullet(aState, metrics); ReflowBullet(aState, metrics);

View File

@@ -1223,7 +1223,7 @@ nsBlockFrame::Destroy(nsIPresContext* aPresContext)
mAbsoluteContainer.DestroyFrames(this, aPresContext); mAbsoluteContainer.DestroyFrames(this, aPresContext);
// Outside bullets are not in our child-list so check for them here // Outside bullets are not in our child-list so check for them here
// and delete them when present. // and delete them when present.
if (HaveOutsideBullet()) { if (mBullet) {
mBullet->Destroy(aPresContext); mBullet->Destroy(aPresContext);
mBullet = nsnull; mBullet = nsnull;
} }
@@ -2480,7 +2480,7 @@ nsBlockFrame::UpdateBulletPosition(nsBlockReflowState& aState)
const nsStyleList* styleList; const nsStyleList* styleList;
GetStyleData(eStyleStruct_List, (const nsStyleStruct*&) styleList); GetStyleData(eStyleStruct_List, (const nsStyleStruct*&) styleList);
if (NS_STYLE_LIST_STYLE_POSITION_INSIDE == styleList->mListStylePosition) { if (NS_STYLE_LIST_STYLE_POSITION_INSIDE == styleList->mListStylePosition) {
if (HaveOutsideBullet()) { if (mBullet && HaveOutsideBullet()) {
// We now have an inside bullet, but used to have an outside // We now have an inside bullet, but used to have an outside
// bullet. Adjust the frame line list // bullet. Adjust the frame line list
nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE); nsLineBox* line = aState.NewLineBox(mBullet, 1, PR_FALSE);
@@ -4061,7 +4061,7 @@ nsBlockFrame::ReflowBlockFrame(nsBlockReflowState& aState,
// rare case: an empty first line followed by a second line that // rare case: an empty first line followed by a second line that
// contains a block (example: <LI>\n<P>... ). This is where // contains a block (example: <LI>\n<P>... ). This is where
// the second case can happen. // the second case can happen.
if (HaveOutsideBullet() && if (mBullet && HaveOutsideBullet() &&
((aLine == mLines) || ((aLine == mLines) ||
((0 == mLines->mBounds.height) && (aLine == mLines->mNext)))) { ((0 == mLines->mBounds.height) && (aLine == mLines->mNext)))) {
// Reflow the bullet // Reflow the bullet
@@ -4683,7 +4683,7 @@ nsBlockFrame::PlaceLine(nsBlockReflowState& aState,
// case is happening then the worst that will happen is that the // case is happening then the worst that will happen is that the
// bullet frame will be reflowed twice. // bullet frame will be reflowed twice.
PRBool addedBullet = PR_FALSE; PRBool addedBullet = PR_FALSE;
if (HaveOutsideBullet() && (aLine == mLines) && if (mBullet && HaveOutsideBullet() && (aLine == mLines) &&
(!aLineLayout.IsZeroHeight() || !aLine->mNext)) { (!aLineLayout.IsZeroHeight() || !aLine->mNext)) {
nsHTMLReflowMetrics metrics(nsnull); nsHTMLReflowMetrics metrics(nsnull);
ReflowBullet(aState, metrics); ReflowBullet(aState, metrics);