From 6649ff6b3d5e5bebf021bf2c085aec7e50402eeb Mon Sep 17 00:00:00 2001 From: "smontagu%smontagu.org" Date: Sun, 10 Oct 2004 18:30:28 +0000 Subject: [PATCH] Bug 167001: Anything below the baseline goes out of input field. Patch by Hideo Saito , r+sr=dbaron git-svn-id: svn://10.0.0.236/trunk@163502 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/forms/nsTextControlFrame.cpp | 13 +++++++------ mozilla/layout/forms/nsTextControlFrame.h | 2 +- .../layout/html/forms/src/nsTextControlFrame.cpp | 13 +++++++------ mozilla/layout/html/forms/src/nsTextControlFrame.h | 2 +- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp index 1b5ff1cd487..d049ad995f8 100644 --- a/mozilla/layout/forms/nsTextControlFrame.cpp +++ b/mozilla/layout/forms/nsTextControlFrame.cpp @@ -1543,7 +1543,7 @@ nsTextControlFrame::ReflowStandard(nsPresContext* aPresContext, { // get the css size and let the frame use or override it nsSize minSize; - nsresult rv = CalculateSizeStandard(aPresContext, aReflowState.rendContext, + nsresult rv = CalculateSizeStandard(aPresContext, aReflowState, aDesiredSize, minSize); NS_ENSURE_SUCCESS(rv, rv); @@ -1582,7 +1582,7 @@ nsTextControlFrame::ReflowStandard(nsPresContext* aPresContext, nsresult nsTextControlFrame::CalculateSizeStandard(nsPresContext* aPresContext, - nsIRenderingContext* aRendContext, + const nsHTMLReflowState& aReflowState, nsSize& aDesiredSize, nsSize& aMinSize) { @@ -1590,15 +1590,16 @@ nsTextControlFrame::CalculateSizeStandard(nsPresContext* aPresContext, aDesiredSize.height = CSS_NOTSET; // Get leading and the Average/MaxAdvance char width - nscoord fontHeight = 0; + nscoord lineHeight = 0; nscoord charWidth = 0; nscoord charMaxAdvance = 0; nsCOMPtr fontMet; nsresult rv = nsFormControlHelper::GetFrameFontFM(this, getter_AddRefs(fontMet)); NS_ENSURE_SUCCESS(rv, rv); - aRendContext->SetFont(fontMet); - fontMet->GetHeight(fontHeight); + nsIRenderingContext* rendContext = aReflowState.rendContext; + rendContext->SetFont(fontMet); + lineHeight = aReflowState.CalcLineHeight(aPresContext, rendContext, aReflowState.frame); fontMet->GetAveCharWidth(charWidth); fontMet->GetMaxAdvance(charMaxAdvance); @@ -1645,7 +1646,7 @@ nsTextControlFrame::CalculateSizeStandard(nsPresContext* aPresContext, // Set the height equal to total number of rows (times the height of each // line, of course) - aDesiredSize.height = fontHeight * GetRows(); + aDesiredSize.height = lineHeight * GetRows(); // Set minimum size equal to desired size. We are form controls. We are Gods // among elements. We do not yield for anybody, not even a table cell. None diff --git a/mozilla/layout/forms/nsTextControlFrame.h b/mozilla/layout/forms/nsTextControlFrame.h index 517be789523..261e07cddb9 100644 --- a/mozilla/layout/forms/nsTextControlFrame.h +++ b/mozilla/layout/forms/nsTextControlFrame.h @@ -276,7 +276,7 @@ protected: nsReflowStatus& aStatus); nsresult CalculateSizeStandard(nsPresContext* aPresContext, - nsIRenderingContext* aRendContext, + const nsHTMLReflowState& aReflowState, nsSize& aDesiredSize, nsSize& aMinSize); diff --git a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp index 1b5ff1cd487..d049ad995f8 100644 --- a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp @@ -1543,7 +1543,7 @@ nsTextControlFrame::ReflowStandard(nsPresContext* aPresContext, { // get the css size and let the frame use or override it nsSize minSize; - nsresult rv = CalculateSizeStandard(aPresContext, aReflowState.rendContext, + nsresult rv = CalculateSizeStandard(aPresContext, aReflowState, aDesiredSize, minSize); NS_ENSURE_SUCCESS(rv, rv); @@ -1582,7 +1582,7 @@ nsTextControlFrame::ReflowStandard(nsPresContext* aPresContext, nsresult nsTextControlFrame::CalculateSizeStandard(nsPresContext* aPresContext, - nsIRenderingContext* aRendContext, + const nsHTMLReflowState& aReflowState, nsSize& aDesiredSize, nsSize& aMinSize) { @@ -1590,15 +1590,16 @@ nsTextControlFrame::CalculateSizeStandard(nsPresContext* aPresContext, aDesiredSize.height = CSS_NOTSET; // Get leading and the Average/MaxAdvance char width - nscoord fontHeight = 0; + nscoord lineHeight = 0; nscoord charWidth = 0; nscoord charMaxAdvance = 0; nsCOMPtr fontMet; nsresult rv = nsFormControlHelper::GetFrameFontFM(this, getter_AddRefs(fontMet)); NS_ENSURE_SUCCESS(rv, rv); - aRendContext->SetFont(fontMet); - fontMet->GetHeight(fontHeight); + nsIRenderingContext* rendContext = aReflowState.rendContext; + rendContext->SetFont(fontMet); + lineHeight = aReflowState.CalcLineHeight(aPresContext, rendContext, aReflowState.frame); fontMet->GetAveCharWidth(charWidth); fontMet->GetMaxAdvance(charMaxAdvance); @@ -1645,7 +1646,7 @@ nsTextControlFrame::CalculateSizeStandard(nsPresContext* aPresContext, // Set the height equal to total number of rows (times the height of each // line, of course) - aDesiredSize.height = fontHeight * GetRows(); + aDesiredSize.height = lineHeight * GetRows(); // Set minimum size equal to desired size. We are form controls. We are Gods // among elements. We do not yield for anybody, not even a table cell. None diff --git a/mozilla/layout/html/forms/src/nsTextControlFrame.h b/mozilla/layout/html/forms/src/nsTextControlFrame.h index 517be789523..261e07cddb9 100644 --- a/mozilla/layout/html/forms/src/nsTextControlFrame.h +++ b/mozilla/layout/html/forms/src/nsTextControlFrame.h @@ -276,7 +276,7 @@ protected: nsReflowStatus& aStatus); nsresult CalculateSizeStandard(nsPresContext* aPresContext, - nsIRenderingContext* aRendContext, + const nsHTMLReflowState& aReflowState, nsSize& aDesiredSize, nsSize& aMinSize);