mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-06 00:10:25 +00:00
Bug 387358. Don't go into an infinite loop searching for end-of-first-letter-cluster; also translate from DOM to textrun offsets. r=smontagu
This commit is contained in:
parent
059812736e
commit
56a324e667
@ -4864,7 +4864,8 @@ nsTextFrame::GetOffsets(PRInt32 &start, PRInt32 &end) const
|
|||||||
static PRBool
|
static PRBool
|
||||||
FindFirstLetterRange(const nsTextFragment* aFrag,
|
FindFirstLetterRange(const nsTextFragment* aFrag,
|
||||||
gfxTextRun* aTextRun,
|
gfxTextRun* aTextRun,
|
||||||
PRInt32 aOffset, PRInt32* aLength)
|
PRInt32 aOffset, const gfxSkipCharsIterator& aIter,
|
||||||
|
PRInt32* aLength)
|
||||||
{
|
{
|
||||||
// Find first non-whitespace, non-punctuation cluster, and stop after it
|
// Find first non-whitespace, non-punctuation cluster, and stop after it
|
||||||
PRInt32 i;
|
PRInt32 i;
|
||||||
@ -4878,12 +4879,16 @@ FindFirstLetterRange(const nsTextFragment* aFrag,
|
|||||||
if (i == length)
|
if (i == length)
|
||||||
return PR_FALSE;
|
return PR_FALSE;
|
||||||
|
|
||||||
// Advance to the end of the cluster (when i+1 starts a new cluster)
|
// Advance to the end of the cluster
|
||||||
while (i + 1 < length) {
|
gfxSkipCharsIterator iter(aIter);
|
||||||
if (aTextRun->IsClusterStart(aOffset + i + 1))
|
PRInt32 nextClusterStart;
|
||||||
|
for (nextClusterStart = i + 1; nextClusterStart < length; ++nextClusterStart) {
|
||||||
|
iter.SetOriginalOffset(nextClusterStart);
|
||||||
|
if (iter.IsOriginalCharSkipped() ||
|
||||||
|
aTextRun->IsClusterStart(iter.GetSkippedOffset()))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*aLength = i + 1;
|
*aLength = nextClusterStart;
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5303,7 +5308,7 @@ nsTextFrame::Reflow(nsPresContext* aPresContext,
|
|||||||
PRBool completedFirstLetter = PR_FALSE;
|
PRBool completedFirstLetter = PR_FALSE;
|
||||||
if (lineLayout.GetFirstLetterStyleOK()) {
|
if (lineLayout.GetFirstLetterStyleOK()) {
|
||||||
AddStateBits(TEXT_FIRST_LETTER);
|
AddStateBits(TEXT_FIRST_LETTER);
|
||||||
completedFirstLetter = FindFirstLetterRange(frag, mTextRun, offset, &length);
|
completedFirstLetter = FindFirstLetterRange(frag, mTextRun, offset, iter, &length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user