diff --git a/widget/src/cocoa/nsNativeThemeCocoa.h b/widget/src/cocoa/nsNativeThemeCocoa.h index e79d175263ea..7952bee69103 100644 --- a/widget/src/cocoa/nsNativeThemeCocoa.h +++ b/widget/src/cocoa/nsNativeThemeCocoa.h @@ -123,7 +123,7 @@ protected: PRBool inDisabled, ThemeButtonValue inValue, ThemeButtonAdornment inAdornment, PRInt32 inState, nsIFrame* aFrame); void DrawDropdown(CGContextRef context, const HIRect& inBoxRect, PRInt32 inState, - PRBool aIsEditable, nsIFrame* aFrame); + PRUint8 aWidgetType, nsIFrame* aFrame); void DrawSpinButtons(CGContextRef context, ThemeButtonKind inKind, const HIRect& inBoxRect, PRBool inDisabled, ThemeDrawState inDrawState, diff --git a/widget/src/cocoa/nsNativeThemeCocoa.mm b/widget/src/cocoa/nsNativeThemeCocoa.mm index d8474311927a..fa1f661f6f7d 100644 --- a/widget/src/cocoa/nsNativeThemeCocoa.mm +++ b/widget/src/cocoa/nsNativeThemeCocoa.mm @@ -866,18 +866,21 @@ static const CellRenderSettings editableMenulistSettings = { void nsNativeThemeCocoa::DrawDropdown(CGContextRef cgContext, const HIRect& inBoxRect, - PRInt32 inState, PRBool aIsEditable, nsIFrame* aFrame) + PRInt32 inState, PRUint8 aWidgetType, nsIFrame* aFrame) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK; - NSCell* cell = aIsEditable ? (NSCell*)mComboBoxCell : (NSCell*)mDropdownCell; + [mDropdownCell setPullsDown:(aWidgetType == NS_THEME_BUTTON)]; + + BOOL isEditable = (aWidgetType == NS_THEME_DROPDOWN_TEXTFIELD); + NSCell* cell = isEditable ? (NSCell*)mComboBoxCell : (NSCell*)mDropdownCell; [cell setEnabled:!IsDisabled(aFrame)]; [cell setShowsFirstResponder:(IsFocused(aFrame) || (inState & NS_EVENT_STATE_FOCUS))]; [cell setHighlighted:((inState & NS_EVENT_STATE_ACTIVE) && (inState & NS_EVENT_STATE_HOVER))]; [cell setControlTint:(FrameIsInActiveWindow(aFrame) ? [NSColor currentControlTint] : NSClearControlTint)]; - const CellRenderSettings& settings = aIsEditable ? editableMenulistSettings : dropdownSettings; + const CellRenderSettings& settings = isEditable ? editableMenulistSettings : dropdownSettings; DrawCellWithSnapping(cell, cgContext, inBoxRect, settings, 0.5f, NativeViewForFrame(aFrame), IsFrameRTL(aFrame)); @@ -1588,6 +1591,8 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame if (IsDefaultButton(aFrame)) { DrawButton(cgContext, kThemePushButton, macRect, true, IsDisabled(aFrame), kThemeButtonOff, kThemeAdornmentNone, eventState, aFrame); + } else if (IsButtonTypeMenu(aFrame)) { + DrawDropdown(cgContext, macRect, eventState, aWidgetType, aFrame); } else { DrawPushButton(cgContext, macRect, IsDisabled(aFrame), eventState, aFrame); } @@ -1664,8 +1669,7 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame case NS_THEME_DROPDOWN: case NS_THEME_DROPDOWN_TEXTFIELD: - DrawDropdown(cgContext, macRect, eventState, - (aWidgetType == NS_THEME_DROPDOWN_TEXTFIELD), aFrame); + DrawDropdown(cgContext, macRect, eventState, aWidgetType, aFrame); break; case NS_THEME_DROPDOWN_BUTTON: @@ -1893,7 +1897,11 @@ nsNativeThemeCocoa::GetWidgetBorder(nsIDeviceContext* aContext, switch (aWidgetType) { case NS_THEME_BUTTON: { - aResult->SizeTo(7, 1, 7, 3); + if (IsButtonTypeMenu(aFrame)) { + *aResult = RTLAwareMargin(kAquaDropdownBorder, aFrame); + } else { + aResult->SizeTo(7, 1, 7, 3); + } break; } diff --git a/widget/src/xpwidgets/nsNativeTheme.cpp b/widget/src/xpwidgets/nsNativeTheme.cpp index 74b61d6d14d8..909c889ea47e 100644 --- a/widget/src/xpwidgets/nsNativeTheme.cpp +++ b/widget/src/xpwidgets/nsNativeTheme.cpp @@ -160,6 +160,17 @@ nsNativeTheme::GetCheckedOrSelected(nsIFrame* aFrame, PRBool aCheckSelected) : nsWidgetAtoms::checked); } +PRBool +nsNativeTheme::IsButtonTypeMenu(nsIFrame* aFrame) +{ + if (!aFrame) + return PR_FALSE; + + nsIContent* content = aFrame->GetContent(); + return content->AttrValueIs(kNameSpaceID_None, nsWidgetAtoms::type, + NS_LITERAL_STRING("menu"), eCaseMatters); +} + PRBool nsNativeTheme::GetIndeterminate(nsIFrame* aFrame) { diff --git a/widget/src/xpwidgets/nsNativeTheme.h b/widget/src/xpwidgets/nsNativeTheme.h index c8e26ff458a5..b691d36d4892 100644 --- a/widget/src/xpwidgets/nsNativeTheme.h +++ b/widget/src/xpwidgets/nsNativeTheme.h @@ -93,6 +93,8 @@ class nsNativeTheme return CheckBooleanAttr(aFrame, nsWidgetAtoms::_default); } + PRBool IsButtonTypeMenu(nsIFrame* aFrame); + // checkbox: PRBool IsChecked(nsIFrame* aFrame) { return GetCheckedOrSelected(aFrame, PR_FALSE);