From e2527bce2911839625b982dd31c195100b90e6d7 Mon Sep 17 00:00:00 2001 From: "rbs%maths.uq.edu.au" Date: Wed, 21 Jul 2004 01:05:44 +0000 Subject: [PATCH] Cleanup font usage in form input controls, b=251637, r=jshin, sr=bzbarsky --- layout/forms/nsComboboxControlFrame.cpp | 20 +---- layout/forms/nsComboboxControlFrame.h | 3 - layout/forms/nsFileControlFrame.cpp | 6 -- layout/forms/nsFileControlFrame.h | 3 - layout/forms/nsFormControlFrame.cpp | 7 -- layout/forms/nsFormControlFrame.h | 3 - layout/forms/nsFormControlHelper.cpp | 77 ++----------------- layout/forms/nsFormControlHelper.h | 18 +---- layout/forms/nsHTMLButtonControlFrame.cpp | 7 -- layout/forms/nsHTMLButtonControlFrame.h | 3 - layout/forms/nsIFormControlFrame.h | 2 - layout/forms/nsImageControlFrame.cpp | 9 --- layout/forms/nsListControlFrame.cpp | 11 +-- layout/forms/nsListControlFrame.h | 2 - layout/forms/nsTextControlFrame.cpp | 9 +-- layout/forms/nsTextControlFrame.h | 2 - .../html/forms/public/nsIFormControlFrame.h | 2 - .../html/forms/src/nsComboboxControlFrame.cpp | 20 +---- .../html/forms/src/nsComboboxControlFrame.h | 3 - layout/html/forms/src/nsFileControlFrame.cpp | 6 -- layout/html/forms/src/nsFileControlFrame.h | 3 - layout/html/forms/src/nsFormControlFrame.cpp | 7 -- layout/html/forms/src/nsFormControlFrame.h | 3 - layout/html/forms/src/nsFormControlHelper.cpp | 77 ++----------------- layout/html/forms/src/nsFormControlHelper.h | 18 +---- .../forms/src/nsHTMLButtonControlFrame.cpp | 7 -- .../html/forms/src/nsHTMLButtonControlFrame.h | 3 - layout/html/forms/src/nsImageControlFrame.cpp | 9 --- layout/html/forms/src/nsListControlFrame.cpp | 11 +-- layout/html/forms/src/nsListControlFrame.h | 2 - layout/html/forms/src/nsTextControlFrame.cpp | 9 +-- layout/html/forms/src/nsTextControlFrame.h | 2 - 32 files changed, 26 insertions(+), 338 deletions(-) diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index 340cae42854e..9eaa77a600ac 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -444,15 +444,6 @@ nsComboboxControlFrame::GetFormContent(nsIContent*& aContent) const return NS_OK; } -//-------------------------------------------------------------- -NS_IMETHODIMP -nsComboboxControlFrame::GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont) -{ - return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont); -} - - //-------------------------------------------------------------- nscoord nsComboboxControlFrame::GetVerticalBorderWidth(float aPixToTwip) const @@ -788,13 +779,9 @@ nsComboboxControlFrame::ReflowItems(nsIPresContext* aPresContext, nsHTMLReflowMetrics& aDesiredSize) { //printf("*****************\n"); - const nsStyleFont* dspFont = mDisplayFrame->GetStyleFont(); - nsIFontMetrics * fontMet; - aPresContext->DeviceContext()->GetMetricsFor(dspFont->mFont, fontMet); - - nscoord visibleHeight; - //nsCOMPtr fontMet; - //nsresult res = nsFormControlHelper::GetFrameFontFM(aPresContext, this, getter_AddRefs(fontMet)); + nscoord visibleHeight = 0; + nsCOMPtr fontMet; + nsresult res = nsFormControlHelper::GetFrameFontFM(mDisplayFrame, getter_AddRefs(fontMet)); if (fontMet) { fontMet->GetHeight(visibleHeight); } @@ -854,7 +841,6 @@ nsComboboxControlFrame::ReflowItems(nsIPresContext* aPresContext, frmWidth-aDesiredSize.width, frmHeight-aDesiredSize.height, (frmWidth-aDesiredSize.width)/15, (frmHeight-aDesiredSize.height)/15); #endif - NS_RELEASE(fontMet); return NS_OK; } #endif diff --git a/layout/forms/nsComboboxControlFrame.h b/layout/forms/nsComboboxControlFrame.h index a2f16d6e98ad..9b55b10997b3 100644 --- a/layout/forms/nsComboboxControlFrame.h +++ b/layout/forms/nsComboboxControlFrame.h @@ -150,9 +150,6 @@ public: void ScrollIntoView(nsIPresContext* aPresContext); virtual void InitializeControl(nsIPresContext* aPresContext); NS_IMETHOD OnContentReset(); - - NS_IMETHOD GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont); NS_IMETHOD GetFormContent(nsIContent*& aContent) const; virtual nscoord GetVerticalBorderWidth(float aPixToTwip) const; virtual nscoord GetHorizontalBorderWidth(float aPixToTwip) const; diff --git a/layout/forms/nsFileControlFrame.cpp b/layout/forms/nsFileControlFrame.cpp index db7519832bfa..67a8ffef27c3 100644 --- a/layout/forms/nsFileControlFrame.cpp +++ b/layout/forms/nsFileControlFrame.cpp @@ -598,12 +598,6 @@ nsFileControlFrame::GetFormContent(nsIContent*& aContent) const return NS_OK; } -NS_IMETHODIMP -nsFileControlFrame::GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont) -{ - return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont); -} nscoord nsFileControlFrame::GetVerticalInsidePadding(nsIPresContext* aPresContext, float aPixToTwip, diff --git a/layout/forms/nsFileControlFrame.h b/layout/forms/nsFileControlFrame.h index a6e2cd37c93b..b43576ac6184 100644 --- a/layout/forms/nsFileControlFrame.h +++ b/layout/forms/nsFileControlFrame.h @@ -109,9 +109,6 @@ public: void SetFocus(PRBool aOn, PRBool aRepaint); void ScrollIntoView(nsIPresContext* aPresContext); - NS_IMETHOD GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont); - NS_IMETHOD GetFormContent(nsIContent*& aContent) const; virtual nscoord GetVerticalInsidePadding(nsIPresContext* aPresContext, float aPixToTwip, diff --git a/layout/forms/nsFormControlFrame.cpp b/layout/forms/nsFormControlFrame.cpp index 229ba97405c4..3b67c3ffe639 100644 --- a/layout/forms/nsFormControlFrame.cpp +++ b/layout/forms/nsFormControlFrame.cpp @@ -779,13 +779,6 @@ nsFormControlFrame::GetFormContent(nsIContent*& aContent) const return NS_OK; } -NS_IMETHODIMP -nsFormControlFrame::GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont) -{ - return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont); -} - nsresult nsFormControlFrame::GetDefaultCheckState(PRBool *aState) { diff --git a/layout/forms/nsFormControlFrame.h b/layout/forms/nsFormControlFrame.h index e6bc4ee93285..8e1cc7efcdf3 100644 --- a/layout/forms/nsFormControlFrame.h +++ b/layout/forms/nsFormControlFrame.h @@ -197,9 +197,6 @@ public: virtual void SetClickPoint(nscoord aX, nscoord aY); - NS_IMETHOD GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont); - NS_IMETHOD GetFormContent(nsIContent*& aContent) const; /** diff --git a/layout/forms/nsFormControlHelper.cpp b/layout/forms/nsFormControlHelper.cpp index 550d03a35e15..9e8585b9b18b 100644 --- a/layout/forms/nsFormControlHelper.cpp +++ b/layout/forms/nsFormControlHelper.cpp @@ -119,19 +119,14 @@ void nsFormControlHelper::GetBoolString(const PRBool aValue, } -nsresult nsFormControlHelper::GetFrameFontFM(nsIPresContext* aPresContext, - nsIFormControlFrame * aFrame, - nsIFontMetrics** aFontMet) +nsresult nsFormControlHelper::GetFrameFontFM(nsIFrame* aFrame, + nsIFontMetrics** aFontMet) { - // Initialize with default font - const nsFont * font = nsnull; - // Get frame font - if (NS_SUCCEEDED(aFrame->GetFont(aPresContext, font))) { - if (font) { // Get font metrics - return aPresContext->DeviceContext()->GetMetricsFor(*font, *aFontMet); - } - } - return NS_ERROR_FAILURE; + nsStyleContext* sc = aFrame->GetStyleContext(); + return aFrame->GetPresContext()->DeviceContext()-> + GetMetricsFor(sc->GetStyleFont()->mFont, + sc->GetStyleVisibility()->mLangGroup, + *aFontMet); } nsresult @@ -175,64 +170,6 @@ nsFormControlHelper::GetWrapPropertyEnum(nsIContent * aContent, nsHTMLTextWrap& return rv; } -nscoord -nsFormControlHelper::GetTextSize(nsIPresContext* aPresContext, nsIFormControlFrame* aFrame, - const nsString& aString, nsSize& aSize, - nsIRenderingContext *aRendContext) -{ - nsCOMPtr fontMet; - nsresult res = GetFrameFontFM(aPresContext, aFrame, getter_AddRefs(fontMet)); - if (NS_SUCCEEDED(res) && fontMet) { - aRendContext->SetFont(fontMet); - - // measure string - aRendContext->GetWidth(aString, aSize.width); - fontMet->GetHeight(aSize.height); - } else { - NS_ASSERTION(PR_FALSE, "Couldn't get Font Metrics"); - aSize.width = 0; - } - - char char1, char2; - GetRepChars(char1, char2); - nscoord char1Width, char2Width; - aRendContext->GetWidth(char1, char1Width); - aRendContext->GetWidth(char2, char2Width); - - return ((char1Width + char2Width) / 2) + 1; -} - -nscoord -nsFormControlHelper::GetTextSize(nsIPresContext* aPresContext, nsIFormControlFrame* aFrame, - PRInt32 aNumChars, nsSize& aSize, - nsIRenderingContext *aRendContext) -{ - nsAutoString val; - char char1, char2; - GetRepChars(char1, char2); - int i; - for (i = 0; i < aNumChars; i+=2) { - val.Append(PRUnichar(char1)); - } - for (i = 1; i < aNumChars; i+=2) { - val.Append(PRUnichar(char2)); - } - return GetTextSize(aPresContext, aFrame, val, aSize, aRendContext); -} - -nsresult -nsFormControlHelper::GetFont(nsIFormControlFrame * aFormFrame, - nsIPresContext* aPresContext, - nsStyleContext * aStyleContext, - const nsFont*& aFont) -{ - const nsStyleFont* styleFont = (const nsStyleFont*)aStyleContext->GetStyleData(eStyleStruct_Font); - - aFont = &styleFont->mFont; - return NS_OK; -} - - // //------------------------------------------------------------------------------------- // Utility methods for rendering Form Elements using GFX diff --git a/layout/forms/nsFormControlHelper.h b/layout/forms/nsFormControlHelper.h index 70b9bd187d6e..14db018ce2e4 100644 --- a/layout/forms/nsFormControlHelper.h +++ b/layout/forms/nsFormControlHelper.h @@ -84,24 +84,8 @@ class nsFormControlHelper public: - - static nscoord GetTextSize(nsIPresContext* aContext, nsIFormControlFrame* aFrame, - const nsString& aString, nsSize& aSize, - nsIRenderingContext *aRendContext); - - static nscoord GetTextSize(nsIPresContext* aContext, nsIFormControlFrame* aFrame, - PRInt32 aNumChars, nsSize& aSize, - nsIRenderingContext *aRendContext); - - // XXX This could be removed now that we no longer have form quirks. - static nsresult GetFont(nsIFormControlFrame * aFormFrame, - nsIPresContext* aPresContext, - nsStyleContext * aStyleContext, - const nsFont*& aFont); - // returns the an addref'ed FontMetrics for the default font for the frame - static nsresult GetFrameFontFM(nsIPresContext* aPresContext, - nsIFormControlFrame * aFrame, + static nsresult GetFrameFontFM(nsIFrame* aFrame, nsIFontMetrics** aFontMet); // Map platform line endings (CR, CRLF, LF) to DOM line endings (LF) diff --git a/layout/forms/nsHTMLButtonControlFrame.cpp b/layout/forms/nsHTMLButtonControlFrame.cpp index a2b2bc9f5ebd..2c3f0ef2ad9c 100644 --- a/layout/forms/nsHTMLButtonControlFrame.cpp +++ b/layout/forms/nsHTMLButtonControlFrame.cpp @@ -568,13 +568,6 @@ nsHTMLButtonControlFrame::GetSkipSides() const return 0; } -NS_IMETHODIMP -nsHTMLButtonControlFrame::GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont) -{ - return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont); -} - NS_IMETHODIMP nsHTMLButtonControlFrame::GetFormContent(nsIContent*& aContent) const { diff --git a/layout/forms/nsHTMLButtonControlFrame.h b/layout/forms/nsHTMLButtonControlFrame.h index 3c8ba29b2659..bbfd7df207d6 100644 --- a/layout/forms/nsHTMLButtonControlFrame.h +++ b/layout/forms/nsHTMLButtonControlFrame.h @@ -150,9 +150,6 @@ public: void SetFocus(PRBool aOn, PRBool aRepaint); void ScrollIntoView(nsIPresContext* aPresContext); - NS_IMETHOD GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont); - NS_IMETHOD GetFormContent(nsIContent*& aContent) const; virtual nscoord GetVerticalInsidePadding(nsIPresContext* aPresContext, float aPixToTwip, diff --git a/layout/forms/nsIFormControlFrame.h b/layout/forms/nsIFormControlFrame.h index 98e1a635f45e..c82f1991b86a 100644 --- a/layout/forms/nsIFormControlFrame.h +++ b/layout/forms/nsIFormControlFrame.h @@ -82,8 +82,6 @@ public: NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight) = 0; - NS_IMETHOD GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont) = 0; /** * Get the content object associated with this frame. Adds a reference to * the content object so the caller must do a release. diff --git a/layout/forms/nsImageControlFrame.cpp b/layout/forms/nsImageControlFrame.cpp index 2c45a3c7edb0..f6c11b9d144d 100644 --- a/layout/forms/nsImageControlFrame.cpp +++ b/layout/forms/nsImageControlFrame.cpp @@ -107,8 +107,6 @@ public: void SetFocus(PRBool aOn, PRBool aRepaint); void ScrollIntoView(nsIPresContext* aPresContext); - NS_IMETHOD GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont); NS_IMETHOD GetFormContent(nsIContent*& aContent) const; virtual nscoord GetVerticalInsidePadding(nsIPresContext* aPresContext, @@ -321,13 +319,6 @@ nsImageControlFrame::MouseClicked(nsIPresContext* aPresContext) // nsHTMLInputElement::HandleDOMEvent(). } -NS_IMETHODIMP -nsImageControlFrame::GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont) -{ - return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont); -} - NS_IMETHODIMP nsImageControlFrame::GetFormContent(nsIContent*& aContent) const { diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index 40491c72ee63..94fca5697617 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -1281,7 +1281,7 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, if (visibleHeight == 0) { if (aReflowState.mComputedHeight != 0) { nsCOMPtr fontMet; - nsresult rvv = nsFormControlHelper::GetFrameFontFM(aPresContext, this, getter_AddRefs(fontMet)); + nsresult rvv = nsFormControlHelper::GetFrameFontFM(this, getter_AddRefs(fontMet)); if (NS_SUCCEEDED(rvv) && fontMet) { aReflowState.rendContext->SetFont(fontMet); fontMet->GetHeight(visibleHeight); @@ -1416,15 +1416,6 @@ nsListControlFrame::GetScrollbarStyles() const verticalStyle); } -//--------------------------------------------------------- -NS_IMETHODIMP -nsListControlFrame::GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont) -{ - return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont); -} - - //--------------------------------------------------------- PRBool nsListControlFrame::IsOptionElement(nsIContent* aContent) diff --git a/layout/forms/nsListControlFrame.h b/layout/forms/nsListControlFrame.h index d370f521bd36..4f5c62a97a9b 100644 --- a/layout/forms/nsListControlFrame.h +++ b/layout/forms/nsListControlFrame.h @@ -139,8 +139,6 @@ public: NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue); NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue); NS_IMETHOD GetMultiple(PRBool* aResult, nsIDOMHTMLSelectElement* aSelect = nsnull); - NS_IMETHOD GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont); NS_IMETHOD GetFormContent(nsIContent*& aContent) const; NS_IMETHOD OnContentReset(); diff --git a/layout/forms/nsTextControlFrame.cpp b/layout/forms/nsTextControlFrame.cpp index d00dc928da61..0eaf580e0a15 100644 --- a/layout/forms/nsTextControlFrame.cpp +++ b/layout/forms/nsTextControlFrame.cpp @@ -1420,7 +1420,7 @@ nsTextControlFrame::CalculateSizeStandard(nsIPresContext* aPresContext, nscoord charMaxAdvance = 0; nsCOMPtr fontMet; - nsresult rv = nsFormControlHelper::GetFrameFontFM(aPresContext, this, getter_AddRefs(fontMet)); + nsresult rv = nsFormControlHelper::GetFrameFontFM(this, getter_AddRefs(fontMet)); NS_ENSURE_SUCCESS(rv, rv); aRendContext->SetFont(fontMet); fontMet->GetHeight(fontHeight); @@ -2120,13 +2120,6 @@ nsTextControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight) return NS_OK; } -NS_IMETHODIMP -nsTextControlFrame::GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont) -{ - return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont); -} - NS_IMETHODIMP nsTextControlFrame::GetFormContent(nsIContent*& aContent) const { diff --git a/layout/forms/nsTextControlFrame.h b/layout/forms/nsTextControlFrame.h index 5538c2c19ef5..c724ce9aa66c 100644 --- a/layout/forms/nsTextControlFrame.h +++ b/layout/forms/nsTextControlFrame.h @@ -144,8 +144,6 @@ public: nscoord aInnerWidth, nscoord aCharWidth) const;/**/ NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight); - NS_IMETHOD GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont); NS_IMETHOD GetFormContent(nsIContent*& aContent) const; NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue); NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue); diff --git a/layout/html/forms/public/nsIFormControlFrame.h b/layout/html/forms/public/nsIFormControlFrame.h index 98e1a635f45e..c82f1991b86a 100644 --- a/layout/html/forms/public/nsIFormControlFrame.h +++ b/layout/html/forms/public/nsIFormControlFrame.h @@ -82,8 +82,6 @@ public: NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight) = 0; - NS_IMETHOD GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont) = 0; /** * Get the content object associated with this frame. Adds a reference to * the content object so the caller must do a release. diff --git a/layout/html/forms/src/nsComboboxControlFrame.cpp b/layout/html/forms/src/nsComboboxControlFrame.cpp index 340cae42854e..9eaa77a600ac 100644 --- a/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -444,15 +444,6 @@ nsComboboxControlFrame::GetFormContent(nsIContent*& aContent) const return NS_OK; } -//-------------------------------------------------------------- -NS_IMETHODIMP -nsComboboxControlFrame::GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont) -{ - return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont); -} - - //-------------------------------------------------------------- nscoord nsComboboxControlFrame::GetVerticalBorderWidth(float aPixToTwip) const @@ -788,13 +779,9 @@ nsComboboxControlFrame::ReflowItems(nsIPresContext* aPresContext, nsHTMLReflowMetrics& aDesiredSize) { //printf("*****************\n"); - const nsStyleFont* dspFont = mDisplayFrame->GetStyleFont(); - nsIFontMetrics * fontMet; - aPresContext->DeviceContext()->GetMetricsFor(dspFont->mFont, fontMet); - - nscoord visibleHeight; - //nsCOMPtr fontMet; - //nsresult res = nsFormControlHelper::GetFrameFontFM(aPresContext, this, getter_AddRefs(fontMet)); + nscoord visibleHeight = 0; + nsCOMPtr fontMet; + nsresult res = nsFormControlHelper::GetFrameFontFM(mDisplayFrame, getter_AddRefs(fontMet)); if (fontMet) { fontMet->GetHeight(visibleHeight); } @@ -854,7 +841,6 @@ nsComboboxControlFrame::ReflowItems(nsIPresContext* aPresContext, frmWidth-aDesiredSize.width, frmHeight-aDesiredSize.height, (frmWidth-aDesiredSize.width)/15, (frmHeight-aDesiredSize.height)/15); #endif - NS_RELEASE(fontMet); return NS_OK; } #endif diff --git a/layout/html/forms/src/nsComboboxControlFrame.h b/layout/html/forms/src/nsComboboxControlFrame.h index a2f16d6e98ad..9b55b10997b3 100644 --- a/layout/html/forms/src/nsComboboxControlFrame.h +++ b/layout/html/forms/src/nsComboboxControlFrame.h @@ -150,9 +150,6 @@ public: void ScrollIntoView(nsIPresContext* aPresContext); virtual void InitializeControl(nsIPresContext* aPresContext); NS_IMETHOD OnContentReset(); - - NS_IMETHOD GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont); NS_IMETHOD GetFormContent(nsIContent*& aContent) const; virtual nscoord GetVerticalBorderWidth(float aPixToTwip) const; virtual nscoord GetHorizontalBorderWidth(float aPixToTwip) const; diff --git a/layout/html/forms/src/nsFileControlFrame.cpp b/layout/html/forms/src/nsFileControlFrame.cpp index db7519832bfa..67a8ffef27c3 100644 --- a/layout/html/forms/src/nsFileControlFrame.cpp +++ b/layout/html/forms/src/nsFileControlFrame.cpp @@ -598,12 +598,6 @@ nsFileControlFrame::GetFormContent(nsIContent*& aContent) const return NS_OK; } -NS_IMETHODIMP -nsFileControlFrame::GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont) -{ - return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont); -} nscoord nsFileControlFrame::GetVerticalInsidePadding(nsIPresContext* aPresContext, float aPixToTwip, diff --git a/layout/html/forms/src/nsFileControlFrame.h b/layout/html/forms/src/nsFileControlFrame.h index a6e2cd37c93b..b43576ac6184 100644 --- a/layout/html/forms/src/nsFileControlFrame.h +++ b/layout/html/forms/src/nsFileControlFrame.h @@ -109,9 +109,6 @@ public: void SetFocus(PRBool aOn, PRBool aRepaint); void ScrollIntoView(nsIPresContext* aPresContext); - NS_IMETHOD GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont); - NS_IMETHOD GetFormContent(nsIContent*& aContent) const; virtual nscoord GetVerticalInsidePadding(nsIPresContext* aPresContext, float aPixToTwip, diff --git a/layout/html/forms/src/nsFormControlFrame.cpp b/layout/html/forms/src/nsFormControlFrame.cpp index 229ba97405c4..3b67c3ffe639 100644 --- a/layout/html/forms/src/nsFormControlFrame.cpp +++ b/layout/html/forms/src/nsFormControlFrame.cpp @@ -779,13 +779,6 @@ nsFormControlFrame::GetFormContent(nsIContent*& aContent) const return NS_OK; } -NS_IMETHODIMP -nsFormControlFrame::GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont) -{ - return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont); -} - nsresult nsFormControlFrame::GetDefaultCheckState(PRBool *aState) { diff --git a/layout/html/forms/src/nsFormControlFrame.h b/layout/html/forms/src/nsFormControlFrame.h index e6bc4ee93285..8e1cc7efcdf3 100644 --- a/layout/html/forms/src/nsFormControlFrame.h +++ b/layout/html/forms/src/nsFormControlFrame.h @@ -197,9 +197,6 @@ public: virtual void SetClickPoint(nscoord aX, nscoord aY); - NS_IMETHOD GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont); - NS_IMETHOD GetFormContent(nsIContent*& aContent) const; /** diff --git a/layout/html/forms/src/nsFormControlHelper.cpp b/layout/html/forms/src/nsFormControlHelper.cpp index 550d03a35e15..9e8585b9b18b 100644 --- a/layout/html/forms/src/nsFormControlHelper.cpp +++ b/layout/html/forms/src/nsFormControlHelper.cpp @@ -119,19 +119,14 @@ void nsFormControlHelper::GetBoolString(const PRBool aValue, } -nsresult nsFormControlHelper::GetFrameFontFM(nsIPresContext* aPresContext, - nsIFormControlFrame * aFrame, - nsIFontMetrics** aFontMet) +nsresult nsFormControlHelper::GetFrameFontFM(nsIFrame* aFrame, + nsIFontMetrics** aFontMet) { - // Initialize with default font - const nsFont * font = nsnull; - // Get frame font - if (NS_SUCCEEDED(aFrame->GetFont(aPresContext, font))) { - if (font) { // Get font metrics - return aPresContext->DeviceContext()->GetMetricsFor(*font, *aFontMet); - } - } - return NS_ERROR_FAILURE; + nsStyleContext* sc = aFrame->GetStyleContext(); + return aFrame->GetPresContext()->DeviceContext()-> + GetMetricsFor(sc->GetStyleFont()->mFont, + sc->GetStyleVisibility()->mLangGroup, + *aFontMet); } nsresult @@ -175,64 +170,6 @@ nsFormControlHelper::GetWrapPropertyEnum(nsIContent * aContent, nsHTMLTextWrap& return rv; } -nscoord -nsFormControlHelper::GetTextSize(nsIPresContext* aPresContext, nsIFormControlFrame* aFrame, - const nsString& aString, nsSize& aSize, - nsIRenderingContext *aRendContext) -{ - nsCOMPtr fontMet; - nsresult res = GetFrameFontFM(aPresContext, aFrame, getter_AddRefs(fontMet)); - if (NS_SUCCEEDED(res) && fontMet) { - aRendContext->SetFont(fontMet); - - // measure string - aRendContext->GetWidth(aString, aSize.width); - fontMet->GetHeight(aSize.height); - } else { - NS_ASSERTION(PR_FALSE, "Couldn't get Font Metrics"); - aSize.width = 0; - } - - char char1, char2; - GetRepChars(char1, char2); - nscoord char1Width, char2Width; - aRendContext->GetWidth(char1, char1Width); - aRendContext->GetWidth(char2, char2Width); - - return ((char1Width + char2Width) / 2) + 1; -} - -nscoord -nsFormControlHelper::GetTextSize(nsIPresContext* aPresContext, nsIFormControlFrame* aFrame, - PRInt32 aNumChars, nsSize& aSize, - nsIRenderingContext *aRendContext) -{ - nsAutoString val; - char char1, char2; - GetRepChars(char1, char2); - int i; - for (i = 0; i < aNumChars; i+=2) { - val.Append(PRUnichar(char1)); - } - for (i = 1; i < aNumChars; i+=2) { - val.Append(PRUnichar(char2)); - } - return GetTextSize(aPresContext, aFrame, val, aSize, aRendContext); -} - -nsresult -nsFormControlHelper::GetFont(nsIFormControlFrame * aFormFrame, - nsIPresContext* aPresContext, - nsStyleContext * aStyleContext, - const nsFont*& aFont) -{ - const nsStyleFont* styleFont = (const nsStyleFont*)aStyleContext->GetStyleData(eStyleStruct_Font); - - aFont = &styleFont->mFont; - return NS_OK; -} - - // //------------------------------------------------------------------------------------- // Utility methods for rendering Form Elements using GFX diff --git a/layout/html/forms/src/nsFormControlHelper.h b/layout/html/forms/src/nsFormControlHelper.h index 70b9bd187d6e..14db018ce2e4 100644 --- a/layout/html/forms/src/nsFormControlHelper.h +++ b/layout/html/forms/src/nsFormControlHelper.h @@ -84,24 +84,8 @@ class nsFormControlHelper public: - - static nscoord GetTextSize(nsIPresContext* aContext, nsIFormControlFrame* aFrame, - const nsString& aString, nsSize& aSize, - nsIRenderingContext *aRendContext); - - static nscoord GetTextSize(nsIPresContext* aContext, nsIFormControlFrame* aFrame, - PRInt32 aNumChars, nsSize& aSize, - nsIRenderingContext *aRendContext); - - // XXX This could be removed now that we no longer have form quirks. - static nsresult GetFont(nsIFormControlFrame * aFormFrame, - nsIPresContext* aPresContext, - nsStyleContext * aStyleContext, - const nsFont*& aFont); - // returns the an addref'ed FontMetrics for the default font for the frame - static nsresult GetFrameFontFM(nsIPresContext* aPresContext, - nsIFormControlFrame * aFrame, + static nsresult GetFrameFontFM(nsIFrame* aFrame, nsIFontMetrics** aFontMet); // Map platform line endings (CR, CRLF, LF) to DOM line endings (LF) diff --git a/layout/html/forms/src/nsHTMLButtonControlFrame.cpp b/layout/html/forms/src/nsHTMLButtonControlFrame.cpp index a2b2bc9f5ebd..2c3f0ef2ad9c 100644 --- a/layout/html/forms/src/nsHTMLButtonControlFrame.cpp +++ b/layout/html/forms/src/nsHTMLButtonControlFrame.cpp @@ -568,13 +568,6 @@ nsHTMLButtonControlFrame::GetSkipSides() const return 0; } -NS_IMETHODIMP -nsHTMLButtonControlFrame::GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont) -{ - return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont); -} - NS_IMETHODIMP nsHTMLButtonControlFrame::GetFormContent(nsIContent*& aContent) const { diff --git a/layout/html/forms/src/nsHTMLButtonControlFrame.h b/layout/html/forms/src/nsHTMLButtonControlFrame.h index 3c8ba29b2659..bbfd7df207d6 100644 --- a/layout/html/forms/src/nsHTMLButtonControlFrame.h +++ b/layout/html/forms/src/nsHTMLButtonControlFrame.h @@ -150,9 +150,6 @@ public: void SetFocus(PRBool aOn, PRBool aRepaint); void ScrollIntoView(nsIPresContext* aPresContext); - NS_IMETHOD GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont); - NS_IMETHOD GetFormContent(nsIContent*& aContent) const; virtual nscoord GetVerticalInsidePadding(nsIPresContext* aPresContext, float aPixToTwip, diff --git a/layout/html/forms/src/nsImageControlFrame.cpp b/layout/html/forms/src/nsImageControlFrame.cpp index 2c45a3c7edb0..f6c11b9d144d 100644 --- a/layout/html/forms/src/nsImageControlFrame.cpp +++ b/layout/html/forms/src/nsImageControlFrame.cpp @@ -107,8 +107,6 @@ public: void SetFocus(PRBool aOn, PRBool aRepaint); void ScrollIntoView(nsIPresContext* aPresContext); - NS_IMETHOD GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont); NS_IMETHOD GetFormContent(nsIContent*& aContent) const; virtual nscoord GetVerticalInsidePadding(nsIPresContext* aPresContext, @@ -321,13 +319,6 @@ nsImageControlFrame::MouseClicked(nsIPresContext* aPresContext) // nsHTMLInputElement::HandleDOMEvent(). } -NS_IMETHODIMP -nsImageControlFrame::GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont) -{ - return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont); -} - NS_IMETHODIMP nsImageControlFrame::GetFormContent(nsIContent*& aContent) const { diff --git a/layout/html/forms/src/nsListControlFrame.cpp b/layout/html/forms/src/nsListControlFrame.cpp index 40491c72ee63..94fca5697617 100644 --- a/layout/html/forms/src/nsListControlFrame.cpp +++ b/layout/html/forms/src/nsListControlFrame.cpp @@ -1281,7 +1281,7 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, if (visibleHeight == 0) { if (aReflowState.mComputedHeight != 0) { nsCOMPtr fontMet; - nsresult rvv = nsFormControlHelper::GetFrameFontFM(aPresContext, this, getter_AddRefs(fontMet)); + nsresult rvv = nsFormControlHelper::GetFrameFontFM(this, getter_AddRefs(fontMet)); if (NS_SUCCEEDED(rvv) && fontMet) { aReflowState.rendContext->SetFont(fontMet); fontMet->GetHeight(visibleHeight); @@ -1416,15 +1416,6 @@ nsListControlFrame::GetScrollbarStyles() const verticalStyle); } -//--------------------------------------------------------- -NS_IMETHODIMP -nsListControlFrame::GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont) -{ - return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont); -} - - //--------------------------------------------------------- PRBool nsListControlFrame::IsOptionElement(nsIContent* aContent) diff --git a/layout/html/forms/src/nsListControlFrame.h b/layout/html/forms/src/nsListControlFrame.h index d370f521bd36..4f5c62a97a9b 100644 --- a/layout/html/forms/src/nsListControlFrame.h +++ b/layout/html/forms/src/nsListControlFrame.h @@ -139,8 +139,6 @@ public: NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue); NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue); NS_IMETHOD GetMultiple(PRBool* aResult, nsIDOMHTMLSelectElement* aSelect = nsnull); - NS_IMETHOD GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont); NS_IMETHOD GetFormContent(nsIContent*& aContent) const; NS_IMETHOD OnContentReset(); diff --git a/layout/html/forms/src/nsTextControlFrame.cpp b/layout/html/forms/src/nsTextControlFrame.cpp index d00dc928da61..0eaf580e0a15 100644 --- a/layout/html/forms/src/nsTextControlFrame.cpp +++ b/layout/html/forms/src/nsTextControlFrame.cpp @@ -1420,7 +1420,7 @@ nsTextControlFrame::CalculateSizeStandard(nsIPresContext* aPresContext, nscoord charMaxAdvance = 0; nsCOMPtr fontMet; - nsresult rv = nsFormControlHelper::GetFrameFontFM(aPresContext, this, getter_AddRefs(fontMet)); + nsresult rv = nsFormControlHelper::GetFrameFontFM(this, getter_AddRefs(fontMet)); NS_ENSURE_SUCCESS(rv, rv); aRendContext->SetFont(fontMet); fontMet->GetHeight(fontHeight); @@ -2120,13 +2120,6 @@ nsTextControlFrame::SetSuggestedSize(nscoord aWidth, nscoord aHeight) return NS_OK; } -NS_IMETHODIMP -nsTextControlFrame::GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont) -{ - return nsFormControlHelper::GetFont(this, aPresContext, mStyleContext, aFont); -} - NS_IMETHODIMP nsTextControlFrame::GetFormContent(nsIContent*& aContent) const { diff --git a/layout/html/forms/src/nsTextControlFrame.h b/layout/html/forms/src/nsTextControlFrame.h index 5538c2c19ef5..c724ce9aa66c 100644 --- a/layout/html/forms/src/nsTextControlFrame.h +++ b/layout/html/forms/src/nsTextControlFrame.h @@ -144,8 +144,6 @@ public: nscoord aInnerWidth, nscoord aCharWidth) const;/**/ NS_IMETHOD SetSuggestedSize(nscoord aWidth, nscoord aHeight); - NS_IMETHOD GetFont(nsIPresContext* aPresContext, - const nsFont*& aFont); NS_IMETHOD GetFormContent(nsIContent*& aContent) const; NS_IMETHOD SetProperty(nsIPresContext* aPresContext, nsIAtom* aName, const nsAString& aValue); NS_IMETHOD GetProperty(nsIAtom* aName, nsAString& aValue);