don't let comboboxes render their labels over the native combobox button on Mac OS X. b=382043 r/sr=roc

This commit is contained in:
joshmoz@gmail.com 2007-05-28 22:31:04 -07:00
parent 5aa5625012
commit c5eb505c59
2 changed files with 26 additions and 31 deletions

View File

@ -580,33 +580,34 @@ nsComboboxControlFrame::GetMinWidth(nsIRenderingContext *aRenderingContext)
nscoord
nsComboboxControlFrame::GetPrefWidth(nsIRenderingContext *aRenderingContext)
{
nscoord result;
DISPLAY_PREF_WIDTH(this, result);
if (NS_LIKELY(mDropdownFrame != nsnull)) {
result = mDropdownFrame->GetPrefWidth(aRenderingContext);
} else {
result = 0;
// get the scrollbar width, we'll use this later
nscoord scrollbarWidth = 0;
nsPresContext* presContext = PresContext();
if (mListControlFrame) {
nsIScrollableFrame* scrollable;
CallQueryInterface(mListControlFrame, &scrollable);
NS_ASSERTION(scrollable, "List must be a scrollable frame");
nsBoxLayoutState bls(presContext, aRenderingContext);
scrollbarWidth = scrollable->GetDesiredScrollbarSizes(&bls).LeftRight();
}
// It's also possible that the pref width of our dropdown is less than that
// of our display frame plus a scrollbar. This can happen, eg, if the
// dropdown is empty.
if (NS_LIKELY(mListControlFrame && mDisplayFrame)) {
nscoord displayResult = nsLayoutUtils::IntrinsicForContainer(aRenderingContext, mDisplayFrame,
nsLayoutUtils::PREF_WIDTH);
nsPresContext *presContext = PresContext();
if (!IsThemed() || presContext->GetTheme()->ThemeNeedsComboboxDropmarker()) {
nsIScrollableFrame* scrollable;
CallQueryInterface(mListControlFrame, &scrollable);
NS_ASSERTION(scrollable, "List must be a scrollable frame");
nsBoxLayoutState bls(presContext, aRenderingContext);
displayResult += scrollable->GetDesiredScrollbarSizes(&bls).LeftRight();
}
result = PR_MAX(result, displayResult);
nscoord displayPrefWidth = 0;
DISPLAY_PREF_WIDTH(this, displayPrefWidth);
if (NS_LIKELY(mDisplayFrame)) {
displayPrefWidth = nsLayoutUtils::IntrinsicForContainer(aRenderingContext, mDisplayFrame,
nsLayoutUtils::PREF_WIDTH);
}
return result;
if (mDropdownFrame) {
nscoord dropdownContentWidth = mDropdownFrame->GetPrefWidth(aRenderingContext) - scrollbarWidth;
displayPrefWidth = PR_MAX(dropdownContentWidth, displayPrefWidth);
}
// add room for the dropmarker button if there is one
if (!IsThemed() || presContext->GetTheme()->ThemeNeedsComboboxDropmarker())
displayPrefWidth += scrollbarWidth;
return displayPrefWidth;
}
NS_IMETHODIMP

View File

@ -852,15 +852,9 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame
return NS_OK;
}
// The left border is simply set to the text does not get too close
// to the edge.
static const int kAquaDropdownLeftBorder = 5;
// The right border is for the ~22-pixel native "button" on the
// right side of a combobox. Since comboboxes are sized with
// extra room on the right for a scrollbar already, we specify the
// difference beween the ~22-pixel native "button" and the scrollbar
// width.
static const int kAquaDropdownRightBorder = 7;
static const int kAquaDropdownRightBorder = 22;
NS_IMETHODIMP
nsNativeThemeCocoa::GetWidgetBorder(nsIDeviceContext* aContext,