From fd3ca70efc4dcb6267e565d8391a4a07e808772a Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Thu, 6 Dec 2007 01:24:04 +0000 Subject: [PATCH] Bug 405577. Allow available width to go negative for inlines/text, so we can tell whether zero-width content fits or not. Also allow textframes to honour a forced break at the end of the text. r+sr=dbaron git-svn-id: svn://10.0.0.236/trunk@240555 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/generic/nsInlineFrame.cpp | 1 - mozilla/layout/generic/nsTextFrameThebes.cpp | 13 +++++++-- .../layout/reftests/bugs/405577-1-ref.html | 28 +++++++++++++++++++ mozilla/layout/reftests/bugs/405577-1.html | 28 +++++++++++++++++++ mozilla/layout/reftests/bugs/reftest.list | 1 + 5 files changed, 67 insertions(+), 4 deletions(-) create mode 100644 mozilla/layout/reftests/bugs/405577-1-ref.html create mode 100644 mozilla/layout/reftests/bugs/405577-1.html 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 +
+ + diff --git a/mozilla/layout/reftests/bugs/405577-1.html b/mozilla/layout/reftests/bugs/405577-1.html new file mode 100644 index 00000000000..937eed44294 --- /dev/null +++ b/mozilla/layout/reftests/bugs/405577-1.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 +
+ + diff --git a/mozilla/layout/reftests/bugs/reftest.list b/mozilla/layout/reftests/bugs/reftest.list index ab8c6dd3c98..459a5db4d6b 100644 --- a/mozilla/layout/reftests/bugs/reftest.list +++ b/mozilla/layout/reftests/bugs/reftest.list @@ -505,6 +505,7 @@ random == 403134-1.html 403134-1-ref.html # bug 405377 == 404666-2.html 404666-2-ref.html == 405186-1.xhtml about:blank == 405305-1.html 405305-1-ref.html +== 405577-1.html 405577-1-ref.html == 405584-1.html 405584-1-ref.html == 406484-1.html 406484-1-ref.html == 406568-1.html 406568-1-ref.html