mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 22:55:23 +00:00
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:
parent
03f2ba2fda
commit
bf18664d80
@ -6396,6 +6396,7 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
|
|||||||
|
|
||||||
// Restrict preformatted text to the nearest newline
|
// Restrict preformatted text to the nearest newline
|
||||||
PRInt32 newLineOffset = -1; // this will be -1 or a content offset
|
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
|
// Pointer to the nsGkAtoms::newline set on this frame's element
|
||||||
NewlineProperty* cachedNewlineOffset = nsnull;
|
NewlineProperty* cachedNewlineOffset = nsnull;
|
||||||
if (textStyle->NewlineIsSignificant()) {
|
if (textStyle->NewlineIsSignificant()) {
|
||||||
@ -6404,9 +6405,18 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
|
|||||||
if (cachedNewlineOffset && cachedNewlineOffset->mStartOffset <= offset &&
|
if (cachedNewlineOffset && cachedNewlineOffset->mStartOffset <= offset &&
|
||||||
(cachedNewlineOffset->mNewlineOffset == -1 ||
|
(cachedNewlineOffset->mNewlineOffset == -1 ||
|
||||||
cachedNewlineOffset->mNewlineOffset >= offset)) {
|
cachedNewlineOffset->mNewlineOffset >= offset)) {
|
||||||
newLineOffset = cachedNewlineOffset->mNewlineOffset;
|
contentNewLineOffset = cachedNewlineOffset->mNewlineOffset;
|
||||||
} else {
|
} 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) {
|
if (newLineOffset >= 0) {
|
||||||
length = newLineOffset + 1 - offset;
|
length = newLineOffset + 1 - offset;
|
||||||
@ -6766,7 +6776,8 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
|
|||||||
// Updated the cached NewlineProperty, or delete it.
|
// Updated the cached NewlineProperty, or delete it.
|
||||||
if (contentLength < maxContentLength &&
|
if (contentLength < maxContentLength &&
|
||||||
textStyle->NewlineIsSignificant() &&
|
textStyle->NewlineIsSignificant() &&
|
||||||
(newLineOffset < 0 || mContentOffset + contentLength <= newLineOffset)) {
|
(contentNewLineOffset < 0 ||
|
||||||
|
mContentOffset + contentLength <= contentNewLineOffset)) {
|
||||||
if (!cachedNewlineOffset) {
|
if (!cachedNewlineOffset) {
|
||||||
cachedNewlineOffset = new NewlineProperty;
|
cachedNewlineOffset = new NewlineProperty;
|
||||||
if (cachedNewlineOffset) {
|
if (cachedNewlineOffset) {
|
||||||
@ -6779,7 +6790,7 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
|
|||||||
}
|
}
|
||||||
if (cachedNewlineOffset) {
|
if (cachedNewlineOffset) {
|
||||||
cachedNewlineOffset->mStartOffset = offset;
|
cachedNewlineOffset->mStartOffset = offset;
|
||||||
cachedNewlineOffset->mNewlineOffset = newLineOffset;
|
cachedNewlineOffset->mNewlineOffset = contentNewLineOffset;
|
||||||
}
|
}
|
||||||
} else if (cachedNewlineOffset) {
|
} else if (cachedNewlineOffset) {
|
||||||
mContent->DeleteProperty(nsGkAtoms::newline);
|
mContent->DeleteProperty(nsGkAtoms::newline);
|
||||||
|
Loading…
Reference in New Issue
Block a user