From 60d15e2983d329740503750900f4270f23176dfb Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Wed, 3 Mar 2010 14:43:19 -0800 Subject: [PATCH 1/7] Revert "fix for scrollviews being drawn below window resize indicator." This reverts commit 18a0deb67860deb4afe3d7589ca43981f8738693. --- AppKit/CPScrollView.j | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/AppKit/CPScrollView.j b/AppKit/CPScrollView.j index 55955a4da..73cae512e 100644 --- a/AppKit/CPScrollView.j +++ b/AppKit/CPScrollView.j @@ -229,19 +229,6 @@ if (shouldShowHorizontalScroller) contentFrame.size.height -= horizontalScrollerHeight; - var _window = [self window], - forceCornerSpace = NO; - - if (_window && [_window contentView]) - { - var windowIsResizable = !!(([_window styleMask] & CPResizableWindowMask) || ([_window styleMask] & CPBorderlessBridgeWindowMask)), - relativeFrame = [self convertRect:[[_window contentView] frame] fromView:nil], - maxPoint = CGPointMake(CGRectGetMaxX([self bounds]), CGRectGetMaxY([self bounds])), - isInWindowCorner = CGRectGetMaxX(relativeFrame) >= maxPoint.x && CGRectGetMaxY(relativeFrame) >= maxPoint.y; - - forceCornerSpace = windowIsResizable && isInWindowCorner; - } - var scrollPoint = [_contentView bounds].origin, wasShowingVerticalScroller = ![_verticalScroller isHidden], wasShowingHorizontalScroller = ![_horizontalScroller isHidden]; @@ -251,7 +238,7 @@ var verticalScrollerY = MAX(_CGRectGetHeight([self _cornerViewFrame]), headerClipViewHeight), verticalScrollerHeight = _CGRectGetHeight([self bounds]) - verticalScrollerY; - if (forceCornerSpace || shouldShowHorizontalScroller) + if (shouldShowHorizontalScroller) verticalScrollerHeight -= horizontalScrollerHeight; [_verticalScroller setFloatValue:(difference.height <= 0.0) ? 0.0 : scrollPoint.y / difference.height]; @@ -268,7 +255,7 @@ { [_horizontalScroller setFloatValue:(difference.width <= 0.0) ? 0.0 : scrollPoint.x / difference.width]; [_horizontalScroller setKnobProportion:_CGRectGetWidth(contentFrame) / _CGRectGetWidth(documentFrame)]; - [_horizontalScroller setFrame:_CGRectMake(0.0, _CGRectGetMaxY(contentFrame), _CGRectGetWidth(contentFrame) - ((!shouldShowVerticalScroller && forceCornerSpace) ? verticalScrollerWidth : 0), horizontalScrollerHeight)]; + [_horizontalScroller setFrame:_CGRectMake(0.0, _CGRectGetMaxY(contentFrame), _CGRectGetWidth(contentFrame), horizontalScrollerHeight)]; } else if (wasShowingHorizontalScroller) { @@ -806,4 +793,4 @@ var CPScrollViewContentViewKey = "CPScrollViewContentView", [aCoder encodeObject:_cornerView forKey:CPScrollViewCornerViewKey]; } -@end \ No newline at end of file +@end From 2f68804279ac590f9cc3bfbee9b95ac12581a0db Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Wed, 3 Mar 2010 14:43:25 -0800 Subject: [PATCH 2/7] Revert "fix for scroller still being drawn below resize indicator on the first reflect of the clipview." This reverts commit fa63551b42bf41c33537d6ebd7f8fadf434c2903. --- AppKit/CPScrollView.j | 5 ----- 1 file changed, 5 deletions(-) diff --git a/AppKit/CPScrollView.j b/AppKit/CPScrollView.j index 73cae512e..6406c96fb 100644 --- a/AppKit/CPScrollView.j +++ b/AppKit/CPScrollView.j @@ -720,11 +720,6 @@ [_headerClipView scrollToPoint:CGPointMake(contentBounds.origin, 0)]; } -- (void)viewDidMoveToWindow -{ - [self reflectScrolledClipView:_contentView]; -} - @end var CPScrollViewContentViewKey = "CPScrollViewContentView", From 3cd763aabb46d56d3cbb9cd2095d3f7f99f19958 Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Wed, 3 Mar 2010 19:42:16 -0800 Subject: [PATCH 3/7] Add #if PLATFORM(DOM) in a missing place in CPView. --- AppKit/CPView.j | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/AppKit/CPView.j b/AppKit/CPView.j index a04a4dc59..90685cb6c 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -528,6 +528,7 @@ var CPViewFlags = { }, _subviews = [newSubviews copy]; +#if PLATFORM(DOM) var index = 0, count = [_subviews count]; @@ -538,6 +539,7 @@ var CPViewFlags = { }, CPDOMDisplayServerRemoveChild(_DOMElement, subview._DOMElement); CPDOMDisplayServerAppendChild(_DOMElement, subview._DOMElement); } +#endif } /* @ignore */ @@ -1756,8 +1758,9 @@ setBoundsOrigin: _DOMContentsElement.style.width = ROUND(_CGRectGetWidth(_frame)) + "px"; _DOMContentsElement.style.height = ROUND(_CGRectGetHeight(_frame)) + "px"; +#if PLATFORM(DOM) CPDOMDisplayServerAppendChild(_DOMElement, _DOMContentsElement); - +#endif _graphicsContext = [CPGraphicsContext graphicsContextWithGraphicsPort:graphicsPort flipped:YES]; } From 0b5db9c4bde619d69538634e06c2daa53916cf88 Mon Sep 17 00:00:00 2001 From: Scott Kyle Date: Wed, 3 Mar 2010 20:02:55 -0800 Subject: [PATCH 4/7] Fix CPArray initWithArray: copyItems: to actually work --- Foundation/CPArray.j | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Foundation/CPArray.j b/Foundation/CPArray.j index eeb8bad8b..39ab864b3 100755 --- a/Foundation/CPArray.j +++ b/Foundation/CPArray.j @@ -209,13 +209,13 @@ var index = 0, count = [anArray count]; - for(; index < count; ++i) + for(; index < count; ++index) { - if (anArray[i].isa) - self[i] = [anArray copy]; + if (anArray[index].isa) + self[index] = [anArray[index] copy]; // Do a deep/shallow copy? else - self[i] = anArray; + self[index] = anArray; } } From e034abef822024f13221d18aec9249384ef2650e Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Wed, 3 Mar 2010 20:38:56 -0800 Subject: [PATCH 5/7] Add a test for the initWithItems:copy: fix. --- Tests/Foundation/CPArrayTest.j | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Tests/Foundation/CPArrayTest.j b/Tests/Foundation/CPArrayTest.j index 04ea56486..f195d99f8 100644 --- a/Tests/Foundation/CPArrayTest.j +++ b/Tests/Foundation/CPArrayTest.j @@ -155,6 +155,14 @@ } } +- (void)testInitWithArrayCopyItems +{ + var a = [[CopyableObject new], 2, 3]; + var b = [[CPArray alloc] initWithArray:a copyItems:YES]; + + [self assert:a notEqual:b]; +} + @end @implementation CPArray (reverse) @@ -169,3 +177,14 @@ } @end + +@implementation CopyableObject : CPObject +{ +} + +- (id)copy +{ + return [[[self class] alloc] init]; +} + +@end From 7512a45cdab9d6b427b023c9a7eaa8283f2b7c0b Mon Sep 17 00:00:00 2001 From: Ross Boucher Date: Wed, 3 Mar 2010 21:20:00 -0800 Subject: [PATCH 6/7] Add #if PLATFORM(DOM) protection to several additional classes. --- AppKit/CPColorPicker.j | 4 ++++ AppKit/CPFlashView.j | 17 +++++++++++++---- AppKit/CPSliderColorPicker.j | 34 +++++++++++++++++++++++++--------- 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/AppKit/CPColorPicker.j b/AppKit/CPColorPicker.j index f8e89f334..8d4ed20c4 100644 --- a/AppKit/CPColorPicker.j +++ b/AppKit/CPColorPicker.j @@ -23,6 +23,8 @@ @import @import "CPColorPanel.j" +#include "Platform/Platform.h" + /*! @ingroup appkit @class CPColorPicker @@ -239,8 +241,10 @@ _blackWheelImage.style.filter = "alpha(opacity=0)" _blackWheelImage.style.position = "absolute"; +#if PLATFORM(DOM) _DOMElement.appendChild(_wheelImage); _DOMElement.appendChild(_blackWheelImage); +#endif [self setWheelSize:aFrame.size]; diff --git a/AppKit/CPFlashView.j b/AppKit/CPFlashView.j index 8f1d99fa8..d3dc99f48 100644 --- a/AppKit/CPFlashView.j +++ b/AppKit/CPFlashView.j @@ -23,6 +23,7 @@ @import "CPFlashMovie.j" @import "CPView.j" +#include "Platform/Platform.h" var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; @@ -35,10 +36,11 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; CPDictionary _params; CPDictionary _paramElements; - +#if PLATFORM(DOM) DOMElement _DOMParamElement; DOMElement _DOMObjectElement; DOMElement _DOMInnerObjectElement; +#endif } - (id)initWithFrame:(CGRect)aFrame @@ -47,6 +49,7 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; if (self) { +#if PLATFORM(DOM) if (!CPBrowserIsEngine(CPInternetExplorerBrowserEngine)) { _DOMObjectElement = document.createElement(@"object"); @@ -71,6 +74,7 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; } else [self _rebuildIEObjects]; +#endif } return self; @@ -82,7 +86,7 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; return; _flashMovie = aFlashMovie; - +#if PLATFORM(DOM) if (!CPBrowserIsEngine(CPInternetExplorerBrowserEngine)) { _DOMParamElement.value = [aFlashMovie filename]; @@ -90,6 +94,7 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; } else [self _rebuildIEObjects]; +#endif } - (CPFlashMovie)flashMovie @@ -120,6 +125,7 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; - (void)setParameters:(CPDictionary)aDictionary { +#if PLATFORM(DOM) if (_paramElements && !CPBrowserIsEngine(CPInternetExplorerBrowserEngine)) { var elements = [_paramElements allValues], @@ -128,9 +134,9 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; for (var i = 0; i < count; i++) _DOMObjectElement.removeChild([elements objectAtIndex:i]); } - +#endif _params = aDictionary; - +#if PLATFORM(DOM) if (!CPBrowserIsEngine(CPInternetExplorerBrowserEngine)) { _paramElements = [CPDictionary dictionary]; @@ -151,6 +157,7 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; } else [self _rebuildIEObjects]; +#endif } - (CPDictionary)parameters @@ -158,6 +165,7 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; return _params; } +#if PLATFORM(DOM) - (void)_rebuildIEObjects { _DOMElement.innerHTML = @""; @@ -176,6 +184,7 @@ var IEFlashCLSID = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; _DOMObjectElement.outerHTML = [CPString stringWithFormat:@"%@", IEFlashCLSID, CGRectGetWidth([self bounds]), CGRectGetHeight([self bounds]), paramString]; } +#endif - (void)mouseDragged:(CPEvent)anEvent { diff --git a/AppKit/CPSliderColorPicker.j b/AppKit/CPSliderColorPicker.j index 05bd5b6b5..66267c647 100644 --- a/AppKit/CPSliderColorPicker.j +++ b/AppKit/CPSliderColorPicker.j @@ -45,14 +45,16 @@ CPTextField _saturationLabel; CPTextField _brightnessLabel; CPTextField _hexLabel; - + +#if PLATFORM(DOM) DOMElement _redValue; DOMElement _greenValue; DOMElement _blueValue; DOMElement _hueValue; DOMElement _saturationValue; DOMElement _brightnessValue; - DOMElement _hexValue; + DOMElement _hexValue; +#endif } - (id)initWithPickerMask:(int)mask colorPanel:(CPColorPanel)owningColorPanel @@ -81,7 +83,8 @@ [_redSlider setTarget: self]; [_redSlider setAction: @selector(sliderChanged:)]; [_redSlider setAutoresizingMask: CPViewWidthSizable]; - + +#if PLATFORM(DOM) var updateFunction = function(aDOMEvent) { if(isNaN(this.value)) @@ -147,6 +150,7 @@ redValue._DOMElement.appendChild(_redValue); [_contentView addSubview: redValue]; +#endif _greenLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 58, 15, 20)]; [_greenLabel setStringValue: "G"]; @@ -159,6 +163,7 @@ [_greenSlider setAction: @selector(sliderChanged:)]; [_greenSlider setAutoresizingMask: CPViewWidthSizable]; +#if PLATFORM(DOM) //green value input box var greenValue = [[CPView alloc] initWithFrame: CPRectMake(aFrame.size.width - 45, 58, 45, 20)]; [greenValue setAutoresizingMask: CPViewMinXMargin]; @@ -168,6 +173,7 @@ greenValue._DOMElement.appendChild(_greenValue); [_contentView addSubview: greenValue]; +#endif _blueLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 81, 15, 20)]; [_blueLabel setStringValue: "B"]; @@ -180,6 +186,7 @@ [_blueSlider setAction: @selector(sliderChanged:)]; [_blueSlider setAutoresizingMask: CPViewWidthSizable]; +#if PLATFORM(DOM) //blue value input box var blueValue = [[CPView alloc] initWithFrame: CPRectMake(aFrame.size.width - 45, 81, 45, 20)]; [blueValue setAutoresizingMask: CPViewMinXMargin]; @@ -189,7 +196,7 @@ blueValue._DOMElement.appendChild(_blueValue); [_contentView addSubview: blueValue]; - +#endif _hsbLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 120, 190, 20)]; [_hsbLabel setStringValue: "Hue, Saturation, Brightness"]; [_hsbLabel setTextColor:[CPColor blackColor]]; @@ -205,6 +212,7 @@ [_hueSlider setAction: @selector(sliderChanged:)]; [_hueSlider setAutoresizingMask: CPViewWidthSizable]; +#if PLATFORM(DOM) //red value input box var hueValue = [[CPView alloc] initWithFrame: CPRectMake(aFrame.size.width - 45, 145, 45, 20)]; [hueValue setAutoresizingMask: CPViewMinXMargin]; @@ -214,7 +222,7 @@ hueValue._DOMElement.appendChild(_hueValue); [_contentView addSubview: hueValue]; - +#endif _saturationLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 168, 15, 20)]; [_saturationLabel setStringValue: "S"]; [_saturationLabel setTextColor:[CPColor blackColor]]; @@ -226,6 +234,7 @@ [_saturationSlider setAction: @selector(sliderChanged:)]; [_saturationSlider setAutoresizingMask: CPViewWidthSizable]; +#if PLATFORM(DOM) //green value input box var saturationValue = [[CPView alloc] initWithFrame: CPRectMake(aFrame.size.width - 45, 168, 45, 20)]; [saturationValue setAutoresizingMask: CPViewMinXMargin]; @@ -235,7 +244,7 @@ saturationValue._DOMElement.appendChild(_saturationValue); [_contentView addSubview: saturationValue]; - +#endif _brightnessLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 191, 15, 20)]; [_brightnessLabel setStringValue: "B"]; [_brightnessLabel setTextColor:[CPColor blackColor]]; @@ -247,6 +256,7 @@ [_brightnessSlider setAction: @selector(sliderChanged:)]; [_brightnessSlider setAutoresizingMask: CPViewWidthSizable]; +#if PLATFORM(DOM) //blue value input box var brightnessValue = [[CPView alloc] initWithFrame: CPRectMake(aFrame.size.width - 45, 191, 45, 20)]; [brightnessValue setAutoresizingMask: CPViewMinXMargin]; @@ -256,11 +266,12 @@ brightnessValue._DOMElement.appendChild(_brightnessValue); [_contentView addSubview: brightnessValue]; - +#endif _hexLabel = [[CPTextField alloc] initWithFrame: CPRectMake(0, 230, 30, 20)]; [_hexLabel setStringValue: "Hex"]; [_hexLabel setTextColor:[CPColor blackColor]]; - + +#if PLATFORM(DOM) //hex input box _hexValue = _redValue.cloneNode(false); _hexValue.style.top = "228px"; @@ -289,7 +300,8 @@ }; _contentView._DOMElement.appendChild(_hexValue); - +#endif + [_contentView addSubview: _rgbLabel]; [_contentView addSubview: _redLabel]; [_contentView addSubview: _greenLabel]; @@ -380,7 +392,9 @@ - (void)updateHex:(CPColor)aColor { +#if PLATFORM(DOM) _hexValue.value = [aColor hexString]; +#endif } - (void)updateRGBSliders:(CPColor)aColor @@ -394,6 +408,7 @@ - (void)updateLabels { +#if PLATFORM(DOM) _hueValue.value = ROUND([_hueSlider floatValue]); _saturationValue.value = ROUND([_saturationSlider floatValue]); _brightnessValue.value = ROUND([_brightnessSlider floatValue]); @@ -401,6 +416,7 @@ _redValue.value = ROUND([_redSlider floatValue] * 255); _greenValue.value = ROUND([_greenSlider floatValue] * 255); _blueValue.value = ROUND([_blueSlider floatValue] * 255); +#endif } - (CPImage)provideNewButtonImage From 64357fde0d96d34bfb82d3a9d775de5cd584d722 Mon Sep 17 00:00:00 2001 From: Randall Luecke Date: Thu, 4 Mar 2010 14:04:15 -0500 Subject: [PATCH 7/7] Fixed bug where you could drag non-existant rows. Closes #520 and #521 --- AppKit/CPTableView.j | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j index 14d85b370..fdc58db0d 100644 --- a/AppKit/CPTableView.j +++ b/AppKit/CPTableView.j @@ -2553,7 +2553,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; // if the table has drag support then we use mouseUp to select a single row. // otherwise it uses mouse down. - if (!(_implementedDataSourceMethods & CPTableViewDataSource_tableView_writeRowsWithIndexes_toPasteboard_)) + if (row >=0 && !(_implementedDataSourceMethods & CPTableViewDataSource_tableView_writeRowsWithIndexes_toPasteboard_)) [self _updateSelectionWithMouseAtRow:row]; [[self window] makeFirstResponder:self]; @@ -2583,7 +2583,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; // or we're dragging from selected rows and we haven't begun a drag session if(!_isSelectingSession && _implementedDataSourceMethods & CPTableViewDataSource_tableView_writeRowsWithIndexes_toPasteboard_) { - if ((ABS(_startTrackingPoint.x - aPoint.x) > 3 || (_verticalMotionCanDrag && ABS(_startTrackingPoint.y - aPoint.y) > 3)) || + if (row >= 0 && (ABS(_startTrackingPoint.x - aPoint.x) > 3 || (_verticalMotionCanDrag && ABS(_startTrackingPoint.y - aPoint.y) > 3)) || ([_selectedRowIndexes containsIndex:row])) { if ([_selectedRowIndexes containsIndex:row]) @@ -2641,8 +2641,8 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5; } _isSelectingSession = YES; - [self _updateSelectionWithMouseAtRow:row]; - [self _updateSelectionWithMouseAtRow:[self rowAtPoint:aPoint]]; + if(row >= 0) + [self _updateSelectionWithMouseAtRow:row]; if ((_implementedDataSourceMethods & CPTableViewDataSource_tableView_setObjectValue_forTableColumn_row_) && !_trackingPointMovedOutOfClickSlop)