зеркало из https://github.com/mozilla/pjs.git
Fix for bug 124209 (Deleting selection in plain text reply compose causes hang)
and bug 124375 (composer / editor hang when delete blank lines) Allow start/end points to be set to empty text nodes to prevent infinite loop. r=glazman@netscape.com sr=sfraser@netscape.com,shaver@mozilla.org
This commit is contained in:
Родитель
06cd3f148a
Коммит
81eb5f8e2f
|
@ -748,30 +748,40 @@ nsWSRunObject::GetWSNodes()
|
||||||
PRInt32 len;
|
PRInt32 len;
|
||||||
res = textNode->GetTextLength(&len);
|
res = textNode->GetTextLength(&len);
|
||||||
NS_ENSURE_SUCCESS(res, res);
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
PRInt32 pos;
|
|
||||||
for (pos=len-1; pos>=0; pos--)
|
if (len < 1)
|
||||||
{
|
{
|
||||||
PRUnichar theChar = textFrag->CharAt(pos);
|
// Zero length text node. Set start point to it
|
||||||
if (!nsCRT::IsAsciiSpace(theChar))
|
// so we can get past it!
|
||||||
|
start.SetPoint(priorNode,0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PRInt32 pos;
|
||||||
|
for (pos=len-1; pos>=0; pos--)
|
||||||
{
|
{
|
||||||
if (theChar != nbsp)
|
PRUnichar theChar = textFrag->CharAt(pos);
|
||||||
|
if (!nsCRT::IsAsciiSpace(theChar))
|
||||||
{
|
{
|
||||||
mStartNode = priorNode;
|
if (theChar != nbsp)
|
||||||
mStartOffset = pos+1;
|
{
|
||||||
mStartReason = eText;
|
mStartNode = priorNode;
|
||||||
break;
|
mStartOffset = pos+1;
|
||||||
}
|
mStartReason = eText;
|
||||||
// as we look backwards update our earliest found nbsp
|
break;
|
||||||
mFirstNBSPNode = priorNode;
|
}
|
||||||
mFirstNBSPOffset = pos;
|
// as we look backwards update our earliest found nbsp
|
||||||
// also keep track of latest nbsp so far
|
mFirstNBSPNode = priorNode;
|
||||||
if (!mLastNBSPNode)
|
mFirstNBSPOffset = pos;
|
||||||
{
|
// also keep track of latest nbsp so far
|
||||||
mLastNBSPNode = priorNode;
|
if (!mLastNBSPNode)
|
||||||
mLastNBSPOffset = pos;
|
{
|
||||||
|
mLastNBSPNode = priorNode;
|
||||||
|
mLastNBSPOffset = pos;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
start.SetPoint(priorNode,pos);
|
||||||
}
|
}
|
||||||
start.SetPoint(priorNode,pos);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -859,30 +869,40 @@ nsWSRunObject::GetWSNodes()
|
||||||
PRInt32 len;
|
PRInt32 len;
|
||||||
res = textNode->GetTextLength(&len);
|
res = textNode->GetTextLength(&len);
|
||||||
NS_ENSURE_SUCCESS(res, res);
|
NS_ENSURE_SUCCESS(res, res);
|
||||||
PRInt32 pos;
|
|
||||||
for (pos=0; pos<len; pos++)
|
if (len < 1)
|
||||||
{
|
{
|
||||||
PRUnichar theChar = textFrag->CharAt(pos);
|
// Zero length text node. Set end point to it
|
||||||
if (!nsCRT::IsAsciiSpace(theChar))
|
// so we can get past it!
|
||||||
|
end.SetPoint(nextNode,0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PRInt32 pos;
|
||||||
|
for (pos=0; pos<len; pos++)
|
||||||
{
|
{
|
||||||
if (theChar != nbsp)
|
PRUnichar theChar = textFrag->CharAt(pos);
|
||||||
|
if (!nsCRT::IsAsciiSpace(theChar))
|
||||||
{
|
{
|
||||||
mEndNode = nextNode;
|
if (theChar != nbsp)
|
||||||
mEndOffset = pos;
|
{
|
||||||
mEndReason = eText;
|
mEndNode = nextNode;
|
||||||
break;
|
mEndOffset = pos;
|
||||||
}
|
mEndReason = eText;
|
||||||
// as we look forwards update our latest found nbsp
|
break;
|
||||||
mLastNBSPNode = nextNode;
|
}
|
||||||
mLastNBSPOffset = pos;
|
// as we look forwards update our latest found nbsp
|
||||||
// also keep track of earliest nbsp so far
|
mLastNBSPNode = nextNode;
|
||||||
if (!mFirstNBSPNode)
|
mLastNBSPOffset = pos;
|
||||||
{
|
// also keep track of earliest nbsp so far
|
||||||
mFirstNBSPNode = nextNode;
|
if (!mFirstNBSPNode)
|
||||||
mFirstNBSPOffset = pos;
|
{
|
||||||
|
mFirstNBSPNode = nextNode;
|
||||||
|
mFirstNBSPOffset = pos;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
end.SetPoint(nextNode,pos+1);
|
||||||
}
|
}
|
||||||
end.SetPoint(nextNode,pos+1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Загрузка…
Ссылка в новой задаче