зеркало из https://github.com/mozilla/pjs.git
Bug 456430 - Fix compiler warnings in widget/src/cocoa/ introduced by bug 439354, r=josh sr=roc
This commit is contained in:
Родитель
f781370a4f
Коммит
d71fce24e4
|
@ -47,7 +47,6 @@
|
|||
#include "nsBaseWidget.h"
|
||||
#include "nsPIWidgetCocoa.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsNativeThemeColors.h"
|
||||
|
||||
class nsCocoaWindow;
|
||||
class nsChildView;
|
||||
|
@ -126,25 +125,6 @@ struct UnifiedGradientInfo {
|
|||
BOOL drawTitlebar; // NO for toolbar, YES for titlebar
|
||||
};
|
||||
|
||||
// Callback used by the default titlebar and toolbar shading.
|
||||
// *aIn == 0 at the top of the titlebar/toolbar, *aIn == 1 at the bottom
|
||||
static void unifiedShading(void* aInfo, const float* aIn, float* aOut)
|
||||
{
|
||||
UnifiedGradientInfo* info = (UnifiedGradientInfo*)aInfo;
|
||||
// The gradient percentage at the bottom of the titlebar / top of the toolbar
|
||||
float start = info->titlebarHeight / (info->titlebarHeight + info->toolbarHeight - 1);
|
||||
const float startGrey = NativeGreyColorAsFloat(headerStartGrey, info->windowIsMain);
|
||||
const float endGrey = NativeGreyColorAsFloat(headerEndGrey, info->windowIsMain);
|
||||
// *aIn is the gradient percentage of the titlebar or toolbar gradient,
|
||||
// a is the gradient percentage of the whole unified gradient.
|
||||
float a = info->drawTitlebar ? *aIn * start : start + *aIn * (1 - start);
|
||||
float result = (1.0f - a) * startGrey + a * endGrey;
|
||||
aOut[0] = result;
|
||||
aOut[1] = result;
|
||||
aOut[2] = result;
|
||||
aOut[3] = 1.0f;
|
||||
}
|
||||
|
||||
// NSColor subclass that allows us to draw separate colors both in the titlebar
|
||||
// and for background of the window.
|
||||
@interface TitlebarAndBackgroundColor : NSColor
|
||||
|
@ -303,6 +283,8 @@ public:
|
|||
NS_IMETHOD BeginSecureKeyboardInput();
|
||||
NS_IMETHOD EndSecureKeyboardInput();
|
||||
|
||||
static void UnifiedShading(void* aInfo, const float* aIn, float* aOut);
|
||||
|
||||
protected:
|
||||
|
||||
nsIWidget* mParent; // if we're a popup, this is our parent [WEAK]
|
||||
|
|
|
@ -66,6 +66,7 @@
|
|||
#include "nsMenuBarX.h"
|
||||
#include "nsMenuUtilsX.h"
|
||||
#include "nsStyleConsts.h"
|
||||
#include "nsNativeThemeColors.h"
|
||||
|
||||
#include "gfxPlatform.h"
|
||||
#include "lcms.h"
|
||||
|
@ -1407,6 +1408,27 @@ NS_IMETHODIMP nsCocoaWindow::EndSecureKeyboardInput()
|
|||
}
|
||||
|
||||
|
||||
// Callback used by the default titlebar and toolbar shading.
|
||||
// *aIn == 0 at the top of the titlebar/toolbar, *aIn == 1 at the bottom
|
||||
/* static */ void
|
||||
nsCocoaWindow::UnifiedShading(void* aInfo, const float* aIn, float* aOut)
|
||||
{
|
||||
UnifiedGradientInfo* info = (UnifiedGradientInfo*)aInfo;
|
||||
// The gradient percentage at the bottom of the titlebar / top of the toolbar
|
||||
float start = info->titlebarHeight / (info->titlebarHeight + info->toolbarHeight - 1);
|
||||
const float startGrey = NativeGreyColorAsFloat(headerStartGrey, info->windowIsMain);
|
||||
const float endGrey = NativeGreyColorAsFloat(headerEndGrey, info->windowIsMain);
|
||||
// *aIn is the gradient percentage of the titlebar or toolbar gradient,
|
||||
// a is the gradient percentage of the whole unified gradient.
|
||||
float a = info->drawTitlebar ? *aIn * start : start + *aIn * (1 - start);
|
||||
float result = (1.0f - a) * startGrey + a * endGrey;
|
||||
aOut[0] = result;
|
||||
aOut[1] = result;
|
||||
aOut[2] = result;
|
||||
aOut[3] = 1.0f;
|
||||
}
|
||||
|
||||
|
||||
@implementation WindowDelegate
|
||||
|
||||
|
||||
|
@ -1983,8 +2005,8 @@ void patternDraw(void* aInfo, CGContextRef aContext)
|
|||
|
||||
// If the titlebar color is nil, draw the default titlebar shading.
|
||||
if (!titlebarColor) {
|
||||
// Create and draw a CGShading that uses unifiedShading() as its callback.
|
||||
CGFunctionCallbacks callbacks = {0, unifiedShading, NULL};
|
||||
// Create and draw a CGShading that uses nsCocoaWindow::UnifiedShading() as its callback.
|
||||
CGFunctionCallbacks callbacks = {0, nsCocoaWindow::UnifiedShading, NULL};
|
||||
CGFunctionRef function = CGFunctionCreate(&info, 1, NULL, 4, NULL, &callbacks);
|
||||
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
|
||||
CGShadingRef shading = CGShadingCreateAxial(colorSpace,
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
#include "nsWidgetAtoms.h"
|
||||
#include "nsToolkit.h"
|
||||
#include "nsCocoaWindow.h"
|
||||
#include "nsNativeThemeColors.h"
|
||||
|
||||
#include "gfxContext.h"
|
||||
#include "gfxQuartzSurface.h"
|
||||
|
@ -1189,7 +1190,7 @@ nsNativeThemeCocoa::DrawUnifiedToolbar(CGContextRef cgContext, const HIRect& inB
|
|||
|
||||
// Draw the gradient
|
||||
UnifiedGradientInfo info = { titlebarHeight, inBoxRect.size.height, isMain, NO };
|
||||
struct CGFunctionCallbacks callbacks = { 0, unifiedShading, NULL };
|
||||
struct CGFunctionCallbacks callbacks = { 0, nsCocoaWindow::UnifiedShading, NULL };
|
||||
CGFunctionRef function = CGFunctionCreate(&info, 1, NULL, 4, NULL, &callbacks);
|
||||
float srcY = inBoxRect.origin.y;
|
||||
float dstY = srcY + inBoxRect.size.height - 1;
|
||||
|
|
Загрузка…
Ссылка в новой задаче