From 42f59aca02bb2a3ce8279d21907236bcafd8e3b2 Mon Sep 17 00:00:00 2001 From: "mark%moxienet.com" Date: Fri, 14 Jul 2006 19:54:08 +0000 Subject: [PATCH] 344570 Make contextual menus look more native on the Mac. r=josh sr=bryner --- layout/style/nsCSSKeywordList.h | 1 + layout/style/nsCSSProps.cpp | 1 + toolkit/themes/pinstripe/global/menu.css | 16 +-- .../pinstripe/global/menu/menu-arrow-dis.gif | Bin 56 -> 58 bytes .../pinstripe/global/menu/menu-arrow-hov.gif | Bin 854 -> 168 bytes .../pinstripe/global/menu/menu-arrow.gif | Bin 847 -> 112 bytes .../pinstripe/global/menu/menu-check-dis.gif | Bin 124 -> 124 bytes .../pinstripe/global/menu/menu-check-dis.png | Bin 369 -> 220 bytes .../pinstripe/global/menu/menu-check-hov.gif | Bin 124 -> 128 bytes .../pinstripe/global/menu/menu-check-hov.png | Bin 299 -> 194 bytes .../pinstripe/global/menu/menu-check.gif | Bin 124 -> 124 bytes .../pinstripe/global/menu/menu-check.png | Bin 346 -> 220 bytes .../pinstripe/global/menu/menu-radio-hov.gif | Bin 62 -> 64 bytes .../pinstripe/global/menu/menu-radio.gif | Bin 62 -> 62 bytes widget/public/nsILookAndFeel.h | 1 + widget/src/mac/nsLookAndFeel.cpp | 6 + widget/src/mac/nsMacWindow.cpp | 114 +++++++++++------- widget/src/mac/nsMacWindow.h | 4 +- widget/src/xpwidgets/nsXPLookAndFeel.cpp | 1 + 19 files changed, 92 insertions(+), 52 deletions(-) diff --git a/layout/style/nsCSSKeywordList.h b/layout/style/nsCSSKeywordList.h index ca88212ea846..daf05b45f3de 100644 --- a/layout/style/nsCSSKeywordList.h +++ b/layout/style/nsCSSKeywordList.h @@ -142,6 +142,7 @@ CSS_KEY(-moz-mac-alternateprimaryhighlight, _moz_mac_alternateprimaryhighlight) CSS_KEY(-moz-mac-focusring, _moz_mac_focusring) CSS_KEY(-moz-mac-menuselect, _moz_mac_menuselect) CSS_KEY(-moz-mac-menushadow, _moz_mac_menushadow) +CSS_KEY(-moz-mac-menutextdisable, _moz_mac_menutextdisable) CSS_KEY(-moz-mac-menutextselect, _moz_mac_menutextselect) CSS_KEY(-moz-mac-secondaryhighlight, _moz_mac_secondaryhighlight) CSS_KEY(-moz-malayalam, _moz_malayalam) diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index 9626ae6a632b..4098ab55c81e 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -434,6 +434,7 @@ const PRInt32 nsCSSProps::kColorKTable[] = { eCSSKeyword__moz_mac_focusring, nsILookAndFeel::eColor__moz_mac_focusring, eCSSKeyword__moz_mac_menuselect, nsILookAndFeel::eColor__moz_mac_menuselect, eCSSKeyword__moz_mac_menushadow, nsILookAndFeel::eColor__moz_mac_menushadow, + eCSSKeyword__moz_mac_menutextdisable, nsILookAndFeel::eColor__moz_mac_menutextdisable, eCSSKeyword__moz_mac_menutextselect, nsILookAndFeel::eColor__moz_mac_menutextselect, eCSSKeyword__moz_mac_accentlightesthighlight, nsILookAndFeel::eColor__moz_mac_accentlightesthighlight, eCSSKeyword__moz_mac_accentregularhighlight, nsILookAndFeel::eColor__moz_mac_accentregularhighlight, diff --git a/toolkit/themes/pinstripe/global/menu.css b/toolkit/themes/pinstripe/global/menu.css index 7412164706f3..5fb2ae0460c4 100644 --- a/toolkit/themes/pinstripe/global/menu.css +++ b/toolkit/themes/pinstripe/global/menu.css @@ -50,7 +50,7 @@ menuitem { -moz-appearance: menuitem !important; -moz-box-align: center; color: MenuText; - font: menu; + font: -moz-pull-down-menu; list-style-image: none; -moz-image-region: auto; } @@ -58,7 +58,7 @@ menuitem { menu[disabled="true"], menuitem[disabled="true"], menu[_moz-menuactive="true"][disabled="true"], menuitem[_moz-menuactive="true"][disabled="true"] { - color: GrayText; + color: -moz-mac-menutextdisable; } /* ..... internal content .... */ @@ -71,20 +71,20 @@ menuitem[_moz-menuactive="true"][disabled="true"] { } .menu-text { - margin-left: 20px !important; + margin-left: 13px !important; font-weight: inherit; } .menu-description { font-style: italic; - color: GrayText; + color: -moz-mac-menutextdisable; -moz-margin-start: 1ex !important; } .menu-accel, .menu-iconic-accel { margin: 0px 2px 0px 7px !important; - padding-right: 14px; + padding-right: 3px; color: inherit; } @@ -129,9 +129,9 @@ menupopup > menu, popup > menu, menupopup > menuitem, popup > menuitem { - padding: 1px 8px 1px 8px !important; + padding: 0px 8px 2px 8px !important; max-width: 42em; - min-height: 20px; + min-height: 19px; } menupopup > menu[_moz-menuactive="true"], @@ -149,7 +149,7 @@ menulist > menupopup > menuitem, menulist > menupopup > menu { padding-right: 25px !important; max-width: none; - font: inherit; + font: -moz-pull-down-menu; color: -moz-FieldText; } diff --git a/toolkit/themes/pinstripe/global/menu/menu-arrow-dis.gif b/toolkit/themes/pinstripe/global/menu/menu-arrow-dis.gif index 414fd6f45b8182d6ff66ccd6e75c85ecbe1bc1ff..c9932b0aa86fe34e62fd780fae00f1aa6e93768f 100644 GIT binary patch literal 58 zcmZ?wbhEHbWMklE_`qmbUS9tH|9{1wEQ|~cj0`#qKmd|qU=r-5On|m diff --git a/toolkit/themes/pinstripe/global/menu/menu-arrow-hov.gif b/toolkit/themes/pinstripe/global/menu/menu-arrow-hov.gif index 741f4ce789c1b50d8060353118ec113c82b0cecb..932918937b440fb7ab4f98ee03be46a00ea7a845 100644 GIT binary patch delta 68 zcmV-K0K5Oz2B-lGM@dFFIbjF@3;^_z3u2QE0}m_=000FgpdpTAX*h{c0>DF%EX#~B a>l$^8f~NG+&b+dw_TH%-z0Nr>7@5IXNmSiUAu?{K>+| wz`)3$1Cj)p!N4MGaKba&;^-pZBX?#$WPMP^ld@Cv)h(e+i>4Rp5rPcX0EM(9O#lD@ literal 847 zcmZ?wbhEHbytmol)GGB9Pz9LmrXN?9FM_fMZru?>+x6Wr=7#OSp=y4mp delta 104 zcmb=a;dS?Pv#?AQU=U!~%)l^FKsx0A|NjgaK=CIFBLf2`gAParq?mz4)8M4%>b(}P pdwm~t7Anl~h+|UdbT*S|^AM3Ny7Sph=4Y6K$%FzA5jO?~YXF}n8E^mq diff --git a/toolkit/themes/pinstripe/global/menu/menu-check-dis.png b/toolkit/themes/pinstripe/global/menu/menu-check-dis.png index 10913c5f75ad0a28ac89cde14b763ac40abe4a77..f3fd7d6ef78431286e90c39ecf7ccfe346ffb6ad 100644 GIT binary patch delta 192 zcmV;x06+in0^9+RB!8nxL_t(|oMK=YaPa^Ce~K`v8u)-%iChB|fDZNsVR8&m1#0w# zVhvIakV4X|jvj94in)MT8HvvURPO=RtcxwsQ8^3@rXa;YwmOt=0o7~|#7qQZ0SL6A z8bAT1gyeJ~Tv3j005cFfB54F+V|?ia-2e~}K+^03#5^P=BsnNBg&JT&D79i2WMJTj u8X!n0nsFIGbY3APDPzR|00030{{sLpeG)ex630&f0000pOXNa>QWZRN6Vp?J zQWH}u3s0unFfcGOd%8G=RNPAX^Z&m+vnqo^gM_9jkn}KWm^g7Fzegv-*E`Lfj4T2d z*%(Z<88mYRq*tVC`^YFXbQm$Lh!pk6blADQu`2Jt6NY-Gjs=VkXM-G0Nu1it8d5JD zDW}j7z{8;Rj45c6!^YhKcI*?17?Q#i>KH`!_vA4;Ff5c#;98=RV8-}U%wd~`Kt0o= z!wwtkU$8N-2yjdNm!1;FnDvkMDi722jhSqW4Gd1@jK&i-F(=8Xn4WLQI`@c6xq;yj zhsy#*CWljEr&#?x}>Xa)dfuY9W>FVdQ&MBb@00~xcDF6Tf diff --git a/toolkit/themes/pinstripe/global/menu/menu-check-hov.gif b/toolkit/themes/pinstripe/global/menu/menu-check-hov.gif index a7697ddf51d263ff951a8d5eeda15c462eb5f41c..7277e07ea7aac87384286b37cf1932e28e500d46 100644 GIT binary patch delta 79 zcmV-V0I>gjfB_IkNk%w1VGsZi0P_Gb|NsAy4HyF~Xfly2B`_@z$VsccH0jN||6nMN lATp2%0vM#qenOzBL`VRLS{$JERKs!A!t#vOuZm&FGBt5ir+KGqPoqHX?#3vGx;94_F>a z{|`LKRg>7_dx6LEv%Er>`c(#jICj$nQ@gW2cnsR45a>QWZRN6Vp?J zQWH}u3s0un02S@^ba4!+xRvzh|9^XCRR)Cy2~ATF>A*Ijp|o)aM;Y{0Eh6V;F@fWRGKR9`FB{m#<>I&jNV0k3{Kky(|O(Khc!wr_R6HNXy zCY9E(F|Y{eb(RJ&hY5G7HZUAgP2@2>FlhoK(8|I%1`dTTUMOL}AmL{>_2m|YZlF&% O89ZJ6T-G@yGywqle_#>- diff --git a/toolkit/themes/pinstripe/global/menu/menu-check.gif b/toolkit/themes/pinstripe/global/menu/menu-check.gif index 7be6dfcfc62bced372d10a55f8b2204db441adde..3f09abb5dfe4bd291c24d1bb297207c924e7e28e 100644 GIT binary patch delta 104 zcmb=a5pef(v#?AQU=U#V%wYKc|Nn`+(t!*ZK=CIFBS=sOM1T}CuxJXL@Lavu;`Q0x o>?bZLb{?GgOq4^&GsUH8!qJJ6o^koEoATM4-#VXhVPLQZ0RF=qYXATM delta 104 zcmb=a;dS?Pv#?AQU=U!~%)l^FKsx0A|NjgaK=CIFBLf2`gAParq?mz4)8M4%>b(}P pd;1@pY!sQ}5$B-L>1?LZ?jaG`c;~a5!p}4jlL-YLB5n)})&RaH8k7J4 diff --git a/toolkit/themes/pinstripe/global/menu/menu-check.png b/toolkit/themes/pinstripe/global/menu/menu-check.png index 6408ee8e36f7f403ab766e88a4534fdfe604c532..a18427658696e5568a814b7d46b5a7d19f6990dd 100644 GIT binary patch delta 192 zcmV;x06+iQ0^9+RB!8nxL_t(|oMK=YaPa^Ce~K`v8f1aki(CU-fDT>+!sHkb0Mxh) zio-}Xz!FJw2zt1oD;5P}A0)mIQ2i{Z<|J%^j>=(RC`AZ8&L3qTM9 z)c^`8FC?d{01K5DL7fB-s=i*B*=mvm*GLq&cKrBg8LOFthLZ|`xgi*6Rm>4Jo00Bgj0gQ}{vOw&GECvuj zEF@@l0a9^L?lzb>Kmf52sW|{hg+aL+kmUdZh=mBvmPne{0e=I14YE8y05PE{76oD- zB)$-kN`!Lvplb#JfB-^w0mzTWK#d$w#pyuI1H=!3co8-i0t67c0WYDnAJC9*Kw1~d zUjQ`l4>kh;0th`CR{`;JsKGH%vEx9^H*tj#Kmef_095!3NKHc$`Uk{o@C7nJ0AVB~ zpdojG)M+U9G&qp|9G?LI0fZ|hZa_~kxBx%^F;beD00M~O%mffX6dM2#U;rHnI3ML3 RHT3`h002ovPDHLkV1n|SZ215H diff --git a/toolkit/themes/pinstripe/global/menu/menu-radio-hov.gif b/toolkit/themes/pinstripe/global/menu/menu-radio-hov.gif index 723473c1654730b21e26d980f7726d14ede25c16..9d7474c866d3fbe0f8c7059ef20c7c7773840560 100644 GIT binary patch literal 64 zcmZ?wbhEHb6krfw_`qQJ|Nnmm1_s5SEQ|~cj0`$JHc(uEfq_Z9rGI7jL;l5cw%qD| SdGKY~??yMbX=z~$4AuZYdlZ=f literal 62 zcmZ?wbhEHb6krfwXkcLY4+e@qSr{1@7#VaJfB+=Jz$Dt!zw-23e#sdHx6)UhUhs;e L?U9EOD}yxvYn~L_ diff --git a/toolkit/themes/pinstripe/global/menu/menu-radio.gif b/toolkit/themes/pinstripe/global/menu/menu-radio.gif index f3a0a48cfc5733c7ca136eb1c46622fe89ee69a3..d845a3059e418db0fff4bfb7e39994ab1fe492bc 100644 GIT binary patch literal 62 zcmZ?wbhEHb6krfw_`qQJ|Nnmm1_s5SEQ~;kK?g*DWEhx4Tl!a?e#^hOXW^kP`E7aa Nr+puJ$gwh50{{ob5^?|l literal 62 zcmZ?wbhEHb6krfwXkY+=|Ns9h{$ycfU|?j>0r5dH3{0Xu{VPwu<(HgMa4UV~=>@Mi M+8%iru`*Z#0NfuD-T(jq diff --git a/widget/public/nsILookAndFeel.h b/widget/public/nsILookAndFeel.h index 3f1a921f5ffb..762e6cb8048d 100644 --- a/widget/public/nsILookAndFeel.h +++ b/widget/public/nsILookAndFeel.h @@ -139,6 +139,7 @@ public: eColor__moz_mac_focusring, //ring around text fields and lists eColor__moz_mac_menuselect, //colour used when mouse is over a menu item eColor__moz_mac_menushadow, //colour used to do shadows on menu items + eColor__moz_mac_menutextdisable, // color used to display text for disabled menu items eColor__moz_mac_menutextselect, //colour used to display text while mouse is over a menu item //all of the accent colours diff --git a/widget/src/mac/nsLookAndFeel.cpp b/widget/src/mac/nsLookAndFeel.cpp index 2464f67ff9fc..1a3d18eceb71 100644 --- a/widget/src/mac/nsLookAndFeel.cpp +++ b/widget/src/mac/nsLookAndFeel.cpp @@ -323,6 +323,9 @@ nsresult nsLookAndFeel::NativeGetColor(const nsColorID aID, nscolor &aColor) case eColor__moz_mac_menushadow: res = GetMacBrushColor(kThemeBrushBevelActiveDark, aColor, NS_RGB(0x88,0x88,0x88)); break; + case eColor__moz_mac_menutextdisable: + res = GetMacTextColor(kThemeTextColorMenuItemDisabled, aColor, NS_RGB(0x99,0x99,0x99)); + break; case eColor__moz_mac_menutextselect: //default to white, which is what Platinum uses, if not available res = GetMacTextColor(kThemeTextColorMenuItemSelected, aColor, NS_RGB(0xFF,0xFF,0xFF)); @@ -539,6 +542,9 @@ NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric) // xul popups are not allowed to overlap the menubar. aMetric = 0; break; + case eMetric_SkipNavigatingDisabledMenuItem: + aMetric = 1; + break; case eMetric_DragFullWindow: aMetric = 1; break; diff --git a/widget/src/mac/nsMacWindow.cpp b/widget/src/mac/nsMacWindow.cpp index 9d0b6ee29e52..73ab17d48bc0 100644 --- a/widget/src/mac/nsMacWindow.cpp +++ b/widget/src/mac/nsMacWindow.cpp @@ -53,11 +53,27 @@ #include "nsCRT.h" #include "nsWidgetSupport.h" -#include +#include +#include -#include -#include -#include +#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3 +#define kWindowFadeTransitionEffect 4 +#define kEventWindowTransitionCompleted 89 + +typedef struct TransitionWindowOptions { + UInt32 version; + EventTime duration; + WindowRef window; + void* userData; +} TransitionWindowOptions; +#endif + +typedef OSStatus (*TransitionWindowWithOptions_type) (WindowRef, + WindowTransitionEffect, + WindowTransitionAction, + const HIRect*, + Boolean, + TransitionWindowOptions*); static const char sScreenManagerContractID[] = "@mozilla.org/gfx/screenmanager;1"; @@ -236,12 +252,6 @@ nsMacWindow::nsMacWindow() : Inherited() nsMacWindow::~nsMacWindow() { if ( mWindowPtr && mWindowMadeHere ) { - - // cleanup our special defproc if we are a popup - if ( mWindowType == eWindowType_popup ) - RemoveBorderlessDefProc ( mWindowPtr ); - - // clean up DragManager stuff if ( mDragTrackingHandlerUPP ) { ::RemoveTrackingHandler ( mDragTrackingHandlerUPP, mWindowPtr ); @@ -593,6 +603,8 @@ nsresult nsMacWindow::StandardCreate(nsIWidget *aParent, // to handle activation { kEventClassWindow, kEventWindowActivated }, { kEventClassWindow, kEventWindowDeactivated }, + // to clean up after a transition is complete + { kEventClassWindow, kEventWindowTransitionCompleted }, }; static EventHandlerUPP sWindowEventHandlerUPP; @@ -635,10 +647,14 @@ nsresult nsMacWindow::StandardCreate(nsIWidget *aParent, NS_ASSERTION ( err == noErr, "can't install drag receive handler"); } - // If we're a popup, we don't want a border (we want CSS to draw it for us). So - // install our own window defProc. - if ( mWindowType == eWindowType_popup ) - InstallBorderlessDefProc(mWindowPtr); + if (mWindowType == eWindowType_popup) { + // Popup windows are used for contextual menus, pop-up/drop-down menus, + // autocomplete dropdowns, and tooltips, all of which have a very slight + // transparency when native. Use 5%, which is almost imperceptible + // and matches what Tiger does. + const float kPopupWindowAlpha = 0.95; + ::SetWindowAlpha(mWindowPtr, kPopupWindowAlpha); + } } // if we created windowPtr @@ -764,6 +780,12 @@ nsMacWindow::WindowEventHandler ( EventHandlerCallRef inHandlerChain, EventRef i } break; + case kEventWindowTransitionCompleted: { + self->mDeathGripDuringTransition = nsnull; + retVal = noErr; + break; + } + } // case of which event? } @@ -792,31 +814,6 @@ NS_IMETHODIMP nsMacWindow::Create(nsNativeWidget aNativeParent, // this is a w } -// -// InstallBorderlessDefProc -// -// For xul popups, we want borderless windows to match win32's borderless windows. Stash -// our fake WDEF into this window which takes care of not-drawing the borders. -// -void -nsMacWindow::InstallBorderlessDefProc ( WindowPtr inWindow ) -{ -} // InstallBorderlessDefProc - - -// -// RemoveBorderlessDefProc -// -// Clean up the mess we've made with our fake defproc. Reset it to -// the system one, just in case someone needs it around after we're -// through with it. -// -void -nsMacWindow::RemoveBorderlessDefProc ( WindowPtr inWindow ) -{ -} - - //------------------------------------------------------------------------- // // Hide or show this window @@ -973,8 +970,43 @@ NS_IMETHODIMP nsMacWindow::Show(PRBool aState) } } else { - if (mWindowPtr) - ::HideWindow(mWindowPtr); + if (mWindowPtr) { + static TransitionWindowWithOptions_type transitionFunc; + if (mWindowType == eWindowType_popup) { + // Popups will hide by fading out with TransitionWindowWithOptions, + // if available. It's present in 10.3 and later. If that SDK or + // newer is used, just grab the address of the function, otherwise, + // dynamically look it up at runtime. Fall back to calling + // HideWindow if TransitionWindowWithOptions isn't available. + static PRBool sChecked; + if (!sChecked) { + sChecked = PR_TRUE; +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3 + transitionFunc = ::TransitionWindowWithOptions; +#else + CFBundleRef carbonBundle = + ::CFBundleGetBundleWithIdentifier(CFSTR("com.apple.Carbon")); + if (carbonBundle) { + transitionFunc = (TransitionWindowWithOptions_type) + ::CFBundleGetFunctionPointerForName(carbonBundle, + CFSTR("TransitionWindowWithOptions")); + } +#endif + } + } + if (mWindowType == eWindowType_popup && transitionFunc) { + mDeathGripDuringTransition = this; + TransitionWindowOptions transitionOptions = { version : 0, + duration : 0.2, + window : nsnull, + userData : nsnull }; + transitionFunc(mWindowPtr, kWindowFadeTransitionEffect, + kWindowHideTransitionAction, nsnull, + PR_TRUE, &transitionOptions); + } + else + ::HideWindow(mWindowPtr); + } mShown = PR_FALSE; } } diff --git a/widget/src/mac/nsMacWindow.h b/widget/src/mac/nsMacWindow.h index 780b44d771c3..4627d482c348 100644 --- a/widget/src/mac/nsMacWindow.h +++ b/widget/src/mac/nsMacWindow.h @@ -136,9 +136,6 @@ public: protected: - void InstallBorderlessDefProc ( WindowPtr inWindow ) ; - void RemoveBorderlessDefProc ( WindowPtr inWindow ) ; - pascal static OSErr DragTrackingHandler ( DragTrackingMessage theMessage, WindowPtr theWindow, void *handlerRefCon, DragReference theDrag ); pascal static OSErr DragReceiveHandler (WindowPtr theWindow, @@ -168,6 +165,7 @@ protected: Point mBoundsOffset; // offset from window structure to content auto_ptr mMacEventHandler; nsIWidget *mOffsetParent; + nsCOMPtr mDeathGripDuringTransition; #if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3 PRPackedBool mNeedsResize; diff --git a/widget/src/xpwidgets/nsXPLookAndFeel.cpp b/widget/src/xpwidgets/nsXPLookAndFeel.cpp index 6372681f7aef..46840379dd5a 100644 --- a/widget/src/xpwidgets/nsXPLookAndFeel.cpp +++ b/widget/src/xpwidgets/nsXPLookAndFeel.cpp @@ -202,6 +202,7 @@ const char nsXPLookAndFeel::sColorPrefs[][38] = "ui.-moz-mac-focusring", "ui.-moz-mac-menuselect", "ui.-moz-mac-menushadow", + "ui.-moz-mac-menutextdisable", "ui.-moz-mac-menutextselect", "ui.-moz-mac-accentlightesthighlight", "ui.-moz-mac-accentregularhighlight",