Cache line breaks that are not in the current frame due to bidi resolution. Bug 595435, r=roc, a=blocker

This commit is contained in:
Simon Montagu 2010-11-08 12:27:42 +02:00
Родитель 1e1a081cdd
Коммит 98e186ab3a
1 изменённых файлов: 15 добавлений и 4 удалений

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

@ -6396,6 +6396,7 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
// Restrict preformatted text to the nearest newline
PRInt32 newLineOffset = -1; // this will be -1 or a content offset
PRInt32 contentNewLineOffset = -1;
// Pointer to the nsGkAtoms::newline set on this frame's element
NewlineProperty* cachedNewlineOffset = nsnull;
if (textStyle->NewlineIsSignificant()) {
@ -6404,9 +6405,18 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
if (cachedNewlineOffset && cachedNewlineOffset->mStartOffset <= offset &&
(cachedNewlineOffset->mNewlineOffset == -1 ||
cachedNewlineOffset->mNewlineOffset >= offset)) {
newLineOffset = cachedNewlineOffset->mNewlineOffset;
contentNewLineOffset = cachedNewlineOffset->mNewlineOffset;
} else {
newLineOffset = FindChar(frag, offset, length, '\n');
contentNewLineOffset = FindChar(frag, offset,
mContent->TextLength() - offset, '\n');
}
if (contentNewLineOffset < offset + length) {
/*
The new line offset could be outside this frame if the frame has been
split by bidi resolution. In that case we won't use it in this reflow
(newLineOffset will remain -1), but we will still cache it in mContent
*/
newLineOffset = contentNewLineOffset;
}
if (newLineOffset >= 0) {
length = newLineOffset + 1 - offset;
@ -6766,7 +6776,8 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
// Updated the cached NewlineProperty, or delete it.
if (contentLength < maxContentLength &&
textStyle->NewlineIsSignificant() &&
(newLineOffset < 0 || mContentOffset + contentLength <= newLineOffset)) {
(contentNewLineOffset < 0 ||
mContentOffset + contentLength <= contentNewLineOffset)) {
if (!cachedNewlineOffset) {
cachedNewlineOffset = new NewlineProperty;
if (cachedNewlineOffset) {
@ -6779,7 +6790,7 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
}
if (cachedNewlineOffset) {
cachedNewlineOffset->mStartOffset = offset;
cachedNewlineOffset->mNewlineOffset = newLineOffset;
cachedNewlineOffset->mNewlineOffset = contentNewLineOffset;
}
} else if (cachedNewlineOffset) {
mContent->DeleteProperty(nsGkAtoms::newline);