From b3f74e27da68981202ef2c1ad5d51fd5f655211d Mon Sep 17 00:00:00 2001 From: "pinkerton%netscape.com" Date: Fri, 5 Oct 2001 14:10:16 +0000 Subject: [PATCH] respect the look&feel pref about showing comboboxes outside the client area. r=rods/sr=sfraser/a=asa. bug# 102834. git-svn-id: svn://10.0.0.236/trunk@104656 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/layout/forms/nsFormControlFrame.cpp | 33 ++++++++++++------- .../html/forms/src/nsFormControlFrame.cpp | 33 ++++++++++++------- .../webshell/tests/viewer/nsSetupRegistry.cpp | 2 +- 3 files changed, 43 insertions(+), 25 deletions(-) diff --git a/mozilla/layout/forms/nsFormControlFrame.cpp b/mozilla/layout/forms/nsFormControlFrame.cpp index 2a96ae9e202..b7859997a58 100644 --- a/mozilla/layout/forms/nsFormControlFrame.cpp +++ b/mozilla/layout/forms/nsFormControlFrame.cpp @@ -74,6 +74,7 @@ #include "nsIDOMHTMLButtonElement.h" #include "nsIEventStateManager.h" #include "nsIScrollableView.h" +#include "nsILookAndFeel.h" #ifdef DEBUG_evaughan //#define DEBUG_rods @@ -964,18 +965,26 @@ nsresult nsFormControlFrame::GetScreenHeight(nsIPresContext* aPresContext, nscoord& aHeight) { aHeight = 0; - nsIDeviceContext* context; - aPresContext->GetDeviceContext( &context ); - if ( nsnull != context ) { - PRInt32 height; - PRInt32 width; - context->GetDeviceSurfaceDimensions(width, height); - float devUnits; - context->GetDevUnitsToAppUnits(devUnits); - aHeight = NSToIntRound(float( height) / devUnits ); - NS_RELEASE( context ); - return NS_OK; - } + nsCOMPtr context; + aPresContext->GetDeviceContext( getter_AddRefs(context) ); + if ( context ) { + nsRect screen; + + PRBool dropdownCanOverlapOSBar = PR_FALSE; + nsCOMPtr lookAndFeel; + aPresContext->GetLookAndFeel(getter_AddRefs(lookAndFeel)); + if ( lookAndFeel ) + lookAndFeel->GetMetric(nsILookAndFeel::eMetric_MenusCanOverlapOSBar, dropdownCanOverlapOSBar); + if ( dropdownCanOverlapOSBar ) + context->GetRect ( screen ); + else + context->GetClientRect(screen); + + float devUnits; + context->GetDevUnitsToAppUnits(devUnits); + aHeight = NSToIntRound(float(screen.height) / devUnits ); + return NS_OK; + } return NS_ERROR_FAILURE; } diff --git a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp index 2a96ae9e202..b7859997a58 100644 --- a/mozilla/layout/html/forms/src/nsFormControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFormControlFrame.cpp @@ -74,6 +74,7 @@ #include "nsIDOMHTMLButtonElement.h" #include "nsIEventStateManager.h" #include "nsIScrollableView.h" +#include "nsILookAndFeel.h" #ifdef DEBUG_evaughan //#define DEBUG_rods @@ -964,18 +965,26 @@ nsresult nsFormControlFrame::GetScreenHeight(nsIPresContext* aPresContext, nscoord& aHeight) { aHeight = 0; - nsIDeviceContext* context; - aPresContext->GetDeviceContext( &context ); - if ( nsnull != context ) { - PRInt32 height; - PRInt32 width; - context->GetDeviceSurfaceDimensions(width, height); - float devUnits; - context->GetDevUnitsToAppUnits(devUnits); - aHeight = NSToIntRound(float( height) / devUnits ); - NS_RELEASE( context ); - return NS_OK; - } + nsCOMPtr context; + aPresContext->GetDeviceContext( getter_AddRefs(context) ); + if ( context ) { + nsRect screen; + + PRBool dropdownCanOverlapOSBar = PR_FALSE; + nsCOMPtr lookAndFeel; + aPresContext->GetLookAndFeel(getter_AddRefs(lookAndFeel)); + if ( lookAndFeel ) + lookAndFeel->GetMetric(nsILookAndFeel::eMetric_MenusCanOverlapOSBar, dropdownCanOverlapOSBar); + if ( dropdownCanOverlapOSBar ) + context->GetRect ( screen ); + else + context->GetClientRect(screen); + + float devUnits; + context->GetDevUnitsToAppUnits(devUnits); + aHeight = NSToIntRound(float(screen.height) / devUnits ); + return NS_OK; + } return NS_ERROR_FAILURE; } diff --git a/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp b/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp index 16e8a4ca84a..fef86cf8416 100644 --- a/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp +++ b/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp @@ -136,7 +136,7 @@ NS_SetupRegistry() // WIDGET #if !defined(XP_UNIX) && !defined(XP_OS2) && !defined(XP_WIN) - nsComponentManager::RegisterComponentLib(kCLookAndFeelCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); + nsComponentManager::RegisterComponentLib(kCLookAndFeelCID, NULL, "@mozilla.org/widget/lookandfeel;1", WIDGET_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kCWindowCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kCVScrollbarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE); nsComponentManager::RegisterComponentLib(kCHScrollbarCID, NULL, NULL, WIDGET_DLL, PR_FALSE, PR_FALSE);