From 30529a6153804d5f87ed2fa7e03e33eacd42f8b1 Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Fri, 3 Sep 1999 14:48:26 +0000 Subject: [PATCH] when in standard mode and calculating desired size it removes the width of the native border because it is implicitly added during the calculation git-svn-id: svn://10.0.0.236/trunk@45896 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/forms/nsTextControlFrame.cpp | 22 ++++++++++++++----- .../html/forms/src/nsTextControlFrame.cpp | 22 ++++++++++++++----- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/mozilla/layout/forms/nsTextControlFrame.cpp b/mozilla/layout/forms/nsTextControlFrame.cpp index 36656155f4c..8bd0417bb75 100644 --- a/mozilla/layout/forms/nsTextControlFrame.cpp +++ b/mozilla/layout/forms/nsTextControlFrame.cpp @@ -243,12 +243,12 @@ nsTextControlFrame::GetDesiredSize(nsIPresContext* aPresContext, areaSpec, desiredSize, minSize, widthExplicit, heightExplicit, ignore); } + float p2t; + aPresContext->GetPixelsToTwips(&p2t); if (NS_FORM_TEXTAREA == type) { nscoord scrollbarWidth = 0; nscoord scrollbarHeight = 0; float scale; - float p2t; - aPresContext->GetPixelsToTwips(&p2t); nsCOMPtr dx; aPresContext->GetDeviceContext(getter_AddRefs(dx)); if (dx) { @@ -273,9 +273,21 @@ nsTextControlFrame::GetDesiredSize(nsIPresContext* aPresContext, } } - aDesiredLayoutSize.width = desiredSize.width; - aDesiredLayoutSize.height = desiredSize.height; - aDesiredLayoutSize.ascent = aDesiredLayoutSize.height; + if (eCompatibility_Standard == mode) { + nsILookAndFeel * lookAndFeel; + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + PRInt32 borderSize; + lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextFieldBorder, borderSize); + nscoord borderTwips = NSIntPixelsToTwips(borderSize, p2t); + desiredSize.width -= borderTwips*2; + desiredSize.height -= borderTwips*2; + NS_RELEASE(lookAndFeel); + } + } + + aDesiredLayoutSize.width = desiredSize.width; + aDesiredLayoutSize.height = desiredSize.height; + aDesiredLayoutSize.ascent = aDesiredLayoutSize.height; aDesiredLayoutSize.descent = 0; if (aDesiredLayoutSize.maxElementSize) { diff --git a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp index 36656155f4c..8bd0417bb75 100644 --- a/mozilla/layout/html/forms/src/nsTextControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsTextControlFrame.cpp @@ -243,12 +243,12 @@ nsTextControlFrame::GetDesiredSize(nsIPresContext* aPresContext, areaSpec, desiredSize, minSize, widthExplicit, heightExplicit, ignore); } + float p2t; + aPresContext->GetPixelsToTwips(&p2t); if (NS_FORM_TEXTAREA == type) { nscoord scrollbarWidth = 0; nscoord scrollbarHeight = 0; float scale; - float p2t; - aPresContext->GetPixelsToTwips(&p2t); nsCOMPtr dx; aPresContext->GetDeviceContext(getter_AddRefs(dx)); if (dx) { @@ -273,9 +273,21 @@ nsTextControlFrame::GetDesiredSize(nsIPresContext* aPresContext, } } - aDesiredLayoutSize.width = desiredSize.width; - aDesiredLayoutSize.height = desiredSize.height; - aDesiredLayoutSize.ascent = aDesiredLayoutSize.height; + if (eCompatibility_Standard == mode) { + nsILookAndFeel * lookAndFeel; + if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull, kILookAndFeelIID, (void**)&lookAndFeel)) { + PRInt32 borderSize; + lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TextFieldBorder, borderSize); + nscoord borderTwips = NSIntPixelsToTwips(borderSize, p2t); + desiredSize.width -= borderTwips*2; + desiredSize.height -= borderTwips*2; + NS_RELEASE(lookAndFeel); + } + } + + aDesiredLayoutSize.width = desiredSize.width; + aDesiredLayoutSize.height = desiredSize.height; + aDesiredLayoutSize.ascent = aDesiredLayoutSize.height; aDesiredLayoutSize.descent = 0; if (aDesiredLayoutSize.maxElementSize) {