bug 418975 - support ­ when calculating min width for table and fieldset. r=roc. landing on the CLOSED TREE after dbaron went to bed :)

This commit is contained in:
Jonathan Kew 2011-03-24 15:22:37 +00:00
parent 6f4c1c50c2
commit 15d01c433c
3 changed files with 44 additions and 7 deletions

View File

@ -3184,7 +3184,8 @@ nsIFrame::InlineMinWidthData::ForceBreak(nsIRenderingContext *aRenderingContext)
}
void
nsIFrame::InlineMinWidthData::OptionallyBreak(nsIRenderingContext *aRenderingContext)
nsIFrame::InlineMinWidthData::OptionallyBreak(nsIRenderingContext *aRenderingContext,
nscoord aHyphenWidth)
{
trailingTextFrame = nsnull;
@ -3193,8 +3194,9 @@ nsIFrame::InlineMinWidthData::OptionallyBreak(nsIRenderingContext *aRenderingCon
// text-indent or negative margin), don't break. Otherwise, do the
// same as ForceBreak. it doesn't really matter when we accumulate
// floats.
if (currentLine < 0 || atStartOfLine)
if (currentLine + aHyphenWidth < 0 || atStartOfLine)
return;
currentLine += aHyphenWidth;
ForceBreak(aRenderingContext);
}

View File

@ -1465,7 +1465,11 @@ public:
// optional breaks to prevent min-width from ending up bigger than
// pref-width.
void ForceBreak(nsIRenderingContext *aRenderingContext);
void OptionallyBreak(nsIRenderingContext *aRenderingContext);
// If the break here is actually taken, aHyphenWidth must be added to the
// width of the current line.
void OptionallyBreak(nsIRenderingContext *aRenderingContext,
nscoord aHyphenWidth = 0);
// The last text frame processed so far in the current line, when
// the last characters in that text frame are relevant for line

View File

@ -6066,8 +6066,25 @@ nsTextFrame::AddInlineMinWidthForFlow(nsIRenderingContext *aRenderingContext,
// OK since we can't really handle tabs for intrinsic sizing anyway.
const nsStyleText* textStyle = GetStyleText();
const nsTextFragment* frag = mContent->GetText();
// If we're hyphenating, the PropertyProvider needs the actual length;
// otherwise we can just pass PR_INT32_MAX to mean "all the text"
PRInt32 len = PR_INT32_MAX;
PRBool hyphenating = frag->GetLength() > 0 &&
(mTextRun->GetFlags() & gfxTextRunFactory::TEXT_ENABLE_HYPHEN_BREAKS) != 0;
if (hyphenating) {
len = frag->GetLength() - iter.GetOriginalOffset();
#ifdef DEBUG
// check that the length we're going to pass to PropertyProvider matches
// the expected range of text in the run
gfxSkipCharsIterator tmpIter(iter);
tmpIter.AdvanceOriginal(len);
NS_ASSERTION(tmpIter.GetSkippedOffset() == flowEndInTextRun,
"nsTextFragment length mismatch?");
#endif
}
PropertyProvider provider(mTextRun, textStyle, frag, this,
iter, PR_INT32_MAX, nsnull, 0);
iter, len, nsnull, 0);
PRBool collapseWhitespace = !textStyle->WhiteSpaceIsSignificant();
PRBool preformatNewlines = textStyle->NewlineIsSignificant();
@ -6076,7 +6093,16 @@ nsTextFrame::AddInlineMinWidthForFlow(nsIRenderingContext *aRenderingContext,
PRUint32 start =
FindStartAfterSkippingWhitespace(&provider, aData, textStyle, &iter, flowEndInTextRun);
// XXX Should we consider hyphenation here?
nsAutoTArray<PRPackedBool,BIG_TEXT_NODE_SIZE> hyphBuffer;
PRPackedBool *hyphBreakBefore = nsnull;
if (hyphenating) {
hyphBreakBefore = hyphBuffer.AppendElements(flowEndInTextRun - start);
if (hyphBreakBefore) {
provider.GetHyphenationBreaks(start, flowEndInTextRun - start,
hyphBreakBefore);
}
}
for (PRUint32 i = start, wordStart = start; i <= flowEndInTextRun; ++i) {
PRBool preformattedNewline = PR_FALSE;
PRBool preformattedTab = PR_FALSE;
@ -6086,8 +6112,11 @@ nsTextFrame::AddInlineMinWidthForFlow(nsIRenderingContext *aRenderingContext,
// starts?
preformattedNewline = preformatNewlines && mTextRun->GetChar(i) == '\n';
preformattedTab = preformatTabs && mTextRun->GetChar(i) == '\t';
if (!mTextRun->CanBreakLineBefore(i) && !preformattedNewline &&
!preformattedTab) {
if (!mTextRun->CanBreakLineBefore(i) &&
!preformattedNewline &&
!preformattedTab &&
(!hyphBreakBefore || !hyphBreakBefore[i - start]))
{
// we can't break here (and it's not the end of the flow)
continue;
}
@ -6129,6 +6158,8 @@ nsTextFrame::AddInlineMinWidthForFlow(nsIRenderingContext *aRenderingContext,
(mTextRun->GetFlags() & nsTextFrameUtils::TEXT_HAS_TRAILING_BREAK))) {
if (preformattedNewline) {
aData->ForceBreak(aRenderingContext);
} else if (hyphBreakBefore && hyphBreakBefore[i - start]) {
aData->OptionallyBreak(aRenderingContext, provider.GetHyphenWidth());
} else {
aData->OptionallyBreak(aRenderingContext);
}