Skip to content
This repository has been archived by the owner on Aug 4, 2022. It is now read-only.

Commit

Permalink
Bug 1335191 - Remove nsIWidget::SetWindowTitlebarColor and the nsCoco…
Browse files Browse the repository at this point in the history
…aWindow implementation. r=spohl

It's unused and no longer has any effect.

MozReview-Commit-ID: DroUFYOovMx
  • Loading branch information
mstange committed Mar 24, 2018
1 parent daf133d commit 4fc2fb9
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 105 deletions.
7 changes: 0 additions & 7 deletions widget/cocoa/nsCocoaWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ typedef struct _nsCocoaWindowList {
// Data Storage
NSMutableDictionary* mState;
BOOL mDrawsIntoWindowFrame;
NSColor* mActiveTitlebarColor;
NSColor* mInactiveTitlebarColor;

// Invalidation disabling
BOOL mDisabledNeedsDisplay;
Expand All @@ -58,8 +56,6 @@ typedef struct _nsCocoaWindowList {
- (NSMutableDictionary*)exportState;
- (void)setDrawsContentsIntoWindowFrame:(BOOL)aState;
- (BOOL)drawsContentsIntoWindowFrame;
- (void)setTitlebarColor:(NSColor*)aColor forActiveWindow:(BOOL)aActive;
- (NSColor*)titlebarColorForActiveWindow:(BOOL)aActive;


- (void)mouseEntered:(NSEvent*)aEvent;
Expand Down Expand Up @@ -179,8 +175,6 @@ typedef struct _nsCocoaWindowList {
NSRect mWindowButtonsRect;
NSRect mFullScreenButtonRect;
}
// Pass nil here to get the default appearance.
- (void)setTitlebarColor:(NSColor*)aColor forActiveWindow:(BOOL)aActive;
- (void)setUnifiedToolbarHeight:(CGFloat)aHeight;
- (CGFloat)unifiedToolbarHeight;
- (CGFloat)titlebarHeight;
Expand Down Expand Up @@ -309,7 +303,6 @@ class nsCocoaWindow final : public nsBaseWidget, public nsPIWidgetCocoa
virtual void SetDrawsTitle(bool aDrawTitle) override;
virtual void SetUseBrightTitlebarForeground(bool aBrightForeground) override;
virtual nsresult SetNonClientMargins(LayoutDeviceIntMargin& aMargins) override;
virtual void SetWindowTitlebarColor(nscolor aColor, bool aActive) override;
virtual void SetDrawsInTitlebar(bool aState) override;
virtual void UpdateThemeGeometries(const nsTArray<ThemeGeometry>& aThemeGeometries) override;
virtual nsresult SynthesizeNativeMouseEvent(LayoutDeviceIntPoint aPoint,
Expand Down
78 changes: 0 additions & 78 deletions widget/cocoa/nsCocoaWindow.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2430,44 +2430,6 @@ DesktopIntRect newBounds(NSToIntRound(aX), NSToIntRound(aY),
NS_OBJC_END_TRY_ABORT_BLOCK_NSRESULT;
}

void
nsCocoaWindow::SetWindowTitlebarColor(nscolor aColor, bool aActive)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;

if (!mWindow)
return;

// If they pass a color with a complete transparent alpha component, use the
// native titlebar appearance.
if (NS_GET_A(aColor) == 0) {
[mWindow setTitlebarColor:nil forActiveWindow:(BOOL)aActive];
} else {
// Transform from sRGBA to monitor RGBA. This seems like it would make trying
// to match the system appearance lame, so probably we just shouldn't color
// correct chrome.
if (gfxPlatform::GetCMSMode() == eCMSMode_All) {
qcms_transform *transform = gfxPlatform::GetCMSRGBATransform();
if (transform) {
uint8_t color[3];
color[0] = NS_GET_R(aColor);
color[1] = NS_GET_G(aColor);
color[2] = NS_GET_B(aColor);
qcms_transform_data(transform, color, color, 1);
aColor = NS_RGB(color[0], color[1], color[2]);
}
}

[mWindow setTitlebarColor:[NSColor colorWithDeviceRed:NS_GET_R(aColor)/255.0
green:NS_GET_G(aColor)/255.0
blue:NS_GET_B(aColor)/255.0
alpha:NS_GET_A(aColor)/255.0]
forActiveWindow:(BOOL)aActive];
}

NS_OBJC_END_TRY_ABORT_BLOCK;
}

void nsCocoaWindow::SetDrawsInTitlebar(bool aState)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
Expand Down Expand Up @@ -3095,8 +3057,6 @@ - (id)initWithContentRect:(NSRect)aContentRect styleMask:(NSUInteger)aStyle back
mDrawsIntoWindowFrame = NO;
[super initWithContentRect:aContentRect styleMask:aStyle backing:aBufferingType defer:aFlag];
mState = nil;
mActiveTitlebarColor = nil;
mInactiveTitlebarColor = nil;
mDisabledNeedsDisplay = NO;
mTrackingArea = nil;
mDirtyRect = NSZeroRect;
Expand Down Expand Up @@ -3186,17 +3146,13 @@ - (void)enableSetNeedsDisplay

- (void)dealloc
{
[mActiveTitlebarColor release];
[mInactiveTitlebarColor release];
[self removeTrackingArea];
ChildViewMouseTracker::OnDestroyWindow(self);
[super dealloc];
}

static const NSString* kStateTitleKey = @"title";
static const NSString* kStateDrawsContentsIntoWindowFrameKey = @"drawsContentsIntoWindowFrame";
static const NSString* kStateActiveTitlebarColorKey = @"activeTitlebarColor";
static const NSString* kStateInactiveTitlebarColorKey = @"inactiveTitlebarColor";
static const NSString* kStateShowsToolbarButton = @"showsToolbarButton";
static const NSString* kStateCollectionBehavior = @"collectionBehavior";

Expand All @@ -3206,8 +3162,6 @@ - (void)importState:(NSDictionary*)aState
[self setTitle:title];
}
[self setDrawsContentsIntoWindowFrame:[[aState objectForKey:kStateDrawsContentsIntoWindowFrameKey] boolValue]];
[self setTitlebarColor:[aState objectForKey:kStateActiveTitlebarColorKey] forActiveWindow:YES];
[self setTitlebarColor:[aState objectForKey:kStateInactiveTitlebarColorKey] forActiveWindow:NO];
[self setShowsToolbarButton:[[aState objectForKey:kStateShowsToolbarButton] boolValue]];
[self setCollectionBehavior:[[aState objectForKey:kStateCollectionBehavior] unsignedIntValue]];
}
Expand All @@ -3220,14 +3174,6 @@ - (NSMutableDictionary*)exportState
}
[state setObject:[NSNumber numberWithBool:[self drawsContentsIntoWindowFrame]]
forKey:kStateDrawsContentsIntoWindowFrameKey];
NSColor* activeTitlebarColor = [self titlebarColorForActiveWindow:YES];
if (activeTitlebarColor) {
[state setObject:activeTitlebarColor forKey:kStateActiveTitlebarColorKey];
}
NSColor* inactiveTitlebarColor = [self titlebarColorForActiveWindow:NO];
if (inactiveTitlebarColor) {
[state setObject:inactiveTitlebarColor forKey:kStateInactiveTitlebarColorKey];
}
[state setObject:[NSNumber numberWithBool:[self showsToolbarButton]]
forKey:kStateShowsToolbarButton];
[state setObject:[NSNumber numberWithUnsignedInt: [self collectionBehavior]]
Expand Down Expand Up @@ -3278,24 +3224,6 @@ - (BOOL)useBrightTitlebarForeground
return mBrightTitlebarForeground;
}

// Pass nil here to get the default appearance.
- (void)setTitlebarColor:(NSColor*)aColor forActiveWindow:(BOOL)aActive
{
[aColor retain];
if (aActive) {
[mActiveTitlebarColor release];
mActiveTitlebarColor = aColor;
} else {
[mInactiveTitlebarColor release];
mInactiveTitlebarColor = aColor;
}
}

- (NSColor*)titlebarColorForActiveWindow:(BOOL)aActive
{
return aActive ? mActiveTitlebarColor : mInactiveTitlebarColor;
}

- (NSView*)trackingAreaView
{
NSView* contentView = [self contentView];
Expand Down Expand Up @@ -3580,12 +3508,6 @@ - (id)initWithContentRect:(NSRect)aContentRect styleMask:(NSUInteger)aStyle back
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}

- (void)setTitlebarColor:(NSColor*)aColor forActiveWindow:(BOOL)aActive
{
[super setTitlebarColor:aColor forActiveWindow:aActive];
[self setTitlebarNeedsDisplayInRect:[self titlebarRect]];
}

- (void)setTitlebarNeedsDisplayInRect:(NSRect)aRect
{
[self setTitlebarNeedsDisplayInRect:aRect sync:NO];
Expand Down
2 changes: 0 additions & 2 deletions widget/nsBaseWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,6 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference
{ return NS_OK; }
virtual bool HasPendingInputEvent() override;
virtual void SetIcon(const nsAString &aIconSpec) override {}
virtual void SetWindowTitlebarColor(nscolor aColor, bool aActive)
override {}
virtual void SetDrawsInTitlebar(bool aState) override {}
virtual bool ShowsResizeIndicator(LayoutDeviceIntRect* aResizerRect) override;
virtual void FreeNativeData(void * data, uint32_t aDataType) override {}
Expand Down
18 changes: 0 additions & 18 deletions widget/nsIWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -1451,24 +1451,6 @@ class nsIWidget : public nsISupports
*/
virtual bool HasPendingInputEvent() = 0;

/**
* Set the background color of the window titlebar for this widget. On Mac,
* for example, this will remove the grey gradient and bottom border and
* instead show a single, solid color.
*
* Ignored on any platform that does not support it. Ignored by widgets that
* do not represent windows.
*
* @param aColor The color to set the title bar background to. Alpha values
* other than fully transparent (0) are respected if possible
* on the platform. An alpha of 0 will cause the window to
* draw with the default style for the platform.
*
* @param aActive Whether the color should be applied to active or inactive
* windows.
*/
virtual void SetWindowTitlebarColor(nscolor aColor, bool aActive) = 0;

/**
* If set to true, the window will draw its contents into the titlebar
* instead of below it.
Expand Down

0 comments on commit 4fc2fb9

Please sign in to comment.