Bug 1335191 - Remove nsIWidget::SetWindowTitlebarColor and the nsCocoaWindow implementation. r?spohl
It's unused and no longer has any effect.
MozReview-Commit-ID: DroUFYOovMx
--- a/widget/cocoa/nsCocoaWindow.h
+++ b/widget/cocoa/nsCocoaWindow.h
@@ -33,18 +33,16 @@ typedef struct _nsCocoaWindowList {
// We don't save shadow, transparency mode or background color because it's not
// worth the hassle - Gecko will reset them anyway as soon as the window is
// resized.
@interface BaseWindow : NSWindow
{
// Data Storage
NSMutableDictionary* mState;
BOOL mDrawsIntoWindowFrame;
- NSColor* mActiveTitlebarColor;
- NSColor* mInactiveTitlebarColor;
// Invalidation disabling
BOOL mDisabledNeedsDisplay;
NSTrackingArea* mTrackingArea;
NSRect mDirtyRect;
@@ -53,18 +51,16 @@ typedef struct _nsCocoaWindowList {
BOOL mBrightTitlebarForeground;
BOOL mUseMenuStyle;
}
- (void)importState:(NSDictionary*)aState;
- (NSMutableDictionary*)exportState;
- (void)setDrawsContentsIntoWindowFrame:(BOOL)aState;
- (BOOL)drawsContentsIntoWindowFrame;
-- (void)setTitlebarColor:(NSColor*)aColor forActiveWindow:(BOOL)aActive;
-- (NSColor*)titlebarColorForActiveWindow:(BOOL)aActive;
- (void)mouseEntered:(NSEvent*)aEvent;
- (void)mouseExited:(NSEvent*)aEvent;
- (void)mouseMoved:(NSEvent*)aEvent;
- (void)updateTrackingArea;
- (NSView*)trackingAreaView;
@@ -174,18 +170,16 @@ typedef struct _nsCocoaWindowList {
// NSWindow subclass for handling windows with toolbars.
@interface ToolbarWindow : BaseWindow
{
CGFloat mUnifiedToolbarHeight;
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;
- (NSRect)titlebarRect;
- (void)setTitlebarNeedsDisplayInRect:(NSRect)aRect sync:(BOOL)aSync;
- (void)setTitlebarNeedsDisplayInRect:(NSRect)aRect;
- (void)setDrawsContentsIntoWindowFrame:(BOOL)aState;
- (void)setSheetAttachmentPosition:(CGFloat)aY;
@@ -304,17 +298,16 @@ public:
virtual void SetWindowOpacity(float aOpacity) override;
virtual void SetWindowTransform(const mozilla::gfx::Matrix& aTransform) override;
virtual void SetShowsToolbarButton(bool aShow) override;
virtual void SetShowsFullScreenButton(bool aShow) override;
virtual void SetWindowAnimationType(WindowAnimationType aType) override;
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,
uint32_t aNativeMessage,
uint32_t aModifierFlags,
nsIObserver* aObserver) override;
void DispatchSizeModeEvent();
--- a/widget/cocoa/nsCocoaWindow.mm
+++ b/widget/cocoa/nsCocoaWindow.mm
@@ -2425,54 +2425,16 @@ nsCocoaWindow::SetNonClientMargins(Layou
SetDrawsInTitlebar(margins.top == 0);
return NS_OK;
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;
if (mWindow)
[mWindow setDrawsContentsIntoWindowFrame:aState];
NS_OBJC_END_TRY_ABORT_BLOCK;
@@ -3090,18 +3052,16 @@ static NSMutableSet *gSwizzledFrameViewC
return frameViewClass;
}
- (id)initWithContentRect:(NSRect)aContentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)aBufferingType defer:(BOOL)aFlag
{
mDrawsIntoWindowFrame = NO;
[super initWithContentRect:aContentRect styleMask:aStyle backing:aBufferingType defer:aFlag];
mState = nil;
- mActiveTitlebarColor = nil;
- mInactiveTitlebarColor = nil;
mDisabledNeedsDisplay = NO;
mTrackingArea = nil;
mDirtyRect = NSZeroRect;
mBeingShown = NO;
mDrawTitle = NO;
mBrightTitlebarForeground = NO;
mUseMenuStyle = NO;
[self updateTrackingArea];
@@ -3181,58 +3141,44 @@ GetMenuMaskImage()
- (void)enableSetNeedsDisplay
{
mDisabledNeedsDisplay = NO;
}
- (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";
- (void)importState:(NSDictionary*)aState
{
if (NSString* title = [aState objectForKey:kStateTitleKey]) {
[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]];
}
- (NSMutableDictionary*)exportState
{
NSMutableDictionary* state = [NSMutableDictionary dictionaryWithCapacity:10];
if (NSString* title = [self title]) {
[state setObject:title forKey:kStateTitleKey];
}
[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]]
forKey:kStateCollectionBehavior];
return state;
}
- (void)setDrawsContentsIntoWindowFrame:(BOOL)aState
@@ -3273,34 +3219,16 @@ static const NSString* kStateCollectionB
[[self standardWindowButton:NSWindowFullScreenButton] setNeedsDisplay:YES];
}
- (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];
return [contentView superview] ? [contentView superview] : contentView;
}
- (ChildView*)mainChildView
{
@@ -3575,22 +3503,16 @@ static const NSString* kStateCollectionB
[self setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge];
[self setContentBorderThickness:0.0f forEdge:NSMaxYEdge];
}
return self;
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];
}
- (void)setTitlebarNeedsDisplayInRect:(NSRect)aRect sync:(BOOL)aSync
{
NSRect titlebarRect = [self titlebarRect];
--- a/widget/nsBaseWidget.h
+++ b/widget/nsBaseWidget.h
@@ -251,18 +251,16 @@ public:
virtual LayoutDeviceIntPoint GetClientOffset() override;
virtual void EnableDragDrop(bool aEnable) override {};
virtual nsresult AsyncEnableDragDrop(bool aEnable) override;
virtual MOZ_MUST_USE nsresult
GetAttention(int32_t aCycleCount) override
{ 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 {}
virtual MOZ_MUST_USE nsresult
BeginResizeDrag(mozilla::WidgetGUIEvent* aEvent,
int32_t aHorizontal,
int32_t aVertical) override
{ return NS_ERROR_NOT_IMPLEMENTED; }
--- a/widget/nsIWidget.h
+++ b/widget/nsIWidget.h
@@ -1447,34 +1447,16 @@ class nsIWidget : public nsISupports
/**
* Ask whether there user input events pending. All input events are
* included, including those not targeted at this nsIwidget instance.
*/
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.
*
* Ignored on any platform that does not support it. Ignored by widgets that
* do not represent windows.
* May result in a resize event, so should only be called from places where
* reflow and painting is allowed.
*