From df51a4d2e45c93c15e64d9a7002e02fbc7b5fc77 Mon Sep 17 00:00:00 2001 From: "bzbarsky%mit.edu" Date: Tue, 4 Jan 2005 20:17:25 +0000 Subject: [PATCH] Don't pass null frames to nsHTMLReflowState::GetContainingBlockFor. Bug 273458, r+sr=dbaron git-svn-id: svn://10.0.0.236/trunk@167260 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/style/nsComputedDOMStyle.cpp | 27 +++++++++++++-------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/mozilla/layout/style/nsComputedDOMStyle.cpp b/mozilla/layout/style/nsComputedDOMStyle.cpp index 928847dd4e9..312a53601bd 100644 --- a/mozilla/layout/style/nsComputedDOMStyle.cpp +++ b/mozilla/layout/style/nsComputedDOMStyle.cpp @@ -100,6 +100,14 @@ NS_NewComputedDOMStyle(nsIComputedDOMStyle** aComputedStyle) return NS_OK; } +static nsIFrame* +GetContainingBlockFor(nsIFrame* aFrame) { + if (!aFrame) { + return nsnull; + } + return nsHTMLReflowState::GetContainingBlockFor(aFrame); +} + nsComputedDOMStyle::nsComputedDOMStyle() : mInner(this), mPresShellWeak(nsnull), mT2P(0.0f) { @@ -1835,8 +1843,7 @@ nsComputedDOMStyle::GetTextIndent(nsIFrame *aFrame, break; case eStyleUnit_Percent: { - nsIFrame *container = - nsHTMLReflowState::GetContainingBlockFor(aFrame); + nsIFrame *container = GetContainingBlockFor(aFrame); if (container) { val->SetTwips(container->GetSize().width * text->mTextIndent.GetPercentValue()); @@ -2715,7 +2722,7 @@ nsComputedDOMStyle::GetMaxHeight(nsIFrame *aFrame, nscoord minHeight = 0; if (positionData->mMinHeight.GetUnit() == eStyleUnit_Percent) { - container = nsHTMLReflowState::GetContainingBlockFor(aFrame); + container = GetContainingBlockFor(aFrame); if (container) { size = container->GetSize(); minHeight = nscoord(size.height * @@ -2732,7 +2739,7 @@ nsComputedDOMStyle::GetMaxHeight(nsIFrame *aFrame, break; case eStyleUnit_Percent: if (!container) { - container = nsHTMLReflowState::GetContainingBlockFor(aFrame); + container = GetContainingBlockFor(aFrame); if (container) { size = container->GetSize(); } else { @@ -2775,7 +2782,7 @@ nsComputedDOMStyle::GetMaxWidth(nsIFrame *aFrame, nscoord minWidth = 0; if (positionData->mMinWidth.GetUnit() == eStyleUnit_Percent) { - container = nsHTMLReflowState::GetContainingBlockFor(aFrame); + container = GetContainingBlockFor(aFrame); if (container) { size = container->GetSize(); minWidth = nscoord(size.width * @@ -2792,7 +2799,7 @@ nsComputedDOMStyle::GetMaxWidth(nsIFrame *aFrame, break; case eStyleUnit_Percent: if (!container) { - container = nsHTMLReflowState::GetContainingBlockFor(aFrame); + container = GetContainingBlockFor(aFrame); if (container) { size = container->GetSize(); } else { @@ -2836,7 +2843,7 @@ nsComputedDOMStyle::GetMinHeight(nsIFrame *aFrame, val->SetTwips(positionData->mMinHeight.GetCoordValue()); break; case eStyleUnit_Percent: - container = nsHTMLReflowState::GetContainingBlockFor(aFrame); + container = GetContainingBlockFor(aFrame); if (container) { val->SetTwips(container->GetSize().height * positionData->mMinHeight.GetPercentValue()); @@ -2876,7 +2883,7 @@ nsComputedDOMStyle::GetMinWidth(nsIFrame *aFrame, val->SetTwips(positionData->mMinWidth.GetCoordValue()); break; case eStyleUnit_Percent: - container = nsHTMLReflowState::GetContainingBlockFor(aFrame); + container = GetContainingBlockFor(aFrame); if (container) { val->SetTwips(container->GetSize().width * positionData->mMinWidth.GetPercentValue()); @@ -2970,7 +2977,7 @@ nsComputedDOMStyle::GetAbsoluteOffset(PRUint8 aSide, nsIFrame* aFrame, nsROCSSPrimitiveValue *val = GetROCSSPrimitiveValue(); NS_ENSURE_TRUE(val, NS_ERROR_OUT_OF_MEMORY); - nsIFrame* container = nsHTMLReflowState::GetContainingBlockFor(aFrame); + nsIFrame* container = GetContainingBlockFor(aFrame); if (container) { nscoord margin = GetMarginWidthCoordFor(aSide, aFrame); nscoord border = GetBorderWidthCoordFor(aSide, container); @@ -3059,7 +3066,7 @@ nsComputedDOMStyle::GetRelativeOffset(PRUint8 aSide, nsIFrame* aFrame, val->SetTwips(sign * coord.GetCoordValue()); break; case eStyleUnit_Percent: - container = nsHTMLReflowState::GetContainingBlockFor(aFrame); + container = GetContainingBlockFor(aFrame); if (container) { nsMargin border; nsMargin padding;