Bug 822053 - Nested balancing column sets restriction shouldn't affect non-balancing column sets. r=roc

This commit is contained in:
Mats Palmgren
2012-12-27 22:24:08 +01:00
parent 531b49fed0
commit f065c7762f
7 changed files with 258 additions and 16 deletions

View File

@@ -312,7 +312,7 @@ load 514800-1.html
load 515811-1.html load 515811-1.html
load 517968.html load 517968.html
load 519031.xhtml load 519031.xhtml
load 520340.html asserts(3-7) load 520340.html # bug 734777
load 522170-1.html load 522170-1.html
load 533379-1.html load 533379-1.html
load 533379-2.html load 533379-2.html

View File

@@ -326,10 +326,13 @@ nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState)
nscoord colGap = GetColumnGap(this, colStyle); nscoord colGap = GetColumnGap(this, colStyle);
int32_t numColumns = colStyle->mColumnCount; int32_t numColumns = colStyle->mColumnCount;
// If column-fill is set to 'balance', then we want to balance the columns.
const bool isBalancing = colStyle->mColumnFill == NS_STYLE_COLUMN_FILL_BALANCE;
if (isBalancing) {
const uint32_t MAX_NESTED_COLUMN_BALANCING = 2; const uint32_t MAX_NESTED_COLUMN_BALANCING = 2;
uint32_t cnt = 1; uint32_t cnt = 0;
for (const nsHTMLReflowState* rs = aReflowState.parentReflowState; rs && cnt for (const nsHTMLReflowState* rs = aReflowState.parentReflowState;
< MAX_NESTED_COLUMN_BALANCING; rs = rs->parentReflowState) { rs && cnt < MAX_NESTED_COLUMN_BALANCING; rs = rs->parentReflowState) {
if (rs->mFlags.mIsColumnBalancing) { if (rs->mFlags.mIsColumnBalancing) {
++cnt; ++cnt;
} }
@@ -337,6 +340,7 @@ nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState)
if (cnt == MAX_NESTED_COLUMN_BALANCING) { if (cnt == MAX_NESTED_COLUMN_BALANCING) {
numColumns = 1; numColumns = 1;
} }
}
nscoord colWidth; nscoord colWidth;
if (colStyle->mColumnWidth.GetUnit() == eStyleUnit_Coord) { if (colStyle->mColumnWidth.GetUnit() == eStyleUnit_Coord) {
@@ -390,17 +394,13 @@ nsColumnSetFrame::ChooseColumnStrategy(const nsHTMLReflowState& aReflowState)
expectedWidthLeftOver = extraSpace - (extraToColumns*numColumns); expectedWidthLeftOver = extraSpace - (extraToColumns*numColumns);
} }
// If column-fill is set to 'balance', then we want to balance the columns. if (isBalancing) {
if (colStyle->mColumnFill == NS_STYLE_COLUMN_FILL_BALANCE) {
// Balancing!
if (numColumns <= 0) { if (numColumns <= 0) {
// Hmm, auto column count, column width or available width is unknown, // Hmm, auto column count, column width or available width is unknown,
// and balancing is required. Let's just use one column then. // and balancing is required. Let's just use one column then.
numColumns = 1; numColumns = 1;
} }
colHeight = NS_MIN(mLastBalanceHeight, colHeight);
colHeight = NS_MIN(mLastBalanceHeight,
colHeight);
} else { } else {
// This is the case when the column-fill property is set to 'auto'. // This is the case when the column-fill property is set to 'auto'.
// No balancing, so don't limit the column count // No balancing, so don't limit the column count

View File

@@ -0,0 +1,61 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Testing nested balancing column sets</title>
<link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822053">
<style type="text/css">
html,body {
color:black; background-color:white; font-size:16px; padding:0; margin:0;
}
.colset {
-moz-column-count: 2;
-moz-column-gap: 1px;
-moz-column-rule: 1px solid black;
border: solid silver;
margin-bottom:1em;
width:30ch;
}
p { margin: 0; }
/* balancing column sets deeper than level 2 should only use 1 column */
.colset .colset .colset,
.colset .colset .colset .colset {
-moz-column-count: 1;
}
</style>
</head>
<body>
<div class="colset">
<p>one one one one one</p>
<div class="colset">
<p>two two two two two</p>
</div>
</div>
<div class="colset">
<p>one one one one one</p>
<div class="colset">
<p>two two two two two</p>
<div class="colset">
<p>three three three three three</p>
</div>
</div>
</div>
<div class="colset">
<p>one one one one one</p>
<div class="colset">
<p>two two two two two</p>
<div class="colset">
<p>three three</p>
<div class="colset">
<p>four four four four four</p>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,55 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Testing nested balancing column sets</title>
<link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822053">
<style type="text/css">
html,body {
color:black; background-color:white; font-size:16px; padding:0; margin:0;
}
.colset {
-moz-column-count: 2;
-moz-column-gap: 1px;
-moz-column-rule: 1px solid black;
border: solid silver;
margin-bottom:1em;
width:30ch;
}
p { margin: 0; }
</style>
</head>
<body>
<div class="colset">
<p>one one one one one</p>
<div class="colset">
<p>two two two two two</p>
</div>
</div>
<div class="colset">
<p>one one one one one</p>
<div class="colset">
<p>two two two two two</p>
<div class="colset">
<p>three three three three three</p>
</div>
</div>
</div>
<div class="colset">
<p>one one one one one</p>
<div class="colset">
<p>two two two two two</p>
<div class="colset">
<p>three three</p>
<div class="colset">
<p>four four four four four</p>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,64 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Testing nested balancing column sets</title>
<link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822053">
<style type="text/css">
html,body {
color:black; background-color:white; font-family:monospace; font-size:16px; padding:0; margin:0;
}
.colset {
-moz-column-count: 2;
-moz-column-gap: 0px;
-moz-column-rule: 1px solid black;
margin-bottom:1em;
width:30ch;
}
.colset.lvl2 {
-moz-column-rule: 1px solid blue;
}
.colset.lvl3 {
-moz-column-rule: 1px solid red;
}
p { margin: 0; }
.non-balancing {
-moz-column-count: 1;
}
.fixed-height.lvl2 {
-moz-column-count: 2;
}
.fixed-height {
-moz-column-count: 1;
height:3em;
}
</style>
</head>
<body>
<div class="colset">
<p>one one one one one</p>
<div class="colset non-balancing lvl2">
<p>two two two two<br>two</p>
</div>
</div>
<div class="colset">
<p>one one one one one<br>one</p>
<div class="colset fixed-height lvl2">
<p>two two two two two</p>
</div>
</div>
<div class="colset">
<p>one<br>one</p>
<div class="colset lvl2">
<p>two</p>
<div class="colset fixed-height lvl3">
<p>three three three three three three</p>
</div>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,60 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/licenses/publicdomain/
-->
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Testing nested balancing column sets</title>
<link rel="author" title="Mats Palmgren" href="https://bugzilla.mozilla.org/show_bug.cgi?id=822053">
<style type="text/css">
html,body {
color:black; background-color:white; font-family:monospace; font-size:16px; padding:0; margin:0;
}
.colset {
-moz-column-count: 2;
-moz-column-gap: 0px;
-moz-column-rule: 1px solid black;
margin-bottom:1em;
width:30ch;
}
.colset.lvl2 {
-moz-column-rule: 1px solid blue;
}
.colset.lvl3 {
-moz-column-rule: 1px solid red;
}
p { margin: 0; }
.non-balancing {
-moz-column-fill: auto;
}
.fixed-height {
height:3em;
}
</style>
</head>
<body>
<div class="colset">
<p>one one one one one</p>
<div class="colset non-balancing lvl2">
<p>two two two two two</p>
</div>
</div>
<div class="colset">
<p>one one one one one<br>one</p>
<div class="colset fixed-height lvl2">
<p>two two two two two</p>
</div>
</div>
<div class="colset">
<p>one<br>one</p>
<div class="colset lvl2">
<p>two</p>
<div class="colset fixed-height lvl3">
<p>three three three three three three</p>
</div>
</div>
</div>
</body>
</html>

View File

@@ -26,3 +26,5 @@ HTTP(..) == columnfill-auto.html columnfill-auto-ref.html
== columnfill-overflow.html columnfill-overflow-ref.html == columnfill-overflow.html columnfill-overflow-ref.html
== margin-collapsing-bug616722-1.html margin-collapsing-bug616722-1-ref.html == margin-collapsing-bug616722-1.html margin-collapsing-bug616722-1-ref.html
== margin-collapsing-bug616722-2.html margin-collapsing-bug616722-2-ref.html == margin-collapsing-bug616722-2.html margin-collapsing-bug616722-2-ref.html
== column-balancing-nested-000.html column-balancing-nested-000-ref.html
== column-balancing-nested-001.html column-balancing-nested-001-ref.html