diff --git a/layout/generic/nsColumnSetFrame.cpp b/layout/generic/nsColumnSetFrame.cpp
index d36b2c602a67..92a784516491 100644
--- a/layout/generic/nsColumnSetFrame.cpp
+++ b/layout/generic/nsColumnSetFrame.cpp
@@ -494,7 +494,11 @@ nsColumnSetFrame::GetMinISize(gfxContext *aRenderingContext)
{
nscoord iSize = 0;
DISPLAY_MIN_WIDTH(this, iSize);
- if (mFrames.FirstChild()) {
+
+ if (mFrames.FirstChild() && !StyleDisplay()->IsContainSize()) {
+ // We want to ignore this in the case that we're size contained
+ // because our children should not contribute to our
+ // intrinsic size.
iSize = mFrames.FirstChild()->GetMinISize(aRenderingContext);
}
const nsStyleColumn* colStyle = StyleColumn();
@@ -539,7 +543,10 @@ nsColumnSetFrame::GetPrefISize(gfxContext *aRenderingContext)
nscoord colISize;
if (colStyle->mColumnWidth.GetUnit() == eStyleUnit_Coord) {
colISize = colStyle->mColumnWidth.GetCoordValue();
- } else if (mFrames.FirstChild()) {
+ } else if (mFrames.FirstChild() && !StyleDisplay()->IsContainSize()) {
+ // We want to ignore this in the case that we're size contained
+ // because our children should not contribute to our
+ // intrinsic size.
colISize = mFrames.FirstChild()->GetPrefISize(aRenderingContext);
} else {
colISize = 0;
@@ -908,6 +915,11 @@ nsColumnSetFrame::ReflowChildren(ReflowOutput& aDesiredSize,
} else {
contentSize.BSize(wm) = aConfig.mComputedBSize;
}
+ } else if (aReflowInput.mStyleDisplay->IsContainSize()) {
+ // If we are intrinsically sized, but are size contained,
+ // we need to behave as if we have no contents. Our BSize
+ // should be zero or minBSize if specified.
+ contentSize.BSize(wm) = aReflowInput.ApplyMinMaxBSize(0);
} else {
// We add the "consumed" block-size back in so that we're applying
// constraints to the correct bSize value, then subtract it again
diff --git a/layout/reftests/w3c-css/submitted/contain/contain-size-multicol-002-ref.html b/layout/reftests/w3c-css/submitted/contain/contain-size-multicol-002-ref.html
new file mode 100644
index 000000000000..c1c9f1388edb
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/contain/contain-size-multicol-002-ref.html
@@ -0,0 +1,49 @@
+
+
+
+
+ CSS Reftest Reference
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/layout/reftests/w3c-css/submitted/contain/contain-size-multicol-002.html b/layout/reftests/w3c-css/submitted/contain/contain-size-multicol-002.html
new file mode 100644
index 000000000000..0e35e2fed26d
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/contain/contain-size-multicol-002.html
@@ -0,0 +1,72 @@
+
+
+
+
+ CSS Test: 'contain: size' on multicol elements should cause them to be sized as if they had no contents.
+
+
+
+
+
+
+
+
+
+
diff --git a/layout/reftests/w3c-css/submitted/contain/contain-size-multicol-003.html b/layout/reftests/w3c-css/submitted/contain/contain-size-multicol-003.html
new file mode 100644
index 000000000000..2883d5f1df5b
--- /dev/null
+++ b/layout/reftests/w3c-css/submitted/contain/contain-size-multicol-003.html
@@ -0,0 +1,73 @@
+
+
+
+
+ CSS Test: 'contain: size' on multicol elements should cause them to be sized and baseline-aligned as if they had no contents.
+
+
+
+
+
+
+
+