Bug 801994. Fix intrinsic width determination in cases when we have an intrinsic ratio and our height is styled as calc() with percentages. r=dholbert

This commit is contained in:
Boris Zbarsky 2012-10-17 17:01:56 -04:00
parent 0eba625d0e
commit fc43a12b01
5 changed files with 22 additions and 3 deletions

View File

@ -2326,14 +2326,19 @@ static bool GetAbsoluteCoord(const nsStyleCoord& aStyle, nscoord& aResult)
return true;
}
// Only call on style coords for which GetAbsoluteCoord returned false.
static bool
GetPercentHeight(const nsStyleCoord& aStyle,
nsIFrame* aFrame,
nscoord& aResult)
{
if (eStyleUnit_Percent != aStyle.GetUnit())
if (eStyleUnit_Percent != aStyle.GetUnit() &&
!aStyle.IsCalcUnit())
return false;
MOZ_ASSERT(!aStyle.IsCalcUnit() || aStyle.CalcHasPercent(),
"GetAbsoluteCoord should have handled this");
nsIFrame *f = aFrame->GetContainingBlock();
if (!f) {
NS_NOTREACHED("top of frame tree not a containing block");
@ -2391,6 +2396,11 @@ GetPercentHeight(const nsStyleCoord& aStyle,
"unknown min-height unit");
}
if (aStyle.IsCalcUnit()) {
aResult = NS_MAX(nsRuleNode::ComputeComputedCalc(aStyle, h), 0);
return true;
}
aResult = NSToCoordRound(aStyle.GetPercentValue() * h);
return true;
}

View File

@ -1,6 +1,6 @@
== intrinsic-1a.html intrinsic-1-ref.html
== intrinsic-1b.html intrinsic-1-ref.html
== intrinsic-1c.html intrinsic-1-ref.html
fails == intrinsic-1d.html intrinsic-1-ref.html # Bug 801994
fails == intrinsic-1e.html intrinsic-1-ref.html # Bug 801994
== intrinsic-1d.html intrinsic-1-ref.html
== intrinsic-1e.html intrinsic-1-ref.html
== intrinsic-1f.html intrinsic-1-ref.html

View File

@ -0,0 +1,4 @@
<!DOCTYPE html>
<div style="height: 200px; float: left; background: green">
<img style="height: 120px; opacity: 0.5;" src="solidblue.png">
</div>

View File

@ -0,0 +1,4 @@
<!DOCTYPE html>
<div style="height: 200px; float: left; background: green">
<img style="height: calc(50% + 20px); opacity: 0.5;" src="solidblue.png">
</div>

View File

@ -1725,3 +1725,4 @@ fuzzy-if(true,17,5859) == 759036-2.html 759036-2-ref.html
== 787947-1.html 787947-1-ref.html
fuzzy(40,800) == 797797-1.html 797797-1-ref.html # 'opacity:N' and rgba(,,,N) text don't match precisely
fuzzy(40,800) == 797797-2.html 797797-2-ref.html # 'opacity:N' and rgba(,,,N) text don't match precisely
== 801994-1.html 801994-1-ref.html