From bff22779ae4591199ba2426f1a7c98ab856249fc Mon Sep 17 00:00:00 2001 From: Darrell Walisser Date: Sat, 4 Aug 2012 13:53:05 -0400 Subject: [PATCH] -capp_lint --- AppKit/CPApplication.j | 8 +-- AppKit/CPWindow/CPWindow.j | 85 ++++++++++++------------- AppKit/CPWindow/_CPStandardWindowView.j | 17 ++--- AppKit/CPWindow/_CPWindowView.j | 10 +-- 4 files changed, 60 insertions(+), 60 deletions(-) diff --git a/AppKit/CPApplication.j b/AppKit/CPApplication.j index a97bca0d9..50003e583 100644 --- a/AppKit/CPApplication.j +++ b/AppKit/CPApplication.j @@ -936,9 +936,9 @@ CPRunContinuesResponse = -1002; [CPException raise:CPInternalInconsistencyException reason:@"The target window of beginSheet: cannot be a sheet"]; return; } - + [aSheet._windowView _enableSheet:YES]; - + // -dw- if a sheet is already visible, we skip this since it serves no purpose and causes // orderOut: to be called on the sheet, which is not what we want. if (![aWindow isVisible]) @@ -1196,8 +1196,8 @@ _CPRunModalLoop = function(anEvent) // yet it works when there is a modal window. Maybe it starts its own modal session, but interaction with the original // modal window seems to continue working as well. Regardless of correctness, this solution beats popovers not working // at all from sheets. - if (theWindow == modalSession._window || - [theWindow worksWhenModal] || + if (theWindow == modalSession._window || + [theWindow worksWhenModal] || [theWindow attachedSheet] == modalSession._window || // -dw- allow modal parent of sheet to be repositioned ([theWindow isKindOfClass:_CPAttachedWindow] && [[theWindow targetView] window] === modalSession._window)) [theWindow sendEvent:anEvent]; diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index 6b4ac9461..04c64f436 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -423,7 +423,7 @@ CPTexturedBackgroundWindowMask _isSheet = NO; _sheetContext = nil; _parentView = nil; - + // Set up our window number. _windowNumber = [CPApp._windows count]; CPApp._windows[_windowNumber] = self; @@ -780,21 +780,21 @@ CPTexturedBackgroundWindowMask if (_hasShadow) { - // if the shadow would be taller/wider than the window height, + // if the shadow would be taller/wider than the window height, // make it the same as the window height. this allows views to // become 0,0 with no shadow on them and makes the sheet // animation look nicer var shadowSize = _CGSizeMake(size.width,size.height); - + if (size.width >= (SHADOW_MARGIN_LEFT + SHADOW_MARGIN_RIGHT)) shadowSize.width += SHADOW_MARGIN_LEFT + SHADOW_MARGIN_RIGHT; - + if (size.height >= (SHADOW_MARGIN_BOTTOM + SHADOW_MARGIN_TOP + SHADOW_DISTANCE)) shadowSize.height += SHADOW_MARGIN_BOTTOM + SHADOW_MARGIN_TOP + SHADOW_DISTANCE; - + [_shadowView setFrameSize:shadowSize]; } - + if (!_isAnimating) [[CPNotificationCenter defaultCenter] postNotificationName:CPWindowDidResizeNotification object:self]; } @@ -831,7 +831,7 @@ CPTexturedBackgroundWindowMask { [self _setClippedFrame:_CGRectMake(anOrigin.x, anOrigin.y, _CGRectGetWidth(_frame), _CGRectGetHeight(_frame)) display:YES animate:NO]; - // reposition sheet + // reposition sheet if ([self attachedSheet]) [self _setAttachedSheetFrameOrigin]; } @@ -892,7 +892,7 @@ CPTexturedBackgroundWindowMask [self._parentView _detachSheetWindow]; return; } - + #if PLATFORM(DOM) if ([self _sharesChromeWithPlatformWindow]) [_platformWindow orderOut:self]; @@ -1605,7 +1605,7 @@ CPTexturedBackgroundWindowMask { case CPLeftMouseDown: [_windowView mouseDown:anEvent]; - + // -dw- if the window is clicked, the sheet should come to front, and become key, // and the window should be immediately behind [self orderFront:self]; @@ -1615,7 +1615,7 @@ CPTexturedBackgroundWindowMask [_windowView mouseMoved:anEvent]; break; } - + return; } @@ -2369,29 +2369,29 @@ CPTexturedBackgroundWindowMask [attachedSheet setFrame:sheetFrame display:YES animate:NO]; } -/* @ignore +/* @ignore Starting point for sheet session, called from CPApplication beginSheet: */ -- (void)_attachSheet:(CPWindow)aSheet modalDelegate:(id)aModalDelegate +- (void)_attachSheet:(CPWindow)aSheet modalDelegate:(id)aModalDelegate didEndSelector:(SEL)aDidEndSelector contextInfo:(id)aContextInfo { if (_sheetContext) { - [CPException raise:CPInternalInconsistencyException + [CPException raise:CPInternalInconsistencyException reason:@"The target window of beginSheet: already has a sheet, did you forget orderOut: ?"]; return; } var sheetFrame = [aSheet frame]; - - _sheetContext = {"sheet":aSheet, "modalDelegate":aModalDelegate, "endSelector":aDidEndSelector, - "contextInfo":aContextInfo, "frame":CGRectMakeCopy(sheetFrame), "returnCode":-1, + + _sheetContext = {"sheet":aSheet, "modalDelegate":aModalDelegate, "endSelector":aDidEndSelector, + "contextInfo":aContextInfo, "frame":CGRectMakeCopy(sheetFrame), "returnCode":-1, "opened": NO }; [self _attachSheetWindow]; } -/* @ignore +/* @ignore Called to animate the sheet in. The timer seems to solve a bug where sheets would be partially animated under certain conditions. */ @@ -2400,14 +2400,14 @@ CPTexturedBackgroundWindowMask _sheetContext["isAttached"] = YES; // it would be ideal to block here and spin an event loop, until attach is complete - [CPTimer scheduledTimerWithTimeInterval:0.0 - target:self + [CPTimer scheduledTimerWithTimeInterval:0.0 + target:self selector:@selector(_sheetShouldAnimateIn:) userInfo:nil repeats:NO]; } -/* @ignore +/* @ignore Called to end the sheet. Note that orderOut: is needed to animate the sheet out, as in Cocoa. The sheet isn't completely gone until _cleanupSheetWindow gets called. */ @@ -2421,15 +2421,15 @@ CPTexturedBackgroundWindowMask if (delegate != nil && endSelector != nil) { if (_sheetContext["isAttached"]) - objj_msgSend(delegate, endSelector, _sheetContext["sheet"], _sheetContext["returnCode"], + objj_msgSend(delegate, endSelector, _sheetContext["sheet"], _sheetContext["returnCode"], _sheetContext["contextInfo"]); else _sheetContext["deferDidEndSelector"] = YES; } } -/* @ignore - Called to animate the sheet out. If called while animating in, schedules an animate +/* @ignore + Called to animate the sheet out. If called while animating in, schedules an animate out at completion */ - (void)_detachSheetWindow @@ -2437,8 +2437,8 @@ CPTexturedBackgroundWindowMask _sheetContext["isAttached"] = NO; // it would be ideal to block here and spin the event loop, until attach is complete - [CPTimer scheduledTimerWithTimeInterval:0.0 - target:self + [CPTimer scheduledTimerWithTimeInterval:0.0 + target:self selector:@selector(_sheetShouldAnimateOut:) userInfo:nil repeats:NO]; @@ -2471,15 +2471,15 @@ CPTexturedBackgroundWindowMask if (deferDidEnd) { - var delegate = _sheetContext["modalDelegate"]; + var delegate = _sheetContext["modalDelegate"], selector = _sheetContext["endSelector"], returnCode = _sheetContext["returnCode"], - contextInfo = _sheetContext["contextInfo"], - + contextInfo = _sheetContext["contextInfo"]; + // context must be destroyed, since didEnd might want to attach another sheet _sheetContext = nil; sheet._parentView = nil; - + objj_msgSend(delegate, selector, sheet, returnCode, contextInfo); } else @@ -2496,8 +2496,8 @@ CPTexturedBackgroundWindowMask if (anim._window != sheet) return; - [CPTimer scheduledTimerWithTimeInterval:0.0 - target:self + [CPTimer scheduledTimerWithTimeInterval:0.0 + target:self selector:@selector(_sheetAnimationDidEnd:) userInfo:nil repeats:NO]; @@ -2511,10 +2511,10 @@ CPTexturedBackgroundWindowMask _sheetContext["isClosing"]) return; - var sheet = _sheetContext["sheet"] + var sheet = _sheetContext["sheet"], sheetFrame = [sheet frame], frame = [self frame]; - + [self _setUpMasksForView:[sheet contentView]]; sheet._isSheet = YES; @@ -2526,11 +2526,11 @@ CPTexturedBackgroundWindowMask endFrame = CGRectMake(originx, originy, sheetFrame.size.width, sheetFrame.size.height); [[CPNotificationCenter defaultCenter] postNotificationName:CPWindowWillBeginSheetNotification object:self]; - - // if sheet is attached to a modal window, the sheet runs + + // if sheet is attached to a modal window, the sheet runs // as if itself and the parent window are modal sheet._isModal = NO; - if ([CPApp modalWindow]===self) + if ([CPApp modalWindow] === self) { [CPApp runModalForWindow:sheet]; sheet._isModal = YES; @@ -2538,14 +2538,13 @@ CPTexturedBackgroundWindowMask [sheet orderFront:self]; [sheet setFrame:startFrame display:YES animate:NO]; - + _sheetContext["opened"] = YES; _sheetContext["shouldClose"] = NO; _sheetContext["isOpening"] = YES; - + [sheet _setFrame:endFrame delegate:self duration:[self animationResizeTime:endFrame] curve:CPAnimationEaseOut]; - // NOTE: cocoa doesn't make window key until animation is done, but a // keypress while animating eventually gets to the window. Therefore, // there must be a runloop specifically designed for sheets? @@ -2565,19 +2564,19 @@ CPTexturedBackgroundWindowMask _sheetContext["shouldClose"] = YES; return; } - + if (_sheetContext["isClosing"]) return; - + _sheetContext["opened"] = NO; _sheetContext["frame"] = startFrame; _sheetContext["isClosing"] = YES; - + // the parent window can be orderedOut to disable the sheet animate out, as in Cocoa if ([self isVisible]) { endFrame.size.height = 0; - [self _setUpMasksForView:[sheet contentView]]; + [self _setUpMasksForView:[sheet contentView]]; [sheet _setFrame:endFrame delegate:self duration:[self animationResizeTime:endFrame] curve:CPAnimationEaseIn]; } else diff --git a/AppKit/CPWindow/_CPStandardWindowView.j b/AppKit/CPWindow/_CPStandardWindowView.j index 97c716bc7..19ffc4d13 100644 --- a/AppKit/CPWindow/_CPStandardWindowView.j +++ b/AppKit/CPWindow/_CPStandardWindowView.j @@ -330,13 +330,13 @@ var STANDARD_GRADIENT_HEIGHT = 41.0, [_headView setFrameSize:CGSizeMake(width, [self toolbarMaxY])]; [_dividerView setFrame:CGRectMake(0.0, CGRectGetMaxY([_headView frame]), width, 1.0)]; - + var dividerMaxY = 0; if (![_dividerView isHidden]) dividerMaxY = CGRectGetMaxY([_dividerView frame]); - + [_bodyView setFrame:CGRectMake(0.0, dividerMaxY, width, CGRectGetHeight(bounds) - dividerMaxY)]; - + var leftOffset = 8; if (_closeButton) @@ -348,7 +348,7 @@ var STANDARD_GRADIENT_HEIGHT = 41.0, var contentRect = CGRectMake(0.0, dividerMaxY, width, CGRectGetHeight([_bodyView frame])); - [[theWindow contentView] setFrame:contentRect]; + [[theWindow contentView] setFrame:contentRect]; } /* - (void)setAnimatingToolbar:(BOOL)isAnimatingToolbar @@ -415,7 +415,7 @@ var STANDARD_GRADIENT_HEIGHT = 41.0, - (void)_enableSheet:(BOOL)enable { [super _enableSheet:enable]; - + [_headView setHidden:enable]; [_dividerView setHidden:enable]; [_closeButton setHidden:enable]; @@ -434,9 +434,10 @@ var STANDARD_GRADIENT_HEIGHT = 41.0, var dy = CGRectGetHeight([_headView frame]) + CGRectGetHeight([_dividerView frame]); if (enable) dy = -dy; - - var newHeight = CGRectGetMaxY(frame) + dy; - var newWidth = CGRectGetMaxX(frame); + + var newHeight = CGRectGetMaxY(frame) + dy, + newWidth = CGRectGetMaxX(frame); + frame.size.height += dy; [self setFrameSize:CGSizeMake(newWidth, newHeight)]; diff --git a/AppKit/CPWindow/_CPWindowView.j b/AppKit/CPWindow/_CPWindowView.j index a4e27e4af..5f5f7d635 100644 --- a/AppKit/CPWindow/_CPWindowView.j +++ b/AppKit/CPWindow/_CPWindowView.j @@ -41,7 +41,7 @@ var _CPWindowViewResizeIndicatorImage = nil; CGPoint _mouseDraggedPoint; CGRect _cachedScreenFrame; - + CPView _sheetShadowView; } @@ -208,13 +208,13 @@ var _CPWindowViewResizeIndicatorImage = nil; - (void)setFrameSize:(CGSize)newSize { [super setFrameSize:newSize]; - + // reposition sheet if the parent window resizes or moves var theWindow = [self window]; - + if ([theWindow attachedSheet]) [theWindow _setAttachedSheetFrameOrigin]; -} +} - (void)setShowsResizeIndicator:(BOOL)shouldShowResizeIndicator { @@ -386,7 +386,7 @@ var _CPWindowViewResizeIndicatorImage = nil; var bundle = [CPBundle bundleForClass:[CPWindow class]]; _sheetShadowView = [[CPView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([self bounds]), 8)]; [_sheetShadowView setAutoresizingMask:CPViewWidthSizable]; - [_sheetShadowView setBackgroundColor:[CPColor colorWithPatternImage:[[CPImage alloc] + [_sheetShadowView setBackgroundColor:[CPColor colorWithPatternImage:[[CPImage alloc] initWithContentsOfFile:[bundle pathForResource:@"CPWindow/CPWindowAttachedSheetShadow.png"] size:CGSizeMake(9,8)]]]; [self addSubview:_sheetShadowView]; }