зеркало из https://github.com/mozilla/gecko-dev.git
Bug 625989 - Always draw in the titlebar on OSX. r=josh,dao f=mstange
This commit is contained in:
Родитель
0a3bf3ab76
Коммит
58712ea44c
|
@ -6721,12 +6721,6 @@ let gPrivateBrowsingUI = {
|
|||
document.getElementById("Tools:Sanitize").setAttribute("disabled", "true");
|
||||
|
||||
if (window.location.href == getBrowserURL()) {
|
||||
#ifdef XP_MACOSX
|
||||
if (!PrivateBrowsingUtils.permanentPrivateBrowsing) {
|
||||
document.documentElement.setAttribute("drawintitlebar", true);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Adjust the window's title
|
||||
let docElement = document.documentElement;
|
||||
if (!PrivateBrowsingUtils.permanentPrivateBrowsing) {
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
titlemodifier=""
|
||||
titlemodifier_normal=""
|
||||
titlemodifier_privatebrowsing="&mainWindow.titlePrivateBrowsingSuffix;"
|
||||
chromemargin="0,-1,-1,-1"
|
||||
#else
|
||||
title_privatebrowsing="&mainWindow.titlemodifier;@PRE_RELEASE_SUFFIX@ &mainWindow.titlePrivateBrowsingSuffix;"
|
||||
titlemodifier="&mainWindow.titlemodifier;@PRE_RELEASE_SUFFIX@"
|
||||
|
|
|
@ -40,8 +40,7 @@
|
|||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
#titlebar-buttonbox-container,
|
||||
#main-window:not([drawintitlebar=true]) > #titlebar {
|
||||
#titlebar-buttonbox-container {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
@ -49,6 +48,10 @@
|
|||
height: 22px;
|
||||
}
|
||||
|
||||
#main-window:not(:-moz-lwtheme):not([privatebrowsingmode=temporary]) > #titlebar {
|
||||
-moz-appearance: -moz-window-titlebar;
|
||||
}
|
||||
|
||||
#main-window[chromehidden~="toolbar"][chromehidden~="location"][chromehidden~="directories"] {
|
||||
border-top: 1px solid rgba(0,0,0,0.65);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,9 @@ LightweightThemeConsumer.prototype = {
|
|||
_lastData: null,
|
||||
_lastScreenWidth: null,
|
||||
_lastScreenHeight: null,
|
||||
#ifdef XP_MACOSX
|
||||
_chromemarginDefault: undefined,
|
||||
#endif
|
||||
|
||||
observe: function (aSubject, aTopic, aData) {
|
||||
if (aTopic != "lightweight-theme-styling-update")
|
||||
|
@ -108,10 +111,21 @@ LightweightThemeConsumer.prototype = {
|
|||
}
|
||||
|
||||
#ifdef XP_MACOSX
|
||||
if (active)
|
||||
root.setAttribute("drawintitlebar", "true");
|
||||
else
|
||||
root.removeAttribute("drawintitlebar");
|
||||
// Sample whether or not we draw in the titlebar by default the first time we update.
|
||||
// If the root has no chromemargin attribute, getAttribute will return null, and
|
||||
// we'll remove the attribute when the lw-theme is deactivated.
|
||||
if (this._chromemarginDefault === undefined)
|
||||
this._chromemarginDefault = root.getAttribute("chromemargin");
|
||||
|
||||
if (active) {
|
||||
root.setAttribute("chromemargin", "0,-1,-1,-1");
|
||||
}
|
||||
else {
|
||||
if (this._chromemarginDefault)
|
||||
root.setAttribute("chromemargin", this._chromemarginDefault);
|
||||
else
|
||||
root.removeAttribute("chromemargin");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
|
@ -540,6 +540,9 @@ 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());
|
||||
}
|
||||
|
|
|
@ -2053,23 +2053,29 @@ nsChildView::MaybeDrawRoundedBottomCorners(GLManager* aManager, nsIntRect aRect)
|
|||
void
|
||||
nsChildView::UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries)
|
||||
{
|
||||
NSWindow* win = [mView window];
|
||||
if (!win || ![win isKindOfClass:[ToolbarWindow class]])
|
||||
if (![mView window] || ![[mView window] isKindOfClass:[ToolbarWindow class]])
|
||||
return;
|
||||
|
||||
float unifiedToolbarHeight = 0;
|
||||
nsIntRect topPixelStrip(0, 0, [win frame].size.width, 1);
|
||||
ToolbarWindow* win = (ToolbarWindow*)[mView window];
|
||||
bool drawsContentsIntoWindowFrame = [win drawsContentsIntoWindowFrame];
|
||||
int32_t windowWidth = mBounds.width;
|
||||
int32_t titlebarHeight = CocoaPointsToDevPixels([win titlebarHeight]);
|
||||
int32_t underTitlebarPos = drawsContentsIntoWindowFrame ? titlebarHeight : 0;
|
||||
int32_t unifiedToolbarBottom = 0;
|
||||
|
||||
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();
|
||||
g.mRect.X() <= 0 &&
|
||||
g.mRect.XMost() >= windowWidth &&
|
||||
g.mRect.Y() <= underTitlebarPos) {
|
||||
unifiedToolbarBottom = g.mRect.YMost();
|
||||
}
|
||||
}
|
||||
[(ToolbarWindow*)win
|
||||
setUnifiedToolbarHeight:DevPixelsToCocoaPoints(unifiedToolbarHeight)];
|
||||
|
||||
CGFloat unifiedHeight = DevPixelsToCocoaPoints(titlebarHeight + unifiedToolbarBottom - underTitlebarPos);
|
||||
[win setUnifiedToolbarHeight:unifiedHeight];
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -269,6 +269,7 @@ public:
|
|||
virtual void SetShowsToolbarButton(bool aShow);
|
||||
virtual void SetShowsFullScreenButton(bool aShow);
|
||||
virtual void SetWindowAnimationType(WindowAnimationType aType);
|
||||
NS_IMETHOD SetNonClientMargins(nsIntMargin &margins);
|
||||
NS_IMETHOD SetWindowTitlebarColor(nscolor aColor, bool aActive);
|
||||
virtual void SetDrawsInTitlebar(bool aState);
|
||||
virtual nsresult SynthesizeNativeMouseEvent(nsIntPoint aPoint,
|
||||
|
|
|
@ -1954,6 +1954,15 @@ void nsCocoaWindow::SetWindowAnimationType(nsIWidget::WindowAnimationType aType)
|
|||
mAnimationType = aType;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCocoaWindow::SetNonClientMargins(nsIntMargin &margins)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
SetDrawsInTitlebar(margins.top == 0);
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCocoaWindow::SetWindowTitlebarColor(nscolor aColor, bool aActive)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
@ -2835,7 +2844,7 @@ static const NSString* kStateShowsToolbarButton = @"showsToolbarButton";
|
|||
[super setBackgroundColor:mColor];
|
||||
mBackgroundColor = [[NSColor whiteColor] retain];
|
||||
|
||||
mUnifiedToolbarHeight = 0.0f;
|
||||
mUnifiedToolbarHeight = 22.0f;
|
||||
|
||||
// setBottomCornerRounded: is a private API call, so we check to make sure
|
||||
// we respond to it just in case.
|
||||
|
@ -2909,6 +2918,7 @@ static const NSString* kStateShowsToolbarButton = @"showsToolbarButton";
|
|||
[self frame].size.width, [self titlebarHeight]);
|
||||
}
|
||||
|
||||
// Returns the unified height of titlebar + toolbar.
|
||||
- (float)unifiedToolbarHeight
|
||||
{
|
||||
return mUnifiedToolbarHeight;
|
||||
|
@ -2920,15 +2930,16 @@ static const NSString* kStateShowsToolbarButton = @"showsToolbarButton";
|
|||
return frameRect.size.height - [self contentRectForFrameRect:frameRect].size.height;
|
||||
}
|
||||
|
||||
// Stores the complete height of titlebar + toolbar.
|
||||
- (void)setUnifiedToolbarHeight:(float)aHeight
|
||||
{
|
||||
if ([self drawsContentsIntoWindowFrame] || aHeight == mUnifiedToolbarHeight)
|
||||
if (aHeight == mUnifiedToolbarHeight)
|
||||
return;
|
||||
|
||||
mUnifiedToolbarHeight = aHeight;
|
||||
|
||||
// Update sheet positioning hint.
|
||||
[self setContentBorderThickness:mUnifiedToolbarHeight forEdge:NSMaxYEdge];
|
||||
[self setContentBorderThickness:mUnifiedToolbarHeight - [self titlebarHeight] forEdge:NSMaxYEdge];
|
||||
|
||||
// Redraw the title bar. If we're inside painting, we'll do it right now,
|
||||
// otherwise we'll just invalidate it.
|
||||
|
@ -3123,18 +3134,18 @@ static const NSString* kStateShowsToolbarButton = @"showsToolbarButton";
|
|||
|
||||
static void
|
||||
DrawNativeTitlebar(CGContextRef aContext, CGRect aTitlebarRect,
|
||||
float aToolbarHeight, BOOL aIsMain)
|
||||
float aUnifiedToolbarHeight, 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 numberWithInt:unifiedHeight], @"kCUIWindowFrameUnifiedTitleBarHeightKey",
|
||||
[NSNumber numberWithInt:aUnifiedToolbarHeight], @"kCUIWindowFrameUnifiedTitleBarHeightKey",
|
||||
[NSNumber numberWithBool:YES], @"kCUIWindowFrameDrawTitleSeparatorKey",
|
||||
nil],
|
||||
nil);
|
||||
|
|
|
@ -107,6 +107,8 @@ protected:
|
|||
NSWindow* aWindow);
|
||||
void DrawStatusBar(CGContextRef cgContext, const HIRect& inBoxRect,
|
||||
nsIFrame *aFrame);
|
||||
void DrawNativeTitlebar(CGContextRef aContext, CGRect aTitlebarRect,
|
||||
float aUnifiedHeight, BOOL aIsMain);
|
||||
void DrawResizer(CGContextRef cgContext, const HIRect& aRect, nsIFrame *aFrame);
|
||||
|
||||
// Scrollbars
|
||||
|
|
|
@ -1789,16 +1789,18 @@ nsNativeThemeCocoa::GetParentScrollbarFrame(nsIFrame *aFrame)
|
|||
static bool
|
||||
ToolbarCanBeUnified(CGContextRef cgContext, const HIRect& inBoxRect, NSWindow* aWindow)
|
||||
{
|
||||
if (![aWindow isKindOfClass:[ToolbarWindow class]] ||
|
||||
[(ToolbarWindow*)aWindow drawsContentsIntoWindowFrame])
|
||||
if (![aWindow isKindOfClass:[ToolbarWindow class]])
|
||||
return false;
|
||||
|
||||
float unifiedToolbarHeight = [(ToolbarWindow*)aWindow unifiedToolbarHeight];
|
||||
CGAffineTransform ctm = CGContextGetUserSpaceToDeviceSpaceTransform(cgContext);
|
||||
CGRect deviceRect = CGRectApplyAffineTransform(inBoxRect, ctm);
|
||||
ToolbarWindow* win = (ToolbarWindow*)aWindow;
|
||||
float unifiedToolbarHeight = [win unifiedToolbarHeight];
|
||||
float titlebarHeight = [win titlebarHeight];
|
||||
bool drawsContentsIntoWindowFrame = [win drawsContentsIntoWindowFrame];
|
||||
float underTitlebarPos = drawsContentsIntoWindowFrame ? titlebarHeight : 0;
|
||||
|
||||
return inBoxRect.origin.x == 0 &&
|
||||
deviceRect.size.width >= [aWindow frame].size.width &&
|
||||
inBoxRect.origin.y <= 0.0 &&
|
||||
inBoxRect.size.width >= [win frame].size.width &&
|
||||
inBoxRect.origin.y <= underTitlebarPos &&
|
||||
floor(inBoxRect.origin.y + inBoxRect.size.height) <= unifiedToolbarHeight;
|
||||
}
|
||||
|
||||
|
@ -1808,15 +1810,14 @@ nsNativeThemeCocoa::DrawUnifiedToolbar(CGContextRef cgContext, const HIRect& inB
|
|||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
float titlebarHeight = [(ToolbarWindow*)aWindow titlebarHeight];
|
||||
float unifiedHeight = titlebarHeight + inBoxRect.size.height;
|
||||
float unifiedHeight = [(ToolbarWindow*)aWindow unifiedToolbarHeight];
|
||||
|
||||
BOOL isMain = [aWindow isMainWindow];
|
||||
|
||||
CGContextSaveGState(cgContext);
|
||||
CGContextClipToRect(cgContext, inBoxRect);
|
||||
|
||||
CGRect drawRect = CGRectOffset(inBoxRect, 0, -titlebarHeight);
|
||||
CGRect drawRect = CGRectOffset(inBoxRect, 0, inBoxRect.size.height - unifiedHeight);
|
||||
if (drawRect.size.width * drawRect.size.height <= CUIDRAW_MAX_AREA) {
|
||||
CUIDraw([NSWindow coreUIRenderer], drawRect, cgContext,
|
||||
(CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
|
@ -1872,6 +1873,34 @@ nsNativeThemeCocoa::DrawStatusBar(CGContextRef cgContext, const HIRect& inBoxRec
|
|||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
void
|
||||
nsNativeThemeCocoa::DrawNativeTitlebar(CGContextRef aContext, CGRect aTitlebarRect,
|
||||
float 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)
|
||||
{
|
||||
|
@ -2134,6 +2163,14 @@ 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);
|
||||
|
@ -2910,6 +2947,7 @@ 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:
|
||||
|
|
Загрузка…
Ссылка в новой задаче