Cache line breaks that are not in the current frame due to bidi resolution. Bug 595435, r=roc, a=blocker
☠☠ backed out by 4bc6545574b0 ☠ ☠
authorSimon Montagu <smontagu@smontagu.org>
Sun, 07 Nov 2010 11:56:25 +0200
changeset 57056 1dad59de62c4b9b79657c1b2a596bb38dc0f20a1
parent 57055 06ec9fa89d20134de97503b807114fc650cd42ea
child 57057 8cbe835425964fab8e13b0e789d13b2dcf38d433
push id16770
push usersmontagu@mozilla.com
push dateSun, 07 Nov 2010 09:57:20 +0000
treeherdermozilla-central@8cbe83542596 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, blocker
bugs595435
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Cache line breaks that are not in the current frame due to bidi resolution. Bug 595435, r=roc, a=blocker
layout/generic/nsTextFrameThebes.cpp
--- a/layout/generic/nsTextFrameThebes.cpp
+++ b/layout/generic/nsTextFrameThebes.cpp
@@ -6391,27 +6391,37 @@ nsTextFrame::ReflowText(nsLineLayout& aL
   // DOM offsets of the text range we need to measure, after trimming
   // whitespace, restricting to first-letter, and restricting preformatted text
   // to nearest newline
   PRInt32 length = maxContentLength;
   PRInt32 offset = GetContentOffset();
 
   // 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()) {
     cachedNewlineOffset =
       static_cast<NewlineProperty*>(mContent->GetProperty(nsGkAtoms::newline));
     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;
     }
   }
   if (atStartOfLine && !textStyle->WhiteSpaceIsSignificant()) {
     // Skip leading whitespace. Make sure we don't skip a 'pre-line'
     // newline if there is one.
@@ -6761,30 +6771,31 @@ nsTextFrame::ReflowText(nsLineLayout& aL
   if (completedFirstLetter) {
     aLineLayout.SetFirstLetterStyleOK(PR_FALSE);
     aStatus |= NS_INLINE_BREAK_FIRST_LETTER_COMPLETE;
   }
 
   // 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) {
         if (NS_FAILED(mContent->SetProperty(nsGkAtoms::newline, cachedNewlineOffset,
                                             NewlineProperty::Destroy))) {
           delete cachedNewlineOffset;
           cachedNewlineOffset = nsnull;
         }
       }
     }
     if (cachedNewlineOffset) {
       cachedNewlineOffset->mStartOffset = offset;
-      cachedNewlineOffset->mNewlineOffset = newLineOffset;
+      cachedNewlineOffset->mNewlineOffset = contentNewLineOffset;
     }
   } else if (cachedNewlineOffset) {
     mContent->DeleteProperty(nsGkAtoms::newline);
   }
 
   // Compute space and letter counts for justification, if required
   if (!textStyle->WhiteSpaceIsSignificant() &&
       lineContainer->GetStyleText()->mTextAlign == NS_STYLE_TEXT_ALIGN_JUSTIFY) {