From 4353d8c6d6981206d60abb99786f65a68743ad98 Mon Sep 17 00:00:00 2001 From: "shliang%netscape.com" Date: Wed, 26 Mar 2003 02:57:05 +0000 Subject: [PATCH] 123617 - can't tab to buttons checkboxes and radios in osx classic. r=jag, sr=bryner. git-svn-id: svn://10.0.0.236/trunk@140329 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/gfx/src/mac/nsNativeThemeMac.cpp | 4 ++-- mozilla/gfx/src/shared/nsNativeTheme.cpp | 19 +++++++++++++++++-- mozilla/gfx/src/shared/nsNativeTheme.h | 8 ++++++-- mozilla/themes/classic/global/mac/button.css | 1 - .../themes/classic/global/mac/checkbox.css | 1 - mozilla/themes/classic/global/mac/radio.css | 4 ---- 6 files changed, 25 insertions(+), 12 deletions(-) diff --git a/mozilla/gfx/src/mac/nsNativeThemeMac.cpp b/mozilla/gfx/src/mac/nsNativeThemeMac.cpp index 515aa129e5c..37c2d2b4351 100644 --- a/mozilla/gfx/src/mac/nsNativeThemeMac.cpp +++ b/mozilla/gfx/src/mac/nsNativeThemeMac.cpp @@ -316,8 +316,8 @@ nsNativeThemeMac::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame* ConvertGeckoToNativeRect(transClipRect, clipRect); ::ClipRect(&clipRect); #endif - - PRInt32 eventState = GetContentState(aFrame); + + PRInt32 eventState = GetContentState(aFrame, aWidgetType); switch ( aWidgetType ) { diff --git a/mozilla/gfx/src/shared/nsNativeTheme.cpp b/mozilla/gfx/src/shared/nsNativeTheme.cpp index 1f4611d3815..f7275af636b 100644 --- a/mozilla/gfx/src/shared/nsNativeTheme.cpp +++ b/mozilla/gfx/src/shared/nsNativeTheme.cpp @@ -84,11 +84,20 @@ nsNativeTheme::GetPrimaryPresShell(nsIFrame* aFrame, nsIPresShell** aResult) } PRInt32 -nsNativeTheme::GetContentState(nsIFrame* aFrame) +nsNativeTheme::GetContentState(nsIFrame* aFrame, PRUint8 aWidgetType) { if (!aFrame) return 0; + PRBool isXULCheckboxRadio = PR_FALSE; + if (aWidgetType == NS_THEME_CHECKBOX || aWidgetType == NS_THEME_RADIO) { + nsCOMPtr checkboxRadioContent; + aFrame->GetContent(getter_AddRefs(checkboxRadioContent)); + isXULCheckboxRadio = checkboxRadioContent->IsContentOfType(nsIContent::eXUL); + if (isXULCheckboxRadio) + aFrame->GetParent(&aFrame); + } + nsCOMPtr shell; GetPrimaryPresShell(aFrame, getter_AddRefs(shell)); if (!shell) @@ -102,6 +111,12 @@ nsNativeTheme::GetContentState(nsIFrame* aFrame) nsCOMPtr content; aFrame->GetContent(getter_AddRefs(content)); esm->GetContentState(content, flags); + + if (isXULCheckboxRadio && aWidgetType == NS_THEME_RADIO) { + if (IsFocused(aFrame)) + flags |= NS_EVENT_STATE_FOCUS; + } + return flags; } @@ -229,7 +244,7 @@ nsNativeTheme::IsWidgetStyled(nsIPresContext* aPresContext, nsIFrame* aFrame, lookAndFeel->GetColor(nsILookAndFeel::eColor_threedface, defaultBGColor); } else { - PRInt32 contentState = GetContentState(aFrame); + PRInt32 contentState = GetContentState(aFrame, aWidgetType); ConvertMarginToTwips(sButtonBorderSize, defaultBorderSize, p2t); if (contentState & NS_EVENT_STATE_HOVER && contentState & NS_EVENT_STATE_ACTIVE) diff --git a/mozilla/gfx/src/shared/nsNativeTheme.h b/mozilla/gfx/src/shared/nsNativeTheme.h index 9128a5a30ff..fce6f394a51 100644 --- a/mozilla/gfx/src/shared/nsNativeTheme.h +++ b/mozilla/gfx/src/shared/nsNativeTheme.h @@ -55,13 +55,13 @@ class nsNativeTheme nsNativeTheme(); // Returns the content state (hover, focus, etc), see nsIEventStateManager.h - PRInt32 GetContentState(nsIFrame* aFrame); + PRInt32 GetContentState(nsIFrame* aFrame, PRUint8 aWidgetType); // Returns whether the widget is already styled by content // Normally called from ThemeSupportsWidget to turn off native theming // for elements that are already styled. PRBool IsWidgetStyled(nsIPresContext* aPresContext, nsIFrame* aFrame, - PRUint8 aWidgetType); + PRUint8 aWidgetType); // Accessors to widget-specific state information @@ -84,6 +84,10 @@ class nsNativeTheme PRBool IsSelected(nsIFrame* aFrame) { return GetCheckedOrSelected(aFrame, PR_TRUE); } + + PRBool IsFocused(nsIFrame* aFrame) { + return CheckBooleanAttr(aFrame, mFocusedAtom); + } // tab: PRBool IsSelectedTab(nsIFrame* aFrame) { diff --git a/mozilla/themes/classic/global/mac/button.css b/mozilla/themes/classic/global/mac/button.css index d3ca939f224..f50cb8621c4 100644 --- a/mozilla/themes/classic/global/mac/button.css +++ b/mozilla/themes/classic/global/mac/button.css @@ -31,7 +31,6 @@ button { -moz-appearance: button; - -moz-user-focus: ignore; margin: 1px 5px 2px 5px; min-width: 6.3em; border: 6px solid; diff --git a/mozilla/themes/classic/global/mac/checkbox.css b/mozilla/themes/classic/global/mac/checkbox.css index 0da43b83b77..06a08083a38 100644 --- a/mozilla/themes/classic/global/mac/checkbox.css +++ b/mozilla/themes/classic/global/mac/checkbox.css @@ -31,7 +31,6 @@ checkbox { -moz-appearance: checkbox-container; - -moz-user-focus: ignore; -moz-box-align: center; margin: 2px 4px; padding: 1px 2px 1px 4px; diff --git a/mozilla/themes/classic/global/mac/radio.css b/mozilla/themes/classic/global/mac/radio.css index e777f298fff..37661642609 100644 --- a/mozilla/themes/classic/global/mac/radio.css +++ b/mozilla/themes/classic/global/mac/radio.css @@ -29,10 +29,6 @@ /* ::::: radio ::::: */ -radiogroup { - -moz-user-focus: ignore; -} - radio { -moz-appearance: radio-container; -moz-box-align: center;