Bug 527682 - Implement -moz-window-shadow values menu, tooltip and sheet. r=dbaron, r=dao, r=josh

This commit is contained in:
Markus Stange 2009-12-30 16:24:08 +01:00
Родитель b85836364a
Коммит ae3e46e759
7 изменённых файлов: 68 добавлений и 11 удалений

Просмотреть файл

@ -1813,14 +1813,8 @@ tabpanels.plain {
background-color: Highlight;
}
#CustomizeToolbarSheet > #main-box {
border-top: none !important;
border-left: 2px solid;
border-right: 2px solid;
border-bottom: 3px solid;
-moz-border-right-colors: -moz-mac-menushadow ThreeDLightShadow !important;
-moz-border-bottom-colors: -moz-mac-menushadow -moz-mac-menushadow ThreeDShadow !important;
-moz-border-left-colors: ThreeDLightShadow ThreeDHighlight !important;
#customizeToolbarSheetPopup {
-moz-window-shadow: sheet;
}
/* ::::: Identity Indicator Styling ::::: */

Просмотреть файл

@ -552,6 +552,7 @@ CSS_KEY(scrollbartrack-horizontal, scrollbartrack_horizontal)
CSS_KEY(scrollbartrack-vertical, scrollbartrack_vertical)
CSS_KEY(scrollbarthumb-horizontal, scrollbarthumb_horizontal)
CSS_KEY(scrollbarthumb-vertical, scrollbarthumb_vertical)
CSS_KEY(sheet, sheet)
CSS_KEY(textfield, textfield)
CSS_KEY(textfield-multiline, textfield_multiline)
CSS_KEY(caret, caret)

Просмотреть файл

@ -1292,6 +1292,9 @@ const PRInt32 nsCSSProps::kWidthKTable[] = {
const PRInt32 nsCSSProps::kWindowShadowKTable[] = {
eCSSKeyword_none, NS_STYLE_WINDOW_SHADOW_NONE,
eCSSKeyword_default, NS_STYLE_WINDOW_SHADOW_DEFAULT,
eCSSKeyword_menu, NS_STYLE_WINDOW_SHADOW_MENU,
eCSSKeyword_tooltip, NS_STYLE_WINDOW_SHADOW_TOOLTIP,
eCSSKeyword_sheet, NS_STYLE_WINDOW_SHADOW_SHEET,
eCSSKeyword_UNKNOWN,-1
};

Просмотреть файл

@ -613,7 +613,7 @@ var gCSSProperties = {
inherited: false,
type: CSS_TYPE_LONGHAND,
initial_values: [ "default" ],
other_values: [ "none" ],
other_values: [ "none", "menu", "tooltip", "sheet" ],
invalid_values: []
},
"azimuth": {

Просмотреть файл

@ -112,6 +112,9 @@ typedef nsEventStatus (* EVENT_CALLBACK)(nsGUIEvent *event);
#define NS_STYLE_WINDOW_SHADOW_NONE 0
#define NS_STYLE_WINDOW_SHADOW_DEFAULT 1
#define NS_STYLE_WINDOW_SHADOW_MENU 2
#define NS_STYLE_WINDOW_SHADOW_TOOLTIP 3
#define NS_STYLE_WINDOW_SHADOW_SHEET 4
/**
* Cursor types.

Просмотреть файл

@ -295,6 +295,7 @@ protected:
nsIAppShell *aAppShell,
nsIToolkit *aToolkit);
void DestroyNativeWindow();
void AdjustWindowShadow();
nsIWidget* mParent; // if we're a popup, this is our parent [WEAK]
BaseWindow* mWindow; // our cocoa window [STRONG]
@ -302,6 +303,7 @@ protected:
nsRefPtr<nsMenuBarX> mMenuBar;
NSWindow* mSheetWindowParent; // if this is a sheet, this is the NSWindow it's attached to
nsChildView* mPopupContentView; // if this is a popup, this is its content widget
PRInt32 mShadowStyle;
PRPackedBool mIsResizing; // we originated the resize, prevent infinite recursion
PRPackedBool mWindowMadeHere; // true if we created the window, false for embedding

Просмотреть файл

@ -92,6 +92,14 @@ extern nsIRollupListener * gRollupListener;
extern nsIWidget * gRollupWidget;
extern BOOL gSomeMenuBarPainted;
extern "C" {
// CGSPrivate.h
typedef NSInteger CGSConnection;
typedef NSInteger CGSWindow;
extern CGSConnection _CGSDefaultConnection(void);
extern CGError CGSSetWindowShadowAndRimParameters(const CGSConnection cid, CGSWindow wid, float standardDeviation, float density, int offsetX, int offsetY, unsigned int flags);
}
#define NS_APPSHELLSERVICE_CONTRACTID "@mozilla.org/appshell/appShellService;1"
NS_IMPL_ISUPPORTS_INHERITED1(nsCocoaWindow, Inherited, nsPIWidgetCocoa)
@ -114,6 +122,7 @@ nsCocoaWindow::nsCocoaWindow()
, mDelegate(nil)
, mSheetWindowParent(nil)
, mPopupContentView(nil)
, mShadowStyle(NS_STYLE_WINDOW_SHADOW_DEFAULT)
, mIsResizing(PR_FALSE)
, mWindowMadeHere(PR_FALSE)
, mSheetNeedsShow(PR_FALSE)
@ -647,6 +656,7 @@ NS_IMETHODIMP nsCocoaWindow::Show(PRBool bState)
[mWindow orderFront:nil];
NS_OBJC_END_TRY_LOGONLY_BLOCK;
SendSetZLevelEvent();
AdjustWindowShadow();
// If our popup window is a non-native context menu, tell the OS (and
// other programs) that a menu has opened. This is how the OS knows to
// close other programs' context menus when ours open.
@ -785,6 +795,48 @@ NS_IMETHODIMP nsCocoaWindow::Show(PRBool bState)
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
}
struct ShadowParams {
float standardDeviation;
float density;
int offsetX;
int offsetY;
unsigned int flags;
};
// These numbers have been determined by looking at the results of
// CGSGetWindowShadowAndRimParameters for native window types.
static const ShadowParams kWindowShadowParameters[] = {
{ 0.0f, 0.0f, 0, 0, 0 }, // none
{ 8.0f, 0.5f, 0, 6, 1 }, // default
{ 10.0f, 0.44f, 0, 10, 512 }, // menu
{ 8.0f, 0.5f, 0, 6, 1 }, // tooltip
{ 4.0f, 0.6f, 0, 4, 512 } // sheet
};
// This method will adjust the window shadow style for popup windows after
// they have been made visible. Before they're visible, their window number
// might be -1, which is not useful.
// We won't attempt to change the shadow for windows that can acquire key state
// since OS X will reset the shadow whenever that happens.
void
nsCocoaWindow::AdjustWindowShadow()
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
if (![mWindow isVisible] || ![mWindow hasShadow] ||
[mWindow canBecomeKeyWindow] || [mWindow windowNumber] == -1)
return;
const ShadowParams& params = kWindowShadowParameters[mShadowStyle];
CGSConnection cid = _CGSDefaultConnection();
CGSSetWindowShadowAndRimParameters(cid, [mWindow windowNumber],
params.standardDeviation, params.density,
params.offsetX, params.offsetY,
params.flags);
NS_OBJC_END_TRY_ABORT_BLOCK;
}
nsresult
nsCocoaWindow::ConfigureChildren(const nsTArray<Configuration>& aConfigurations)
{
@ -1353,8 +1405,10 @@ NS_IMETHODIMP nsCocoaWindow::SetWindowShadowStyle(PRInt32 aStyle)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
if ([mWindow hasShadow] != (aStyle != NS_STYLE_WINDOW_SHADOW_NONE))
[mWindow setHasShadow:(aStyle != NS_STYLE_WINDOW_SHADOW_NONE)];
mShadowStyle = aStyle;
[mWindow setHasShadow:(aStyle != NS_STYLE_WINDOW_SHADOW_NONE)];
AdjustWindowShadow();
return NS_OK;
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;