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

This commit is contained in:
roc+@cs.cmu.edu 2007-12-05 17:24:03 -08:00
parent e90527d8c5
commit 96732f1829
5 changed files with 67 additions and 4 deletions

View File

@ -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);

View File

@ -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

View File

@ -0,0 +1,28 @@
<html>
<head>
<style>
b { white-space:nowrap; }
div { border:1px solid black; }
</style>
</head>
<body>
<div style="width:100px">
<b><img src="mozilla-banner.gif" width="100">This is text</b><br>
<b><img src="mozilla-banner.gif" width="100">This is text</b><br>
<b><img src="mozilla-banner.gif" width="100">This is text</b><br>
<b><img src="mozilla-banner.gif" width="100">This is text</b>
</div>
<div style="width:200px">
<b><img src="mozilla-banner.gif" width="100">This is text</b><br>
<b><img src="mozilla-banner.gif" width="100">This is text</b><br>
<b><img src="mozilla-banner.gif" width="100">This is text</b><br>
<b><img src="mozilla-banner.gif" width="100">This is text</b>
</div>
<div style="width:400px">
<b><img src="mozilla-banner.gif" width="100">This is text</b>
<b><img src="mozilla-banner.gif" width="100">This is text</b><br>
<b><img src="mozilla-banner.gif" width="100">This is text</b>
<b><img src="mozilla-banner.gif" width="100">This is text</b>
</div>
</body>
</html>

View File

@ -0,0 +1,28 @@
<html>
<head>
<style>
b { white-space:nowrap; }
div { border:1px solid black; }
</style>
</head>
<body>
<div style="width:100px">
<b><img src="mozilla-banner.gif" width="100">This is text</b><span>
</span><b><img src="mozilla-banner.gif" width="100">This is text</b><span>
</span><b><img src="mozilla-banner.gif" width="100">This is text</b><span>
</span><b><img src="mozilla-banner.gif" width="100">This is text</b>
</div>
<div style="width:200px">
<b><img src="mozilla-banner.gif" width="100">This is text</b><span>
</span><b><img src="mozilla-banner.gif" width="100">This is text</b><span>
</span><b><img src="mozilla-banner.gif" width="100">This is text</b><span>
</span><b><img src="mozilla-banner.gif" width="100">This is text</b>
</div>
<div style="width:400px">
<b><img src="mozilla-banner.gif" width="100">This is text</b><span>
</span><b><img src="mozilla-banner.gif" width="100">This is text</b><span>
</span><b><img src="mozilla-banner.gif" width="100">This is text</b><span>
</span><b><img src="mozilla-banner.gif" width="100">This is text</b>
</div>
</body>
</html>

View File

@ -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