Backed out 2 changesets (bug 871590) CLOSED TREE

This commit is contained in:
Markus Stange 2013-05-22 14:10:46 +02:00
Родитель cc576286a2
Коммит 78a27ca962
8 изменённых файлов: 45 добавлений и 118 удалений

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

@ -1567,8 +1567,7 @@ nsDisplayBackgroundImage::nsDisplayBackgroundImage(nsDisplayListBuilder* aBuilde
mFrame->IsThemed(disp, &mThemeTransparency);
// Perform necessary RegisterThemeGeometry
if (disp->mAppearance == NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR ||
disp->mAppearance == NS_THEME_TOOLBAR ||
disp->mAppearance == NS_THEME_WINDOW_TITLEBAR) {
disp->mAppearance == NS_THEME_TOOLBAR) {
RegisterThemeGeometry(aBuilder, aFrame);
} else if (disp->mAppearance == NS_THEME_WIN_BORDERLESS_GLASS ||
disp->mAppearance == NS_THEME_WIN_GLASS) {

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

@ -454,11 +454,11 @@ public:
* Notifies the builder that a particular themed widget exists
* at the given rectangle within the currently built display list.
* For certain appearance values (currently only
* NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR, NS_THEME_TOOLBAR and
* NS_THEME_WINDOW_TITLEBAR) this gets called during every display list
* construction, for every themed widget of the right type within the
* display list, except for themed widgets which are transformed or have
* effects applied to them (e.g. CSS opacity or filters).
* NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR and NS_THEME_TOOLBAR) this gets
* called during every display list construction, for every themed widget of
* the right type within the display list, except for themed widgets which
* are transformed or have effects applied to them (e.g. CSS opacity or
* filters).
*
* @param aWidgetType the -moz-appearance value for the themed widget
* @param aRect the device-pixel rect relative to the widget's displayRoot

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

@ -553,9 +553,6 @@ public:
}
// unit conversion convenience functions
int32_t CocoaPointsToDevPixels(CGFloat aPts) {
return nsCocoaUtils::CocoaPointsToDevPixels(aPts, BackingScaleFactor());
}
nsIntPoint CocoaPointsToDevPixels(const NSPoint& aPt) {
return nsCocoaUtils::CocoaPointsToDevPixels(aPt, BackingScaleFactor());
}

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

@ -2072,58 +2072,26 @@ nsChildView::MaybeDrawRoundedBottomCorners(GLManager* aManager, nsIntRect aRect)
LOCAL_GL_ONE, LOCAL_GL_ONE);
}
static int32_t
FindTitlebarBottom(const nsTArray<nsIWidget::ThemeGeometry>& aThemeGeometries,
int32_t aWindowWidth)
{
int32_t titlebarBottom = 0;
for (uint32_t i = 0; i < aThemeGeometries.Length(); ++i) {
const nsIWidget::ThemeGeometry& g = aThemeGeometries[i];
if ((g.mWidgetType == NS_THEME_WINDOW_TITLEBAR) &&
g.mRect.X() <= 0 &&
g.mRect.XMost() >= aWindowWidth &&
g.mRect.Y() <= 0) {
titlebarBottom = std::max(titlebarBottom, g.mRect.YMost());
}
}
return titlebarBottom;
}
static int32_t
FindUnifiedToolbarBottom(const nsTArray<nsIWidget::ThemeGeometry>& aThemeGeometries,
int32_t aWindowWidth, int32_t aTitlebarBottom)
{
int32_t unifiedToolbarBottom = aTitlebarBottom;
for (uint32_t i = 0; i < aThemeGeometries.Length(); ++i) {
const nsIWidget::ThemeGeometry& g = aThemeGeometries[i];
if ((g.mWidgetType == NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR ||
g.mWidgetType == NS_THEME_TOOLBAR) &&
g.mRect.X() <= 0 &&
g.mRect.XMost() >= aWindowWidth &&
g.mRect.Y() <= aTitlebarBottom) {
unifiedToolbarBottom = std::max(unifiedToolbarBottom, g.mRect.YMost());
}
}
return unifiedToolbarBottom;
}
void
nsChildView::UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries)
{
if (![mView window] || ![[mView window] isKindOfClass:[ToolbarWindow class]])
NSWindow* win = [mView window];
if (!win || ![win isKindOfClass:[ToolbarWindow class]])
return;
int32_t windowWidth = mBounds.width;
int32_t titlebarBottom = FindTitlebarBottom(aThemeGeometries, windowWidth);
int32_t unifiedToolbarBottom =
FindUnifiedToolbarBottom(aThemeGeometries, windowWidth, titlebarBottom);
float unifiedToolbarHeight = 0;
nsIntRect topPixelStrip(0, 0, [win frame].size.width, 1);
ToolbarWindow* win = (ToolbarWindow*)[mView window];
bool drawsContentsIntoWindowFrame = [win drawsContentsIntoWindowFrame];
int32_t titlebarHeight = CocoaPointsToDevPixels([win titlebarHeight]);
int32_t contentOffset = drawsContentsIntoWindowFrame ? titlebarHeight : 0;
int32_t devUnifiedHeight = titlebarHeight + unifiedToolbarBottom - contentOffset;
[win setUnifiedToolbarHeight:DevPixelsToCocoaPoints(devUnifiedHeight)];
for (uint32_t i = 0; i < aThemeGeometries.Length(); ++i) {
const ThemeGeometry& g = aThemeGeometries[i];
if ((g.mWidgetType == NS_THEME_MOZ_MAC_UNIFIED_TOOLBAR ||
g.mWidgetType == NS_THEME_TOOLBAR) &&
g.mRect.Contains(topPixelStrip)) {
unifiedToolbarHeight = g.mRect.YMost();
}
}
[(ToolbarWindow*)win
setUnifiedToolbarHeight:DevPixelsToCocoaPoints(unifiedToolbarHeight)];
}
NS_IMETHODIMP

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

@ -179,15 +179,15 @@ typedef struct _nsCocoaWindowList {
@interface ToolbarWindow : BaseWindow
{
TitlebarAndBackgroundColor *mColor;
CGFloat mUnifiedToolbarHeight;
float mUnifiedToolbarHeight;
NSColor *mBackgroundColor;
NSView *mTitlebarView; // strong
}
// Pass nil here to get the default appearance.
- (void)setTitlebarColor:(NSColor*)aColor forActiveWindow:(BOOL)aActive;
- (void)setUnifiedToolbarHeight:(CGFloat)aHeight;
- (CGFloat)unifiedToolbarHeight;
- (CGFloat)titlebarHeight;
- (void)setUnifiedToolbarHeight:(float)aHeight;
- (float)unifiedToolbarHeight;
- (float)titlebarHeight;
- (NSRect)titlebarRect;
- (void)setTitlebarNeedsDisplayInRect:(NSRect)aRect sync:(BOOL)aSync;
- (void)setTitlebarNeedsDisplayInRect:(NSRect)aRect;

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

@ -2870,7 +2870,7 @@ static const NSString* kStateShowsToolbarButton = @"showsToolbarButton";
[super setBackgroundColor:mColor];
mBackgroundColor = [[NSColor whiteColor] retain];
mUnifiedToolbarHeight = 22.0f;
mUnifiedToolbarHeight = 0.0f;
// setBottomCornerRounded: is a private API call, so we check to make sure
// we respond to it just in case.
@ -2946,28 +2946,26 @@ static const NSString* kStateShowsToolbarButton = @"showsToolbarButton";
[self frame].size.width, [self titlebarHeight]);
}
// Returns the unified height of titlebar + toolbar.
- (CGFloat)unifiedToolbarHeight
- (float)unifiedToolbarHeight
{
return mUnifiedToolbarHeight;
}
- (CGFloat)titlebarHeight
- (float)titlebarHeight
{
NSRect frameRect = [self frame];
return frameRect.size.height - [self contentRectForFrameRect:frameRect].size.height;
}
// Stores the complete height of titlebar + toolbar.
- (void)setUnifiedToolbarHeight:(CGFloat)aHeight
- (void)setUnifiedToolbarHeight:(float)aHeight
{
if (aHeight == mUnifiedToolbarHeight)
if ([self drawsContentsIntoWindowFrame] || aHeight == mUnifiedToolbarHeight)
return;
mUnifiedToolbarHeight = aHeight;
// Update sheet positioning hint.
[self setContentBorderThickness:mUnifiedToolbarHeight - [self titlebarHeight] forEdge:NSMaxYEdge];
[self setContentBorderThickness:mUnifiedToolbarHeight forEdge:NSMaxYEdge];
// Redraw the title bar. If we're inside painting, we'll do it right now,
// otherwise we'll just invalidate it.
@ -3154,18 +3152,18 @@ static const NSString* kStateShowsToolbarButton = @"showsToolbarButton";
static void
DrawNativeTitlebar(CGContextRef aContext, CGRect aTitlebarRect,
CGFloat aUnifiedToolbarHeight, BOOL aIsMain)
float aToolbarHeight, BOOL aIsMain)
{
if (aTitlebarRect.size.width * aTitlebarRect.size.height > CUIDRAW_MAX_AREA) {
return;
}
int unifiedHeight = aTitlebarRect.size.height + aToolbarHeight;
CUIDraw([NSWindow coreUIRenderer], aTitlebarRect, aContext,
(CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:
@"kCUIWidgetWindowFrame", @"widget",
@"regularwin", @"windowtype",
(aIsMain ? @"normal" : @"inactive"), @"state",
[NSNumber numberWithDouble:aUnifiedToolbarHeight], @"kCUIWindowFrameUnifiedTitleBarHeightKey",
[NSNumber numberWithInt:unifiedHeight], @"kCUIWindowFrameUnifiedTitleBarHeightKey",
[NSNumber numberWithBool:YES], @"kCUIWindowFrameDrawTitleSeparatorKey",
nil],
nil);

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

@ -108,8 +108,6 @@ protected:
NSWindow* aWindow);
void DrawStatusBar(CGContextRef cgContext, const HIRect& inBoxRect,
nsIFrame *aFrame);
void DrawNativeTitlebar(CGContextRef aContext, CGRect aTitlebarRect,
CGFloat aUnifiedHeight, BOOL aIsMain);
void DrawResizer(CGContextRef cgContext, const HIRect& aRect, nsIFrame *aFrame);
// Scrollbars

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

@ -1782,7 +1782,7 @@ nsNativeThemeCocoa::GetParentScrollbarFrame(nsIFrame *aFrame)
do {
if (scrollbarFrame->GetType() == nsGkAtoms::scrollbarFrame) break;
} while ((scrollbarFrame = scrollbarFrame->GetParent()));
// We return null if we can't find a parent scrollbar frame
return scrollbarFrame;
}
@ -1790,14 +1790,17 @@ nsNativeThemeCocoa::GetParentScrollbarFrame(nsIFrame *aFrame)
static bool
ToolbarCanBeUnified(CGContextRef cgContext, const HIRect& inBoxRect, NSWindow* aWindow)
{
if (![aWindow isKindOfClass:[ToolbarWindow class]])
if (![aWindow isKindOfClass:[ToolbarWindow class]] ||
[(ToolbarWindow*)aWindow drawsContentsIntoWindowFrame])
return false;
ToolbarWindow* win = (ToolbarWindow*)aWindow;
float unifiedToolbarHeight = [win unifiedToolbarHeight];
float unifiedToolbarHeight = [(ToolbarWindow*)aWindow unifiedToolbarHeight];
CGAffineTransform ctm = CGContextGetUserSpaceToDeviceSpaceTransform(cgContext);
CGRect deviceRect = CGRectApplyAffineTransform(inBoxRect, ctm);
return inBoxRect.origin.x == 0 &&
inBoxRect.size.width >= [win frame].size.width &&
CGRectGetMaxY(inBoxRect) <= unifiedToolbarHeight;
deviceRect.size.width >= [aWindow frame].size.width &&
inBoxRect.origin.y <= 0.0 &&
floor(inBoxRect.origin.y + inBoxRect.size.height) <= unifiedToolbarHeight;
}
void
@ -1806,14 +1809,15 @@ nsNativeThemeCocoa::DrawUnifiedToolbar(CGContextRef cgContext, const HIRect& inB
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
float unifiedHeight = [(ToolbarWindow*)aWindow unifiedToolbarHeight];
float titlebarHeight = [(ToolbarWindow*)aWindow titlebarHeight];
float unifiedHeight = titlebarHeight + inBoxRect.size.height;
BOOL isMain = [aWindow isMainWindow];
CGContextSaveGState(cgContext);
CGContextClipToRect(cgContext, inBoxRect);
CGRect drawRect = CGRectOffset(inBoxRect, 0, inBoxRect.size.height - unifiedHeight);
CGRect drawRect = CGRectOffset(inBoxRect, 0, -titlebarHeight);
if (drawRect.size.width * drawRect.size.height <= CUIDRAW_MAX_AREA) {
CUIDraw([NSWindow coreUIRenderer], drawRect, cgContext,
(CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:
@ -1869,34 +1873,6 @@ nsNativeThemeCocoa::DrawStatusBar(CGContextRef cgContext, const HIRect& inBoxRec
NS_OBJC_END_TRY_ABORT_BLOCK;
}
void
nsNativeThemeCocoa::DrawNativeTitlebar(CGContextRef aContext, CGRect aTitlebarRect,
CGFloat aUnifiedHeight, BOOL aIsMain)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
if (aTitlebarRect.size.width * aTitlebarRect.size.height > CUIDRAW_MAX_AREA) {
return;
}
CGContextSaveGState(aContext);
CUIDraw([NSWindow coreUIRenderer], aTitlebarRect, aContext,
(CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:
@"kCUIWidgetWindowFrame", @"widget",
@"regularwin", @"windowtype",
(aIsMain ? @"normal" : @"inactive"), @"state",
[NSNumber numberWithInt:aUnifiedHeight], @"kCUIWindowFrameUnifiedTitleBarHeightKey",
[NSNumber numberWithBool:NO], @"kCUIWindowFrameDrawTitleSeparatorKey",
[NSNumber numberWithBool:YES], @"is.flipped",
nil],
nil);
CGContextRestoreGState(aContext);
NS_OBJC_END_TRY_ABORT_BLOCK;
}
static void
RenderResizer(CGContextRef cgContext, const HIRect& aRenderRect, void* aData)
{
@ -2159,14 +2135,6 @@ nsNativeThemeCocoa::DrawWidgetBackground(nsRenderingContext* aContext,
}
break;
case NS_THEME_WINDOW_TITLEBAR: {
NSWindow* win = NativeWindowForFrame(aFrame);
BOOL isMain = [win isMainWindow];
float unifiedToolbarHeight = [(ToolbarWindow*)win unifiedToolbarHeight];
DrawNativeTitlebar(cgContext, macRect, unifiedToolbarHeight, isMain);
}
break;
case NS_THEME_TOOLBOX: {
HIThemeHeaderDrawInfo hdi = { 0, kThemeStateActive, kHIThemeHeaderKindWindow };
HIThemeDrawHeader(&macRect, &hdi, cgContext, HITHEME_ORIENTATION);
@ -2993,7 +2961,6 @@ nsNativeThemeCocoa::ThemeSupportsWidget(nsPresContext* aPresContext, nsIFrame* a
case NS_THEME_DIALOG:
case NS_THEME_WINDOW:
case NS_THEME_WINDOW_TITLEBAR:
case NS_THEME_MENUPOPUP:
case NS_THEME_MENUITEM:
case NS_THEME_MENUSEPARATOR: