mjudge checkin in from ftangs machine. fixing japanese lockup. this will not fix the strange loss of the commit event to the ESM however. that was making thisproblem obvious.

This commit is contained in:
ftang@netscape.com
2000-04-10 21:02:25 +00:00
parent 75e320d3b2
commit d30c9a4408
2 changed files with 192 additions and 222 deletions

View File

@@ -852,6 +852,12 @@ DrawSelectionIterator::DrawSelectionIterator(const SelectionDetails *aSelDetails
} }
details= details->mNext; details= details->mNext;
} }
if (!mInit && mTypes) //we have details but none that we care about.
{
delete mTypes;
mTypes = nsnull;
mDone = PR_TRUE;//we are finished
}
} }
else if (details->mStart == details->mEnd)//no collapsed selections here! else if (details->mStart == details->mEnd)//no collapsed selections here!
{ {
@@ -897,7 +903,10 @@ DrawSelectionIterator::FillCurrentData()
{ {
mCurrentIdx+=mCurrentLength;//advance to this chunk mCurrentIdx+=mCurrentLength;//advance to this chunk
if (mCurrentIdx >= mLength) if (mCurrentIdx >= mLength)
{
mDone = PR_TRUE;
return; return;
}
uint8 typevalue = mTypes[mCurrentIdx]; uint8 typevalue = mTypes[mCurrentIdx];
while (typevalue == mTypes[mCurrentIdx+mCurrentLength] && (mCurrentIdx+mCurrentLength) <mLength) while (typevalue == mTypes[mCurrentIdx+mCurrentLength] && (mCurrentIdx+mCurrentLength) <mLength)
{ {
@@ -1740,46 +1749,39 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
sdptr = sdptr->mNext; sdptr = sdptr->mNext;
} }
//while we have substrings... //while we have substrings...
if (details) PRBool drawn = PR_FALSE;
DrawSelectionIterator iter(details,text,(PRUint32)textLength,aTextStyle);
if (!iter.IsDone() && iter.First())
{ {
DrawSelectionIterator iter(details,text,(PRUint32)textLength,aTextStyle); nscoord currentX = dx;
if (iter.First()) nscoord newWidth;//temp
while (!iter.IsDone())
{ {
nscoord currentX = dx; PRUnichar *currenttext = iter.CurrentTextUnicharPtr();
nscoord newWidth;//temp PRUint32 currentlength= iter.CurrentLength();
while (!iter.IsDone()) TextStyle &currentStyle = iter.CurrentStyle();
nscolor currentFGColor = iter.CurrentForeGroundColor();
nscolor currentBKColor;
if (NS_SUCCEEDED(aRenderingContext.GetWidth(currenttext, currentlength,newWidth)))//ADJUST FOR CHAR SPACING
{ {
PRUnichar *currenttext = iter.CurrentTextUnicharPtr(); if (iter.CurrentBackGroundColor(currentBKColor))
PRUint32 currentlength= iter.CurrentLength(); {//DRAW RECT HERE!!!
TextStyle &currentStyle = iter.CurrentStyle(); aRenderingContext.SetColor(currentBKColor);
nscolor currentFGColor = iter.CurrentForeGroundColor(); aRenderingContext.FillRect(currentX, dy, newWidth, mRect.height);
nscolor currentBKColor; currentFGColor = EnsureDifferentColors(currentFGColor, currentBKColor);
if (NS_SUCCEEDED(aRenderingContext.GetWidth(currenttext, currentlength,newWidth)))//ADJUST FOR CHAR SPACING
{
if (iter.CurrentBackGroundColor(currentBKColor))
{//DRAW RECT HERE!!!
aRenderingContext.SetColor(currentBKColor);
aRenderingContext.FillRect(currentX, dy, newWidth, mRect.height);
currentFGColor = EnsureDifferentColors(currentFGColor, currentBKColor);
}
} }
else
newWidth =0;
aRenderingContext.SetColor(currentFGColor);
aRenderingContext.DrawString(currenttext, currentlength, currentX, dy);
currentX+=newWidth;//increment twips X start
iter.Next();
} }
} else
else newWidth =0;
{
aRenderingContext.SetColor(aTextStyle.mColor->mColor);
aRenderingContext.DrawString(text, PRUint32(textLength), dx, dy); aRenderingContext.SetColor(currentFGColor);
aRenderingContext.DrawString(currenttext, currentlength, currentX, dy);
currentX+=newWidth;//increment twips X start
iter.Next();
} }
} }
else else
@@ -1801,7 +1803,6 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
} }
} }
//measure Spaced Textvoid //measure Spaced Textvoid
nsresult nsresult
nsTextFrame::GetPositionSlowly(nsIPresContext* aPresContext, nsTextFrame::GetPositionSlowly(nsIPresContext* aPresContext,
@@ -2202,48 +2203,40 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext,
sdptr->mEnd = ip[sdptr->mEnd] - mContentOffset; sdptr->mEnd = ip[sdptr->mEnd] - mContentOffset;
sdptr = sdptr->mNext; sdptr = sdptr->mNext;
} }
if (details)
{
DrawSelectionIterator iter(details,text,(PRUint32)textLength,aTextStyle);
if (iter.First())
{
nscoord currentX = dx;
nscoord newWidth;//temp
while (!iter.IsDone())
{
PRUnichar *currenttext = iter.CurrentTextUnicharPtr();
PRUint32 currentlength= iter.CurrentLength();
TextStyle &currentStyle = iter.CurrentStyle();
nscolor currentFGColor = iter.CurrentForeGroundColor();
nscolor currentBKColor;
GetWidth(aRenderingContext,aTextStyle,currenttext, (PRInt32)currentlength,&newWidth);
if (newWidth)
{
if (iter.CurrentBackGroundColor(currentBKColor))
{//DRAW RECT HERE!!!
aRenderingContext.SetColor(currentBKColor);
aRenderingContext.FillRect(currentX, dy, newWidth, mRect.height);
currentFGColor = EnsureDifferentColors(currentFGColor, currentBKColor);
}
}
else
newWidth =0;
aRenderingContext.SetColor(currentFGColor);
RenderString(aRenderingContext,aStyleContext, aTextStyle, currenttext,
currentlength, currentX, dy, width, details);
//increment twips X start but remember to get ready for next draw by reducing current x by letter spacing amount
currentX+=newWidth;// + aTextStyle.mLetterSpacing;
iter.Next(); DrawSelectionIterator iter(details,text,(PRUint32)textLength,aTextStyle);
} if (!iter.IsDone() && iter.First())
} {
else nscoord currentX = dx;
{ nscoord newWidth;//temp
aRenderingContext.SetColor(aTextStyle.mColor->mColor); while (!iter.IsDone())
RenderString(aRenderingContext,aStyleContext, aTextStyle, text, {
PRUint32(textLength), dx, dy, width, details); PRUnichar *currenttext = iter.CurrentTextUnicharPtr();
} PRUint32 currentlength= iter.CurrentLength();
TextStyle &currentStyle = iter.CurrentStyle();
nscolor currentFGColor = iter.CurrentForeGroundColor();
nscolor currentBKColor;
GetWidth(aRenderingContext,aTextStyle,currenttext, (PRInt32)currentlength,&newWidth);
if (newWidth)
{
if (iter.CurrentBackGroundColor(currentBKColor))
{//DRAW RECT HERE!!!
aRenderingContext.SetColor(currentBKColor);
aRenderingContext.FillRect(currentX, dy, newWidth, mRect.height);
currentFGColor = EnsureDifferentColors(currentFGColor, currentBKColor);
}
}
else
newWidth =0;
aRenderingContext.SetColor(currentFGColor);
RenderString(aRenderingContext,aStyleContext, aTextStyle, currenttext,
currentlength, currentX, dy, width, details);
//increment twips X start but remember to get ready for next draw by reducing current x by letter spacing amount
currentX+=newWidth;// + aTextStyle.mLetterSpacing;
iter.Next();
}
} }
else else
{ {
@@ -2354,45 +2347,37 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext,
sdptr->mEnd = ip[sdptr->mEnd] - mContentOffset; sdptr->mEnd = ip[sdptr->mEnd] - mContentOffset;
sdptr = sdptr->mNext; sdptr = sdptr->mNext;
} }
if (details) DrawSelectionIterator iter(details,(PRUnichar *)text,(PRUint32)textLength,aTextStyle);//ITS OK TO CAST HERE THE RESULT WE USE WILLNOT DO BAD CONVERSION
if (!iter.IsDone() && iter.First())
{ {
DrawSelectionIterator iter(details,(PRUnichar *)text,(PRUint32)textLength,aTextStyle);//ITS OK TO CAST HERE THE RESULT WE USE WILLNOT DO BAD CONVERSION nscoord currentX = dx;
if (iter.First()) nscoord newWidth;//temp
while (!iter.IsDone())
{ {
nscoord currentX = dx; char *currenttext = iter.CurrentTextCStrPtr();
nscoord newWidth;//temp PRUint32 currentlength= iter.CurrentLength();
while (!iter.IsDone()) TextStyle &currentStyle = iter.CurrentStyle();
nscolor currentFGColor = iter.CurrentForeGroundColor();
nscolor currentBKColor;
if (NS_SUCCEEDED(aRenderingContext.GetWidth(currenttext, currentlength,newWidth)))//ADJUST FOR CHAR SPACING
{ {
char *currenttext = iter.CurrentTextCStrPtr(); if (iter.CurrentBackGroundColor(currentBKColor))
PRUint32 currentlength= iter.CurrentLength(); {//DRAW RECT HERE!!!
TextStyle &currentStyle = iter.CurrentStyle(); aRenderingContext.SetColor(currentBKColor);
nscolor currentFGColor = iter.CurrentForeGroundColor(); aRenderingContext.FillRect(currentX, dy, newWidth, mRect.height);
nscolor currentBKColor; currentFGColor = EnsureDifferentColors(currentFGColor, currentBKColor);
if (NS_SUCCEEDED(aRenderingContext.GetWidth(currenttext, currentlength,newWidth)))//ADJUST FOR CHAR SPACING
{
if (iter.CurrentBackGroundColor(currentBKColor))
{//DRAW RECT HERE!!!
aRenderingContext.SetColor(currentBKColor);
aRenderingContext.FillRect(currentX, dy, newWidth, mRect.height);
currentFGColor = EnsureDifferentColors(currentFGColor, currentBKColor);
}
} }
else
newWidth =0;
aRenderingContext.SetColor(currentFGColor);
aRenderingContext.DrawString(currenttext, currentlength, currentX, dy);
currentX+=newWidth;//increment twips X start
iter.Next();
} }
} else
else newWidth =0;
{
aRenderingContext.SetColor(aTextStyle.mColor->mColor); aRenderingContext.SetColor(currentFGColor);
aRenderingContext.DrawString(text, PRUint32(textLength), dx, dy); aRenderingContext.DrawString(currenttext, currentlength, currentX, dy);
currentX+=newWidth;//increment twips X start
iter.Next();
} }
} }
else else

View File

@@ -852,6 +852,12 @@ DrawSelectionIterator::DrawSelectionIterator(const SelectionDetails *aSelDetails
} }
details= details->mNext; details= details->mNext;
} }
if (!mInit && mTypes) //we have details but none that we care about.
{
delete mTypes;
mTypes = nsnull;
mDone = PR_TRUE;//we are finished
}
} }
else if (details->mStart == details->mEnd)//no collapsed selections here! else if (details->mStart == details->mEnd)//no collapsed selections here!
{ {
@@ -897,7 +903,10 @@ DrawSelectionIterator::FillCurrentData()
{ {
mCurrentIdx+=mCurrentLength;//advance to this chunk mCurrentIdx+=mCurrentLength;//advance to this chunk
if (mCurrentIdx >= mLength) if (mCurrentIdx >= mLength)
{
mDone = PR_TRUE;
return; return;
}
uint8 typevalue = mTypes[mCurrentIdx]; uint8 typevalue = mTypes[mCurrentIdx];
while (typevalue == mTypes[mCurrentIdx+mCurrentLength] && (mCurrentIdx+mCurrentLength) <mLength) while (typevalue == mTypes[mCurrentIdx+mCurrentLength] && (mCurrentIdx+mCurrentLength) <mLength)
{ {
@@ -1740,46 +1749,39 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
sdptr = sdptr->mNext; sdptr = sdptr->mNext;
} }
//while we have substrings... //while we have substrings...
if (details) PRBool drawn = PR_FALSE;
DrawSelectionIterator iter(details,text,(PRUint32)textLength,aTextStyle);
if (!iter.IsDone() && iter.First())
{ {
DrawSelectionIterator iter(details,text,(PRUint32)textLength,aTextStyle); nscoord currentX = dx;
if (iter.First()) nscoord newWidth;//temp
while (!iter.IsDone())
{ {
nscoord currentX = dx; PRUnichar *currenttext = iter.CurrentTextUnicharPtr();
nscoord newWidth;//temp PRUint32 currentlength= iter.CurrentLength();
while (!iter.IsDone()) TextStyle &currentStyle = iter.CurrentStyle();
nscolor currentFGColor = iter.CurrentForeGroundColor();
nscolor currentBKColor;
if (NS_SUCCEEDED(aRenderingContext.GetWidth(currenttext, currentlength,newWidth)))//ADJUST FOR CHAR SPACING
{ {
PRUnichar *currenttext = iter.CurrentTextUnicharPtr(); if (iter.CurrentBackGroundColor(currentBKColor))
PRUint32 currentlength= iter.CurrentLength(); {//DRAW RECT HERE!!!
TextStyle &currentStyle = iter.CurrentStyle(); aRenderingContext.SetColor(currentBKColor);
nscolor currentFGColor = iter.CurrentForeGroundColor(); aRenderingContext.FillRect(currentX, dy, newWidth, mRect.height);
nscolor currentBKColor; currentFGColor = EnsureDifferentColors(currentFGColor, currentBKColor);
if (NS_SUCCEEDED(aRenderingContext.GetWidth(currenttext, currentlength,newWidth)))//ADJUST FOR CHAR SPACING
{
if (iter.CurrentBackGroundColor(currentBKColor))
{//DRAW RECT HERE!!!
aRenderingContext.SetColor(currentBKColor);
aRenderingContext.FillRect(currentX, dy, newWidth, mRect.height);
currentFGColor = EnsureDifferentColors(currentFGColor, currentBKColor);
}
} }
else
newWidth =0;
aRenderingContext.SetColor(currentFGColor);
aRenderingContext.DrawString(currenttext, currentlength, currentX, dy);
currentX+=newWidth;//increment twips X start
iter.Next();
} }
} else
else newWidth =0;
{
aRenderingContext.SetColor(aTextStyle.mColor->mColor);
aRenderingContext.DrawString(text, PRUint32(textLength), dx, dy); aRenderingContext.SetColor(currentFGColor);
aRenderingContext.DrawString(currenttext, currentlength, currentX, dy);
currentX+=newWidth;//increment twips X start
iter.Next();
} }
} }
else else
@@ -1801,7 +1803,6 @@ nsTextFrame::PaintUnicodeText(nsIPresContext* aPresContext,
} }
} }
//measure Spaced Textvoid //measure Spaced Textvoid
nsresult nsresult
nsTextFrame::GetPositionSlowly(nsIPresContext* aPresContext, nsTextFrame::GetPositionSlowly(nsIPresContext* aPresContext,
@@ -2202,48 +2203,40 @@ nsTextFrame::PaintTextSlowly(nsIPresContext* aPresContext,
sdptr->mEnd = ip[sdptr->mEnd] - mContentOffset; sdptr->mEnd = ip[sdptr->mEnd] - mContentOffset;
sdptr = sdptr->mNext; sdptr = sdptr->mNext;
} }
if (details)
{
DrawSelectionIterator iter(details,text,(PRUint32)textLength,aTextStyle);
if (iter.First())
{
nscoord currentX = dx;
nscoord newWidth;//temp
while (!iter.IsDone())
{
PRUnichar *currenttext = iter.CurrentTextUnicharPtr();
PRUint32 currentlength= iter.CurrentLength();
TextStyle &currentStyle = iter.CurrentStyle();
nscolor currentFGColor = iter.CurrentForeGroundColor();
nscolor currentBKColor;
GetWidth(aRenderingContext,aTextStyle,currenttext, (PRInt32)currentlength,&newWidth);
if (newWidth)
{
if (iter.CurrentBackGroundColor(currentBKColor))
{//DRAW RECT HERE!!!
aRenderingContext.SetColor(currentBKColor);
aRenderingContext.FillRect(currentX, dy, newWidth, mRect.height);
currentFGColor = EnsureDifferentColors(currentFGColor, currentBKColor);
}
}
else
newWidth =0;
aRenderingContext.SetColor(currentFGColor);
RenderString(aRenderingContext,aStyleContext, aTextStyle, currenttext,
currentlength, currentX, dy, width, details);
//increment twips X start but remember to get ready for next draw by reducing current x by letter spacing amount
currentX+=newWidth;// + aTextStyle.mLetterSpacing;
iter.Next(); DrawSelectionIterator iter(details,text,(PRUint32)textLength,aTextStyle);
} if (!iter.IsDone() && iter.First())
} {
else nscoord currentX = dx;
{ nscoord newWidth;//temp
aRenderingContext.SetColor(aTextStyle.mColor->mColor); while (!iter.IsDone())
RenderString(aRenderingContext,aStyleContext, aTextStyle, text, {
PRUint32(textLength), dx, dy, width, details); PRUnichar *currenttext = iter.CurrentTextUnicharPtr();
} PRUint32 currentlength= iter.CurrentLength();
TextStyle &currentStyle = iter.CurrentStyle();
nscolor currentFGColor = iter.CurrentForeGroundColor();
nscolor currentBKColor;
GetWidth(aRenderingContext,aTextStyle,currenttext, (PRInt32)currentlength,&newWidth);
if (newWidth)
{
if (iter.CurrentBackGroundColor(currentBKColor))
{//DRAW RECT HERE!!!
aRenderingContext.SetColor(currentBKColor);
aRenderingContext.FillRect(currentX, dy, newWidth, mRect.height);
currentFGColor = EnsureDifferentColors(currentFGColor, currentBKColor);
}
}
else
newWidth =0;
aRenderingContext.SetColor(currentFGColor);
RenderString(aRenderingContext,aStyleContext, aTextStyle, currenttext,
currentlength, currentX, dy, width, details);
//increment twips X start but remember to get ready for next draw by reducing current x by letter spacing amount
currentX+=newWidth;// + aTextStyle.mLetterSpacing;
iter.Next();
}
} }
else else
{ {
@@ -2354,45 +2347,37 @@ nsTextFrame::PaintAsciiText(nsIPresContext* aPresContext,
sdptr->mEnd = ip[sdptr->mEnd] - mContentOffset; sdptr->mEnd = ip[sdptr->mEnd] - mContentOffset;
sdptr = sdptr->mNext; sdptr = sdptr->mNext;
} }
if (details) DrawSelectionIterator iter(details,(PRUnichar *)text,(PRUint32)textLength,aTextStyle);//ITS OK TO CAST HERE THE RESULT WE USE WILLNOT DO BAD CONVERSION
if (!iter.IsDone() && iter.First())
{ {
DrawSelectionIterator iter(details,(PRUnichar *)text,(PRUint32)textLength,aTextStyle);//ITS OK TO CAST HERE THE RESULT WE USE WILLNOT DO BAD CONVERSION nscoord currentX = dx;
if (iter.First()) nscoord newWidth;//temp
while (!iter.IsDone())
{ {
nscoord currentX = dx; char *currenttext = iter.CurrentTextCStrPtr();
nscoord newWidth;//temp PRUint32 currentlength= iter.CurrentLength();
while (!iter.IsDone()) TextStyle &currentStyle = iter.CurrentStyle();
nscolor currentFGColor = iter.CurrentForeGroundColor();
nscolor currentBKColor;
if (NS_SUCCEEDED(aRenderingContext.GetWidth(currenttext, currentlength,newWidth)))//ADJUST FOR CHAR SPACING
{ {
char *currenttext = iter.CurrentTextCStrPtr(); if (iter.CurrentBackGroundColor(currentBKColor))
PRUint32 currentlength= iter.CurrentLength(); {//DRAW RECT HERE!!!
TextStyle &currentStyle = iter.CurrentStyle(); aRenderingContext.SetColor(currentBKColor);
nscolor currentFGColor = iter.CurrentForeGroundColor(); aRenderingContext.FillRect(currentX, dy, newWidth, mRect.height);
nscolor currentBKColor; currentFGColor = EnsureDifferentColors(currentFGColor, currentBKColor);
if (NS_SUCCEEDED(aRenderingContext.GetWidth(currenttext, currentlength,newWidth)))//ADJUST FOR CHAR SPACING
{
if (iter.CurrentBackGroundColor(currentBKColor))
{//DRAW RECT HERE!!!
aRenderingContext.SetColor(currentBKColor);
aRenderingContext.FillRect(currentX, dy, newWidth, mRect.height);
currentFGColor = EnsureDifferentColors(currentFGColor, currentBKColor);
}
} }
else
newWidth =0;
aRenderingContext.SetColor(currentFGColor);
aRenderingContext.DrawString(currenttext, currentlength, currentX, dy);
currentX+=newWidth;//increment twips X start
iter.Next();
} }
} else
else newWidth =0;
{
aRenderingContext.SetColor(aTextStyle.mColor->mColor); aRenderingContext.SetColor(currentFGColor);
aRenderingContext.DrawString(text, PRUint32(textLength), dx, dy); aRenderingContext.DrawString(currenttext, currentlength, currentX, dy);
currentX+=newWidth;//increment twips X start
iter.Next();
} }
} }
else else