Bug 374100. Regression in GetTextAtOffset for forced line breaks. r=parente

This commit is contained in:
aaronleventhal%moonset.net 2007-03-15 19:43:53 +00:00
Родитель d583a6fdcd
Коммит 52724056f8
1 изменённых файлов: 16 добавлений и 13 удалений

Просмотреть файл

@ -704,15 +704,17 @@ nsresult nsHyperTextAccessible::GetTextHelper(EGetTextType aType, nsAccessibleTe
return NS_ERROR_INVALID_ARG;
}
PRInt32 finalStartOffset, finalEndOffset;
// If aType == eGetAt we'll change both the start and end offset from
// the original offset
if (aType == eGetAfter) {
startOffset = aOffset;
finalStartOffset = aOffset;
}
else {
startOffset = GetRelativeOffset(presShell, startFrame, startOffset,
finalStartOffset = GetRelativeOffset(presShell, startFrame, startOffset,
amount, eDirPrevious, needsStart);
NS_ENSURE_TRUE(startOffset >= 0, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(finalStartOffset >= 0, NS_ERROR_FAILURE);
}
if (aType == eGetBefore) {
@ -721,12 +723,13 @@ nsresult nsHyperTextAccessible::GetTextHelper(EGetTextType aType, nsAccessibleTe
else {
// Start moving forward from the start so that we don't get
// 2 words/lines if the offset occured on whitespace boundary
endOffset = startOffset; // Passed by reference to GetPosAndText()
// Careful, startOffset and endOffset are passed by reference to GetPosAndText() and changed
startOffset = endOffset = finalStartOffset;
nsIFrame *endFrame = GetPosAndText(startOffset, endOffset);
if (!endFrame) {
return NS_ERROR_FAILURE;
}
endOffset = GetRelativeOffset(presShell, endFrame, endOffset, amount,
finalEndOffset = GetRelativeOffset(presShell, endFrame, endOffset, amount,
eDirNext, needsStart);
NS_ENSURE_TRUE(endOffset >= 0, NS_ERROR_FAILURE);
}
@ -738,13 +741,13 @@ nsresult nsHyperTextAccessible::GetTextHelper(EGetTextType aType, nsAccessibleTe
return GetTextHelper(eGetAfter, aBoundaryType, aOffset, aStartOffset, aEndOffset, aText);
}
*aStartOffset = startOffset;
*aEndOffset = endOffset;
*aStartOffset = finalStartOffset;
*aEndOffset = finalEndOffset;
NS_ASSERTION((startOffset < aOffset && endOffset >= aOffset) || aType != eGetBefore, "Incorrect results for GetTextHelper");
NS_ASSERTION((startOffset <= aOffset && endOffset > aOffset) || aType == eGetBefore, "Incorrect results for GetTextHelper");
NS_ASSERTION((finalStartOffset < aOffset && finalEndOffset >= aOffset) || aType != eGetBefore, "Incorrect results for GetTextHelper");
NS_ASSERTION((finalStartOffset <= aOffset && finalEndOffset > aOffset) || aType == eGetBefore, "Incorrect results for GetTextHelper");
return GetPosAndText(startOffset, endOffset, &aText) ? NS_OK : NS_ERROR_FAILURE;
return GetPosAndText(finalStartOffset, finalEndOffset, &aText) ? NS_OK : NS_ERROR_FAILURE;
}
/**