diff --git a/widget/src/cocoa/nsNativeThemeCocoa.mm b/widget/src/cocoa/nsNativeThemeCocoa.mm index 7cf3d76f785..b25e1d18ae4 100644 --- a/widget/src/cocoa/nsNativeThemeCocoa.mm +++ b/widget/src/cocoa/nsNativeThemeCocoa.mm @@ -719,6 +719,18 @@ nsNativeThemeCocoa::DrawButton(CGContextRef cgContext, ThemeButtonKind inKind, // leave things alone on Tiger drawFrame.size.height -= 1; } + } else if (inKind == kThemeListHeaderButton) { + CGContextClipToRect(cgContext, inBoxRect); + // Always remove the top border. + drawFrame.origin.y -= 1; + drawFrame.size.height += 1; + // Remove the left border in LTR mode and the right border in RTL mode. + drawFrame.size.width += 1; + PRBool isLast = IsLastTreeHeaderCell(aFrame); + if (isLast) + drawFrame.size.width += 1; // Also remove the other border. + if (!IsFrameRTL(aFrame) || isLast) + drawFrame.origin.x -= 1; } if (!needsScaling) { @@ -1461,7 +1473,7 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame TreeSortDirection sortDirection = GetTreeSortDirection(aFrame); DrawButton(cgContext, kThemeListHeaderButton, macRect, PR_FALSE, IsDisabled(aFrame), sortDirection == eTreeSortDirection_Natural ? kThemeButtonOff : kThemeButtonOn, - sortDirection == eTreeSortDirection_Descending ? + sortDirection == eTreeSortDirection_Ascending ? kThemeAdornmentHeaderButtonSortUp : kThemeAdornmentNone, eventState, aFrame); } break; @@ -1817,7 +1829,7 @@ nsNativeThemeCocoa::GetMinimumWidgetSize(nsIRenderingContext* aContext, { SInt32 headerHeight = 0; ::GetThemeMetric(kThemeMetricListHeaderHeight, &headerHeight); - aResult->SizeTo(0, headerHeight); + aResult->SizeTo(0, headerHeight - 1); // We don't need the top border. break; } diff --git a/widget/src/windows/nsNativeThemeWin.cpp b/widget/src/windows/nsNativeThemeWin.cpp index c8309ee1afd..3a8e41f3acb 100644 --- a/widget/src/windows/nsNativeThemeWin.cpp +++ b/widget/src/windows/nsNativeThemeWin.cpp @@ -168,11 +168,6 @@ static SIZE GetGutterSize(HANDLE theme, HDC hdc) return ret; } -static inline PRBool IsFrameRTL(nsIFrame *frame) -{ - return frame->GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL; -} - static HRESULT DrawThemeBGRTLAware(HANDLE theme, HDC hdc, int part, int state, const RECT *widgetRect, const RECT *clipRect, PRBool isRTL) diff --git a/widget/src/xpwidgets/nsNativeTheme.cpp b/widget/src/xpwidgets/nsNativeTheme.cpp index c7e441358ff..352991f4658 100644 --- a/widget/src/xpwidgets/nsNativeTheme.cpp +++ b/widget/src/xpwidgets/nsNativeTheme.cpp @@ -169,6 +169,12 @@ nsNativeTheme::IsWidgetStyled(nsPresContext* aPresContext, nsIFrame* aFrame, NS_AUTHOR_SPECIFIED_BACKGROUND); } +PRBool +nsNativeTheme::IsFrameRTL(nsIFrame* aFrame) +{ + return aFrame && aFrame->GetStyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL; +} + // scrollbar button: PRInt32 nsNativeTheme::GetScrollbarButtonType(nsIFrame* aFrame) @@ -212,6 +218,34 @@ nsNativeTheme::GetTreeSortDirection(nsIFrame* aFrame) return eTreeSortDirection_Natural; } +PRBool +nsNativeTheme::IsLastTreeHeaderCell(nsIFrame* aFrame) +{ + if (!aFrame) + return PR_FALSE; + + // A tree column picker is always the last header cell. + if (aFrame->GetContent()->Tag() == nsWidgetAtoms::treecolpicker) + return PR_TRUE; + + // Find the parent tree. + nsIContent* parent = aFrame->GetContent()->GetParent(); + while (parent && parent->Tag() != nsWidgetAtoms::tree) { + parent = parent->GetParent(); + } + + // If the column picker is visible, this can't be the last column. + if (parent && !parent->AttrValueIs(kNameSpaceID_None, nsWidgetAtoms::hidecolumnpicker, + NS_LITERAL_STRING("true"), eCaseMatters)) + return PR_FALSE; + + while ((aFrame = aFrame->GetNextSibling())) { + if (aFrame->GetRect().width > 0) + return PR_FALSE; + } + return PR_TRUE; +} + // tab: PRBool nsNativeTheme::IsBottomTab(nsIFrame* aFrame) diff --git a/widget/src/xpwidgets/nsNativeTheme.h b/widget/src/xpwidgets/nsNativeTheme.h index 3e5495a1fe7..4070093436e 100644 --- a/widget/src/xpwidgets/nsNativeTheme.h +++ b/widget/src/xpwidgets/nsNativeTheme.h @@ -85,6 +85,9 @@ class nsNativeTheme return CheckBooleanAttr(aFrame, nsWidgetAtoms::disabled); } + // RTL chrome direction + PRBool IsFrameRTL(nsIFrame* aFrame); + // button: PRBool IsDefaultButton(nsIFrame* aFrame) { return CheckBooleanAttr(aFrame, nsWidgetAtoms::_default); @@ -119,6 +122,7 @@ class nsNativeTheme // treeheadercell: TreeSortDirection GetTreeSortDirection(nsIFrame* aFrame); + PRBool IsLastTreeHeaderCell(nsIFrame* aFrame); // tab: PRBool IsBottomTab(nsIFrame* aFrame); diff --git a/widget/src/xpwidgets/nsWidgetAtomList.h b/widget/src/xpwidgets/nsWidgetAtomList.h index 6f103a16ff5..1549da09bb8 100644 --- a/widget/src/xpwidgets/nsWidgetAtomList.h +++ b/widget/src/xpwidgets/nsWidgetAtomList.h @@ -77,6 +77,7 @@ WIDGET_ATOM(focused, "focused") WIDGET_ATOM(Forward, "Forward") WIDGET_ATOM(Home, "Home") WIDGET_ATOM(hidden, "hidden") +WIDGET_ATOM(hidecolumnpicker, "hidecolumnpicker") WIDGET_ATOM(horizontal, "horizontal") WIDGET_ATOM(vertical, "vertical") WIDGET_ATOM(id, "id") @@ -118,6 +119,8 @@ WIDGET_ATOM(state, "state") WIDGET_ATOM(step, "step") WIDGET_ATOM(Stop, "Stop") WIDGET_ATOM(_true, "true") +WIDGET_ATOM(tree, "tree") +WIDGET_ATOM(treecolpicker, "treecolpicker") WIDGET_ATOM(type, "type") WIDGET_ATOM(value, "value")