mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 03:45:46 +00:00
Bug 1018845 - Make the fullscreen button easier to see on dark backgrounds. r=roc
This commit is contained in:
parent
a96f34f232
commit
1c0e700dea
@ -160,6 +160,7 @@ GK_ATOM(browser, "browser")
|
||||
GK_ATOM(mozbrowser, "mozbrowser")
|
||||
GK_ATOM(bulletinboard, "bulletinboard")
|
||||
GK_ATOM(button, "button")
|
||||
GK_ATOM(brighttitlebarforeground, "brighttitlebarforeground")
|
||||
GK_ATOM(callTemplate, "call-template")
|
||||
GK_ATOM(cancel, "cancel")
|
||||
GK_ATOM(canvas, "canvas")
|
||||
|
@ -1159,8 +1159,12 @@ nsXULElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(document);
|
||||
if (xuldoc) {
|
||||
xuldoc->ResetDocumentLWTheme();
|
||||
UpdateBrightTitlebarForeground(document);
|
||||
}
|
||||
}
|
||||
else if (aName == nsGkAtoms::brighttitlebarforeground) {
|
||||
UpdateBrightTitlebarForeground(document);
|
||||
}
|
||||
}
|
||||
|
||||
if (aName == nsGkAtoms::src && document) {
|
||||
@ -1196,8 +1200,12 @@ nsXULElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName,
|
||||
nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(doc);
|
||||
if (xuldoc) {
|
||||
xuldoc->ResetDocumentLWTheme();
|
||||
UpdateBrightTitlebarForeground(doc);
|
||||
}
|
||||
}
|
||||
else if (aName == nsGkAtoms::brighttitlebarforeground) {
|
||||
UpdateBrightTitlebarForeground(doc);
|
||||
}
|
||||
else if (aName == nsGkAtoms::drawintitlebar) {
|
||||
SetDrawsInTitlebar(false);
|
||||
}
|
||||
@ -1985,6 +1993,22 @@ nsXULElement::SetDrawsTitle(bool aState)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsXULElement::UpdateBrightTitlebarForeground(nsIDocument* aDoc)
|
||||
{
|
||||
nsIWidget* mainWidget = GetWindowWidget();
|
||||
if (mainWidget) {
|
||||
// We can do this synchronously because SetBrightTitlebarForeground doesn't have any
|
||||
// synchronous effects apart from a harmless invalidation.
|
||||
mainWidget->SetUseBrightTitlebarForeground(
|
||||
aDoc->GetDocumentLWTheme() == nsIDocument::Doc_Theme_Bright ||
|
||||
aDoc->GetRootElement()->AttrValueIs(kNameSpaceID_None,
|
||||
nsGkAtoms::brighttitlebarforeground,
|
||||
NS_LITERAL_STRING("true"),
|
||||
eCaseMatters));
|
||||
}
|
||||
}
|
||||
|
||||
class MarginSetter : public nsRunnable
|
||||
{
|
||||
public:
|
||||
|
@ -692,6 +692,7 @@ protected:
|
||||
|
||||
void SetDrawsInTitlebar(bool aState);
|
||||
void SetDrawsTitle(bool aState);
|
||||
void UpdateBrightTitlebarForeground(nsIDocument* aDocument);
|
||||
|
||||
void RemoveBroadcaster(const nsAString & broadcasterId);
|
||||
|
||||
|
@ -2431,7 +2431,27 @@ nsChildView::UpdateTitlebarCGContext()
|
||||
|
||||
[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:[view isFlipped]]];
|
||||
|
||||
[cell drawWithFrame:[button bounds] inView:button];
|
||||
if ([window useBrightTitlebarForeground] && !nsCocoaFeatures::OnYosemiteOrLater() &&
|
||||
view == [window standardWindowButton:NSWindowFullScreenButton]) {
|
||||
// Make the fullscreen button visible on dark titlebar backgrounds by
|
||||
// drawing it into a new transparency layer and turning it white.
|
||||
CGRect r = NSRectToCGRect([view bounds]);
|
||||
CGContextBeginTransparencyLayerWithRect(ctx, r, nullptr);
|
||||
|
||||
// Draw twice for double opacity.
|
||||
[cell drawWithFrame:[button bounds] inView:button];
|
||||
[cell drawWithFrame:[button bounds] inView:button];
|
||||
|
||||
// Make it white.
|
||||
CGContextSetBlendMode(ctx, kCGBlendModeSourceIn);
|
||||
CGContextSetRGBFillColor(ctx, 1, 1, 1, 1);
|
||||
CGContextFillRect(ctx, r);
|
||||
CGContextSetBlendMode(ctx, kCGBlendModeNormal);
|
||||
|
||||
CGContextEndTransparencyLayer(ctx);
|
||||
} else {
|
||||
[cell drawWithFrame:[button bounds] inView:button];
|
||||
}
|
||||
|
||||
[NSGraphicsContext setCurrentContext:context];
|
||||
CGContextRestoreGState(ctx);
|
||||
|
@ -79,6 +79,7 @@ typedef struct _nsCocoaWindowList {
|
||||
|
||||
BOOL mBeingShown;
|
||||
BOOL mDrawTitle;
|
||||
BOOL mBrightTitlebarForeground;
|
||||
}
|
||||
|
||||
- (void)importState:(NSDictionary*)aState;
|
||||
@ -109,6 +110,9 @@ typedef struct _nsCocoaWindowList {
|
||||
- (void)setWantsTitleDrawn:(BOOL)aDrawTitle;
|
||||
- (BOOL)wantsTitleDrawn;
|
||||
|
||||
- (void)setUseBrightTitlebarForeground:(BOOL)aBrightForeground;
|
||||
- (BOOL)useBrightTitlebarForeground;
|
||||
|
||||
- (void)disableSetNeedsDisplay;
|
||||
- (void)enableSetNeedsDisplay;
|
||||
|
||||
@ -302,6 +306,7 @@ public:
|
||||
virtual void SetShowsFullScreenButton(bool aShow);
|
||||
virtual void SetWindowAnimationType(WindowAnimationType aType);
|
||||
virtual void SetDrawsTitle(bool aDrawTitle);
|
||||
virtual void SetUseBrightTitlebarForeground(bool aBrightForeground) MOZ_OVERRIDE;
|
||||
NS_IMETHOD SetNonClientMargins(nsIntMargin &margins);
|
||||
NS_IMETHOD SetWindowTitlebarColor(nscolor aColor, bool aActive);
|
||||
virtual void SetDrawsInTitlebar(bool aState);
|
||||
|
@ -2000,6 +2000,16 @@ nsCocoaWindow::SetDrawsTitle(bool aDrawTitle)
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
void
|
||||
nsCocoaWindow::SetUseBrightTitlebarForeground(bool aBrightForeground)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
[mWindow setUseBrightTitlebarForeground:aBrightForeground];
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCocoaWindow::SetNonClientMargins(nsIntMargin &margins)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
@ -2642,6 +2652,7 @@ static NSMutableSet *gSwizzledFrameViewClasses = nil;
|
||||
mTrackingArea = nil;
|
||||
mBeingShown = NO;
|
||||
mDrawTitle = NO;
|
||||
mBrightTitlebarForeground = NO;
|
||||
[self updateTrackingArea];
|
||||
|
||||
return self;
|
||||
@ -2740,6 +2751,17 @@ static const NSString* kStateShowsToolbarButton = @"showsToolbarButton";
|
||||
return mDrawTitle;
|
||||
}
|
||||
|
||||
- (void)setUseBrightTitlebarForeground:(BOOL)aBrightForeground
|
||||
{
|
||||
mBrightTitlebarForeground = aBrightForeground;
|
||||
[[self standardWindowButton:NSWindowFullScreenButton] setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
- (BOOL)useBrightTitlebarForeground
|
||||
{
|
||||
return mBrightTitlebarForeground;
|
||||
}
|
||||
|
||||
// Pass nil here to get the default appearance.
|
||||
- (void)setTitlebarColor:(NSColor*)aColor forActiveWindow:(BOOL)aActive
|
||||
{
|
||||
|
@ -98,8 +98,8 @@ typedef void* nsNativeWidget;
|
||||
#endif
|
||||
|
||||
#define NS_IWIDGET_IID \
|
||||
{ 0x5b27abd6, 0x9e53, 0x4a0a, \
|
||||
{ 0x86, 0xf, 0x77, 0x5c, 0xc5, 0x69, 0x35, 0xf } };
|
||||
{ 0xcfe7543b, 0x8c0e, 0x40c3, \
|
||||
{ 0x9a, 0x6d, 0x77, 0x6e, 0x84, 0x8a, 0x7c, 0xfc } };
|
||||
|
||||
/*
|
||||
* Window shadow styles
|
||||
@ -1366,6 +1366,12 @@ class nsIWidget : public nsISupports {
|
||||
*/
|
||||
virtual void SetDrawsTitle(bool aDrawTitle) {}
|
||||
|
||||
/**
|
||||
* Indicates whether the widget should attempt to make titlebar controls
|
||||
* easier to see on dark titlebar backgrounds.
|
||||
*/
|
||||
virtual void SetUseBrightTitlebarForeground(bool aBrightForeground) {}
|
||||
|
||||
/**
|
||||
* Hide window chrome (borders, buttons) for this widget.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user