From c23983c0e30ece4fd74ba1f3aa1e387a492becc2 Mon Sep 17 00:00:00 2001 From: Markus Stange Date: Wed, 30 Dec 2009 16:23:51 +0100 Subject: [PATCH] Bug 534170 - Remove uses of -moz-mac-unified-toolbar and instead make all toolbars at the top of the window unified. r=dao, r=josh --- .../themes/pinstripe/global/preferences.css | 2 +- toolkit/themes/pinstripe/global/toolbar.css | 6 ---- .../themes/pinstripe/global/viewbuttons.css | 2 +- widget/src/cocoa/nsNativeThemeCocoa.h | 2 +- widget/src/cocoa/nsNativeThemeCocoa.mm | 31 +++++++++++++------ 5 files changed, 24 insertions(+), 19 deletions(-) diff --git a/toolkit/themes/pinstripe/global/preferences.css b/toolkit/themes/pinstripe/global/preferences.css index c16bf08a6c4..63df346abbf 100644 --- a/toolkit/themes/pinstripe/global/preferences.css +++ b/toolkit/themes/pinstripe/global/preferences.css @@ -64,7 +64,7 @@ prefwindow[type="child"] > prefpane { .paneSelector { font: message-box; padding: 1px 4px; - -moz-appearance: -moz-mac-unified-toolbar; + -moz-appearance: toolbar; margin: 0; } diff --git a/toolkit/themes/pinstripe/global/toolbar.css b/toolkit/themes/pinstripe/global/toolbar.css index dd0c0233956..15e1a075033 100644 --- a/toolkit/themes/pinstripe/global/toolbar.css +++ b/toolkit/themes/pinstripe/global/toolbar.css @@ -80,12 +80,6 @@ toolbarseparator { min-height: 24px; } -.toolbar-primary, -window > toolbox:nth-of-type(1) > toolbar:nth-of-type(1) { - -moz-appearance: -moz-mac-unified-toolbar; -} - - /* ::::: toolbarpaletteitem ::::: */ toolbarpaletteitem { diff --git a/toolkit/themes/pinstripe/global/viewbuttons.css b/toolkit/themes/pinstripe/global/viewbuttons.css index e88d4064c21..ee370da1ec5 100644 --- a/toolkit/themes/pinstripe/global/viewbuttons.css +++ b/toolkit/themes/pinstripe/global/viewbuttons.css @@ -37,7 +37,7 @@ %include shared.inc #topBar { - -moz-appearance: -moz-mac-unified-toolbar; + -moz-appearance: toolbar; } .viewGroupWrapper { diff --git a/widget/src/cocoa/nsNativeThemeCocoa.h b/widget/src/cocoa/nsNativeThemeCocoa.h index f14e145aadd..10902f12bc9 100644 --- a/widget/src/cocoa/nsNativeThemeCocoa.h +++ b/widget/src/cocoa/nsNativeThemeCocoa.h @@ -132,7 +132,7 @@ protected: ThemeButtonAdornment inAdornment, PRInt32 inState, nsIFrame* aFrame); void DrawUnifiedToolbar(CGContextRef cgContext, const HIRect& inBoxRect, - nsIFrame *aFrame); + NSWindow* aWindow); void DrawStatusBar(CGContextRef cgContext, const HIRect& inBoxRect, nsIFrame *aFrame); void DrawResizer(CGContextRef cgContext, const HIRect& aRect, nsIFrame *aFrame); diff --git a/widget/src/cocoa/nsNativeThemeCocoa.mm b/widget/src/cocoa/nsNativeThemeCocoa.mm index ee8401aa63f..b0a58611f84 100644 --- a/widget/src/cocoa/nsNativeThemeCocoa.mm +++ b/widget/src/cocoa/nsNativeThemeCocoa.mm @@ -1385,26 +1385,32 @@ static BOOL DrawingAtWindowTop(CGContextRef cgContext, float viewHeight, float y return ctm.ty - yPos >= viewHeight; } +static BOOL +ToolbarCanBeUnified(CGContextRef cgContext, const HIRect& inBoxRect, NSWindow* aWindow) +{ + return [aWindow isKindOfClass:[ToolbarWindow class]] && + ![(ToolbarWindow*)aWindow drawsContentsIntoWindowFrame] && + DrawingAtWindowTop(cgContext, [[aWindow contentView] bounds].size.height, + inBoxRect.origin.y); +} + void nsNativeThemeCocoa::DrawUnifiedToolbar(CGContextRef cgContext, const HIRect& inBoxRect, - nsIFrame *aFrame) + NSWindow* aWindow) { NS_OBJC_BEGIN_TRY_ABORT_BLOCK; float titlebarHeight = 0; - NSWindow* win = NativeWindowForFrame(aFrame); - if ([win isKindOfClass:[ToolbarWindow class]] && - ![(ToolbarWindow*)win drawsContentsIntoWindowFrame] && - DrawingAtWindowTop(cgContext, [[win contentView] bounds].size.height, inBoxRect.origin.y)) { + if (ToolbarCanBeUnified(cgContext, inBoxRect, aWindow)) { // Consider the titlebar height when calculating the gradient. - titlebarHeight = [(ToolbarWindow*)win titlebarHeight]; + titlebarHeight = [(ToolbarWindow*)aWindow titlebarHeight]; // Notify the window about the toolbar's height so that it can draw the // correct gradient in the titlebar. - [(ToolbarWindow*)win setUnifiedToolbarHeight:inBoxRect.size.height]; + [(ToolbarWindow*)aWindow setUnifiedToolbarHeight:inBoxRect.size.height]; } - BOOL isMain = [win isMainWindow] || ![NSView focusView]; + BOOL isMain = [aWindow isMainWindow] || ![NSView focusView]; // Draw the gradient UnifiedGradientInfo info = { titlebarHeight, inBoxRect.size.height, isMain, NO }; @@ -1707,11 +1713,16 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsIRenderingContext* aContext, nsIFrame break; case NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR: - DrawUnifiedToolbar(cgContext, macRect, aFrame); + DrawUnifiedToolbar(cgContext, macRect, NativeWindowForFrame(aFrame)); break; case NS_THEME_TOOLBAR: { - BOOL isMain = [NativeWindowForFrame(aFrame) isMainWindow] || ![NSView focusView]; + NSWindow* win = NativeWindowForFrame(aFrame); + if (ToolbarCanBeUnified(cgContext, macRect, win)) { + DrawUnifiedToolbar(cgContext, macRect, win); + break; + } + BOOL isMain = [win isMainWindow] || ![NSView focusView]; CGRect drawRect = macRect; // top border