зеркало из https://github.com/mozilla/gecko-dev.git
Bug 522217 - Persist window settings like title and titlebarcolor when switching to and from fullscreen mode. r=josh
--HG-- extra : rebase_source : 485a737dadacf66f06981c4b244e82b7dfa9ee45
This commit is contained in:
Родитель
a7f052038b
Коммит
1efc09c079
|
@ -59,6 +59,30 @@ typedef struct _nsCocoaWindowList {
|
|||
nsCocoaWindow *window; // Weak
|
||||
} nsCocoaWindowList;
|
||||
|
||||
// NSWindow subclass that is the base class for all of our own window classes.
|
||||
// This class handles the storage of those settings that need to be persisted
|
||||
// across window destruction and reconstruction, i.e. when switching to and from
|
||||
// fullscreen mode.
|
||||
// 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
|
||||
{
|
||||
NSMutableDictionary* mState;
|
||||
BOOL mDrawsIntoWindowFrame;
|
||||
NSColor* mActiveTitlebarColor;
|
||||
NSColor* mInactiveTitlebarColor;
|
||||
}
|
||||
|
||||
- (void)importState:(NSDictionary*)aState;
|
||||
- (NSMutableDictionary*)exportState;
|
||||
- (void)setDrawsContentsIntoWindowFrame:(BOOL)aState;
|
||||
- (BOOL)drawsContentsIntoWindowFrame;
|
||||
- (void)setTitlebarColor:(NSColor*)aColor forActiveWindow:(BOOL)aActive;
|
||||
- (NSColor*)titlebarColorForActiveWindow:(BOOL)aActive;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSWindow (Undocumented)
|
||||
|
||||
// If a window has been explicitly removed from the "window cache" (to
|
||||
|
@ -75,7 +99,7 @@ typedef struct _nsCocoaWindowList {
|
|||
|
||||
@end
|
||||
|
||||
@interface PopupWindow : NSWindow
|
||||
@interface PopupWindow : BaseWindow
|
||||
{
|
||||
@private
|
||||
BOOL mIsContextMenu;
|
||||
|
@ -88,7 +112,7 @@ typedef struct _nsCocoaWindowList {
|
|||
|
||||
@end
|
||||
|
||||
@interface BorderlessWindow : NSWindow
|
||||
@interface BorderlessWindow : BaseWindow
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -129,35 +153,21 @@ struct UnifiedGradientInfo {
|
|||
// and for background of the window.
|
||||
@interface TitlebarAndBackgroundColor : NSColor
|
||||
{
|
||||
NSColor *mActiveTitlebarColor;
|
||||
NSColor *mInactiveTitlebarColor;
|
||||
NSColor *mBackgroundColor;
|
||||
ToolbarWindow *mWindow; // [WEAK] (we are owned by the window)
|
||||
}
|
||||
|
||||
- (id)initWithActiveTitlebarColor:(NSColor*)aActiveTitlebarColor
|
||||
inactiveTitlebarColor:(NSColor*)aInactiveTitlebarColor
|
||||
backgroundColor:(NSColor*)aBackgroundColor
|
||||
forWindow:(ToolbarWindow*)aWindow;
|
||||
- (id)initWithWindow:(ToolbarWindow*)aWindow;
|
||||
|
||||
// Pass nil here to get the default appearance.
|
||||
- (void)setTitlebarColor:(NSColor*)aColor forActiveWindow:(BOOL)aActive;
|
||||
- (NSColor*)activeTitlebarColor;
|
||||
- (NSColor*)inactiveTitlebarColor;
|
||||
|
||||
- (void)setBackgroundColor:(NSColor*)aColor;
|
||||
- (NSColor*)backgroundColor;
|
||||
|
||||
- (ToolbarWindow*)window;
|
||||
@end
|
||||
|
||||
// NSWindow subclass for handling windows with toolbars.
|
||||
@interface ToolbarWindow : NSWindow
|
||||
@interface ToolbarWindow : BaseWindow
|
||||
{
|
||||
TitlebarAndBackgroundColor *mColor;
|
||||
float mUnifiedToolbarHeight;
|
||||
BOOL mDrawsIntoWindowFrame;
|
||||
NSColor *mBackgroundColor;
|
||||
}
|
||||
// Pass nil here to get the default appearance.
|
||||
- (void)setTitlebarColor:(NSColor*)aColor forActiveWindow:(BOOL)aActive;
|
||||
- (void)setUnifiedToolbarHeight:(float)aToolbarHeight;
|
||||
- (float)unifiedToolbarHeight;
|
||||
|
@ -166,10 +176,6 @@ struct UnifiedGradientInfo {
|
|||
- (void)setTitlebarNeedsDisplayInRect:(NSRect)aRect sync:(BOOL)aSync;
|
||||
- (void)setTitlebarNeedsDisplayInRect:(NSRect)aRect;
|
||||
- (void)setDrawsContentsIntoWindowFrame:(BOOL)aState;
|
||||
- (BOOL)drawsContentsIntoWindowFrame;
|
||||
// This method is also available on NSWindows (via a category), and is the
|
||||
// preferred way to check the background color of a window.
|
||||
- (NSColor*)windowBackgroundColor;
|
||||
@end
|
||||
|
||||
class nsCocoaWindow : public nsBaseWidget, public nsPIWidgetCocoa
|
||||
|
@ -286,7 +292,7 @@ protected:
|
|||
void DestroyNativeWindow();
|
||||
|
||||
nsIWidget* mParent; // if we're a popup, this is our parent [WEAK]
|
||||
NSWindow* mWindow; // our cocoa window [STRONG]
|
||||
BaseWindow* mWindow; // our cocoa window [STRONG]
|
||||
WindowDelegate* mDelegate; // our delegate for processing window msgs [STRONG]
|
||||
nsRefPtr<nsMenuBarX> mMenuBar;
|
||||
NSWindow* mSheetWindowParent; // if this is a sheet, this is the NSWindow it's attached to
|
||||
|
|
|
@ -356,7 +356,7 @@ nsresult nsCocoaWindow::CreateNativeWindow(const NSRect &aRect,
|
|||
// NSLog(@"Top-level window being created at Cocoa rect: %f, %f, %f, %f\n",
|
||||
// rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
|
||||
|
||||
Class windowClass = [NSWindow class];
|
||||
Class windowClass = [BaseWindow class];
|
||||
// If we have a titlebar on a top-level window, we want to be able to control the
|
||||
// titlebar color (for unified windows), so use the special ToolbarWindow class.
|
||||
// Note that we need to check the window type because we mark sheets as
|
||||
|
@ -948,12 +948,18 @@ NS_IMETHODIMP nsCocoaWindow::HideWindowChrome(PRBool aShouldHide)
|
|||
[contentView retain];
|
||||
[contentView removeFromSuperviewWithoutNeedingDisplay];
|
||||
|
||||
// Save state (like window title).
|
||||
NSMutableDictionary* state = [mWindow exportState];
|
||||
|
||||
// Recreate the window with the right border style.
|
||||
NSRect frameRect = [mWindow frame];
|
||||
DestroyNativeWindow();
|
||||
nsresult rv = CreateNativeWindow(frameRect, aShouldHide ? eBorderStyle_none : mBorderStyle, PR_TRUE);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Re-import state.
|
||||
[mWindow importState:state];
|
||||
|
||||
// Reparent the content view.
|
||||
[mWindow setContentView:contentView];
|
||||
[contentView release];
|
||||
|
@ -1388,18 +1394,10 @@ NS_IMETHODIMP nsCocoaWindow::SetWindowTitlebarColor(nscolor aColor, PRBool aActi
|
|||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NSRESULT;
|
||||
|
||||
// If our cocoa window isn't a ToolbarWindow, something is wrong.
|
||||
if (![mWindow isKindOfClass:[ToolbarWindow class]]) {
|
||||
// Don't output a warning for the hidden window.
|
||||
NS_WARN_IF_FALSE(SameCOMIdentity(nsCocoaUtils::GetHiddenWindowWidget(), (nsIWidget*)this),
|
||||
"Calling SetWindowTitlebarColor on window that isn't of the ToolbarWindow class.");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// If they pass a color with a complete transparent alpha component, use the
|
||||
// native titlebar appearance.
|
||||
if (NS_GET_A(aColor) == 0) {
|
||||
[(ToolbarWindow*)mWindow setTitlebarColor:nil forActiveWindow:(BOOL)aActive];
|
||||
[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
|
||||
|
@ -1416,11 +1414,11 @@ NS_IMETHODIMP nsCocoaWindow::SetWindowTitlebarColor(nscolor aColor, PRBool aActi
|
|||
}
|
||||
}
|
||||
|
||||
[(ToolbarWindow*)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];
|
||||
[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];
|
||||
}
|
||||
return NS_OK;
|
||||
|
||||
|
@ -1430,11 +1428,8 @@ NS_IMETHODIMP nsCocoaWindow::SetWindowTitlebarColor(nscolor aColor, PRBool aActi
|
|||
void nsCocoaWindow::SetDrawsInTitlebar(PRBool aState)
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
if (![mWindow isKindOfClass:[ToolbarWindow class]])
|
||||
return;
|
||||
|
||||
[(ToolbarWindow*)mWindow setDrawsContentsIntoWindowFrame:aState];
|
||||
[mWindow setDrawsContentsIntoWindowFrame:aState];
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
@ -1761,17 +1756,81 @@ nsCocoaWindow::UnifiedShading(void* aInfo, const CGFloat* aIn, CGFloat* aOut)
|
|||
|
||||
@end
|
||||
|
||||
// Category on NSWindow so callers can use the same method on both ToolbarWindows
|
||||
// and NSWindows for accessing the background color.
|
||||
@implementation NSWindow(ToolbarWindowCompat)
|
||||
@implementation BaseWindow
|
||||
|
||||
- (NSColor*)windowBackgroundColor
|
||||
- (id)initWithContentRect:(NSRect)aContentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)aBufferingType defer:(BOOL)aFlag
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
||||
[super initWithContentRect:aContentRect styleMask:aStyle backing:aBufferingType defer:aFlag];
|
||||
mState = nil;
|
||||
mDrawsIntoWindowFrame = NO;
|
||||
mActiveTitlebarColor = nil;
|
||||
mInactiveTitlebarColor = nil;
|
||||
return self;
|
||||
}
|
||||
|
||||
return [self backgroundColor];
|
||||
- (void)dealloc
|
||||
{
|
||||
[mActiveTitlebarColor release];
|
||||
[mInactiveTitlebarColor release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
||||
static const NSString* kStateTitleKey = @"title";
|
||||
static const NSString* kStateDrawsContentsIntoWindowFrameKey = @"drawsContentsIntoWindowFrame";
|
||||
static const NSString* kStateActiveTitlebarColorKey = @"activeTitlebarColor";
|
||||
static const NSString* kStateInactiveTitlebarColorKey = @"inactiveTitlebarColor";
|
||||
|
||||
- (void)importState:(NSDictionary*)aState
|
||||
{
|
||||
[self setTitle:[aState objectForKey:kStateTitleKey]];
|
||||
[self setDrawsContentsIntoWindowFrame:[[aState objectForKey:kStateDrawsContentsIntoWindowFrameKey] boolValue]];
|
||||
[self setTitlebarColor:[aState objectForKey:kStateActiveTitlebarColorKey] forActiveWindow:YES];
|
||||
[self setTitlebarColor:[aState objectForKey:kStateInactiveTitlebarColorKey] forActiveWindow:NO];
|
||||
}
|
||||
|
||||
- (NSMutableDictionary*)exportState
|
||||
{
|
||||
NSMutableDictionary* state = [NSMutableDictionary dictionaryWithCapacity:10];
|
||||
[state setObject:[self 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];
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
- (void)setDrawsContentsIntoWindowFrame:(BOOL)aState
|
||||
{
|
||||
mDrawsIntoWindowFrame = aState;
|
||||
}
|
||||
|
||||
- (BOOL)drawsContentsIntoWindowFrame
|
||||
{
|
||||
return mDrawsIntoWindowFrame;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -1816,15 +1875,12 @@ nsCocoaWindow::UnifiedShading(void* aInfo, const CGFloat* aIn, CGFloat* aOut)
|
|||
|
||||
aStyle = aStyle | NSTexturedBackgroundWindowMask;
|
||||
if ((self = [super initWithContentRect:aContentRect styleMask:aStyle backing:aBufferingType defer:aFlag])) {
|
||||
mColor = [[TitlebarAndBackgroundColor alloc] initWithActiveTitlebarColor:nil
|
||||
inactiveTitlebarColor:nil
|
||||
backgroundColor:[NSColor whiteColor]
|
||||
forWindow:self];
|
||||
// Call the superclass's implementation, to avoid our guard method below.
|
||||
mColor = [[TitlebarAndBackgroundColor alloc] initWithWindow:self];
|
||||
// Bypass our guard method below.
|
||||
[super setBackgroundColor:mColor];
|
||||
mBackgroundColor = [NSColor whiteColor];
|
||||
|
||||
mUnifiedToolbarHeight = 0.0f;
|
||||
mDrawsIntoWindowFrame = NO;
|
||||
|
||||
// setBottomCornerRounded: is a private API call, so we check to make sure
|
||||
// we respond to it just in case.
|
||||
|
@ -1841,43 +1897,28 @@ nsCocoaWindow::UnifiedShading(void* aInfo, const CGFloat* aIn, CGFloat* aOut)
|
|||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
[mColor release];
|
||||
[mBackgroundColor release];
|
||||
[super dealloc];
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
// We don't provide our own implementation of -backgroundColor because NSWindow
|
||||
// looks at it, apparently. This is here to keep someone from messing with our
|
||||
// custom NSColor subclass.
|
||||
- (void)setBackgroundColor:(NSColor*)aColor
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
[mColor setBackgroundColor:aColor];
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
// If you need to get at the background color of the window (in the traditional
|
||||
// sense) use this method instead.
|
||||
- (NSColor*)windowBackgroundColor
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
||||
|
||||
return [mColor backgroundColor];
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
||||
}
|
||||
|
||||
// Pass nil here to get the default appearance.
|
||||
- (void)setTitlebarColor:(NSColor*)aColor forActiveWindow:(BOOL)aActive
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
[mColor setTitlebarColor:aColor forActiveWindow:aActive];
|
||||
[super setTitlebarColor:aColor forActiveWindow:aActive];
|
||||
[self setTitlebarNeedsDisplayInRect:[self titlebarRect]];
|
||||
}
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
- (void)setBackgroundColor:(NSColor*)aColor
|
||||
{
|
||||
[aColor retain];
|
||||
[mBackgroundColor release];
|
||||
mBackgroundColor = aColor;
|
||||
}
|
||||
|
||||
- (NSColor*)windowBackgroundColor
|
||||
{
|
||||
return mBackgroundColor;
|
||||
}
|
||||
|
||||
// This is called by nsNativeThemeCocoa.mm's DrawUnifiedToolbar.
|
||||
|
@ -1936,8 +1977,8 @@ nsCocoaWindow::UnifiedShading(void* aInfo, const CGFloat* aIn, CGFloat* aOut)
|
|||
|
||||
- (void)setDrawsContentsIntoWindowFrame:(BOOL)aState
|
||||
{
|
||||
BOOL stateChanged = (mDrawsIntoWindowFrame != aState);
|
||||
mDrawsIntoWindowFrame = aState;
|
||||
BOOL stateChanged = ([self drawsContentsIntoWindowFrame] != aState);
|
||||
[super setDrawsContentsIntoWindowFrame:aState];
|
||||
if (stateChanged) {
|
||||
nsCocoaWindow *geckoWindow = [[self delegate] geckoWidget];
|
||||
if (geckoWindow) {
|
||||
|
@ -1948,11 +1989,6 @@ nsCocoaWindow::UnifiedShading(void* aInfo, const CGFloat* aIn, CGFloat* aOut)
|
|||
}
|
||||
}
|
||||
|
||||
- (BOOL)drawsContentsIntoWindowFrame
|
||||
{
|
||||
return mDrawsIntoWindowFrame;
|
||||
}
|
||||
|
||||
// Returning YES here makes the setShowsToolbarButton method work even though
|
||||
// the window doesn't contain an NSToolbar.
|
||||
- (BOOL)_hasToolbar
|
||||
|
@ -2037,28 +2073,14 @@ nsCocoaWindow::UnifiedShading(void* aInfo, const CGFloat* aIn, CGFloat* aOut)
|
|||
// the titlebar area.
|
||||
@implementation TitlebarAndBackgroundColor
|
||||
|
||||
- (id)initWithActiveTitlebarColor:(NSColor*)aActiveTitlebarColor
|
||||
inactiveTitlebarColor:(NSColor*)aInactiveTitlebarColor
|
||||
backgroundColor:(NSColor*)aBackgroundColor
|
||||
forWindow:(ToolbarWindow*)aWindow
|
||||
- (id)initWithWindow:(ToolbarWindow*)aWindow
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
mActiveTitlebarColor = [aActiveTitlebarColor retain];
|
||||
mInactiveTitlebarColor = [aInactiveTitlebarColor retain];
|
||||
mBackgroundColor = [aBackgroundColor retain];
|
||||
mWindow = aWindow; // weak ref to avoid a cycle
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[mActiveTitlebarColor release];
|
||||
[mInactiveTitlebarColor release];
|
||||
[mBackgroundColor release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
// Our pattern width is 1 pixel. CoreGraphics can cache and tile for us.
|
||||
static const float sPatternWidth = 1.0f;
|
||||
|
||||
|
@ -2090,8 +2112,7 @@ DrawTitlebarGradient(CGContextRef aContext, float aTitlebarHeight,
|
|||
static void
|
||||
RepeatedPatternDrawCallback(void* aInfo, CGContextRef aContext)
|
||||
{
|
||||
TitlebarAndBackgroundColor *color = (TitlebarAndBackgroundColor*)aInfo;
|
||||
ToolbarWindow *window = [color window];
|
||||
ToolbarWindow *window = (ToolbarWindow*)aInfo;
|
||||
|
||||
// Remember: this context is NOT flipped, so the origin is in the bottom left.
|
||||
float titlebarHeight = [window titlebarHeight];
|
||||
|
@ -2101,7 +2122,7 @@ RepeatedPatternDrawCallback(void* aInfo, CGContextRef aContext)
|
|||
[NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithGraphicsPort:aContext flipped:NO]];
|
||||
|
||||
BOOL isMain = [window isMainWindow];
|
||||
NSColor *titlebarColor = isMain ? [color activeTitlebarColor] : [color inactiveTitlebarColor];
|
||||
NSColor *titlebarColor = [window titlebarColorForActiveWindow:isMain];
|
||||
if (!titlebarColor) {
|
||||
// If the titlebar color is nil, draw the default titlebar shading.
|
||||
DrawTitlebarGradient(aContext, titlebarHeight, titlebarOrigin,
|
||||
|
@ -2113,7 +2134,7 @@ RepeatedPatternDrawCallback(void* aInfo, CGContextRef aContext)
|
|||
}
|
||||
|
||||
// Draw the background color of the window everywhere but where the titlebar is.
|
||||
[[color backgroundColor] set];
|
||||
[[window windowBackgroundColor] set];
|
||||
NSRectFill(NSMakeRect(0.0f, 0.0f, 1.0f, titlebarOrigin));
|
||||
|
||||
[NSGraphicsContext restoreGraphicsState];
|
||||
|
@ -2123,8 +2144,7 @@ RepeatedPatternDrawCallback(void* aInfo, CGContextRef aContext)
|
|||
static void
|
||||
ContentPatternDrawCallback(void* aInfo, CGContextRef aContext)
|
||||
{
|
||||
TitlebarAndBackgroundColor *color = (TitlebarAndBackgroundColor*)aInfo;
|
||||
ToolbarWindow *window = (ToolbarWindow*)[color window];
|
||||
ToolbarWindow *window = (ToolbarWindow*)aInfo;
|
||||
|
||||
NSView* view = [[[window contentView] subviews] lastObject];
|
||||
if (!view || ![view isKindOfClass:[ChildView class]])
|
||||
|
@ -2143,14 +2163,12 @@ ContentPatternDrawCallback(void* aInfo, CGContextRef aContext)
|
|||
|
||||
- (void)setFill
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
|
||||
CGPatternDrawPatternCallback cb = [mWindow drawsContentsIntoWindowFrame] ?
|
||||
&ContentPatternDrawCallback : &RepeatedPatternDrawCallback;
|
||||
CGPatternCallbacks callbacks = {0, cb, NULL};
|
||||
float patternWidth = [mWindow drawsContentsIntoWindowFrame] ? [mWindow frame].size.width : sPatternWidth;
|
||||
CGPatternRef pattern = CGPatternCreate(self, CGRectMake(0.0f, 0.0f, patternWidth, [mWindow frame].size.height),
|
||||
CGPatternRef pattern = CGPatternCreate(mWindow, CGRectMake(0.0f, 0.0f, patternWidth, [mWindow frame].size.height),
|
||||
CGAffineTransformIdentity, patternWidth, [mWindow frame].size.height,
|
||||
kCGPatternTilingConstantSpacing, true, &callbacks);
|
||||
|
||||
|
@ -2162,54 +2180,11 @@ ContentPatternDrawCallback(void* aInfo, CGContextRef aContext)
|
|||
CGFloat component = 1.0f;
|
||||
CGContextSetFillPattern(context, pattern, &component);
|
||||
CGPatternRelease(pattern);
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
// Pass nil here to get the default appearance.
|
||||
- (void)setTitlebarColor:(NSColor*)aColor forActiveWindow:(BOOL)aActive
|
||||
- (void)set
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
if (aActive) {
|
||||
[mActiveTitlebarColor autorelease];
|
||||
mActiveTitlebarColor = [aColor retain];
|
||||
} else {
|
||||
[mInactiveTitlebarColor autorelease];
|
||||
mInactiveTitlebarColor = [aColor retain];
|
||||
}
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
- (NSColor*)activeTitlebarColor
|
||||
{
|
||||
return mActiveTitlebarColor;
|
||||
}
|
||||
|
||||
- (NSColor*)inactiveTitlebarColor
|
||||
{
|
||||
return mInactiveTitlebarColor;
|
||||
}
|
||||
|
||||
- (void)setBackgroundColor:(NSColor*)aColor
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
[mBackgroundColor autorelease];
|
||||
mBackgroundColor = [aColor retain];
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
- (NSColor*)backgroundColor
|
||||
{
|
||||
return mBackgroundColor;
|
||||
}
|
||||
|
||||
- (ToolbarWindow*)window
|
||||
{
|
||||
return mWindow;
|
||||
[self setFill];
|
||||
}
|
||||
|
||||
- (NSString*)colorSpaceName
|
||||
|
@ -2217,15 +2192,6 @@ ContentPatternDrawCallback(void* aInfo, CGContextRef aContext)
|
|||
return NSDeviceRGBColorSpace;
|
||||
}
|
||||
|
||||
- (void)set
|
||||
{
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
[self setFill];
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation PopupWindow
|
||||
|
|
|
@ -75,6 +75,8 @@ _TEST_FILES += native_menus_window.xul \
|
|||
test_bug428405.xul \
|
||||
test_bug466599.xul \
|
||||
test_bug485118.xul \
|
||||
test_bug522217.xul \
|
||||
window_bug522217.xul \
|
||||
test_platform_colors.xul \
|
||||
$(NULL)
|
||||
endif
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=522217
|
||||
-->
|
||||
<window title="Mozilla Bug 522217"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<title>Test for Bug 522217</title>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
|
||||
|
||||
<body xmlns="http://www.w3.org/1999/xhtml">
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
|
||||
<script class="testbody" type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
SimpleTest.waitForFocus(function () {
|
||||
window.open("window_bug522217.xul", "_blank",
|
||||
"chrome,resizable,width=400,height=300");
|
||||
});
|
||||
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
</window>
|
|
@ -0,0 +1,61 @@
|
|||
<?xml version="1.0"?>
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<window title="Mozilla Bug 522217"
|
||||
onload="start();"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/javascript"
|
||||
src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" />
|
||||
|
||||
<body xmlns="http://www.w3.org/1999/xhtml" id="body">
|
||||
</body>
|
||||
|
||||
<script class="testbody" type="application/javascript">
|
||||
<![CDATA[
|
||||
|
||||
function ok(aCondition, aMessage)
|
||||
{
|
||||
window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage);
|
||||
}
|
||||
|
||||
function is(aLeft, aRight, aMessage)
|
||||
{
|
||||
window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage);
|
||||
}
|
||||
|
||||
function isnot(aLeft, aRight, aMessage)
|
||||
{
|
||||
window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage);
|
||||
}
|
||||
|
||||
function start() {
|
||||
window.onfocus = function () {
|
||||
window.onfocus = null;
|
||||
var oldOuterWidth = window.outerWidth, oldOuterHeight = window.outerHeight;
|
||||
var oldInnerWidth = window.innerWidth, oldInnerHeight = window.innerHeight;
|
||||
document.documentElement.setAttribute("drawintitlebar", "true");
|
||||
is(window.outerWidth, oldOuterWidth, "drawintitlebar shouldn't change the window's outerWidth");
|
||||
is(window.outerHeight, oldOuterHeight, "drawintitlebar shouldn't change the window's outerHeight");
|
||||
is(window.innerWidth, oldOuterWidth, "if drawintitlebar is set, innerWidth and outerWidth should be the same");
|
||||
is(window.innerHeight, oldOuterHeight, "if drawintitlebar is set, innerHeight and outerHeight should be the same");
|
||||
window.fullScreen = true;
|
||||
window.fullScreen = false;
|
||||
is(window.outerWidth, oldOuterWidth, "wrong outerWidth after fullscreen mode");
|
||||
is(window.outerHeight, oldOuterHeight, "wrong outerHeight after fullscreen mode");
|
||||
is(window.innerWidth, oldOuterWidth, "wrong innerWidth after fullscreen mode");
|
||||
is(window.innerHeight, oldOuterHeight, "wrong innerHeight after fullscreen mode");
|
||||
document.documentElement.removeAttribute("drawintitlebar");
|
||||
is(window.outerWidth, oldOuterWidth, "wrong outerWidth after removing drawintitlebar");
|
||||
is(window.outerHeight, oldOuterHeight, "wrong outerHeight after removing drawintitlebar");
|
||||
is(window.innerWidth, oldInnerWidth, "wrong innerWidth after removing drawintitlebar");
|
||||
is(window.innerHeight, oldInnerHeight, "wrong innerHeight after removing drawintitlebar");
|
||||
window.opener.wrappedJSObject.SimpleTest.finish();
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
]]>
|
||||
</script>
|
||||
|
||||
</window>
|
Загрузка…
Ссылка в новой задаче