Bug 1260031 - Not force break before a block when calculating intrinsic width if the current line is empty and the block cannot intersect floats. r=dbaron

MozReview-Commit-ID: 9rNUDK5t5jg

--HG--
extra : rebase_source : 2a852efe3f9801884e558f22ae7d9550fae87836
This commit is contained in:
Xidorn Quan 2016-08-23 09:29:45 +10:00
Родитель 104d30ab53
Коммит 4e5bd79656
10 изменённых файлов: 92 добавлений и 3 удалений

Просмотреть файл

@ -783,7 +783,9 @@ nsBlockFrame::GetPrefISize(nsRenderingContext *aRenderingContext)
AutoNoisyIndenter lineindent(gNoisyIntrinsic);
#endif
if (line->IsBlock()) {
data.ForceBreak();
if (!data.mLineIsEmpty || BlockCanIntersectFloats(line->mFirstChild)) {
data.ForceBreak();
}
data.mCurrentLine = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
line->mFirstChild, nsLayoutUtils::PREF_ISIZE);
data.ForceBreak();
@ -794,8 +796,13 @@ nsBlockFrame::GetPrefISize(nsRenderingContext *aRenderingContext)
// percentage basis of 0 unconditionally would give strange
// behavior for calc(10%-3px).
const nsStyleCoord &indent = StyleText()->mTextIndent;
if (indent.ConvertsToLength())
data.mCurrentLine += nsRuleNode::ComputeCoordPercentCalc(indent, 0);
if (indent.ConvertsToLength()) {
nscoord length = indent.ToLength();
if (length != 0) {
data.mCurrentLine += length;
data.mLineIsEmpty = false;
}
}
}
// XXX Bug NNNNNN Should probably handle percentage text-indent.

Просмотреть файл

@ -125,6 +125,7 @@ nsFirstLetterFrame::AddInlinePrefISize(nsRenderingContext *aRenderingContext,
nsIFrame::InlinePrefISizeData *aData)
{
DoInlineIntrinsicISize(aRenderingContext, aData, nsLayoutUtils::PREF_ISIZE);
aData->mLineIsEmpty = false;
}
// Needed for floating first-letter frames.

Просмотреть файл

@ -4443,6 +4443,7 @@ nsIFrame::InlinePrefISizeData::DefaultAddInlinePrefISize(nscoord aISize)
mCurrentLine = NSCoordSaturatingAdd(mCurrentLine, aISize);
mTrailingWhitespace = 0;
mSkipWhitespace = false;
mLineIsEmpty = false;
}
void
@ -4532,6 +4533,7 @@ nsIFrame::InlinePrefISizeData::ForceBreak()
mPrevLines = std::max(mPrevLines, mCurrentLine);
mCurrentLine = mTrailingWhitespace = 0;
mSkipWhitespace = true;
mLineIsEmpty = true;
}
static void

Просмотреть файл

@ -1828,10 +1828,17 @@ public:
};
struct InlinePrefISizeData : public InlineIntrinsicISizeData {
InlinePrefISizeData()
: mLineIsEmpty(true)
{}
void ForceBreak();
// The default implementation for nsIFrame::AddInlinePrefISize.
void DefaultAddInlinePrefISize(nscoord aISize);
// True if the current line contains nothing other than placeholders.
bool mLineIsEmpty;
};
/**

Просмотреть файл

@ -273,6 +273,7 @@ nsInlineFrame::AddInlinePrefISize(nsRenderingContext *aRenderingContext,
nsIFrame::InlinePrefISizeData *aData)
{
DoInlineIntrinsicISize(aRenderingContext, aData, nsLayoutUtils::PREF_ISIZE);
aData->mLineIsEmpty = false;
}
/* virtual */

Просмотреть файл

@ -87,6 +87,7 @@ nsRubyFrame::AddInlinePrefISize(nsRenderingContext *aRenderingContext,
e.GetBaseContainer()->AddInlinePrefISize(aRenderingContext, aData);
}
}
aData->mLineIsEmpty = false;
}
/* virtual */ void

Просмотреть файл

@ -8347,6 +8347,7 @@ nsTextFrame::AddInlinePrefISizeForFlow(nsRenderingContext *aRenderingContext,
if (StyleContext()->IsTextCombined()) {
aData->mCurrentLine += provider.GetFontMetrics()->EmHeight();
aData->mTrailingWhitespace = 0;
aData->mLineIsEmpty = false;
return;
}
@ -8384,6 +8385,7 @@ nsTextFrame::AddInlinePrefISizeForFlow(nsRenderingContext *aRenderingContext,
textRun->GetAdvanceWidth(Range(lineStart, i), &provider));
width = std::max(0, width);
aData->mCurrentLine = NSCoordSaturatingAdd(aData->mCurrentLine, width);
aData->mLineIsEmpty = false;
if (collapseWhitespace) {
uint32_t trimStart = GetEndOfTrimmedText(frag, textStyle, lineStart, i, &iter);
@ -8410,6 +8412,7 @@ nsTextFrame::AddInlinePrefISizeForFlow(nsRenderingContext *aRenderingContext,
AdvanceToNextTab(aData->mCurrentLine, this,
textRun, &tabWidth);
aData->mCurrentLine = nscoord(afterTab + spacing.mAfter);
aData->mLineIsEmpty = false;
lineStart = i + 1;
} else if (preformattedNewline) {
aData->ForceBreak();

Просмотреть файл

@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bug 1260031 - Intrinsic width with float</title>
<style>
#left {
display: inline-block;
width: 50px;
height: 50px;
background: green;
}
#right {
display: inline-block;
width: 50px;
height: 50px;
background: blue;
}
</style>
</head>
<body>
<div id="test">
<div id="wrapper">
<div id="left"></div><div id="right"></div>
</div>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bug 1260031 - Intrinsic width with float</title>
<style>
#wrapper {
background: red;
width: -moz-fit-content;
width: fit-content;
}
#left {
float: left;
width: 50px;
height: 50px;
background: green;
}
#right {
width: 50px;
height: 50px;
background: blue;
}
</style>
</head>
<body>
<div id="test">
<div id="wrapper">
<div id="left"></div>
<div id="right"></div>
</div>
</div>
<script>
document.getElementById("right").style = location.search.slice(1);
</script>
</body>
</html>

Просмотреть файл

@ -21,6 +21,9 @@ fails == 345369-2.html 345369-2-ref.html
== 775350-1.html 775350-1-ref.html
== 1114329.html 1114329-ref.html
== 1236745-1.html 1236745-1-ref.html
== 1260031-1.html?display:table 1260031-1-ref.html
== 1260031-1.html?display:table-cell 1260031-1-ref.html
== 1260031-1.html?overflow:hidden 1260031-1-ref.html
== float-in-rtl-1a.html float-in-rtl-1-ref.html
fuzzy-if(skiaContent,1,27000) == float-in-rtl-1b.html float-in-rtl-1-ref.html
fuzzy-if(skiaContent,1,27000) == float-in-rtl-1c.html float-in-rtl-1-ref.html