344570 Make contextual menus look more native on the Mac. r=josh sr=bryner
@ -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)
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Before Width: | Height: | Size: 56 B After Width: | Height: | Size: 58 B |
Before Width: | Height: | Size: 854 B After Width: | Height: | Size: 168 B |
Before Width: | Height: | Size: 847 B After Width: | Height: | Size: 112 B |
Before Width: | Height: | Size: 124 B After Width: | Height: | Size: 124 B |
Before Width: | Height: | Size: 369 B After Width: | Height: | Size: 220 B |
Before Width: | Height: | Size: 124 B After Width: | Height: | Size: 128 B |
Before Width: | Height: | Size: 299 B After Width: | Height: | Size: 194 B |
Before Width: | Height: | Size: 124 B After Width: | Height: | Size: 124 B |
Before Width: | Height: | Size: 346 B After Width: | Height: | Size: 220 B |
Before Width: | Height: | Size: 62 B After Width: | Height: | Size: 64 B |
Before Width: | Height: | Size: 62 B After Width: | Height: | Size: 62 B |
@ -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
|
||||
|
@ -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;
|
||||
|
@ -53,11 +53,27 @@
|
||||
#include "nsCRT.h"
|
||||
#include "nsWidgetSupport.h"
|
||||
|
||||
#include <CFString.h>
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
#include <Gestalt.h>
|
||||
#include <Quickdraw.h>
|
||||
#include <MacWindows.h>
|
||||
#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;
|
||||
}
|
||||
}
|
||||
|
@ -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<nsMacEventHandler> mMacEventHandler;
|
||||
nsIWidget *mOffsetParent;
|
||||
nsCOMPtr<nsIWidget> mDeathGripDuringTransition;
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_3
|
||||
PRPackedBool mNeedsResize;
|
||||
|
@ -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",
|
||||
|