Check for null FontMetrics to prevent crash. r=shanjian sr=kin

This commit is contained in:
attinasi%netscape.com 2002-04-25 22:00:22 +00:00
parent 76b6d83637
commit 2fe443e329
2 changed files with 12 additions and 4 deletions

View File

@ -2290,6 +2290,10 @@ ComputeLineHeight(nsIPresContext* aPresContext,
nsCOMPtr<nsIFontMetrics> fm;
deviceContext->GetMetricsFor(font->mFont, langGroup, *getter_AddRefs(fm));
if (!fm) {
NS_WARNING( "null font metrics for the device context - we have to fix this someday...");
}
if (unit == eStyleUnit_Factor) {
// For factor units the computed value of the line-height property
// is found by multiplying the factor by the font's <b>actual</b>
@ -2303,7 +2307,7 @@ ComputeLineHeight(nsIPresContext* aPresContext,
// precise layout in the face of imprecise fonts.
nscoord emHeight = font->mFont.size;
#ifdef NEW_FONT_HEIGHT_APIS
if (!nsHTMLReflowState::UseComputedHeight()) {
if (!nsHTMLReflowState::UseComputedHeight() && fm) {
fm->GetEmHeight(emHeight);
}
#endif
@ -2312,7 +2316,7 @@ ComputeLineHeight(nsIPresContext* aPresContext,
NS_ASSERTION(eStyleUnit_Normal == unit, "bad unit");
lineHeight = font->mFont.size;
#ifdef NEW_FONT_HEIGHT_APIS
if (!nsHTMLReflowState::UseComputedHeight()) {
if (!nsHTMLReflowState::UseComputedHeight() && fm) {
lineHeight = GetNormalLineHeight(fm);
}
#endif

View File

@ -2290,6 +2290,10 @@ ComputeLineHeight(nsIPresContext* aPresContext,
nsCOMPtr<nsIFontMetrics> fm;
deviceContext->GetMetricsFor(font->mFont, langGroup, *getter_AddRefs(fm));
if (!fm) {
NS_WARNING( "null font metrics for the device context - we have to fix this someday...");
}
if (unit == eStyleUnit_Factor) {
// For factor units the computed value of the line-height property
// is found by multiplying the factor by the font's <b>actual</b>
@ -2303,7 +2307,7 @@ ComputeLineHeight(nsIPresContext* aPresContext,
// precise layout in the face of imprecise fonts.
nscoord emHeight = font->mFont.size;
#ifdef NEW_FONT_HEIGHT_APIS
if (!nsHTMLReflowState::UseComputedHeight()) {
if (!nsHTMLReflowState::UseComputedHeight() && fm) {
fm->GetEmHeight(emHeight);
}
#endif
@ -2312,7 +2316,7 @@ ComputeLineHeight(nsIPresContext* aPresContext,
NS_ASSERTION(eStyleUnit_Normal == unit, "bad unit");
lineHeight = font->mFont.size;
#ifdef NEW_FONT_HEIGHT_APIS
if (!nsHTMLReflowState::UseComputedHeight()) {
if (!nsHTMLReflowState::UseComputedHeight() && fm) {
lineHeight = GetNormalLineHeight(fm);
}
#endif