diff --git a/widget/cocoa/nsNativeThemeCocoa.h b/widget/cocoa/nsNativeThemeCocoa.h index e37833709ce4..09e778d7b0fb 100644 --- a/widget/cocoa/nsNativeThemeCocoa.h +++ b/widget/cocoa/nsNativeThemeCocoa.h @@ -102,6 +102,9 @@ protected: const HIRect& inBoxRect, bool inIsDefault, ThemeButtonValue inValue, ThemeButtonAdornment inAdornment, mozilla::EventStates inState, nsIFrame* aFrame); + void DrawFocusOutline(CGContextRef cgContext, const HIRect& inBoxRect, + mozilla::EventStates inState, uint8_t aWidgetType, + nsIFrame* aFrame); void DrawDropdown(CGContextRef context, const HIRect& inBoxRect, mozilla::EventStates inState, uint8_t aWidgetType, nsIFrame* aFrame); diff --git a/widget/cocoa/nsNativeThemeCocoa.mm b/widget/cocoa/nsNativeThemeCocoa.mm index aa1fd81fc096..163d42c903ac 100644 --- a/widget/cocoa/nsNativeThemeCocoa.mm +++ b/widget/cocoa/nsNativeThemeCocoa.mm @@ -1036,6 +1036,29 @@ nsNativeThemeCocoa::DrawPushButton(CGContextRef cgContext, const HIRect& inBoxRe NS_OBJC_END_TRY_ABORT_BLOCK; } +void +nsNativeThemeCocoa::DrawFocusOutline(CGContextRef cgContext, const HIRect& inBoxRect, + EventStates inState, uint8_t aWidgetType, + nsIFrame* aFrame) +{ + NS_OBJC_BEGIN_TRY_ABORT_BLOCK; + + HIThemeFrameDrawInfo fdi; + fdi.version = 0; + fdi.kind = kHIThemeFrameTextFieldSquare; + fdi.state = kThemeStateActive; + fdi.isFocused = TRUE; + +#if DRAW_IN_FRAME_DEBUG + CGContextSetRGBFillColor(cgContext, 0.0, 0.0, 0.5, 0.25); + CGContextFillRect(cgContext, inBoxRect); +#endif + + HIThemeDrawFrame(&inBoxRect, &fdi, cgContext, HITHEME_ORIENTATION); + + NS_OBJC_END_TRY_ABORT_BLOCK; +} + typedef void (*RenderHIThemeControlFunction)(CGContextRef cgContext, const HIRect& aRenderRect, void* aData); static void @@ -2268,6 +2291,10 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext, } break; + case NS_THEME_FOCUS_OUTLINE: + DrawFocusOutline(cgContext, macRect, eventState, aWidgetType, aFrame); + break; + case NS_THEME_MOZ_MAC_HELP_BUTTON: DrawPushButton(cgContext, macRect, eventState, aWidgetType, aFrame); break; @@ -2892,6 +2919,11 @@ nsNativeThemeCocoa::GetWidgetOverflow(nsDeviceContext* aContext, nsIFrame* aFram aOverflowRect->Inflate(m); return true; } + case NS_THEME_FOCUS_OUTLINE: + { + aOverflowRect->Inflate(NSIntPixelsToAppUnits(2, p2a)); + return true; + } } return false; @@ -3387,6 +3419,8 @@ nsNativeThemeCocoa::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* a scrollFrame && scrollFrame->GetScrollbarVisibility()); break; } + case NS_THEME_FOCUS_OUTLINE: + return true; } return false;