diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp
index 7bde97c420f5..5bf492264d77 100644
--- a/layout/generic/nsHTMLReflowState.cpp
+++ b/layout/generic/nsHTMLReflowState.cpp
@@ -1996,8 +1996,9 @@ nsHTMLReflowState::InitConstraints(nsPresContext* aPresContext,
// 'height' property doesn't apply to table columns and column groups
heightUnit = eStyleUnit_Auto;
}
- // calc() acts like 'auto' on internal table elements
- if (eStyleUnit_Auto == heightUnit || height.IsCalcUnit()) {
+ // calc() with percentages acts like 'auto' on internal table elements
+ if (eStyleUnit_Auto == heightUnit ||
+ (height.IsCalcUnit() && height.CalcHasPercent())) {
mComputedHeight = NS_AUTOHEIGHT;
} else {
NS_ASSERTION(heightUnit == mStylePosition->mHeight.GetUnit(),
@@ -2541,8 +2542,8 @@ nsHTMLReflowState::ComputeMinMaxValues(nscoord aContainingBlockWidth,
// Check for percentage based values and a containing block height that
// depends on the content height. Treat them like 'auto'
- // Likewise, check for calc() on internal table elements; calc() on
- // such elements is unsupported.
+ // Likewise, check for calc() with percentages on internal table elements;
+ // that's treated as 'auto' too.
// Likewise, if we're a child of a flex container who's measuring our
// intrinsic height, then we want to disregard our min-height.
@@ -2555,7 +2556,7 @@ nsHTMLReflowState::ComputeMinMaxValues(nscoord aContainingBlockWidth,
(NS_AUTOHEIGHT == aContainingBlockHeight &&
minHeight.HasPercent()) ||
(mFrameType == NS_CSS_FRAME_TYPE_INTERNAL_TABLE &&
- minHeight.IsCalcUnit()) ||
+ minHeight.IsCalcUnit() && minHeight.CalcHasPercent()) ||
mFlags.mIsFlexContainerMeasuringHeight) {
mComputedMinHeight = 0;
} else {
@@ -2571,14 +2572,14 @@ nsHTMLReflowState::ComputeMinMaxValues(nscoord aContainingBlockWidth,
} else {
// Check for percentage based values and a containing block height that
// depends on the content height. Treat them like 'none'
- // Likewise, check for calc() on internal table elements; calc() on
- // such elements is unsupported.
+ // Likewise, check for calc() with percentages on internal table elements;
+ // that's treated as 'auto' too.
// Likewise, if we're a child of a flex container who's measuring our
// intrinsic height, then we want to disregard our max-height.
if ((NS_AUTOHEIGHT == aContainingBlockHeight &&
maxHeight.HasPercent()) ||
(mFrameType == NS_CSS_FRAME_TYPE_INTERNAL_TABLE &&
- maxHeight.IsCalcUnit()) ||
+ maxHeight.IsCalcUnit() && maxHeight.CalcHasPercent()) ||
mFlags.mIsFlexContainerMeasuringHeight) {
mComputedMaxHeight = NS_UNCONSTRAINEDSIZE;
} else {
diff --git a/layout/reftests/bugs/776443-1-ref.html b/layout/reftests/bugs/776443-1-ref.html
new file mode 100644
index 000000000000..b9d60104b64c
--- /dev/null
+++ b/layout/reftests/bugs/776443-1-ref.html
@@ -0,0 +1,7 @@
+
+
+
+
diff --git a/layout/reftests/bugs/776443-1.html b/layout/reftests/bugs/776443-1.html
new file mode 100644
index 000000000000..0d3cbe3062a0
--- /dev/null
+++ b/layout/reftests/bugs/776443-1.html
@@ -0,0 +1,6 @@
+
+
+
diff --git a/layout/reftests/bugs/reftest.list b/layout/reftests/bugs/reftest.list
index f68bed664628..80ba3df7af64 100644
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1714,6 +1714,7 @@ needs-focus == 731726-1.html 731726-1-ref.html
== 758561-1.html 758561-1-ref.html
fuzzy-if(true,1,19) == 759036-1.html 759036-1-ref.html
fuzzy-if(true,17,5859) == 759036-2.html 759036-2-ref.html
+== 776443-1.html 776443-1-ref.html
== 776265-1a.html 776265-1-ref.html
== 776265-1b.html 776265-1-ref.html
== 776265-1c.html 776265-1-ref.html
diff --git a/layout/reftests/css-calc/height-table-1-ref.html b/layout/reftests/css-calc/height-table-1-ref.html
index 6ad5282cc412..1eed5c98e557 100644
--- a/layout/reftests/css-calc/height-table-1-ref.html
+++ b/layout/reftests/css-calc/height-table-1-ref.html
@@ -1,5 +1,12 @@
-Test that height:calc() has no effect on inner table elements
+Test that height:calc() with no percentages has an effect on inner table elements
+
diff --git a/layout/reftests/css-calc/height-table-1.html b/layout/reftests/css-calc/height-table-1.html
index 0c655a95a3ba..33f7aac1722e 100644
--- a/layout/reftests/css-calc/height-table-1.html
+++ b/layout/reftests/css-calc/height-table-1.html
@@ -1,9 +1,9 @@
-Test that height:calc() has no effect on inner table elements
+Test that height:calc() with no percentages has an effect on inner table elements
diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp
index b96fea7d2849..10cad95786aa 100644
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -1543,8 +1543,9 @@ nsTableFrame::AncestorsHaveStyleHeight(const nsHTMLReflowState& aParentReflowSta
(nsGkAtoms::tableRowFrame == frameType) ||
(nsGkAtoms::tableRowGroupFrame == frameType)) {
const nsStyleCoord &height = rs->mStylePosition->mHeight;
- // calc() treated like 'auto' on internal table elements
- if (height.GetUnit() != eStyleUnit_Auto && !height.IsCalcUnit()) {
+ // calc() with percentages treated like 'auto' on internal table elements
+ if (height.GetUnit() != eStyleUnit_Auto &&
+ (!height.IsCalcUnit() || !height.HasPercent())) {
return true;
}
}
diff --git a/layout/tables/nsTableRowFrame.cpp b/layout/tables/nsTableRowFrame.cpp
index f86a3263a987..e596e2412b16 100644
--- a/layout/tables/nsTableRowFrame.cpp
+++ b/layout/tables/nsTableRowFrame.cpp
@@ -488,13 +488,13 @@ nsTableRowFrame::CalcHeight(const nsHTMLReflowState& aReflowState)
ResetHeight(computedHeight);
const nsStylePosition* position = GetStylePosition();
- if (eStyleUnit_Coord == position->mHeight.GetUnit()) {
- SetFixedHeight(position->mHeight.GetCoordValue());
+ if (position->mHeight.ConvertsToLength()) {
+ SetFixedHeight(nsRuleNode::ComputeCoordPercentCalc(position->mHeight, 0));
}
else if (eStyleUnit_Percent == position->mHeight.GetUnit()) {
SetPctHeight(position->mHeight.GetPercentValue());
}
- // calc() is treated like 'auto' on table rows.
+ // calc() with percentages is treated like 'auto' on table rows.
for (nsIFrame* kidFrame = mFrames.FirstChild(); kidFrame;
kidFrame = kidFrame->GetNextSibling()) {
@@ -606,6 +606,13 @@ nsTableRowFrame::CalculateCellActualHeight(nsTableCellFrame* aCellFrame,
int32_t rowSpan = tableFrame->GetEffectiveRowSpan(*aCellFrame);
switch (position->mHeight.GetUnit()) {
+ case eStyleUnit_Calc: {
+ if (position->mHeight.CalcHasPercent()) {
+ // Treat this like "auto"
+ break;
+ }
+ // Fall through to the coord case
+ }
case eStyleUnit_Coord: {
nscoord outsideBoxSizing = 0;
// In quirks mode, table cell width should be content-box, but height
@@ -627,7 +634,9 @@ nsTableRowFrame::CalculateCellActualHeight(nsTableCellFrame* aCellFrame,
}
}
- specifiedHeight = position->mHeight.GetCoordValue() + outsideBoxSizing;
+ specifiedHeight =
+ nsRuleNode::ComputeCoordPercentCalc(position->mHeight, 0) +
+ outsideBoxSizing;
if (1 == rowSpan)
SetFixedHeight(specifiedHeight);
@@ -640,7 +649,7 @@ nsTableRowFrame::CalculateCellActualHeight(nsTableCellFrame* aCellFrame,
break;
}
case eStyleUnit_Auto:
- default: // includes calc(), which we treat like 'auto'
+ default:
break;
}
@@ -1370,7 +1379,8 @@ void nsTableRowFrame::InitHasCellWithStyleHeight(nsTableFrame* aTableFrame)
const nsStyleCoord &cellHeight = cellFrame->GetStylePosition()->mHeight;
if (aTableFrame->GetEffectiveRowSpan(*cellFrame) == 1 &&
cellHeight.GetUnit() != eStyleUnit_Auto &&
- !cellHeight.IsCalcUnit() /* calc() treated like 'auto' */) {
+ /* calc() with percentages treated like 'auto' */
+ (!cellHeight.IsCalcUnit() || !cellHeight.HasPercent())) {
AddStateBits(NS_ROW_HAS_CELL_WITH_STYLE_HEIGHT);
return;
}