diff --git a/mozilla/layout/generic/nsInlineFrame.cpp b/mozilla/layout/generic/nsInlineFrame.cpp index 2a087b78228..840decdb0d7 100644 --- a/mozilla/layout/generic/nsInlineFrame.cpp +++ b/mozilla/layout/generic/nsInlineFrame.cpp @@ -430,7 +430,6 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext, availableWidth -= leftEdge; availableWidth -= ltr ? aReflowState.mComputedBorderPadding.right : aReflowState.mComputedBorderPadding.left; - availableWidth = PR_MAX(0, availableWidth); } lineLayout->BeginSpan(this, &aReflowState, leftEdge, leftEdge + availableWidth); diff --git a/mozilla/layout/generic/nsTextFrameThebes.cpp b/mozilla/layout/generic/nsTextFrameThebes.cpp index 9b70277fe10..902c3534001 100644 --- a/mozilla/layout/generic/nsTextFrameThebes.cpp +++ b/mozilla/layout/generic/nsTextFrameThebes.cpp @@ -5326,7 +5326,9 @@ nsTextFrame::Reflow(nsPresContext* aPresContext, PRInt32 limitLength = length; PRInt32 forceBreak = lineLayout.GetForcedBreakPosition(mContent); + PRBool forceBreakAfter = PR_FALSE; if (forceBreak >= offset + length) { + forceBreakAfter = forceBreak == offset + length; // The break is not within the text considered for this textframe. forceBreak = -1; } @@ -5480,9 +5482,14 @@ nsTextFrame::Reflow(nsPresContext* aPresContext, lineLayout.NotifyOptionalBreakPosition(mContent, offset + length, textMetrics.mAdvanceWidth + provider.GetHyphenWidth() <= availWidth); } - PRBool breakAfter = PR_FALSE; - if ((charsFit == length && transformedOffset + transformedLength == mTextRun->GetLength() && - (mTextRun->GetFlags() & nsTextFrameUtils::TEXT_HAS_TRAILING_BREAK))) { + PRBool breakAfter = forceBreakAfter; + if (!breakAfter && charsFit == length && + transformedOffset + transformedLength == mTextRun->GetLength() && + (mTextRun->GetFlags() & nsTextFrameUtils::TEXT_HAS_TRAILING_BREAK)) { + // We placed all the text in the textrun and we have a break opportunity at + // the end of the textrun. We need to record it because the following + // content may not care about nsLineBreaker. + // Note that because we didn't break, we can be sure that (thanks to the // code up above) textMetrics.mAdvanceWidth includes the width of any // trailing whitespace. So we need to subtract trimmableWidth here diff --git a/mozilla/layout/reftests/bugs/405577-1-ref.html b/mozilla/layout/reftests/bugs/405577-1-ref.html new file mode 100644 index 00000000000..a6046053601 --- /dev/null +++ b/mozilla/layout/reftests/bugs/405577-1-ref.html @@ -0,0 +1,28 @@ + +
+ + + +
This is text
This is text
This is text
This is text
+
This is text
This is text
This is text
This is text
+
This is text
+
This is text
This is text
+
This is text
+
This is text
+
This is text
+
This is text
+
This is text
+
This is text
+
This is text
+
This is text
+
This is text
+
This is text
+
This is text
+
This is text
+
This is text
+