From 7f5900aa67c2733f85c93fac0b8e57eb58c0b3ff Mon Sep 17 00:00:00 2001 From: "shanjian%netscape.com" Date: Fri, 24 May 2002 20:11:14 +0000 Subject: [PATCH] #142562 problem with newMetrics; - nsresult rv = mContext->GetMetricsFor(aFont, *getter_AddRefs(newMetrics)); + nsresult rv = mContext->GetMetricsFor(aFont, aLangGroup, *getter_AddRefs(newMetrics)); if (NS_SUCCEEDED(rv)) { rv = SetFont(newMetrics); } diff --git a/gfx/src/gtk/nsRenderingContextGTK.h b/gfx/src/gtk/nsRenderingContextGTK.h index a34e518eed6d..a8fda5441181 100644 --- a/gfx/src/gtk/nsRenderingContextGTK.h +++ b/gfx/src/gtk/nsRenderingContextGTK.h @@ -108,7 +108,7 @@ public: NS_IMETHOD SetColor(nscolor aColor); NS_IMETHOD GetColor(nscolor &aColor) const; - NS_IMETHOD SetFont(const nsFont& aFont); + NS_IMETHOD SetFont(const nsFont& aFont, nsIAtom* aLangGroup); NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics); NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics); diff --git a/gfx/src/mac/nsRenderingContextMac.cpp b/gfx/src/mac/nsRenderingContextMac.cpp index f74e68f3ad18..8b66a55a62a5 100644 --- a/gfx/src/mac/nsRenderingContextMac.cpp +++ b/gfx/src/mac/nsRenderingContextMac.cpp @@ -801,13 +801,13 @@ NS_IMETHODIMP nsRenderingContextMac::GetLineStyle(nsLineStyle &aLineStyle) //------------------------------------------------------------------------ -NS_IMETHODIMP nsRenderingContextMac::SetFont(const nsFont& aFont) +NS_IMETHODIMP nsRenderingContextMac::SetFont(const nsFont& aFont, nsIAtom* aLangGroup) { NS_IF_RELEASE(mGS->mFontMetrics); if (mContext) - mContext->GetMetricsFor(aFont, mGS->mFontMetrics); - + mContext->GetMetricsFor(aFont, aLangGroup, mGS->mFontMetrics); + mChanges |= kFontChanged; return NS_OK; diff --git a/gfx/src/mac/nsRenderingContextMac.h b/gfx/src/mac/nsRenderingContextMac.h index 3d7b3a8af0ea..7352feaf2a65 100644 --- a/gfx/src/mac/nsRenderingContextMac.h +++ b/gfx/src/mac/nsRenderingContextMac.h @@ -96,7 +96,7 @@ public: NS_IMETHOD GetLineStyle(nsLineStyle &aLineStyle); NS_IMETHOD SetColor(nscolor aColor); NS_IMETHOD GetColor(nscolor &aColor) const; - NS_IMETHOD SetFont(const nsFont& aFont); + NS_IMETHOD SetFont(const nsFont& aFont, nsIAtom* aLangGroup); NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics); NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics); NS_IMETHOD Translate(nscoord aX, nscoord aY); diff --git a/gfx/src/os2/nsRenderingContextOS2.cpp b/gfx/src/os2/nsRenderingContextOS2.cpp index 0141258e1abe..b432b2a3e867 100644 --- a/gfx/src/os2/nsRenderingContextOS2.cpp +++ b/gfx/src/os2/nsRenderingContextOS2.cpp @@ -769,10 +769,10 @@ NS_IMETHODIMP nsRenderingContextOS2::GetLineStyle( nsLineStyle &aLineStyle) return NS_OK; } -NS_IMETHODIMP nsRenderingContextOS2::SetFont( const nsFont &aFont) +NS_IMETHODIMP nsRenderingContextOS2::SetFont( const nsFont &aFont, nsIAtom* aLangGroup) { NS_IF_RELEASE( mFontMetrics); - mContext->GetMetricsFor( aFont, mFontMetrics); + mContext->GetMetricsFor( aFont, aLangGroup, mFontMetrics); return NS_OK; } diff --git a/gfx/src/os2/nsRenderingContextOS2.h b/gfx/src/os2/nsRenderingContextOS2.h index 8adc53895292..4aec086d02fa 100644 --- a/gfx/src/os2/nsRenderingContextOS2.h +++ b/gfx/src/os2/nsRenderingContextOS2.h @@ -92,7 +92,7 @@ public: NS_IMETHOD SetColor(nscolor aColor); NS_IMETHOD GetColor(nscolor &aColor) const; - NS_IMETHOD SetFont(const nsFont& aFont); + NS_IMETHOD SetFont(const nsFont& aFont, nsIAtom* aLangGroup); NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics); NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics); diff --git a/gfx/src/photon/nsRenderingContextPh.cpp b/gfx/src/photon/nsRenderingContextPh.cpp index c676e83b0643..8d62103c8660 100644 --- a/gfx/src/photon/nsRenderingContextPh.cpp +++ b/gfx/src/photon/nsRenderingContextPh.cpp @@ -529,10 +529,11 @@ NS_IMETHODIMP nsRenderingContextPh :: GetLineStyle( nsLineStyle &aLineStyle ) } -NS_IMETHODIMP nsRenderingContextPh :: SetFont( const nsFont& aFont ) +NS_IMETHODIMP nsRenderingContextPh :: SetFont( const nsFont& aFont, nsIAtom* aLangGroup ) { nsIFontMetrics* newMetrics; - nsresult rv = mContext->GetMetricsFor( aFont, newMetrics ); + nsresult rv = mContext->GetMetricsFor( aFont, aLangGroup, newMetrics ); + if( NS_SUCCEEDED( rv ) ) { rv = SetFont( newMetrics ); NS_RELEASE( newMetrics ); diff --git a/gfx/src/photon/nsRenderingContextPh.h b/gfx/src/photon/nsRenderingContextPh.h index 2eef699fcdaa..a3ff786cf06d 100644 --- a/gfx/src/photon/nsRenderingContextPh.h +++ b/gfx/src/photon/nsRenderingContextPh.h @@ -100,7 +100,7 @@ public: NS_IMETHOD SetColor(nscolor aColor); NS_IMETHOD GetColor(nscolor &aColor) const; - NS_IMETHOD SetFont(const nsFont& aFont); + NS_IMETHOD SetFont(const nsFont& aFont, nsIAtom* aLangGroup); NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics); NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics); diff --git a/gfx/src/ps/nsRenderingContextPS.cpp b/gfx/src/ps/nsRenderingContextPS.cpp index 9e3b231b166b..e2557e049afb 100644 --- a/gfx/src/ps/nsRenderingContextPS.cpp +++ b/gfx/src/ps/nsRenderingContextPS.cpp @@ -516,10 +516,11 @@ nsRenderingContextPS :: GetLineStyle(nsLineStyle &aLineStyle) * @update 12/21/98 dwc */ NS_IMETHODIMP -nsRenderingContextPS::SetFont(const nsFont& aFont) +nsRenderingContextPS::SetFont(const nsFont& aFont, nsIAtom* aLangGroup) { nsCOMPtr newMetrics; - nsresult rv = mContext->GetMetricsFor(aFont, *getter_AddRefs(newMetrics)); + nsresult rv = mContext->GetMetricsFor( aFont, aLangGroup, *getter_AddRefs(newMetrics) ); + if (NS_SUCCEEDED(rv)) { rv = SetFont(newMetrics); } diff --git a/gfx/src/ps/nsRenderingContextPS.h b/gfx/src/ps/nsRenderingContextPS.h index c1f758ecb6c5..b7dd1e5d393e 100644 --- a/gfx/src/ps/nsRenderingContextPS.h +++ b/gfx/src/ps/nsRenderingContextPS.h @@ -104,7 +104,7 @@ public: NS_IMETHOD SetColor(nscolor aColor); NS_IMETHOD GetColor(nscolor &aColor) const; - NS_IMETHOD SetFont(const nsFont& aFont); + NS_IMETHOD SetFont(const nsFont& aFont, nsIAtom* aLangGroup); NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics); NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics); diff --git a/gfx/src/qt/nsRenderingContextQT.cpp b/gfx/src/qt/nsRenderingContextQT.cpp index 43091d58cf8f..31135ff5671e 100644 --- a/gfx/src/qt/nsRenderingContextQT.cpp +++ b/gfx/src/qt/nsRenderingContextQT.cpp @@ -523,10 +523,11 @@ NS_IMETHODIMP nsRenderingContextQT::GetColor(nscolor &aColor) const return NS_OK; } -NS_IMETHODIMP nsRenderingContextQT::SetFont(const nsFont &aFont) +NS_IMETHODIMP nsRenderingContextQT::SetFont(const nsFont &aFont, nsIAtom* aLangGroup) { nsCOMPtr newMetrics; - nsresult rv = mContext->GetMetricsFor(aFont,*getter_AddRefs(newMetrics)); + nsresult rv = mContext->GetMetricsFor(aFont, aLangGroup, *getter_AddRefs(newMetrics)); + if (NS_SUCCEEDED(rv)) { rv = SetFont(newMetrics); } diff --git a/gfx/src/qt/nsRenderingContextQT.h b/gfx/src/qt/nsRenderingContextQT.h index cf3cb3964792..e59f97775d92 100644 --- a/gfx/src/qt/nsRenderingContextQT.h +++ b/gfx/src/qt/nsRenderingContextQT.h @@ -107,7 +107,7 @@ public: NS_IMETHOD SetColor(nscolor aColor); NS_IMETHOD GetColor(nscolor &aColor) const; - NS_IMETHOD SetFont(const nsFont& aFont); + NS_IMETHOD SetFont(const nsFont& aFont, nsIAtom* aLangGroup); NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics); NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics); diff --git a/gfx/src/windows/nsRenderingContextWin.cpp b/gfx/src/windows/nsRenderingContextWin.cpp index c84389fb0cec..8f3e3b61d5f9 100644 --- a/gfx/src/windows/nsRenderingContextWin.cpp +++ b/gfx/src/windows/nsRenderingContextWin.cpp @@ -991,10 +991,10 @@ NS_IMETHODIMP nsRenderingContextWin :: GetLineStyle(nsLineStyle &aLineStyle) return NS_OK; } -NS_IMETHODIMP nsRenderingContextWin :: SetFont(const nsFont& aFont) +NS_IMETHODIMP nsRenderingContextWin :: SetFont(const nsFont& aFont, nsIAtom* aLangGroup) { NS_IF_RELEASE(mFontMetrics); - mContext->GetMetricsFor(aFont, mFontMetrics); + mContext->GetMetricsFor(aFont, aLangGroup, mFontMetrics); return NS_OK; } diff --git a/gfx/src/windows/nsRenderingContextWin.h b/gfx/src/windows/nsRenderingContextWin.h index ecab272da804..d1ae7eed71f0 100644 --- a/gfx/src/windows/nsRenderingContextWin.h +++ b/gfx/src/windows/nsRenderingContextWin.h @@ -83,7 +83,7 @@ public: NS_IMETHOD SetColor(nscolor aColor); NS_IMETHOD GetColor(nscolor &aColor) const; - NS_IMETHOD SetFont(const nsFont& aFont); + NS_IMETHOD SetFont(const nsFont& aFont, nsIAtom* aLangGroup); NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics); NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics); diff --git a/gfx/src/xlib/nsRenderingContextXlib.cpp b/gfx/src/xlib/nsRenderingContextXlib.cpp index f9638b1fbfb9..ccdfaa345ea2 100644 --- a/gfx/src/xlib/nsRenderingContextXlib.cpp +++ b/gfx/src/xlib/nsRenderingContextXlib.cpp @@ -600,10 +600,11 @@ nsRenderingContextXlib::GetColor(nscolor &aColor) const } NS_IMETHODIMP -nsRenderingContextXlib::SetFont(const nsFont& aFont) +nsRenderingContextXlib::SetFont(const nsFont& aFont, nsIAtom* aLangGroup) { nsCOMPtr newMetrics; - nsresult rv = mContext->GetMetricsFor(aFont, *getter_AddRefs(newMetrics)); + nsresult rv = mContext->GetMetricsFor( aFont, aLangGroup, *getter_AddRefs(newMetrics) ); + if (NS_SUCCEEDED(rv)) { rv = SetFont(newMetrics); } diff --git a/gfx/src/xlib/nsRenderingContextXlib.h b/gfx/src/xlib/nsRenderingContextXlib.h index 5c02b87eed2d..ec0189923ab1 100644 --- a/gfx/src/xlib/nsRenderingContextXlib.h +++ b/gfx/src/xlib/nsRenderingContextXlib.h @@ -106,7 +106,7 @@ public: NS_IMETHOD SetColor(nscolor aColor); NS_IMETHOD GetColor(nscolor &aColor) const; - NS_IMETHOD SetFont(const nsFont& aFont); + NS_IMETHOD SetFont(const nsFont& aFont, nsIAtom* aLangGroup); NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics); NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics); diff --git a/layout/base/nsCaret.cpp b/layout/base/nsCaret.cpp index 1aed2e4496ea..017d73af6016 100644 --- a/layout/base/nsCaret.cpp +++ b/layout/base/nsCaret.cpp @@ -973,8 +973,14 @@ void nsCaret::DrawCaret() if (frameRect.height == 0) { const nsStyleFont* fontStyle; + const nsStyleVisibility* vis; mLastCaretFrame->GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)fontStyle); - mRendContext->SetFont(fontStyle->mFont); + mLastCaretFrame->GetStyleData(eStyleStruct_Visibility, (const nsStyleStruct*&)vis); + nsCOMPtr langGroup; + if (vis && vis->mLanguage) + vis->mLanguage->GetLanguageGroup(getter_AddRefs(langGroup)); + mRendContext->SetFont(fontStyle->mFont, langGroup); + nsCOMPtr fm; mRendContext->GetFontMetrics(*getter_AddRefs(fm)); if (fm) diff --git a/layout/base/src/nsCaret.cpp b/layout/base/src/nsCaret.cpp index 1aed2e4496ea..017d73af6016 100644 --- a/layout/base/src/nsCaret.cpp +++ b/layout/base/src/nsCaret.cpp @@ -973,8 +973,14 @@ void nsCaret::DrawCaret() if (frameRect.height == 0) { const nsStyleFont* fontStyle; + const nsStyleVisibility* vis; mLastCaretFrame->GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)fontStyle); - mRendContext->SetFont(fontStyle->mFont); + mLastCaretFrame->GetStyleData(eStyleStruct_Visibility, (const nsStyleStruct*&)vis); + nsCOMPtr langGroup; + if (vis && vis->mLanguage) + vis->mLanguage->GetLanguageGroup(getter_AddRefs(langGroup)); + mRendContext->SetFont(fontStyle->mFont, langGroup); + nsCOMPtr fm; mRendContext->GetFontMetrics(*getter_AddRefs(fm)); if (fm) diff --git a/layout/generic/nsBRFrame.cpp b/layout/generic/nsBRFrame.cpp index f1cbc402a01e..57d2de128ec9 100644 --- a/layout/generic/nsBRFrame.cpp +++ b/layout/generic/nsBRFrame.cpp @@ -158,9 +158,7 @@ BRFrame::Reflow(nsIPresContext* aPresContext, // We also do this in strict mode because BR should act like a // normal inline frame. That line-height is used is important // here for cases where the line-height is less that 1. - const nsStyleFont* font = (const nsStyleFont*) - mStyleContext->GetStyleData(eStyleStruct_Font); - aReflowState.rendContext->SetFont(font->mFont); + SetFontFromStyle(aReflowState.rendContext, mStyleContext); nsCOMPtr fm; aReflowState.rendContext->GetFontMetrics(*getter_AddRefs(fm)); if (fm) { diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 1dd41f26a63d..c5f86f9dfaaf 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -224,6 +224,27 @@ nsIFrameDebug::RootFrameList(nsIPresContext* aPresContext, FILE* out, PRInt32 aI #endif // end nsIFrameDebug +// a handy utility to set font +void SetFontFromStyle(nsIRenderingContext* aRC, nsIStyleContext* aSC) +{ + const nsStyleFont *font = (const nsStyleFont*) + aSC->GetStyleData(eStyleStruct_Font); + NS_ASSERTION(font, "invalid font in style context"); + + if (font) { + const nsStyleVisibility* visibility = (const nsStyleVisibility*) + aSC->GetStyleData(eStyleStruct_Visibility); + NS_ASSERTION(visibility, "invalid visibility in style context"); + + nsCOMPtr langGroup; + if (visibility && visibility->mLanguage) { + visibility->mLanguage->GetLanguageGroup(getter_AddRefs(langGroup)); + } + + aRC->SetFont(font->mFont, langGroup); + } +} + nsresult NS_NewEmptyFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) { diff --git a/layout/generic/nsFrame.h b/layout/generic/nsFrame.h index d8df8ad73271..6deb5e59d4a1 100644 --- a/layout/generic/nsFrame.h +++ b/layout/generic/nsFrame.h @@ -111,6 +111,8 @@ #define NS_FRAME_TRACE_REFLOW_OUT(_method, _status) #endif +// handy utilities +extern void SetFontFromStyle(nsIRenderingContext* aRC, nsIStyleContext* aSC); //---------------------------------------------------------------------- diff --git a/layout/generic/nsHTMLReflowState.cpp b/layout/generic/nsHTMLReflowState.cpp index 4b74544e8ee2..a8f9ca52a510 100644 --- a/layout/generic/nsHTMLReflowState.cpp +++ b/layout/generic/nsHTMLReflowState.cpp @@ -2378,7 +2378,7 @@ nsHTMLReflowState::CalcLineHeight(nsIPresContext* aPresContext, lineHeight = font->mFont.size; } else { - aRenderingContext->SetFont(font->mFont); + SetFontFromStyle(aRenderingContext, sc); nsCOMPtr fm; aRenderingContext->GetFontMetrics(*getter_AddRefs(fm)); #ifdef NEW_FONT_HEIGHT_APIS @@ -2416,21 +2416,9 @@ nsHTMLReflowState::ComputeHorizontalValue(nscoord aContainingBlockWidth, // pretend its zero... } else { - const nsStyleFont* font; - frame->GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&) font); - - const nsStyleVisibility* vis; - frame->GetStyleData(eStyleStruct_Visibility, (const nsStyleStruct*&)vis); - - nsCOMPtr deviceContext; - rendContext->GetDeviceContext(*getter_AddRefs(deviceContext)); - nsCOMPtr langGroup; - if (vis->mLanguage) { - vis->mLanguage->GetLanguageGroup(getter_AddRefs(langGroup)); - } - nsCOMPtr fm; - deviceContext->GetMetricsFor(font->mFont, langGroup, *getter_AddRefs(fm)); - rendContext->SetFont(fm); + nsCOMPtr styleContext; + frame->GetStyleContext(getter_AddRefs(styleContext)); + SetFontFromStyle(rendContext, styleContext); nscoord fontWidth; rendContext->GetWidth('M', fontWidth); aResult = aCoord.GetIntValue() * fontWidth; diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index dc3286e30011..4b99c0858cac 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -1063,12 +1063,9 @@ nsImageFrame::DisplayAltText(nsIPresContext* aPresContext, { const nsStyleColor* color = (const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color); - const nsStyleFont* font = - (const nsStyleFont*)mStyleContext->GetStyleData(eStyleStruct_Font); - // Set font and color aRenderingContext.SetColor(color->mColor); - aRenderingContext.SetFont(font->mFont); + SetFontFromStyle(&aRenderingContext, mStyleContext); // Format the text to display within the formatting rect nsIFontMetrics* fm; diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp index a41efb2773a3..c4b5fffca991 100644 --- a/layout/generic/nsInlineFrame.cpp +++ b/layout/generic/nsInlineFrame.cpp @@ -601,15 +601,9 @@ nsInlineFrame::ReflowFrames(nsIPresContext* aPresContext, aMetrics.width += aReflowState.mComputedBorderPadding.right; } + SetFontFromStyle(aReflowState.rendContext, mStyleContext); nsCOMPtr fm; - const nsStyleFont* font; - GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)font); - if (font) { - aReflowState.rendContext->SetFont(font->mFont); - aReflowState.rendContext->GetFontMetrics(*getter_AddRefs(fm)); - } else { - NS_WARNING("No font retrieved from style context - sorry but font metrics are not available"); - } + aReflowState.rendContext->GetFontMetrics(*getter_AddRefs(fm)); if (fm) { // Compute final height of the frame. @@ -640,6 +634,8 @@ nsInlineFrame::ReflowFrames(nsIPresContext* aPresContext, // little hack lets us override that behavior to allow for more // precise layout in the face of imprecise fonts. if (nsHTMLReflowState::UseComputedHeight()) { + const nsStyleFont* font; + GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)font); aMetrics.height = font->mFont.size + aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom; diff --git a/layout/generic/nsLineLayout.cpp b/layout/generic/nsLineLayout.cpp index 3581555989bc..d1e0165d63b1 100644 --- a/layout/generic/nsLineLayout.cpp +++ b/layout/generic/nsLineLayout.cpp @@ -2173,10 +2173,10 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd) nsIFrame* spanFrame = spanFramePFD->mFrame; // Get the parent frame's font for all of the frames in this span - const nsStyleFont* parentFont; - spanFrame->GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)parentFont); + nsCOMPtr styleContext; + spanFrame->GetStyleContext(getter_AddRefs(styleContext)); nsIRenderingContext* rc = mBlockReflowState->rendContext; - rc->SetFont(parentFont->mFont); + SetFontFromStyle(mBlockReflowState->rendContext, styleContext); nsCOMPtr fm; rc->GetFontMetrics(*getter_AddRefs(fm)); @@ -2705,6 +2705,8 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd) nscoord fontAscent, fontHeight; fm->GetMaxAscent(fontAscent); if (nsHTMLReflowState::UseComputedHeight()) { + const nsStyleFont* parentFont; + spanFrame->GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)parentFont); fontHeight = parentFont->mFont.size; } else diff --git a/layout/generic/nsPageFrame.cpp b/layout/generic/nsPageFrame.cpp index f91e16b65ae1..fda9e0267b4c 100644 --- a/layout/generic/nsPageFrame.cpp +++ b/layout/generic/nsPageFrame.cpp @@ -690,7 +690,7 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, rect.SetRect(0, 0, mRect.width - mPD->mShadowSize.width, mRect.height - mPD->mShadowSize.height); - aRenderingContext.SetFont(*mPD->mHeadFootFont); + aRenderingContext.SetFont(*mPD->mHeadFootFont, nsnull); aRenderingContext.SetColor(NS_RGB(0,0,0)); // Get the FontMetrics to determine width.height of strings @@ -698,7 +698,7 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, aPresContext->GetDeviceContext(getter_AddRefs(deviceContext)); NS_ASSERTION(deviceContext, "Couldn't get the device context"); nsCOMPtr fontMet; - deviceContext->GetMetricsFor(*mPD->mHeadFootFont, *getter_AddRefs(fontMet)); + deviceContext->GetMetricsFor(*mPD->mHeadFootFont, nsnull, *getter_AddRefs(fontMet)); nscoord ascent = 0; nscoord visibleHeight = 0; if (fontMet) { diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index aceb8e874f16..81ae5fc6a386 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -393,7 +393,6 @@ nsresult nsBlinkTimer::RemoveBlinkFrame(nsIFrame* aFrame) return NS_OK; } - //---------------------------------------------------------------------- #ifdef IBMBIDI @@ -560,15 +559,9 @@ public: NS_ASSERTION(plainFont, "null plainFont: font problems in TextStyle::TextStyle"); PRUint8 originalDecorations = plainFont->decorations; plainFont->decorations = NS_FONT_DECORATION_NONE; - nsCOMPtr deviceContext; - aRenderingContext.GetDeviceContext(*getter_AddRefs(deviceContext)); - nsCOMPtr langGroup; - if (mVisibility->mLanguage) { - mVisibility->mLanguage->GetLanguageGroup(getter_AddRefs(langGroup)); - } mAveCharWidth = 0; - deviceContext->GetMetricsFor(*plainFont, langGroup, mNormalFont); - aRenderingContext.SetFont(mNormalFont); // some users of the struct expect this state + SetFontFromStyle(&aRenderingContext, sc); // some users of the struct expect this state + aRenderingContext.GetFontMetrics(mNormalFont); mNormalFont->GetSpaceWidth(mSpaceWidth); #if defined(_WIN32) || defined(XP_OS2) mNormalFont->GetAveCharWidth(mAveCharWidth); @@ -3397,22 +3390,7 @@ nsTextFrame::GetPosition(nsIPresContext* aCX, } // Find the font metrics for this text - nsIStyleContext* styleContext; - GetStyleContext(&styleContext); - const nsStyleFont *font = (const nsStyleFont*) - styleContext->GetStyleData(eStyleStruct_Font); - const nsStyleVisibility* visibility = (const nsStyleVisibility*) - styleContext->GetStyleData(eStyleStruct_Visibility); - NS_RELEASE(styleContext); - nsCOMPtr langGroup; - if (visibility && visibility->mLanguage) { - visibility->mLanguage->GetLanguageGroup(getter_AddRefs(langGroup)); - } - nsCOMPtr fm; - nsCOMPtr dx; - aCX->GetDeviceContext(getter_AddRefs(dx)); - dx->GetMetricsFor(font->mFont, langGroup, *getter_AddRefs(fm)); - acx->SetFont(fm); + SetFontFromStyle(acx, mStyleContext); // Get the renderable form of the text nsCOMPtr doc(getter_AddRefs(GetDocument(aCX))); @@ -5405,8 +5383,7 @@ nsTextFrame::Reflow(nsIPresContext* aPresContext, aData.Mid(aText, mContentOffset, mContentLength); // Set the font - const nsStyleFont* font = (const nsStyleFont*)mStyleContext->GetStyleData(eStyleStruct_Font); - aReflowState.rendContext->SetFont(font->mFont); + SetFontFromStyle(aReflowState.rendContext, mStyleContext); // Now get the exact bounding metrics of the text nsBoundingMetrics bm; @@ -5522,9 +5499,8 @@ nsTextFrame::TrimTrailingWhiteSpace(nsIPresContext* aPresContext, if (XP_IS_SPACE(ch)) { // Get font metrics for a space so we can adjust the width by the // right amount. - const nsStyleFont* fontStyle = (const nsStyleFont*) - mStyleContext->GetStyleData(eStyleStruct_Font); - aRC.SetFont(fontStyle->mFont); + SetFontFromStyle(&aRC, mStyleContext); + aRC.GetWidth(' ', dw); // NOTE: Trailing whitespace includes word and letter spacing! nsStyleUnit unit; diff --git a/layout/html/base/src/nsBRFrame.cpp b/layout/html/base/src/nsBRFrame.cpp index f1cbc402a01e..57d2de128ec9 100644 --- a/layout/html/base/src/nsBRFrame.cpp +++ b/layout/html/base/src/nsBRFrame.cpp @@ -158,9 +158,7 @@ BRFrame::Reflow(nsIPresContext* aPresContext, // We also do this in strict mode because BR should act like a // normal inline frame. That line-height is used is important // here for cases where the line-height is less that 1. - const nsStyleFont* font = (const nsStyleFont*) - mStyleContext->GetStyleData(eStyleStruct_Font); - aReflowState.rendContext->SetFont(font->mFont); + SetFontFromStyle(aReflowState.rendContext, mStyleContext); nsCOMPtr fm; aReflowState.rendContext->GetFontMetrics(*getter_AddRefs(fm)); if (fm) { diff --git a/layout/html/base/src/nsFrame.cpp b/layout/html/base/src/nsFrame.cpp index 1dd41f26a63d..c5f86f9dfaaf 100644 --- a/layout/html/base/src/nsFrame.cpp +++ b/layout/html/base/src/nsFrame.cpp @@ -224,6 +224,27 @@ nsIFrameDebug::RootFrameList(nsIPresContext* aPresContext, FILE* out, PRInt32 aI #endif // end nsIFrameDebug +// a handy utility to set font +void SetFontFromStyle(nsIRenderingContext* aRC, nsIStyleContext* aSC) +{ + const nsStyleFont *font = (const nsStyleFont*) + aSC->GetStyleData(eStyleStruct_Font); + NS_ASSERTION(font, "invalid font in style context"); + + if (font) { + const nsStyleVisibility* visibility = (const nsStyleVisibility*) + aSC->GetStyleData(eStyleStruct_Visibility); + NS_ASSERTION(visibility, "invalid visibility in style context"); + + nsCOMPtr langGroup; + if (visibility && visibility->mLanguage) { + visibility->mLanguage->GetLanguageGroup(getter_AddRefs(langGroup)); + } + + aRC->SetFont(font->mFont, langGroup); + } +} + nsresult NS_NewEmptyFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame) { diff --git a/layout/html/base/src/nsFrame.h b/layout/html/base/src/nsFrame.h index d8df8ad73271..6deb5e59d4a1 100644 --- a/layout/html/base/src/nsFrame.h +++ b/layout/html/base/src/nsFrame.h @@ -111,6 +111,8 @@ #define NS_FRAME_TRACE_REFLOW_OUT(_method, _status) #endif +// handy utilities +extern void SetFontFromStyle(nsIRenderingContext* aRC, nsIStyleContext* aSC); //---------------------------------------------------------------------- diff --git a/layout/html/base/src/nsHTMLReflowState.cpp b/layout/html/base/src/nsHTMLReflowState.cpp index 4b74544e8ee2..a8f9ca52a510 100644 --- a/layout/html/base/src/nsHTMLReflowState.cpp +++ b/layout/html/base/src/nsHTMLReflowState.cpp @@ -2378,7 +2378,7 @@ nsHTMLReflowState::CalcLineHeight(nsIPresContext* aPresContext, lineHeight = font->mFont.size; } else { - aRenderingContext->SetFont(font->mFont); + SetFontFromStyle(aRenderingContext, sc); nsCOMPtr fm; aRenderingContext->GetFontMetrics(*getter_AddRefs(fm)); #ifdef NEW_FONT_HEIGHT_APIS @@ -2416,21 +2416,9 @@ nsHTMLReflowState::ComputeHorizontalValue(nscoord aContainingBlockWidth, // pretend its zero... } else { - const nsStyleFont* font; - frame->GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&) font); - - const nsStyleVisibility* vis; - frame->GetStyleData(eStyleStruct_Visibility, (const nsStyleStruct*&)vis); - - nsCOMPtr deviceContext; - rendContext->GetDeviceContext(*getter_AddRefs(deviceContext)); - nsCOMPtr langGroup; - if (vis->mLanguage) { - vis->mLanguage->GetLanguageGroup(getter_AddRefs(langGroup)); - } - nsCOMPtr fm; - deviceContext->GetMetricsFor(font->mFont, langGroup, *getter_AddRefs(fm)); - rendContext->SetFont(fm); + nsCOMPtr styleContext; + frame->GetStyleContext(getter_AddRefs(styleContext)); + SetFontFromStyle(rendContext, styleContext); nscoord fontWidth; rendContext->GetWidth('M', fontWidth); aResult = aCoord.GetIntValue() * fontWidth; diff --git a/layout/html/base/src/nsImageFrame.cpp b/layout/html/base/src/nsImageFrame.cpp index dc3286e30011..4b99c0858cac 100644 --- a/layout/html/base/src/nsImageFrame.cpp +++ b/layout/html/base/src/nsImageFrame.cpp @@ -1063,12 +1063,9 @@ nsImageFrame::DisplayAltText(nsIPresContext* aPresContext, { const nsStyleColor* color = (const nsStyleColor*)mStyleContext->GetStyleData(eStyleStruct_Color); - const nsStyleFont* font = - (const nsStyleFont*)mStyleContext->GetStyleData(eStyleStruct_Font); - // Set font and color aRenderingContext.SetColor(color->mColor); - aRenderingContext.SetFont(font->mFont); + SetFontFromStyle(&aRenderingContext, mStyleContext); // Format the text to display within the formatting rect nsIFontMetrics* fm; diff --git a/layout/html/base/src/nsInlineFrame.cpp b/layout/html/base/src/nsInlineFrame.cpp index a41efb2773a3..c4b5fffca991 100644 --- a/layout/html/base/src/nsInlineFrame.cpp +++ b/layout/html/base/src/nsInlineFrame.cpp @@ -601,15 +601,9 @@ nsInlineFrame::ReflowFrames(nsIPresContext* aPresContext, aMetrics.width += aReflowState.mComputedBorderPadding.right; } + SetFontFromStyle(aReflowState.rendContext, mStyleContext); nsCOMPtr fm; - const nsStyleFont* font; - GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)font); - if (font) { - aReflowState.rendContext->SetFont(font->mFont); - aReflowState.rendContext->GetFontMetrics(*getter_AddRefs(fm)); - } else { - NS_WARNING("No font retrieved from style context - sorry but font metrics are not available"); - } + aReflowState.rendContext->GetFontMetrics(*getter_AddRefs(fm)); if (fm) { // Compute final height of the frame. @@ -640,6 +634,8 @@ nsInlineFrame::ReflowFrames(nsIPresContext* aPresContext, // little hack lets us override that behavior to allow for more // precise layout in the face of imprecise fonts. if (nsHTMLReflowState::UseComputedHeight()) { + const nsStyleFont* font; + GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)font); aMetrics.height = font->mFont.size + aReflowState.mComputedBorderPadding.top + aReflowState.mComputedBorderPadding.bottom; diff --git a/layout/html/base/src/nsLineLayout.cpp b/layout/html/base/src/nsLineLayout.cpp index 3581555989bc..d1e0165d63b1 100644 --- a/layout/html/base/src/nsLineLayout.cpp +++ b/layout/html/base/src/nsLineLayout.cpp @@ -2173,10 +2173,10 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd) nsIFrame* spanFrame = spanFramePFD->mFrame; // Get the parent frame's font for all of the frames in this span - const nsStyleFont* parentFont; - spanFrame->GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)parentFont); + nsCOMPtr styleContext; + spanFrame->GetStyleContext(getter_AddRefs(styleContext)); nsIRenderingContext* rc = mBlockReflowState->rendContext; - rc->SetFont(parentFont->mFont); + SetFontFromStyle(mBlockReflowState->rendContext, styleContext); nsCOMPtr fm; rc->GetFontMetrics(*getter_AddRefs(fm)); @@ -2705,6 +2705,8 @@ nsLineLayout::VerticalAlignFrames(PerSpanData* psd) nscoord fontAscent, fontHeight; fm->GetMaxAscent(fontAscent); if (nsHTMLReflowState::UseComputedHeight()) { + const nsStyleFont* parentFont; + spanFrame->GetStyleData(eStyleStruct_Font, (const nsStyleStruct*&)parentFont); fontHeight = parentFont->mFont.size; } else diff --git a/layout/html/base/src/nsPageFrame.cpp b/layout/html/base/src/nsPageFrame.cpp index f91e16b65ae1..fda9e0267b4c 100644 --- a/layout/html/base/src/nsPageFrame.cpp +++ b/layout/html/base/src/nsPageFrame.cpp @@ -690,7 +690,7 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, rect.SetRect(0, 0, mRect.width - mPD->mShadowSize.width, mRect.height - mPD->mShadowSize.height); - aRenderingContext.SetFont(*mPD->mHeadFootFont); + aRenderingContext.SetFont(*mPD->mHeadFootFont, nsnull); aRenderingContext.SetColor(NS_RGB(0,0,0)); // Get the FontMetrics to determine width.height of strings @@ -698,7 +698,7 @@ nsPageFrame::Paint(nsIPresContext* aPresContext, aPresContext->GetDeviceContext(getter_AddRefs(deviceContext)); NS_ASSERTION(deviceContext, "Couldn't get the device context"); nsCOMPtr fontMet; - deviceContext->GetMetricsFor(*mPD->mHeadFootFont, *getter_AddRefs(fontMet)); + deviceContext->GetMetricsFor(*mPD->mHeadFootFont, nsnull, *getter_AddRefs(fontMet)); nscoord ascent = 0; nscoord visibleHeight = 0; if (fontMet) { diff --git a/layout/html/base/src/nsTextFrame.cpp b/layout/html/base/src/nsTextFrame.cpp index aceb8e874f16..81ae5fc6a386 100644 --- a/layout/html/base/src/nsTextFrame.cpp +++ b/layout/html/base/src/nsTextFrame.cpp @@ -393,7 +393,6 @@ nsresult nsBlinkTimer::RemoveBlinkFrame(nsIFrame* aFrame) return NS_OK; } - //---------------------------------------------------------------------- #ifdef IBMBIDI @@ -560,15 +559,9 @@ public: NS_ASSERTION(plainFont, "null plainFont: font problems in TextStyle::TextStyle"); PRUint8 originalDecorations = plainFont->decorations; plainFont->decorations = NS_FONT_DECORATION_NONE; - nsCOMPtr deviceContext; - aRenderingContext.GetDeviceContext(*getter_AddRefs(deviceContext)); - nsCOMPtr langGroup; - if (mVisibility->mLanguage) { - mVisibility->mLanguage->GetLanguageGroup(getter_AddRefs(langGroup)); - } mAveCharWidth = 0; - deviceContext->GetMetricsFor(*plainFont, langGroup, mNormalFont); - aRenderingContext.SetFont(mNormalFont); // some users of the struct expect this state + SetFontFromStyle(&aRenderingContext, sc); // some users of the struct expect this state + aRenderingContext.GetFontMetrics(mNormalFont); mNormalFont->GetSpaceWidth(mSpaceWidth); #if defined(_WIN32) || defined(XP_OS2) mNormalFont->GetAveCharWidth(mAveCharWidth); @@ -3397,22 +3390,7 @@ nsTextFrame::GetPosition(nsIPresContext* aCX, } // Find the font metrics for this text - nsIStyleContext* styleContext; - GetStyleContext(&styleContext); - const nsStyleFont *font = (const nsStyleFont*) - styleContext->GetStyleData(eStyleStruct_Font); - const nsStyleVisibility* visibility = (const nsStyleVisibility*) - styleContext->GetStyleData(eStyleStruct_Visibility); - NS_RELEASE(styleContext); - nsCOMPtr langGroup; - if (visibility && visibility->mLanguage) { - visibility->mLanguage->GetLanguageGroup(getter_AddRefs(langGroup)); - } - nsCOMPtr fm; - nsCOMPtr dx; - aCX->GetDeviceContext(getter_AddRefs(dx)); - dx->GetMetricsFor(font->mFont, langGroup, *getter_AddRefs(fm)); - acx->SetFont(fm); + SetFontFromStyle(acx, mStyleContext); // Get the renderable form of the text nsCOMPtr doc(getter_AddRefs(GetDocument(aCX))); @@ -5405,8 +5383,7 @@ nsTextFrame::Reflow(nsIPresContext* aPresContext, aData.Mid(aText, mContentOffset, mContentLength); // Set the font - const nsStyleFont* font = (const nsStyleFont*)mStyleContext->GetStyleData(eStyleStruct_Font); - aReflowState.rendContext->SetFont(font->mFont); + SetFontFromStyle(aReflowState.rendContext, mStyleContext); // Now get the exact bounding metrics of the text nsBoundingMetrics bm; @@ -5522,9 +5499,8 @@ nsTextFrame::TrimTrailingWhiteSpace(nsIPresContext* aPresContext, if (XP_IS_SPACE(ch)) { // Get font metrics for a space so we can adjust the width by the // right amount. - const nsStyleFont* fontStyle = (const nsStyleFont*) - mStyleContext->GetStyleData(eStyleStruct_Font); - aRC.SetFont(fontStyle->mFont); + SetFontFromStyle(&aRC, mStyleContext); + aRC.GetWidth(' ', dw); // NOTE: Trailing whitespace includes word and letter spacing! nsStyleUnit unit; diff --git a/layout/mathml/base/src/nsMathMLChar.cpp b/layout/mathml/base/src/nsMathMLChar.cpp index d6d48d16ce42..ef724b859195 100644 --- a/layout/mathml/base/src/nsMathMLChar.cpp +++ b/layout/mathml/base/src/nsMathMLChar.cpp @@ -589,7 +589,7 @@ nsGlyphTable::GetBoundingMetrics(nsIRenderingContext& aRenderingContext, if (aGlyphCode.font) { // glyph not associated to our primary font, it comes from an external font mFontName.StringAt(aGlyphCode.font, aFont.name); - aRenderingContext.SetFont(aFont); + aRenderingContext.SetFont(aFont, nsnull); } //if (mType == NS_TABLE_TYPE_UNICODE) @@ -601,7 +601,7 @@ nsGlyphTable::GetBoundingMetrics(nsIRenderingContext& aRenderingContext, if (aGlyphCode.font) { // restore our primary font in the rendering context mFontName.StringAt(0, aFont.name); - aRenderingContext.SetFont(aFont); + aRenderingContext.SetFont(aFont, nsnull); } return rv; } @@ -624,7 +624,7 @@ nsGlyphTable::DrawGlyph(nsIRenderingContext& aRenderingContext, if (aGlyphCode.font) { // glyph not associated to our primary font, it comes from an external font mFontName.StringAt(aGlyphCode.font, aFont.name); - aRenderingContext.SetFont(aFont); + aRenderingContext.SetFont(aFont, nsnull); } //if (mType == NS_TABLE_TYPE_UNICODE) @@ -636,7 +636,7 @@ nsGlyphTable::DrawGlyph(nsIRenderingContext& aRenderingContext, if (aGlyphCode.font) { // restore our primary font in the rendering context mFontName.StringAt(0, aFont.name); - aRenderingContext.SetFont(aFont); + aRenderingContext.SetFont(aFont, nsnull); } if (aClipRect) { aRenderingContext.PopState(clipState); @@ -1480,7 +1480,7 @@ nsMathMLChar::Stretch(nsIPresContext* aPresContext, fontName.Assign(NS_LITERAL_STRING("CMSY10")); // assumptions in the sqrt code, we need SetFirstFamily(theFont, fontName); // to force precedence on this TeX font } - aRenderingContext.SetFont(theFont); + aRenderingContext.SetFont(theFont, nsnull); rv = aRenderingContext.GetBoundingMetrics(mData.get(), PRUint32(mData.Length()), mBoundingMetrics); @@ -1577,7 +1577,7 @@ nsMathMLChar::Stretch(nsIPresContext* aPresContext, } glyphTable->GetPrimaryFontName(fontName); SetFirstFamily(theFont, fontName); - aRenderingContext.SetFont(theFont); + aRenderingContext.SetFont(theFont, nsnull); #ifdef NOISY_SEARCH char str[50]; fontName.ToCString(str, sizeof(str)); @@ -1674,7 +1674,7 @@ nsMathMLChar::Stretch(nsIPresContext* aPresContext, // See if the parts of this table fit in the desired space /////////////////////// glyphTable->GetPrimaryFontName(fontName); SetFirstFamily(theFont, fontName); - aRenderingContext.SetFont(theFont); + aRenderingContext.SetFont(theFont, nsnull); // Compute the bounding metrics of all partial glyphs PRInt32 i; nsGlyphCode chdata[4]; @@ -1956,7 +1956,7 @@ nsMathMLChar::Paint(nsIPresContext* aPresContext, fontName.Assign(NS_LITERAL_STRING("CMSY10")); // assumptions in the sqrt code, we need SetFirstFamily(theFont, fontName); // to force precedence on this TeX font } - aRenderingContext.SetFont(theFont); + aRenderingContext.SetFont(theFont, nsnull); //printf("Painting %04X like a normal char\n", mData[0]); //aRenderingContext.SetColor(NS_RGB(255,0,0)); aRenderingContext.DrawString(mData.get(), len, mRect.x, mRect.y + mBoundingMetrics.ascent); @@ -1965,7 +1965,7 @@ nsMathMLChar::Paint(nsIPresContext* aPresContext, // Set the stretchy font and grab some metrics to adjust the placements ... mGlyphTable->GetPrimaryFontName(fontName); SetFirstFamily(theFont, fontName); - aRenderingContext.SetFont(theFont); + aRenderingContext.SetFont(theFont, nsnull); // if there is a glyph of appropriate size, paint that glyph if (mGlyph) { //printf("Painting %04X with a glyph of appropriate size\n", mData[0]); diff --git a/layout/mathml/base/src/nsMathMLContainerFrame.cpp b/layout/mathml/base/src/nsMathMLContainerFrame.cpp index 26933e589835..3691049828d1 100644 --- a/layout/mathml/base/src/nsMathMLContainerFrame.cpp +++ b/layout/mathml/base/src/nsMathMLContainerFrame.cpp @@ -78,7 +78,7 @@ nsMathMLContainerFrame::ReflowError(nsIPresContext* aPresContext, // Set font const nsStyleFont *font = NS_STATIC_CAST(const nsStyleFont*, mStyleContext->GetStyleData(eStyleStruct_Font)); - aRenderingContext.SetFont(font->mFont); + aRenderingContext.SetFont(font->mFont, nsnull); // bounding metrics nsAutoString errorMsg; errorMsg.AssignWithConversion("invalid-markup"); @@ -122,7 +122,7 @@ nsMathMLContainerFrame::PaintError(nsIPresContext* aPresContext, // Set color and font ... const nsStyleFont *font = NS_STATIC_CAST(const nsStyleFont*, mStyleContext->GetStyleData(eStyleStruct_Font)); - aRenderingContext.SetFont(font->mFont); + aRenderingContext.SetFont(font->mFont, nsnull); aRenderingContext.SetColor(NS_RGB(255,0,0)); aRenderingContext.FillRect(0, 0, mRect.width, mRect.height); diff --git a/layout/mathml/base/src/nsMathMLmfencedFrame.cpp b/layout/mathml/base/src/nsMathMLmfencedFrame.cpp index b993067d1459..27315b72a736 100644 --- a/layout/mathml/base/src/nsMathMLmfencedFrame.cpp +++ b/layout/mathml/base/src/nsMathMLmfencedFrame.cpp @@ -282,7 +282,7 @@ nsMathMLmfencedFrame::doReflow(nsIPresContext* aPresContext, const nsStyleFont* font; aForFrame->GetStyleData(eStyleStruct_Font, (const nsStyleStruct *&)font); nsCOMPtr fm; - aReflowState.rendContext->SetFont(font->mFont); + aReflowState.rendContext->SetFont(font->mFont, nsnull); aReflowState.rendContext->GetFontMetrics(*getter_AddRefs(fm)); nscoord axisHeight, em; GetAxisHeight(*aReflowState.rendContext, fm, axisHeight); diff --git a/layout/mathml/base/src/nsMathMLmfracFrame.cpp b/layout/mathml/base/src/nsMathMLmfracFrame.cpp index 65963d5c8572..e33bd265a8ac 100644 --- a/layout/mathml/base/src/nsMathMLmfracFrame.cpp +++ b/layout/mathml/base/src/nsMathMLmfracFrame.cpp @@ -290,7 +290,7 @@ nsMathMLmfracFrame::Place(nsIPresContext* aPresContext, const nsStyleFont *font = NS_STATIC_CAST(const nsStyleFont*, mStyleContext->GetStyleData(eStyleStruct_Font)); - aRenderingContext.SetFont(font->mFont); + aRenderingContext.SetFont(font->mFont, nsnull); nsCOMPtr fm; aRenderingContext.GetFontMetrics(*getter_AddRefs(fm)); diff --git a/layout/mathml/base/src/nsMathMLmmultiscriptsFrame.cpp b/layout/mathml/base/src/nsMathMLmmultiscriptsFrame.cpp index 21f59f47413a..d7d79e1d6243 100644 --- a/layout/mathml/base/src/nsMathMLmmultiscriptsFrame.cpp +++ b/layout/mathml/base/src/nsMathMLmmultiscriptsFrame.cpp @@ -168,7 +168,7 @@ nsMathMLmmultiscriptsFrame::Place(nsIPresContext* aPresContext, // get x-height (an ex) const nsStyleFont *font = NS_STATIC_CAST(const nsStyleFont*, mStyleContext->GetStyleData(eStyleStruct_Font)); - aRenderingContext.SetFont(font->mFont); + aRenderingContext.SetFont(font->mFont, nsnull); nsCOMPtr fm; aRenderingContext.GetFontMetrics(*getter_AddRefs(fm)); diff --git a/layout/mathml/base/src/nsMathMLmoFrame.cpp b/layout/mathml/base/src/nsMathMLmoFrame.cpp index 7bd6fab1fd11..c6003eb7ac96 100644 --- a/layout/mathml/base/src/nsMathMLmoFrame.cpp +++ b/layout/mathml/base/src/nsMathMLmoFrame.cpp @@ -605,7 +605,7 @@ nsMathMLmoFrame::Stretch(nsIPresContext* aPresContext, const nsStyleFont *font = NS_STATIC_CAST(const nsStyleFont*, mStyleContext->GetStyleData(eStyleStruct_Font)); nsCOMPtr fm; - aRenderingContext.SetFont(font->mFont); + aRenderingContext.SetFont(font->mFont, nsnull); aRenderingContext.GetFontMetrics(*getter_AddRefs(fm)); nscoord leading = 0, axisHeight, height; GetAxisHeight(aRenderingContext, fm, axisHeight); diff --git a/layout/mathml/base/src/nsMathMLmoverFrame.cpp b/layout/mathml/base/src/nsMathMLmoverFrame.cpp index fd3538f57359..78368a727347 100644 --- a/layout/mathml/base/src/nsMathMLmoverFrame.cpp +++ b/layout/mathml/base/src/nsMathMLmoverFrame.cpp @@ -301,7 +301,7 @@ nsMathMLmoverFrame::Place(nsIPresContext* aPresContext, const nsStyleFont* font = (const nsStyleFont*) mStyleContext->GetStyleData (eStyleStruct_Font); - aRenderingContext.SetFont(font->mFont); + aRenderingContext.SetFont(font->mFont, nsnull); nsCOMPtr fm; aRenderingContext.GetFontMetrics(*getter_AddRefs(fm)); diff --git a/layout/mathml/base/src/nsMathMLmrootFrame.cpp b/layout/mathml/base/src/nsMathMLmrootFrame.cpp index 526798bb0e84..97f3c43985d1 100644 --- a/layout/mathml/base/src/nsMathMLmrootFrame.cpp +++ b/layout/mathml/base/src/nsMathMLmrootFrame.cpp @@ -227,7 +227,7 @@ nsMathMLmrootFrame::Reflow(nsIPresContext* aPresContext, const nsStyleFont *font = NS_STATIC_CAST(const nsStyleFont*, mStyleContext->GetStyleData(eStyleStruct_Font)); - renderingContext.SetFont(font->mFont); + renderingContext.SetFont(font->mFont, nsnull); nsCOMPtr fm; renderingContext.GetFontMetrics(*getter_AddRefs(fm)); diff --git a/layout/mathml/base/src/nsMathMLmsqrtFrame.cpp b/layout/mathml/base/src/nsMathMLmsqrtFrame.cpp index 7280174b25bd..09a1c08455c2 100644 --- a/layout/mathml/base/src/nsMathMLmsqrtFrame.cpp +++ b/layout/mathml/base/src/nsMathMLmsqrtFrame.cpp @@ -199,7 +199,7 @@ nsMathMLmsqrtFrame::Reflow(nsIPresContext* aPresContext, nsIRenderingContext& renderingContext = *aReflowState.rendContext; const nsStyleFont *font = NS_STATIC_CAST(const nsStyleFont*, mStyleContext->GetStyleData(eStyleStruct_Font)); - renderingContext.SetFont(font->mFont); + renderingContext.SetFont(font->mFont, nsnull); nsCOMPtr fm; renderingContext.GetFontMetrics(*getter_AddRefs(fm)); diff --git a/layout/mathml/base/src/nsMathMLmsubsupFrame.cpp b/layout/mathml/base/src/nsMathMLmsubsupFrame.cpp index bcafe1393a00..0203bc103162 100644 --- a/layout/mathml/base/src/nsMathMLmsubsupFrame.cpp +++ b/layout/mathml/base/src/nsMathMLmsubsupFrame.cpp @@ -209,7 +209,7 @@ nsMathMLmsubsupFrame::PlaceSubSupScript(nsIPresContext* aPresContext, const nsStyleFont* font; baseFrame->GetStyleData(eStyleStruct_Font, (const nsStyleStruct *&)font); - aRenderingContext.SetFont(font->mFont); + aRenderingContext.SetFont(font->mFont, nsnull); nsCOMPtr fm; aRenderingContext.GetFontMetrics(*getter_AddRefs(fm)); diff --git a/layout/mathml/base/src/nsMathMLmtableFrame.cpp b/layout/mathml/base/src/nsMathMLmtableFrame.cpp index ea716fdf3f69..4c86b9bf29d6 100644 --- a/layout/mathml/base/src/nsMathMLmtableFrame.cpp +++ b/layout/mathml/base/src/nsMathMLmtableFrame.cpp @@ -557,7 +557,7 @@ nsMathMLmtableOuterFrame::Reflow(nsIPresContext* aPresContext, // XXX should instead use style data from the row of reference here ? const nsStyleFont* font; GetStyleData(eStyleStruct_Font, (const nsStyleStruct *&)font); - aReflowState.rendContext->SetFont(font->mFont); + aReflowState.rendContext->SetFont(font->mFont, nsnull); nsCOMPtr fm; aReflowState.rendContext->GetFontMetrics(*getter_AddRefs(fm)); nscoord axisHeight; diff --git a/layout/mathml/base/src/nsMathMLmunderFrame.cpp b/layout/mathml/base/src/nsMathMLmunderFrame.cpp index 38468822abc4..d9bbea74350b 100644 --- a/layout/mathml/base/src/nsMathMLmunderFrame.cpp +++ b/layout/mathml/base/src/nsMathMLmunderFrame.cpp @@ -298,7 +298,7 @@ nsMathMLmunderFrame::Place(nsIPresContext* aPresContext, const nsStyleFont* font = (const nsStyleFont*) mStyleContext->GetStyleData (eStyleStruct_Font); - aRenderingContext.SetFont(font->mFont); + aRenderingContext.SetFont(font->mFont, nsnull); nsCOMPtr fm; aRenderingContext.GetFontMetrics(*getter_AddRefs(fm)); diff --git a/layout/mathml/base/src/nsMathMLmunderoverFrame.cpp b/layout/mathml/base/src/nsMathMLmunderoverFrame.cpp index 6a5f035d5aea..842f73aca71b 100644 --- a/layout/mathml/base/src/nsMathMLmunderoverFrame.cpp +++ b/layout/mathml/base/src/nsMathMLmunderoverFrame.cpp @@ -341,7 +341,7 @@ nsMathMLmunderoverFrame::Place(nsIPresContext* aPresContext, const nsStyleFont* font = (const nsStyleFont*) mStyleContext->GetStyleData (eStyleStruct_Font); - aRenderingContext.SetFont(font->mFont); + aRenderingContext.SetFont(font->mFont, nsnull); nsCOMPtr fm; aRenderingContext.GetFontMetrics(*getter_AddRefs(fm)); diff --git a/layout/xul/base/src/nsTextBoxFrame.cpp b/layout/xul/base/src/nsTextBoxFrame.cpp index 8bb9a40c688e..4388e1af6ec2 100644 --- a/layout/xul/base/src/nsTextBoxFrame.cpp +++ b/layout/xul/base/src/nsTextBoxFrame.cpp @@ -425,7 +425,7 @@ nsTextBoxFrame::PaintTitle(nsIPresContext* aPresContext, aRenderingContext.FillRect(textRect.x, textRect.y + baseline - offset, mRect.width, size); } - aRenderingContext.SetFont(fontStyle->mFont); + aRenderingContext.SetFont(fontStyle->mFont, nsnull); CalculateUnderline(aRenderingContext); diff --git a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index 5fa811ee3ad0..0b2adedb9cde 100644 --- a/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -1532,7 +1532,7 @@ nsTreeBodyFrame::GetCellWidth(PRInt32 aRow, const nsAString& aColID, mPresContext->GetShell(getter_AddRefs(shell)); nsCOMPtr rc; shell->CreateRenderingContext(this, getter_AddRefs(rc)); - rc->SetFont(fontStyle->mFont); + rc->SetFont(fontStyle->mFont, nsnull); // Get the width of the text itself nscoord width; diff --git a/webshell/tests/viewer/windows/nsButton.cpp b/webshell/tests/viewer/windows/nsButton.cpp index 3bccb8733ddd..84a46fbfbe02 100644 --- a/webshell/tests/viewer/windows/nsButton.cpp +++ b/webshell/tests/viewer/windows/nsButton.cpp @@ -278,15 +278,16 @@ NS_METHOD nsButton::Paint(nsIRenderingContext& aRenderingContext, //DrawScaledLine(aRenderingContext, right-onePixel, rect.y+twoPixels, right-onePixel, bottom, scale, appUnits, PR_FALSE); // right + 1 //DrawScaledLine(aRenderingContext, rect.x+twoPixels, bottom-onePixel, right, bottom-onePixel, scale, appUnits, PR_TRUE); // bottom + 1 + - aRenderingContext.SetFont(*mFont); + nsIFontMetrics* metrics; + context->GetMetricsFor(*mFont, metrics); + aRenderingContext.SetFont(metrics); nscoord textWidth; nscoord textHeight; aRenderingContext.GetWidth(mLabel, textWidth); - nsIFontMetrics* metrics; - context->GetMetricsFor(*mFont, metrics); metrics->GetMaxAscent(textHeight); nscoord x = ((rect.width - textWidth) / 2) + rect.x; diff --git a/webshell/tests/viewer/windows/nsTextWidget.cpp b/webshell/tests/viewer/windows/nsTextWidget.cpp index 22aea2ac9d4d..c8a61421513d 100644 --- a/webshell/tests/viewer/windows/nsTextWidget.cpp +++ b/webshell/tests/viewer/windows/nsTextWidget.cpp @@ -296,14 +296,14 @@ NS_METHOD nsTextWidget::Paint(nsIRenderingContext& aRenderingContext, //DrawScaledLine(aRenderingContext, rect.x+twoPixels, bottom-onePixel, right, bottom-onePixel, scale, appUnits, PR_TRUE); // bottom + 1 - aRenderingContext.SetFont(*mFont); + nsIFontMetrics* metrics; + context->GetMetricsFor(*mFont, metrics); + aRenderingContext.SetFont(metrics); nscoord textWidth; nscoord textHeight; aRenderingContext.GetWidth(mText, textWidth); - nsIFontMetrics* metrics; - context->GetMetricsFor(*mFont, metrics); metrics->GetMaxAscent(textHeight); nscoord x = (twoPixels * 2) + rect.x;