Compare commits

...
67 Commits
Author SHA1 Message Date
Tom Robinson e719978079 Re-enable flatten compression by default. 2010-04-01 23:49:23 -07:00
Tom Robinson fe3e7795b2 Add charset attributes to all external script tags, including flatten. Fixes unicode bugs in flatten. 2010-04-01 23:39:14 -07:00
Tom Robinson 8f1972799d Add some charset options, and disable compressor by default. 2010-04-01 23:16:25 -07:00
Tom Robinson 5858360b4c Add comrpessor support to flatten. 2010-04-01 12:01:45 -07:00
Tom Robinson a9d71ca6dd Fixes flatten, splitting mode. Also escape dollar signs before replacing. 2010-04-01 11:08:47 -07:00
Tom Robinson f2be5b49d0 Fixes flatten, non-splitting mode. 2010-04-01 10:57:17 -07:00
Tom Robinson f90e98baaa Only enable debug logger in browsers, not command line utilities. 2010-03-31 17:29:09 -07:00
Francisco Ryan Tolmasky I 6d150e6609 Fix for menu bar being broken if displayed after a window is ordered front in IE.
Reviewed by me.
2010-03-31 17:08:05 -07:00
Paul BaumgartandTom Robinson 222900aa2a Add some dependency checking to bootstrap.sh: make sure correct JVM is
being used and ensure other dependencies are installed and on the $PATH.
2010-03-31 15:02:17 -07:00
Tom Robinson 0e18551500 Use "CommonJS" task as the dependency for "test" task for now. 2010-03-31 13:52:17 -07:00
Randall Luecke 3ec5c2fc6c Made drag feedback view in the tableview more correct, fixed encoding issues. 2010-03-31 16:06:35 -04:00
Ross Boucher 2e6061a5f3 Fix for a potential error in IE when setting a width to a negative value. 2010-03-31 11:09:14 -07:00
Francisco Ryan Tolmasky I f67dfd85ef Fix for loading Cappuccino apps locally on Windows.
Reviewed by me.
2010-03-30 16:30:45 -07:00
Tom Robinson 3712da3bba Enable default logger in debug frameworks. Add configurable options to index-debug.html. 2010-03-30 14:16:10 -07:00
Ross Boucher 862e8db063 Sprite images recursively. 2010-03-30 12:09:35 -07:00
Ross Boucher db13748e6c Revert "Add guard div to protect against iframes consuming events during tracking."
This reverts commit 0e4d476d76.
2010-03-30 10:59:53 -07:00
Ross Boucher 77a648db94 Fix a nil variable error that caused problems in Firefox 2. 2010-03-30 10:58:54 -07:00
Francisco Ryan Tolmasky I e3cb8c4264 One more fix for image spriting.
Reviewed by me.
2010-03-30 00:46:01 -07:00
Francisco Ryan Tolmasky I 83fade3b29 Fail more gracefully when main cib is not found.
Reviewed by me.
2010-03-29 23:28:48 -07:00
Randall Luecke f9a111bfec Fixed nib2cib bug with cornerview where resources were not loaded from the correct location. 2010-03-30 01:42:24 -04:00
Francisco Ryan Tolmasky I 12433558fa Fix for a few minor regressions:
1. Split out flatten specific code to get file size back down.
2. Fix for non-native string URL not working with the URLCache (typeof x !=== "string")
3. Fix for slight IE performance regression.

Reviewed by me.
2010-03-28 15:04:42 -07:00
Francisco Ryan Tolmasky I 466593e820 Fix for HelloWorld not flattening correctly.
Reviewed by me.
2010-03-28 15:04:42 -07:00
Francisco Ryan Tolmasky I bbfc1feaaf Fix for user code errors during load not being reported (Cappuccino failing silently).
Reviewed by me.
2010-03-28 15:04:42 -07:00
Francisco Ryan Tolmasky I ee36e8ba5c Don't generate image files if there aren't any.
Reviewed by me.
2010-03-28 15:04:42 -07:00
Ross BoucherandFrancisco Ryan Tolmasky I f51ed977a2 Update the CPDictionary test suite. 2010-03-28 15:04:42 -07:00
Emmanuel MaillardandFrancisco Ryan Tolmasky I e5a37f69dd - add containsKey: method 2010-03-28 15:04:42 -07:00
Ross BoucherandFrancisco Ryan Tolmasky I cb1440d550 define out DOM code from _CPImageAndTextView.
Closes #562.
2010-03-28 15:04:42 -07:00
Ross BoucherandFrancisco Ryan Tolmasky I ce9fb31b80 CPBox should autoresize its content view. 2010-03-28 15:04:42 -07:00
Ross BoucherandFrancisco Ryan Tolmasky I f568629685 Whitespace fix. 2010-03-28 15:04:42 -07:00
Emmanuel MaillardandFrancisco Ryan Tolmasky I 9975c1f20f - CGPathAddQuadCurveToPoint fix for an unknown variable when using a transformation matrix 2010-03-28 15:04:42 -07:00
Francisco Ryan Tolmasky I f4585dc2f0 Fix for unrecognized selector in CPURL's initWithCoder:.
Reviewed by me.
2010-03-28 15:04:42 -07:00
Ross BoucherandFrancisco Ryan Tolmasky I baa7946039 Typo. Closes #572. 2010-03-28 15:04:42 -07:00
Scott KyleandFrancisco Ryan Tolmasky I 9cc2d40a8a Some somewhat minor style fixes 2010-03-28 15:04:42 -07:00
Ross BoucherandFrancisco Ryan Tolmasky I 0f3fd2ddb7 Remove duplicate method declaration. 2010-03-28 15:04:42 -07:00
Ross BoucherandFrancisco Ryan Tolmasky I 63845c9015 Missing - on a method. 2010-03-28 15:04:41 -07:00
Francisco Ryan Tolmasky I 62c87d1236 Fixed a bug where CPKeyedUnarchiver would incorrectly unarchive 0 as null.
Reviewed by me.
2010-03-28 15:04:41 -07:00
Randall LueckeandFrancisco Ryan Tolmasky I b1c633c18b Fixed black background of dragview in Opera and IE. 2010-03-28 15:04:41 -07:00
Ross BoucherandFrancisco Ryan Tolmasky I d7a17811dc Use === not ==. 2010-03-28 15:04:41 -07:00
Alan RogersandFrancisco Ryan Tolmasky I d5cea283d4 Updated test and fix for gh issue #539 2010-03-28 15:04:41 -07:00
Alan RogersandFrancisco Ryan Tolmasky I 564399c78b Little fix for CPDictionary, we should not try and recursively convert null JSON objects. 2010-03-28 15:04:41 -07:00
Alan RogersandFrancisco Ryan Tolmasky I d5dcedcb4a Adding a unit test to verify fix to +[CPDictionary dictionaryWithJSObject:(JSObject)object recursively:(BOOL)recursively] 2010-03-28 15:04:41 -07:00
Emmanuel MaillardandFrancisco Ryan Tolmasky I 6c24828c40 - fix typo 2010-03-28 15:04:41 -07:00
Emmanuel MaillardandFrancisco Ryan Tolmasky I 620e7f9306 - fix a typo in documentation 2010-03-28 15:04:41 -07:00
Scott KyleandFrancisco Ryan Tolmasky I f27fe2011b deleteBackwards: => deleteBackward: 2010-03-28 15:04:41 -07:00
aburkhalterandFrancisco Ryan Tolmasky I bdcc112797 Trivial syntax fixes. 2010-03-28 15:04:41 -07:00
Francisco Ryan Tolmasky I 9dfec49b09 Fix for empty data URLs, MHTML, etc. files being created when no image resources exist, causing a useless xhr.
Reviewed by me.
2010-03-28 15:04:41 -07:00
Randall LueckeandFrancisco Ryan Tolmasky I 851632c2d5 Fixed default height in tableheader for Nib2Cib. 2010-03-28 15:04:41 -07:00
Tom RobinsonandFrancisco Ryan Tolmasky I d47cbc4453 Add --split option to flatten. Asynchronously load multiple flattened files. 2010-03-28 15:04:41 -07:00
Tom RobinsonandFrancisco Ryan Tolmasky I 32605ccd12 Fix for flatten in Firefox (silly security restriction makes onreadystatechange not readable) 2010-03-28 15:04:41 -07:00
Francisco Ryan Tolmasky I 9cb7951624 Slight fix for collectionView:canDragItemsAtIndexes:withEvent: not passing the correct event.
Reviewed by me.
2010-03-28 15:04:41 -07:00
Francisco Ryan Tolmasky I a1f0437555 Added collectionView:canDragItemAtIndexes:forEvent:.
Reviewed by me.
2010-03-28 15:04:41 -07:00
Francisco Ryan Tolmasky I 85693139a6 Added itemAtIndex: to CPCollectionView and updates API names.
Reviewed by me.
2010-03-28 15:04:40 -07:00
Randall LueckeandFrancisco Ryan Tolmasky I c11bf5aae1 Fixed TableTest for IE. 2010-03-28 15:04:40 -07:00
Tom RobinsonandFrancisco Ryan Tolmasky I cb6ef75283 Refactor objj_eval to work in the browser. Move from CommonJS-specific code to Objective-J proper. 2010-03-28 15:04:40 -07:00
Tom RobinsonandFrancisco Ryan Tolmasky I 8d02ba7b53 Add default theme to flattened app, "-P" option for specifying other inlined files. 2010-03-28 15:04:40 -07:00
Tom RobinsonandFrancisco Ryan Tolmasky I 47f596935a Make asyncLoader a configurable option on exports. 2010-03-28 15:04:40 -07:00
Tom RobinsonandFrancisco Ryan Tolmasky I ca0eda08a4 Fix objj_eval (used in objj REPL, etc). 2010-03-28 15:04:40 -07:00
Randall LueckeandFrancisco Ryan Tolmasky I 22afcd453c Fixed failed TableCibTest in Firefox. 2010-03-28 15:04:40 -07:00
Randall LueckeandFrancisco Ryan Tolmasky I 55fd42c2ce Various nib2cib improvements on the tableview. 2010-03-28 15:04:40 -07:00
Ross BoucherandFrancisco Ryan Tolmasky I bed1485aef Remove two calls to a dead function. 2010-03-28 15:04:40 -07:00
Randall LueckeandFrancisco Ryan Tolmasky I 23840b1230 Fixed Nib2Cib selection color for the tableview. 2010-03-28 15:04:40 -07:00
Ross BoucherandFrancisco Ryan Tolmasky I 49e0b2ba9f Fix for sizeWithFont: in Internet Explorer. 2010-03-28 15:04:40 -07:00
Tom RobinsonandFrancisco Ryan Tolmasky I 02462cdca6 Typo in window.clearNativeInterval. 2010-03-28 15:04:40 -07:00
Randall LueckeandFrancisco Ryan Tolmasky I 7a5f8cacb0 Fixed bug with nib2cib tableviews loading incorrect resources. 2010-03-28 15:04:40 -07:00
Ross BoucherandFrancisco Ryan Tolmasky I 98d9f43a44 A few minor bug fixes for key/main window handling. 2010-03-28 15:04:40 -07:00
Tom RobinsonandFrancisco Ryan Tolmasky I 4f5f4b187d Update flatten to use new file/function caching system. 2010-03-28 15:04:40 -07:00
Tom RobinsonandFrancisco Ryan Tolmasky I 7db5411f25 Add CFHTTPRequest and FileExecutable hooks for inlining files and module functions (for flatten). Removed hook used by flatten. 2010-03-28 15:04:40 -07:00
63 changed files with 950 additions and 592 deletions
+10 -8
View File
@@ -860,12 +860,11 @@ CPRunContinuesResponse = -1002;
if ([windowController respondsToSelector:anAction]) if ([windowController respondsToSelector:anAction])
return windowController; return windowController;
var theDocument = [windowController document]; var theDocument = [windowController document];
if (theDocument !== delegate && [theDocument respondsToSelector:anAction])
if (theDocument != delegate && [theDocument respondsToSelector:anAction])
return theDocument; return theDocument;
return nil; return nil;
} }
@@ -874,7 +873,7 @@ CPRunContinuesResponse = -1002;
Checks for a target in the following order: Checks for a target in the following order:
<ol> <ol>
<li>a responder from the key window</li> <li>a responder from the key window</li>
<li>a responder frmo the main window</li> <li>a responder from the main window</li>
<li>the CPApplication instance</li> <li>the CPApplication instance</li>
<li>the application delegate</li> <li>the application delegate</li>
<li>the document controller</li> <li>the document controller</li>
@@ -913,8 +912,6 @@ CPRunContinuesResponse = -1002;
- (void)setCallback:(Function)aCallback forNextEventMatchingMask:(unsigned int)aMask untilDate:(CPDate)anExpiration inMode:(CPString)aMode dequeue:(BOOL)shouldDequeue - (void)setCallback:(Function)aCallback forNextEventMatchingMask:(unsigned int)aMask untilDate:(CPDate)anExpiration inMode:(CPString)aMode dequeue:(BOOL)shouldDequeue
{ {
_eventListeners.push(_CPEventListenerMake(aMask, aCallback)); _eventListeners.push(_CPEventListenerMake(aMask, aCallback));
if (_eventListeners.length == 3) objj_debug_print_backtrace();
} }
- (CPEvent)setTarget:(id)aTarget selector:(SEL)aSelector forNextEventMatchingMask:(unsigned int)aMask untilDate:(CPDate)anExpiration inMode:(CPString)aMode dequeue:(BOOL)shouldDequeue - (CPEvent)setTarget:(id)aTarget selector:(SEL)aSelector forNextEventMatchingMask:(unsigned int)aMask untilDate:(CPDate)anExpiration inMode:(CPString)aMode dequeue:(BOOL)shouldDequeue
@@ -1063,7 +1060,7 @@ CPRunContinuesResponse = -1002;
else if ([self mainWindow]) else if ([self mainWindow])
[[self mainWindow] makeKeyAndOrderFront:self]; [[self mainWindow] makeKeyAndOrderFront:self];
else else
[[[self mainMenu] window] makeKeyWindow]; //FIXME this may not actually work [[self mainMenu]._menuWindow makeKeyWindow]; //FIXME this may not actually work
_previousKeyWindow = nil; _previousKeyWindow = nil;
_previousMainWindow = nil; _previousMainWindow = nil;
@@ -1227,6 +1224,11 @@ var _CPAppBootstrapperActions = nil;
[self performActions]; [self performActions];
} }
+ (void)cibDidFailToLoad:(CPCib)aCib
{
throw new Error("Could not load main cib file (Did you forget to nib2cib it?).");
}
+ (void)reset + (void)reset
{ {
_CPAppBootstrapperActions = nil; _CPAppBootstrapperActions = nil;
+1
View File
@@ -162,6 +162,7 @@ CPGrooveBorder = 3;
[aView setFrame:CGRectInset([self bounds], _contentMargin.width + _borderWidth, _contentMargin.height + _borderWidth)]; [aView setFrame:CGRectInset([self bounds], _contentMargin.width + _borderWidth, _contentMargin.height + _borderWidth)];
[self replaceSubview:_contentView with:aView]; [self replaceSubview:_contentView with:aView];
[aView setAutoresizingMask:CPViewWidthSizable|CPViewHeightSizable];
_contentView = aView; _contentView = aView;
} }
+2 -5
View File
@@ -502,8 +502,6 @@ CPButtonStateMixed = CPThemeState("mixed");
} }
else else
return [[_CPImageAndTextView alloc] initWithFrame:_CGRectMakeZero()]; return [[_CPImageAndTextView alloc] initWithFrame:_CGRectMakeZero()];
return [super createEphemeralSubviewNamed:aName];
} }
- (void)layoutSubviews - (void)layoutSubviews
@@ -511,9 +509,8 @@ CPButtonStateMixed = CPThemeState("mixed");
var bezelView = [self layoutEphemeralSubviewNamed:@"bezel-view" var bezelView = [self layoutEphemeralSubviewNamed:@"bezel-view"
positioned:CPWindowBelow positioned:CPWindowBelow
relativeToEphemeralSubviewNamed:@"content-view"]; relativeToEphemeralSubviewNamed:@"content-view"];
if (bezelView) [bezelView setBackgroundColor:[self currentValueForThemeAttribute:@"bezel-color"]];
[bezelView setBackgroundColor:[self currentValueForThemeAttribute:@"bezel-color"]];
var contentView = [self layoutEphemeralSubviewNamed:@"content-view" var contentView = [self layoutEphemeralSubviewNamed:@"content-view"
positioned:CPWindowAbove positioned:CPWindowAbove
+14 -6
View File
@@ -120,9 +120,13 @@
[super setBoundsOrigin:aPoint]; [super setBoundsOrigin:aPoint];
var superview = [self superview]; var superview = [self superview],
if([superview isKindOfClass:[CPScrollView class]]) // This is hack to avoid having to import CPScrollView.
// FIXME: Should CPScrollView be finding out about this on its own somehow?
scrollViewClass = objj_getClass("CPScrollView");
if([superview isKindOfClass:scrollViewClass])
[superview reflectScrolledClipView:self]; [superview reflectScrolledClipView:self];
} }
@@ -173,9 +177,13 @@
return; return;
// ... and we're in a scroll view of course. // ... and we're in a scroll view of course.
var superview = [self superview]; var superview = [self superview],
if ([superview isKindOfClass:[CPScrollView class]]) // This is hack to avoid having to import CPScrollView.
// FIXME: Should CPScrollView be finding out about this on its own somehow?
scrollViewClass = objj_getClass("CPScrollView");
if ([superview isKindOfClass:scrollViewClass])
[superview reflectScrolledClipView:self]; [superview reflectScrolledClipView:self];
} }
+55 -30
View File
@@ -597,6 +597,10 @@
if (![_selectionIndexes count]) if (![_selectionIndexes count])
return; return;
if ([_delegate respondsToSelector:@selector(collectionView:canDragItemsAtIndexes:withEvent:)] &&
![_delegate collectionView:self canDragItemsAtIndexes:_selectionIndexes withEvent:_mouseDownEvent])
return;
// Set up the pasteboard // Set up the pasteboard
var dragTypes = [_delegate collectionView:self dragTypesForItemsAtIndexes:_selectionIndexes]; var dragTypes = [_delegate collectionView:self dragTypesForItemsAtIndexes:_selectionIndexes];
@@ -676,41 +680,42 @@
return _delegate; return _delegate;
} }
- (CPCollectionViewItem)itemAtIndex:(unsigned)anIndex
{
return [_items objectAtIndex:anIndex];
}
- (CGRect)frameForItemAtIndex:(unsigned)anIndex
{
return [[[self itemAtIndex:anIndex] view] frame];
}
- (CGRect)frameForItemsAtIndexes:(CPIndexSet)anIndexSet
{
var indexArray = [],
frame = CGRectNull;
[anIndexSet getIndexes:indexArray maxCount:-1 inIndexRange:nil];
var index = 0,
count = [indexArray count];
for (; index < count; ++index)
frame = CGRectUnion(frame, [self rectForItemAtIndex:indexArray[index]]);
return frame;
}
@end @end
@implementation CPCollectionView (KeyboardInteraction) @implementation CPCollectionView (KeyboardInteraction)
- (CGRect)rectForItemAtIndex:(int)index
{
// Don't re-compute anything just grab the current frame
// This allows subclasses to override tile without messing this up.
return [[_items[index] view] frame];
}
- (CGRect)rectForItemsAtIndexes:(CPIndexSet)indexSet
{
var indexArray = [],
rect = nil;
[indexSet getIndexes:indexArray maxCount:-1 inIndexRange:nil];
for (var i = 0, count = indexArray.length; i < count; ++i)
{
var index = indexArray[i];
if (rect == nil)
rect = [self rectForItemAtIndex:index];
else
rect = CGRectUnion(rect, [self rectForItemAtIndex:index]);
}
return rect;
}
- (void)_scrollToSelection - (void)_scrollToSelection
{ {
var rect = [self rectForItemsAtIndexes:[self selectionIndexes]]; var frame = [self frameForItemsAtIndexes:[self selectionIndexes]];
if (rect)
[self scrollRectToVisible:rect]; if (!CGRectIsNull(frame))
[self scrollRectToVisible:frame];
} }
- (void)moveLeft:(id)sender - (void)moveLeft:(id)sender
@@ -753,7 +758,7 @@
[self _scrollToSelection]; [self _scrollToSelection];
} }
- (void)deleteBackwards:(id)sender - (void)deleteBackward:(id)sender
{ {
if ([[self delegate] respondsToSelector:@selector(collectionView:shouldDeleteItemsAtIndexes:)]) if ([[self delegate] respondsToSelector:@selector(collectionView:shouldDeleteItemsAtIndexes:)])
{ {
@@ -775,6 +780,26 @@
@end @end
@implementation CPCollectionView (Deprecated)
- (CGRect)rectForItemAtIndex:(int)anIndex
{
_CPReportLenientDeprecation([self class], _cmd, @selector(frameForItemAtIndex:));
// Don't re-compute anything just grab the current frame
// This allows subclasses to override tile without messing this up.
return [self frameForItemAtIndex:anIndex];
}
- (CGRect)rectForItemsAtIndexes:(CPIndexSet)anIndexSet
{
_CPReportLenientDeprecation([self class], _cmd, @selector(frameForItemsAtIndexes:));
return [self frameForItemsAtIndexes:anIndexSet];
}
@end
var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeKey", var CPCollectionViewMinItemSizeKey = @"CPCollectionViewMinItemSizeKey",
CPCollectionViewMaxItemSizeKey = @"CPCollectionViewMaxItemSizeKey", CPCollectionViewMaxItemSizeKey = @"CPCollectionViewMaxItemSizeKey",
CPCollectionViewVerticalMarginKey = @"CPCollectionViewVerticalMarginKey", CPCollectionViewVerticalMarginKey = @"CPCollectionViewVerticalMarginKey",
+1 -1
View File
@@ -51,7 +51,7 @@ var CPSharedFontManager = nil,
// Changing the Default Font Conversion Classes // Changing the Default Font Conversion Classes
/*! /*!
Sets the class that will be used to create the applcation's Sets the class that will be used to create the application's
font manager. font manager.
*/ */
+ (void)setFontManagerFactory:(Class)aClass + (void)setFontManagerFactory:(Class)aClass
+2 -2
View File
@@ -227,8 +227,8 @@ var SelectionColor = nil,
CGContextClosePath(context); CGContextClosePath(context);
CGContextSetShadowWithColor(context, CGSizeMake(0.0, 1.0), 1.1, _shadowColor); CGContextSetShadowWithColor(context, CGSizeMake(0.0, 1.0), 1.1, _shadowColor || [CPColor whiteColor]);
CGContextSetFillColor(context, _color); CGContextSetFillColor(context, _color || [CPColor blackColor]);
CGContextFillPath(context); CGContextFillPath(context);
} }
+2 -3
View File
@@ -235,7 +235,7 @@ NAMES_FOR_PARTS[CPScrollerKnob] = @"knob";
*/ */
- (void)checkSpaceForParts - (void)checkSpaceForParts
{ {
var bounds = [self bounds]; var bounds = [self bounds];
// Assume we won't be needing the arrows. // Assume we won't be needing the arrows.
if (_knobProportion === 1.0) if (_knobProportion === 1.0)
@@ -290,8 +290,7 @@ NAMES_FOR_PARTS[CPScrollerKnob] = @"knob";
_partRects[CPScrollerDecrementLine] = _CGRectMakeZero(); _partRects[CPScrollerDecrementLine] = _CGRectMakeZero();
_partRects[CPScrollerKnobSlot] = _CGRectMake(trackInset.left, 0, width - trackInset.left - trackInset.right, height); _partRects[CPScrollerKnobSlot] = _CGRectMake(trackInset.left, 0, width - trackInset.left - trackInset.right, height);
} }
} }
else else
{ {
var decrementLineSize = [self currentValueForThemeAttribute:"decrement-line-size"], var decrementLineSize = [self currentValueForThemeAttribute:"decrement-line-size"],
+15 -17
View File
@@ -158,21 +158,24 @@ var _CPTableColumnHeaderViewStringValueKey = @"_CPTableColumnHeaderViewStringVal
CPTableView _tableView @accessors(property=tableView); CPTableView _tableView @accessors(property=tableView);
} }
- (void)initWithFrame:(CGRect)aFrame - (void)_init
{
_resizedColumn = -1;
_draggedColumn = -1;
_pressedColumn = -1;
_draggedDistance = 0.0;
_lastLocation = nil;
_columnOldWidth = nil;
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 22.0))]];
}
- (id)initWithFrame:(CGRect)aFrame
{ {
self = [super initWithFrame:aFrame]; self = [super initWithFrame:aFrame];
if (self) if (self)
{ [self _init];
_resizedColumn = -1;
_draggedColumn = -1;
_pressedColumn = -1;
_draggedDistance = 0.0;
_lastLocation = nil;
_columnOldWidth = nil;
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 22.0))]];
}
return self; return self;
} }
@@ -479,12 +482,7 @@ var CPTableHeaderViewTableViewKey = @"CPTableHeaderViewTableViewKey";
{ {
if (self = [super initWithCoder:aCoder]) if (self = [super initWithCoder:aCoder])
{ {
_resizedColumn = -1; [self _init];
_draggedColumn = -1;
_pressedColumn = -1;
_draggedDistance = 0.0;
_lastLocation = nil;
_columnOldWidth = nil;
_tableView = [aCoder decodeObjectForKey:CPTableHeaderViewTableViewKey]; _tableView = [aCoder decodeObjectForKey:CPTableHeaderViewTableViewKey];
} }
+27 -31
View File
@@ -261,14 +261,14 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
[_headerView setTableView:self]; [_headerView setTableView:self];
_cornerView = [[_CPCornerView alloc] initWithFrame:CGRectMake(0, 0, [CPScroller scrollerWidth], CGRectGetHeight([_headerView frame]))]; _cornerView = [[_CPCornerView alloc] initWithFrame:CGRectMake(0, 0, [CPScroller scrollerWidth], CGRectGetHeight([_headerView frame]))];
_lastSelectedRow = -1; _lastSelectedRow = -1;
_selectedColumnIndexes = [CPIndexSet indexSet]; _selectedColumnIndexes = [CPIndexSet indexSet];
_selectedRowIndexes = [CPIndexSet indexSet]; _selectedRowIndexes = [CPIndexSet indexSet];
_currentHighlightedTableColumn = nil; _currentHighlightedTableColumn = nil;
_sortDescriptors = [CPArray array]; _sortDescriptors = [CPArray array];
_draggedRowIndexes = [CPIndexSet indexSet]; _draggedRowIndexes = [CPIndexSet indexSet];
_verticalMotionCanDrag = YES; _verticalMotionCanDrag = YES;
_isSelectingSession = NO; _isSelectingSession = NO;
@@ -276,10 +276,6 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
_retargetedDropOperation = nil; _retargetedDropOperation = nil;
_dragOperationDefaultMask = nil; _dragOperationDefaultMask = nil;
_destinationDragStyle = CPTableViewDraggingDestinationFeedbackStyleRegular; _destinationDragStyle = CPTableViewDraggingDestinationFeedbackStyleRegular;
_dropOperationFeedbackView = [[_dropOperationDrawingView alloc] initWithFrame:_CGRectMakeZero()];
[self addSubview:_dropOperationFeedbackView];
[_dropOperationFeedbackView setHidden:YES];
[_dropOperationFeedbackView setTableView:self];
_tableDrawView = [[_CPTableDrawView alloc] initWithTableView:self]; _tableDrawView = [[_CPTableDrawView alloc] initWithTableView:self];
[_tableDrawView setBackgroundColor:[CPColor clearColor]]; [_tableDrawView setBackgroundColor:[CPColor clearColor]];
@@ -294,6 +290,9 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
// FIX ME: we have a lot of redundent init stuff in initWithFrame: and initWithCoder: we should move it all into here. // FIX ME: we have a lot of redundent init stuff in initWithFrame: and initWithCoder: we should move it all into here.
- (void)_init - (void)_init
{ {
_dropOperationFeedbackView = [[_dropOperationDrawingView alloc] initWithFrame:_CGRectMakeZero()];
[_dropOperationFeedbackView setTableView:self];
_lastColumnShouldSnap = NO; _lastColumnShouldSnap = NO;
_backgroundColor = [CPColor whiteColor]; _backgroundColor = [CPColor whiteColor];
@@ -1762,25 +1761,18 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
return YES; return YES;
} }
- (CPImage)dragImageForRowsWithIndexes:(CPIndexSet)dragRows - (CPImage)dragImageForRowsWithIndexes:(CPIndexSet)dragRows tableColumns:(CPArray)theTableColumns event:(CPEvent)dragEvent offset:(CPPointPointer)dragImageOffset
tableColumns:(CPArray)theTableColumns
event:(CPEvent)dragEvent
offset:(CPPointPointer)dragImageOffset
{ {
return [[CPImage alloc] initWithContentsOfFile:@"Frameworks/AppKit/Resources/GenericFile.png" size:CGSizeMake(32,32)]; return [[CPImage alloc] initWithContentsOfFile:@"Frameworks/AppKit/Resources/GenericFile.png" size:CGSizeMake(32,32)];
} }
- (CPView)dragViewForRowsWithIndexes:(CPIndexSet)theDraggedRows - (CPView)dragViewForRowsWithIndexes:(CPIndexSet)theDraggedRows tableColumns:(CPArray)theTableColumns event:(CPEvent)theDragEvent offset:(CPPoint)dragViewOffset
tableColumns:(CPArray)theTableColumns
event:(CPEvent)theDragEvent
offset:(CPPoint)dragViewOffset
{ {
var bounds = [self bounds], var bounds = [self bounds],
view = [[CPView alloc] initWithFrame:bounds]; view = [[CPView alloc] initWithFrame:bounds];
[view setBackgroundColor:[CPColor clearColor]];
[view setAlphaValue:0.7]; [view setAlphaValue:0.7];
// We have to fetch all the data views for the selected rows and columns // We have to fetch all the data views for the selected rows and columns
// After that we can copy these add them to a transparent drag view and use that drag view // After that we can copy these add them to a transparent drag view and use that drag view
// to make it appear we are dragging images of those rows (as you would do in regular Cocoa) // to make it appear we are dragging images of those rows (as you would do in regular Cocoa)
@@ -1790,35 +1782,34 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
exposedRowsLength = [_exposedRows lastIndex] - firstExposedRow + 1, exposedRowsLength = [_exposedRows lastIndex] - firstExposedRow + 1,
columns = [], columns = [],
rows = []; rows = [];
[_exposedColumns getIndexes:columns maxCount:-1 inIndexRange:CPMakeRange(firstExposedColumn, exposedColumnsLength)]; [_exposedColumns getIndexes:columns maxCount:-1 inIndexRange:CPMakeRange(firstExposedColumn, exposedColumnsLength)];
[theDraggedRows getIndexes:rows maxCount:-1 inIndexRange:CPMakeRange(firstExposedRow, exposedRowsLength)]; [theDraggedRows getIndexes:rows maxCount:-1 inIndexRange:CPMakeRange(firstExposedRow, exposedRowsLength)];
var columnIndex = [columns count]; var columnIndex = [columns count];
while (columnIndex--) while (columnIndex--)
{ {
var column = columns[columnIndex], var column = columns[columnIndex],
tableColumn = [_tableColumns objectAtIndex:column], tableColumn = [_tableColumns objectAtIndex:column],
rowIndex = [rows count]; rowIndex = [rows count];
while (rowIndex--) while (rowIndex--)
{ {
var row = rows[rowIndex]; var row = rows[rowIndex];
var dataView = [self _newDataViewForRow:row tableColumn:tableColumn]; var dataView = [self _newDataViewForRow:row tableColumn:tableColumn];
[dataView setBackgroundColor:[CPColor clearColor]];
[dataView setFrame:[self frameOfDataViewAtColumn:column row:row]]; [dataView setFrame:[self frameOfDataViewAtColumn:column row:row]];
[dataView setObjectValue:[self _objectValueForTableColumn:tableColumn row:row]]; [dataView setObjectValue:[self _objectValueForTableColumn:tableColumn row:row]];
[view addSubview:dataView]; [view addSubview:dataView];
} }
} }
var dragPoint = [self convertPoint:[theDragEvent locationInWindow] fromView:nil]; var dragPoint = [self convertPoint:[theDragEvent locationInWindow] fromView:nil];
dragViewOffset.x = CGRectGetWidth(bounds)/2 - dragPoint.x; dragViewOffset.x = CGRectGetWidth(bounds)/2 - dragPoint.x;
dragViewOffset.y = CGRectGetHeight(bounds)/2 - dragPoint.y; dragViewOffset.y = CGRectGetHeight(bounds)/2 - dragPoint.y;
return view; return view;
} }
@@ -1840,7 +1831,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
var numberOfRows = [self numberOfRows] + 1; var numberOfRows = [self numberOfRows] + 1;
var reason = @"Attempt to set dropRow=" + row + var reason = @"Attempt to set dropRow=" + row +
" dropOperation=CPTableViewDropOn when [0 - " + numberOfRows + "] is valid range of rows." " dropOperation=CPTableViewDropOn when [0 - " + numberOfRows + "] is valid range of rows."
[[CPException exceptionWithName:@"Error" reason:reason userInfo:nil] raise]; [[CPException exceptionWithName:@"Error" reason:reason userInfo:nil] raise];
} }
@@ -1896,7 +1887,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
return; return;
_sortDescriptors = newSortDescriptors; _sortDescriptors = newSortDescriptors;
[self _sendDataSourceSortDescriptorsDidChange:oldSortDescriptors]; [self _sendDataSourceSortDescriptorsDidChange:oldSortDescriptors];
} }
@@ -2765,7 +2756,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
*/ */
- (void)draggingExited:(id)sender - (void)draggingExited:(id)sender
{ {
[_dropOperationFeedbackView setHidden:YES]; [_dropOperationFeedbackView removeFromSuperview];
} }
/* /*
@@ -2781,7 +2772,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
_retargetedDropOperation = nil; _retargetedDropOperation = nil;
_retargetedDropRow = nil; _retargetedDropRow = nil;
_draggedRowIndexes = [CPIndexSet indexSet]; _draggedRowIndexes = [CPIndexSet indexSet];
[_dropOperationFeedbackView setHidden:YES]; [_dropOperationFeedbackView removeFromSuperview];
} }
/* /*
@ignore @ignore
@@ -2914,7 +2905,7 @@ CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
{ {
// FIX ME: is there anything else that needs to happen here? // FIX ME: is there anything else that needs to happen here?
// actual validation is called in dragginUpdated: // actual validation is called in dragginUpdated:
[_dropOperationFeedbackView setHidden:YES]; [_dropOperationFeedbackView removeFromSuperview];
return (_implementedDataSourceMethods & CPTableViewDataSource_tableView_validateDrop_proposedRow_proposedDropOperation_); return (_implementedDataSourceMethods & CPTableViewDataSource_tableView_validateDrop_proposedRow_proposedDropOperation_);
} }
@@ -3190,6 +3181,7 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
CPTableViewGridColorKey = @"CPTableViewGridColorKey", CPTableViewGridColorKey = @"CPTableViewGridColorKey",
CPTableViewGridStyleMaskKey = @"CPTableViewGridStyleMaskKey", CPTableViewGridStyleMaskKey = @"CPTableViewGridStyleMaskKey",
CPTableViewUsesAlternatingBackgroundKey = @"CPTableViewUsesAlternatingBackgroundKey", CPTableViewUsesAlternatingBackgroundKey = @"CPTableViewUsesAlternatingBackgroundKey",
CPTableViewAlternatingRowColorsKey = @"CPTableViewAlternatingRowColorsKey",
CPTableViewHeaderViewKey = @"CPTableViewHeaderViewKey", CPTableViewHeaderViewKey = @"CPTableViewHeaderViewKey",
CPTableViewCornerViewKey = @"CPTableViewCornerViewKey"; CPTableViewCornerViewKey = @"CPTableViewCornerViewKey";
@@ -3239,6 +3231,9 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
_gridColor = [aCoder decodeObjectForKey:CPTableViewGridColorKey] || [CPColor grayColor]; _gridColor = [aCoder decodeObjectForKey:CPTableViewGridColorKey] || [CPColor grayColor];
_gridStyleMask = [aCoder decodeIntForKey:CPTableViewGridStyleMaskKey] || CPTableViewGridNone; _gridStyleMask = [aCoder decodeIntForKey:CPTableViewGridStyleMaskKey] || CPTableViewGridNone;
_alternatingRowBackgroundColors = [aCoder decodeObjectForKey:CPTableViewAlternatingRowColorsKey];
_usesAlternatingRowBackgroundColors = [aCoder decodeObjectForKey:CPTableViewUsesAlternatingBackgroundKey]
_headerView = [aCoder decodeObjectForKey:CPTableViewHeaderViewKey]; _headerView = [aCoder decodeObjectForKey:CPTableViewHeaderViewKey];
_cornerView = [aCoder decodeObjectForKey:CPTableViewCornerViewKey]; _cornerView = [aCoder decodeObjectForKey:CPTableViewCornerViewKey];
@@ -3282,6 +3277,7 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
[aCoder encodeInt:_gridStyleMask forKey:CPTableViewGridStyleMaskKey]; [aCoder encodeInt:_gridStyleMask forKey:CPTableViewGridStyleMaskKey];
[aCoder encodeBool:_usesAlternatingRowBackgroundColors forKey:CPTableViewUsesAlternatingBackgroundKey]; [aCoder encodeBool:_usesAlternatingRowBackgroundColors forKey:CPTableViewUsesAlternatingBackgroundKey];
[aCoder encodeObject:_alternatingRowBackgroundColors forKey:CPTableViewAlternatingRowColorsKey]
[aCoder encodeObject:_cornerView forKey:CPTableViewCornerViewKey]; [aCoder encodeObject:_cornerView forKey:CPTableViewCornerViewKey];
[aCoder encodeObject:_headerView forKey:CPTableViewHeaderViewKey]; [aCoder encodeObject:_headerView forKey:CPTableViewHeaderViewKey];
+3 -3
View File
@@ -813,7 +813,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
if (![CPPlatform isBrowser]) if (![CPPlatform isBrowser])
{ {
[self copy:sender]; [self copy:sender];
[self deleteBackwards:sender]; [self deleteBackward:sender];
} }
} }
@@ -826,7 +826,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
if (![[pasteboard types] containsObject:CPStringPboardType]) if (![[pasteboard types] containsObject:CPStringPboardType])
return; return;
[self deleteBackwards:sender]; [self deleteBackward:sender];
var selectedRange = [self selectedRange], var selectedRange = [self selectedRange],
stringValue = [self stringValue], stringValue = [self stringValue],
@@ -912,7 +912,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
[self selectText:sender]; [self selectText:sender];
} }
- (void)deleteBackwards:(id)sender - (void)deleteBackward:(id)sender
{ {
var selectedRange = [self selectedRange], var selectedRange = [self selectedRange],
stringValue = [self stringValue], stringValue = [self stringValue],
+1 -1
View File
@@ -668,7 +668,7 @@ var CPViewFlags = { },
return _tag; return _tag;
} }
- (void)viewWithTag:(CPInteger)aTag - (CPView)viewWithTag:(CPInteger)aTag
{ {
if ([self tag] == aTag) if ([self tag] == aTag)
return self; return self;
+5 -7
View File
@@ -1497,7 +1497,8 @@ CPTexturedBackgroundWindowMask
if (_firstResponder != self && [_firstResponder respondsToSelector:@selector(resignKeyWindow)]) if (_firstResponder != self && [_firstResponder respondsToSelector:@selector(resignKeyWindow)])
[_firstResponder resignKeyWindow]; [_firstResponder resignKeyWindow];
CPApp._keyWindow = nil; if (CPApp._keyWindow === self)
CPApp._keyWindow = nil;
[[CPNotificationCenter defaultCenter] [[CPNotificationCenter defaultCenter]
postNotificationName:CPWindowDidResignKeyNotification postNotificationName:CPWindowDidResignKeyNotification
@@ -1858,7 +1859,8 @@ CPTexturedBackgroundWindowMask
postNotificationName:CPWindowDidResignMainNotification postNotificationName:CPWindowDidResignMainNotification
object:self]; object:self];
CPApp._mainWindow = nil; if (CPApp._mainWindow === self)
CPApp._mainWindow = nil;
} }
- (void)_updateMainAndKeyWindows - (void)_updateMainAndKeyWindows
@@ -1866,9 +1868,6 @@ CPTexturedBackgroundWindowMask
var allWindows = [CPApp orderedWindows], var allWindows = [CPApp orderedWindows],
windowCount = [allWindows count]; windowCount = [allWindows count];
if (!windowCount)
return;
if ([self isKeyWindow]) if ([self isKeyWindow])
{ {
var keyWindow = [CPApp keyWindow]; var keyWindow = [CPApp keyWindow];
@@ -1893,11 +1892,10 @@ CPTexturedBackgroundWindowMask
} }
if (![CPApp keyWindow]) if (![CPApp keyWindow])
[keyWindow makeKeyWindow]; [menuWindow makeKeyWindow];
} }
} }
if ([self isMainWindow]) if ([self isMainWindow])
{ {
var mainWindow = [CPApp mainWindow]; var mainWindow = [CPApp mainWindow];
-19
View File
@@ -322,25 +322,6 @@
return _documents; return _documents;
} }
- (void)setViewController:(CPViewController)aViewController
{
var containerView = [self viewControllerContainerView] || [[self window] contentView],
view = [_viewController view],
frame = view ? [view frame] : [containerView bounds];
[view removeFromSuperview];
_viewController = aViewController;
view = [_viewController view];
if (view)
{
[view setFrame:frame];
[containerView addSubview:view];
}
}
- (void)setViewControllerContainerView:(CPView)aView - (void)setViewControllerContainerView:(CPView)aView
{ {
_viewControllerContainerView = aView; _viewControllerContainerView = aView;
+6 -1
View File
@@ -171,12 +171,17 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey";
- (void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)data - (void)connection:(CPURLConnection)aConnection didReceiveData:(CPString)data
{ {
// FIXME: Why aren't we getting connection:didFailWithError:
if (!data)
return [self connection:aConnection didFailWithError:nil];
_data = [CPData dataWithRawString:data]; _data = [CPData dataWithRawString:data];
} }
- (void)connection:(CPURLConnection)aConnection didFailWithError:(CPError)anError - (void)connection:(CPURLConnection)aConnection didFailWithError:(CPError)anError
{ {
alert("cib: connection failed."); if ([_loadDelegate respondsToSelector:@selector(cibDidFailToLoad:)])
[_loadDelegate cibDidFailToLoad:self];
_loadDelegate = nil; _loadDelegate = nil;
} }
+5
View File
@@ -118,4 +118,9 @@ var CPCibOwner = @"CPCibOwner";
[_loadDelegate cibDidFinishLoading:aCib]; [_loadDelegate cibDidFinishLoading:aCib];
} }
- (void)cibDidFailToLoad:(CPCib)aCib
{
[_loadDelegate cibDidFailToLoad:aCib];
}
@end @end
+1 -2
View File
@@ -777,8 +777,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
@ignore @ignore
*/ */
+ (void)runLoopUpdateLayers + (void)runLoopUpdateLayers
{if (window.oops) {alert(window.latest); objj_debug_print_backtrace();} {
window.loop = true;
for (UID in CALayerRegisteredRunLoopUpdates) for (UID in CALayerRegisteredRunLoopUpdates)
{ {
var layer = CALayerRegisteredRunLoopUpdates[UID], var layer = CALayerRegisteredRunLoopUpdates[UID],
+1 -1
View File
@@ -210,7 +210,7 @@ function CGPathAddQuadCurveToPoint(aPath, aTransform, cpx, cpy, x, y)
if (aTransform) if (aTransform)
{ {
cp = _CGPointApplyAffineTransform(control, aTransform); cp = _CGPointApplyAffineTransform(cp, aTransform);
end = _CGPointApplyAffineTransform(end, aTransform); end = _CGPointApplyAffineTransform(end, aTransform);
} }
+4 -3
View File
@@ -40,6 +40,10 @@ var screenNeedsInitialization = NO,
return; return;
screenNeedsInitialization = [CPPlatform isBrowser]; screenNeedsInitialization = [CPPlatform isBrowser];
// We do this here because doing it later breaks IE.
if (document.documentElement)
document.documentElement.style.overflow = "hidden";
} }
+ (BOOL)isBrowser + (BOOL)isBrowser
@@ -121,9 +125,6 @@ var screenNeedsInitialization = NO,
bodyElement.style.overflow = "hidden"; bodyElement.style.overflow = "hidden";
if (document.documentElement)
document.documentElement.style.overflow = "hidden";
[[CPNotificationCenter defaultCenter] [[CPNotificationCenter defaultCenter]
postNotificationName:CPPlatformDidClearBodyElementNotification postNotificationName:CPPlatformDidClearBodyElementNotification
object:self]; object:self];
+56 -50
View File
@@ -22,9 +22,10 @@
#include "../CoreGraphics/CGGeometry.h" #include "../CoreGraphics/CGGeometry.h"
var DOMSpanElement = nil, var DOMFixedWidthSpanElement = nil,
DOMIFrameElement = nil, DOMFlexibleWidthSpanElement = nil,
DefaultFont = nil; DOMIFrameElement = nil,
DefaultFont = nil;
@implementation CPPlatformString : CPBasePlatformString @implementation CPPlatformString : CPBasePlatformString
{ {
@@ -37,25 +38,30 @@ var DOMSpanElement = nil,
+ (void)createDOMElements + (void)createDOMElements
{ {
var style;
DOMIFrameElement = document.createElement("iframe"); DOMIFrameElement = document.createElement("iframe");
// necessary for Safari caching bug: // necessary for Safari caching bug:
DOMIFrameElement.name = "iframe_" + FLOOR(RAND() * 10000); DOMIFrameElement.name = "iframe_" + FLOOR(RAND() * 10000);
DOMIFrameElement.style.position = "absolute";
DOMIFrameElement.style.left = "-100px";
DOMIFrameElement.style.top = "-100px";
DOMIFrameElement.style.width = "1px";
DOMIFrameElement.style.height = "1px";
DOMIFrameElement.style.borderWidth = "0px";
DOMIFrameElement.style.overflow = "hidden";
DOMIFrameElement.style.zIndex = 100000000000;
DOMIFrameElement.className = "cpdontremove"; DOMIFrameElement.className = "cpdontremove";
style = DOMIFrameElement.style;
style.position = "absolute";
style.left = "-100px";
style.top = "-100px";
style.width = "1px";
style.height = "1px";
style.borderWidth = "0px";
style.overflow = "hidden";
style.zIndex = 100000000000;
var bodyElement = [CPPlatform mainBodyElement]; var bodyElement = [CPPlatform mainBodyElement];
bodyElement.appendChild(DOMIFrameElement); bodyElement.appendChild(DOMIFrameElement);
var DOMIFrameDocument = (DOMIFrameElement.contentDocument || DOMIFrameElement.contentWindow.document); var DOMIFrameDocument = (DOMIFrameElement.contentDocument || DOMIFrameElement.contentWindow.document);
DOMIFrameDocument.write("<html><head></head><body></body></html>"); DOMIFrameDocument.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'+
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head></head><body></body></html>');
DOMIFrameDocument.close(); DOMIFrameDocument.close();
// IE needs this wide <div> to prevent unwanted text wrapping: // IE needs this wide <div> to prevent unwanted text wrapping:
@@ -65,18 +71,39 @@ var DOMSpanElement = nil,
DOMIFrameDocument.body.appendChild(DOMDivElement); DOMIFrameDocument.body.appendChild(DOMDivElement);
DOMSpanElement = DOMIFrameDocument.createElement("span"); DOMFlexibleWidthSpanElement = DOMIFrameDocument.createElement("span");
DOMSpanElement.style.position = "absolute"; style = DOMFlexibleWidthSpanElement.style;
DOMSpanElement.style.visibility = "visible"; style.position = "absolute";
DOMSpanElement.style.padding = "0px"; style.visibility = "visible";
DOMSpanElement.style.margin = "0px"; style.padding = "0px";
style.margin = "0px";
style.whiteSpace = "pre";
try { DOMFixedWidthSpanElement = DOMIFrameDocument.createElement("span");
DOMSpanElement.style.whiteSpace = "pre"; style = DOMFixedWidthSpanElement.style;
style.display = "block";
style.position = "absolute";
style.visibility = "visible";
style.padding = "0px";
style.margin = "0px";
style.width = "1px";
style.wordWrap = "break-word";
try
{
style.whiteSpace = "pre";
style.whiteSpace = "-o-pre-wrap";
style.whiteSpace = "-pre-wrap";
style.whiteSpace = "-moz-pre-wrap";
style.whiteSpace = "pre-wrap";
}
catch(e)
{
//some versions of IE throw exceptions for unsupported properties.
style.whiteSpace = "pre";
} }
catch (e) {}
DOMDivElement.appendChild(DOMSpanElement); DOMDivElement.appendChild(DOMFlexibleWidthSpanElement);
DOMDivElement.appendChild(DOMFixedWidthSpanElement);
} }
+ (CGSize)sizeOfString:(CPString)aString withFont:(CPFont)aFont forWidth:(float)aWidth + (CGSize)sizeOfString:(CPString)aString withFont:(CPFont)aFont forWidth:(float)aWidth
@@ -92,44 +119,23 @@ var DOMSpanElement = nil,
if (!DOMIFrameElement) if (!DOMIFrameElement)
[self createDOMElements]; [self createDOMElements];
var style = DOMSpanElement.style; var span;
if (!aWidth) if (!aWidth)
{ span = DOMFlexibleWidthSpanElement;
style.width = "";
try {
style.whiteSpace = "pre";
}
catch (e) {}
style.wordWrap = "normal";
}
else else
{ {
style.width = ROUND(aWidth) + "px"; span = DOMFixedWidthSpanElement;
try span.style.width = ROUND(aWidth) + "px";
{
style.whiteSpace = "-o-pre-wrap";
style.whiteSpace = "-pre-wrap";
style.whiteSpace = "-moz-pre-wrap";
style.whiteSpace = "pre-wrap";
} catch(e)
{
//some versions of IE throw exceptions for unsupported properties.
}
style.wordWrap = "break-word";
} }
style.font = [aFont cssString]; span.style.font = [aFont cssString];
if (CPFeatureIsCompatible(CPJavascriptInnerTextFeature)) if (CPFeatureIsCompatible(CPJavascriptInnerTextFeature))
DOMSpanElement.innerText = aString; span.innerText = aString;
else if (CPFeatureIsCompatible(CPJavascriptTextContentFeature)) else if (CPFeatureIsCompatible(CPJavascriptTextContentFeature))
DOMSpanElement.textContent = aString; span.textContent = aString;
return _CGSizeMake(DOMSpanElement.clientWidth, DOMSpanElement.clientHeight); return _CGSizeMake(span.clientWidth, span.clientHeight);
} }
@end @end
+1 -20
View File
@@ -129,8 +129,6 @@ var CPDOMEventGetClickCount,
CPDOMEventStop, CPDOMEventStop,
StopDOMEventPropagation; StopDOMEventPropagation;
var _DOMEventGuard;
//right now we hard code q, w, r and t as keys to propogate //right now we hard code q, w, r and t as keys to propogate
//these aren't normal keycodes, they are with modifier key codes //these aren't normal keycodes, they are with modifier key codes
//might be mac only, we should investigate futher later. //might be mac only, we should investigate futher later.
@@ -257,19 +255,6 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
// Make sure the pastboard element is blurred. // Make sure the pastboard element is blurred.
_DOMPasteboardElement.blur(); _DOMPasteboardElement.blur();
// Create a full screen div to protect against iframes and other elements from consuming events during tracking
// FIXME: multiple windows
_DOMEventGuard = theDocument.createElement("div");
_DOMEventGuard.style.position = "absolute";
_DOMEventGuard.style.top = "0px";
_DOMEventGuard.style.left = "0px";
_DOMEventGuard.style.width = "100%";
_DOMEventGuard.style.height = "100%";
_DOMEventGuard.style.zIndex = "999";
_DOMEventGuard.style.display = "none";
_DOMEventGuard.className = "cpdontremove";
_DOMBodyElement.appendChild(_DOMEventGuard);
} }
- (void)registerDOMWindow - (void)registerDOMWindow
@@ -804,7 +789,6 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
} }
} }
- (void)_checkPasteboardElement - (void)_checkPasteboardElement
{ {
var value = _DOMPasteboardElement.value; var value = _DOMPasteboardElement.value;
@@ -1117,13 +1101,10 @@ var supportsNativeDragAndDrop = [CPPlatform supportsDragAndDrop];
if (StopDOMEventPropagation && (!supportsNativeDragAndDrop || type !== "mousedown" && !isDragging)) if (StopDOMEventPropagation && (!supportsNativeDragAndDrop || type !== "mousedown" && !isDragging))
CPDOMEventStop(aDOMEvent, self); CPDOMEventStop(aDOMEvent, self);
// if there are any tracking event listeners then show the event guard so we don't lose events to iframes
_DOMEventGuard.style.display = (CPApp._eventListeners.length === 0) ? "none" : "";
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode]; [[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
} }
(CPArray)orderedWindowsAtLevel:(int)aLevel - (CPArray)orderedWindowsAtLevel:(int)aLevel
{ {
var layer = [self layerAtLevel:aLevel create:NO]; var layer = [self layerAtLevel:aLevel create:NO];
+20 -8
View File
@@ -5,13 +5,18 @@
{ {
} }
- (void)_init
{
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 23.0))]];
}
- (id)initWithFrame:(CGRect)aFrame - (id)initWithFrame:(CGRect)aFrame
{ {
if (self = [super initWithFrame:aFrame]) if (self = [super initWithFrame:aFrame])
{ {
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 23.0))]]; [self _init];
} }
return self; return self;
} }
@@ -20,16 +25,23 @@
var context = [[CPGraphicsContext currentContext] graphicsPort]; var context = [[CPGraphicsContext currentContext] graphicsPort];
CGContextSetStrokeColor(context, [CPColor colorWithHexString:@"dce0e2"]); CGContextSetStrokeColor(context, [CPColor colorWithHexString:@"dce0e2"]);
var points = [ var points = [
CGPointMake(aRect.origin.x, aRect.origin.y),
CGPointMake(aRect.origin.x + aRect.size.width, aRect.origin.y),
CGPointMake(aRect.origin.x, aRect.origin.y + 0.5), CGPointMake(aRect.origin.x, aRect.origin.y + 0.5),
CGPointMake(aRect.origin.x, aRect.origin.y + aRect.size.height) CGPointMake(aRect.origin.x, aRect.origin.y + aRect.size.height)
]; ];
CGContextStrokeLineSegments(context, points, 2); CGContextStrokeLineSegments(context, points, 2);
} }
- (id)initWithCoder:(CPCoder)aCoder
{
self = [super initWithCoder:aCoder];
{
[self _init];
}
return self;
}
@end @end
+25 -38
View File
@@ -332,7 +332,8 @@ var HORIZONTAL_MARGIN = 3.0,
hasDOMTextElement = !!_DOMTextElement; hasDOMTextElement = !!_DOMTextElement;
// Create or destroy the DOM Text Element as necessary // Create or destroy the DOM Text Element as necessary
if (needsDOMTextElement !== hasDOMTextElement) if (needsDOMTextElement !== hasDOMTextElement)
{
if (hasDOMTextElement) if (hasDOMTextElement)
{ {
_DOMElement.removeChild(_DOMTextElement); _DOMElement.removeChild(_DOMTextElement);
@@ -361,6 +362,7 @@ var HORIZONTAL_MARGIN = 3.0,
// We have to set all these values now. // We have to set all these values now.
_flags |= _CPImageAndTextViewTextChangedFlag | _CPImageAndTextViewFontChangedFlag | _CPImageAndTextViewLineBreakModeChangedFlag; _flags |= _CPImageAndTextViewTextChangedFlag | _CPImageAndTextViewFontChangedFlag | _CPImageAndTextViewLineBreakModeChangedFlag;
} }
}
var textStyle = hasDOMTextElement ? _DOMTextElement.style : nil; var textStyle = hasDOMTextElement ? _DOMTextElement.style : nil;
@@ -369,6 +371,7 @@ var HORIZONTAL_MARGIN = 3.0,
hasDOMTextShadowElement = !!_DOMTextShadowElement; hasDOMTextShadowElement = !!_DOMTextShadowElement;
if (needsDOMTextShadowElement !== hasDOMTextShadowElement) if (needsDOMTextShadowElement !== hasDOMTextShadowElement)
{
if (hasDOMTextShadowElement) if (hasDOMTextShadowElement)
{ {
_DOMElement.removeChild(_DOMTextShadowElement); _DOMElement.removeChild(_DOMTextShadowElement);
@@ -386,6 +389,7 @@ var HORIZONTAL_MARGIN = 3.0,
shadowStyle.font = [_font ? _font : [CPFont systemFontOfSize:12.0] cssString]; shadowStyle.font = [_font ? _font : [CPFont systemFontOfSize:12.0] cssString];
shadowStyle.position = "absolute"; shadowStyle.position = "absolute";
shadowStyle.whiteSpace = textStyle.whiteSpace; shadowStyle.whiteSpace = textStyle.whiteSpace;
shadowStyle.wordWrap = textStyle.wordWrap;
shadowStyle.color = [_textShadowColor cssString]; shadowStyle.color = [_textShadowColor cssString];
shadowStyle.zIndex = 150; shadowStyle.zIndex = 150;
@@ -394,7 +398,6 @@ var HORIZONTAL_MARGIN = 3.0,
if (document.attachEvent) if (document.attachEvent)
{ {
shadowStyle.overflow = textStyle.overflow; shadowStyle.overflow = textStyle.overflow;
shadowStyle.wordWrap = textStyle.wordWrap;
} }
else else
{ {
@@ -408,6 +411,7 @@ var HORIZONTAL_MARGIN = 3.0,
_flags |= _CPImageAndTextViewTextChangedFlag; //sigh... _flags |= _CPImageAndTextViewTextChangedFlag; //sigh...
} }
}
var shadowStyle = hasDOMTextShadowElement ? _DOMTextShadowElement.style : nil; var shadowStyle = hasDOMTextShadowElement ? _DOMTextShadowElement.style : nil;
@@ -447,9 +451,7 @@ var HORIZONTAL_MARGIN = 3.0,
case CPLineBreakByClipping: textStyle.overflow = "hidden"; case CPLineBreakByClipping: textStyle.overflow = "hidden";
textStyle.textOverflow = "clip"; textStyle.textOverflow = "clip";
textStyle.whiteSpace = "pre"; textStyle.whiteSpace = "pre";
textStyle.wordWrap = "normal";
if (document.attachEvent)
textStyle.wordWrap = "normal";
break; break;
@@ -459,26 +461,23 @@ var HORIZONTAL_MARGIN = 3.0,
case CPLineBreakByTruncatingTail: textStyle.textOverflow = "ellipsis"; case CPLineBreakByTruncatingTail: textStyle.textOverflow = "ellipsis";
textStyle.whiteSpace = "nowrap"; textStyle.whiteSpace = "nowrap";
textStyle.overflow = "hidden"; textStyle.overflow = "hidden";
textStyle.wordWrap = "normal";
if (document.attachEvent)
textStyle.wordWrap = "normal";
break; break;
case CPLineBreakByCharWrapping: case CPLineBreakByCharWrapping:
case CPLineBreakByWordWrapping: if (document.attachEvent) case CPLineBreakByWordWrapping: textStyle.wordWrap = "break-word";
{ try {
textStyle.whiteSpace = "pre"; textStyle.whiteSpace = "pre";
textStyle.wordWrap = "break-word";
}
else
{
textStyle.whiteSpace = "-o-pre-wrap"; textStyle.whiteSpace = "-o-pre-wrap";
textStyle.whiteSpace = "-pre-wrap"; textStyle.whiteSpace = "-pre-wrap";
textStyle.whiteSpace = "-moz-pre-wrap"; textStyle.whiteSpace = "-moz-pre-wrap";
textStyle.whiteSpace = "pre-wrap"; textStyle.whiteSpace = "pre-wrap";
} }
catch (e) {
//internet explorer doesn't like these properties
textStyle.whiteSpace = "pre";
}
textStyle.overflow = "hidden"; textStyle.overflow = "hidden";
textStyle.textOverflow = "clip"; textStyle.textOverflow = "clip";
@@ -490,7 +489,6 @@ var HORIZONTAL_MARGIN = 3.0,
{ {
if (document.attachEvent) if (document.attachEvent)
{ {
shadowStyle.wordWrap = textStyle.wordWrap;
shadowStyle.overflow = textStyle.overflow; shadowStyle.overflow = textStyle.overflow;
} }
else else
@@ -499,6 +497,7 @@ var HORIZONTAL_MARGIN = 3.0,
shadowStyle.overflowY = textStyle.overflowY; shadowStyle.overflowY = textStyle.overflowY;
} }
shadowStyle.wordWrap = textStyle.wordWrap;
shadowStyle.whiteSpace = textStyle.whiteSpace; shadowStyle.whiteSpace = textStyle.whiteSpace;
shadowStyle.textOverflow = textStyle.textOverflow; shadowStyle.textOverflow = textStyle.textOverflow;
} }
@@ -510,6 +509,7 @@ var HORIZONTAL_MARGIN = 3.0,
// Create or destroy DOM Image element // Create or destroy DOM Image element
if (needsDOMImageElement !== hasDOMImageElement) if (needsDOMImageElement !== hasDOMImageElement)
{
if (hasDOMImageElement) if (hasDOMImageElement)
{ {
_DOMElement.removeChild(_DOMImageElement); _DOMElement.removeChild(_DOMImageElement);
@@ -539,8 +539,8 @@ var HORIZONTAL_MARGIN = 3.0,
_DOMElement.appendChild(_DOMImageElement); _DOMElement.appendChild(_DOMImageElement);
hasDOMImageElement = YES; hasDOMImageElement = YES;
} }
#endif }
var size = [self bounds].size, var size = [self bounds].size,
textRect = _CGRectMake(0.0, 0.0, size.width, size.height); textRect = _CGRectMake(0.0, 0.0, size.width, size.height);
@@ -572,67 +572,54 @@ var HORIZONTAL_MARGIN = 3.0,
imageHeight *= scale; imageHeight *= scale;
} }
#if PLATFORM(DOM)
_DOMImageElement.width = imageWidth; _DOMImageElement.width = imageWidth;
_DOMImageElement.height = imageHeight; _DOMImageElement.height = imageHeight;
imageStyle.width = imageWidth + "px"; imageStyle.width = MAX(imageWidth, 0) + "px";
imageStyle.height = imageHeight + "px"; imageStyle.height = MAX(imageHeight, 0) + "px";
#endif
if (_imagePosition === CPImageBelow) if (_imagePosition === CPImageBelow)
{ {
#if PLATFORM(DOM)
imageStyle.left = FLOOR(centerX - imageWidth / 2.0) + "px"; imageStyle.left = FLOOR(centerX - imageWidth / 2.0) + "px";
imageStyle.top = FLOOR(size.height - imageHeight) + "px"; imageStyle.top = FLOOR(size.height - imageHeight) + "px";
#endif
textRect.size.height = size.height - imageHeight - VERTICAL_MARGIN; textRect.size.height = size.height - imageHeight - VERTICAL_MARGIN;
} }
else if (_imagePosition === CPImageAbove) else if (_imagePosition === CPImageAbove)
{ {
#if PLATFORM(DOM)
CPDOMDisplayServerSetStyleLeftTop(_DOMImageElement, NULL, FLOOR(centerX - imageWidth / 2.0), 0); CPDOMDisplayServerSetStyleLeftTop(_DOMImageElement, NULL, FLOOR(centerX - imageWidth / 2.0), 0);
#endif
textRect.origin.y += imageHeight + VERTICAL_MARGIN; textRect.origin.y += imageHeight + VERTICAL_MARGIN;
textRect.size.height = size.height - imageHeight - VERTICAL_MARGIN; textRect.size.height = size.height - imageHeight - VERTICAL_MARGIN;
} }
else if (_imagePosition === CPImageLeft) else if (_imagePosition === CPImageLeft)
{ {
#if PLATFORM(DOM)
imageStyle.top = FLOOR(centerY - imageHeight / 2.0) + "px"; imageStyle.top = FLOOR(centerY - imageHeight / 2.0) + "px";
imageStyle.left = "0px"; imageStyle.left = "0px";
#endif
textRect.origin.x = imageWidth + HORIZONTAL_MARGIN; textRect.origin.x = imageWidth + HORIZONTAL_MARGIN;
textRect.size.width -= imageWidth + HORIZONTAL_MARGIN; textRect.size.width -= imageWidth + HORIZONTAL_MARGIN;
} }
else if (_imagePosition === CPImageRight) else if (_imagePosition === CPImageRight)
{ {
#if PLATFORM(DOM)
imageStyle.top = FLOOR(centerY - imageHeight / 2.0) + "px"; imageStyle.top = FLOOR(centerY - imageHeight / 2.0) + "px";
imageStyle.left = FLOOR(size.width - imageWidth) + "px"; imageStyle.left = FLOOR(size.width - imageWidth) + "px";
#endif
textRect.size.width -= imageWidth + HORIZONTAL_MARGIN; textRect.size.width -= imageWidth + HORIZONTAL_MARGIN;
} }
else if (_imagePosition === CPImageOnly) else if (_imagePosition === CPImageOnly)
{ {
#if PLATFORM(DOM)
imageStyle.top = FLOOR(centerY - imageHeight / 2.0) + "px"; imageStyle.top = FLOOR(centerY - imageHeight / 2.0) + "px";
imageStyle.left = FLOOR(centerX - imageWidth / 2.0) + "px"; imageStyle.left = FLOOR(centerX - imageWidth / 2.0) + "px";
#endif
} }
} }
#if PLATFORM(DOM)
if (hasDOMTextElement) if (hasDOMTextElement)
{ {
var textRectX = _CGRectGetMinX(textRect), var textRectX = _CGRectGetMinX(textRect),
textRectY = _CGRectGetMinY(textRect), textRectY = _CGRectGetMinY(textRect),
textRectWidth = _CGRectGetWidth(textRect), textRectWidth = _CGRectGetWidth(textRect),
textRectHeight = _CGRectGetHeight(textRect); textRectHeight = _CGRectGetHeight(textRect);
if (_verticalAlignment !== CPTopVerticalTextAlignment) if (_verticalAlignment !== CPTopVerticalTextAlignment)
{ {
if (!_textSize) if (!_textSize)
@@ -659,8 +646,8 @@ var HORIZONTAL_MARGIN = 3.0,
textStyle.top = ROUND(textRectY) + "px"; textStyle.top = ROUND(textRectY) + "px";
textStyle.left = ROUND(textRectX) + "px"; textStyle.left = ROUND(textRectX) + "px";
textStyle.width = ROUND(textRectWidth) + "px"; textStyle.width = MAX(ROUND(textRectWidth), 0) + "px";
textStyle.height = ROUND(textRectHeight) + "px"; textStyle.height = MAX(ROUND(textRectHeight), 0) + "px";
if (shadowStyle) if (shadowStyle)
{ {
@@ -669,8 +656,8 @@ var HORIZONTAL_MARGIN = 3.0,
shadowStyle.top = ROUND(textRectY + _textShadowOffset.height) + "px"; shadowStyle.top = ROUND(textRectY + _textShadowOffset.height) + "px";
shadowStyle.left = ROUND(textRectX + _textShadowOffset.width) + "px"; shadowStyle.left = ROUND(textRectX + _textShadowOffset.width) + "px";
shadowStyle.width = ROUND(textRectWidth) + "px"; shadowStyle.width = MAX(ROUND(textRectWidth), 0) + "px";
shadowStyle.height = ROUND(textRectHeight) + "px"; shadowStyle.height = MAX(ROUND(textRectHeight), 0) + "px";
} }
} }
#endif #endif
+200 -96
View File
@@ -8,6 +8,7 @@ require("narwhal").ensureEngine("rhino");
var FILE = require("file"); var FILE = require("file");
var OS = require("os"); var OS = require("os");
var UTIL = require("util");
var stream = require("term").stream; var stream = require("term").stream;
var parser = new (require("args").Parser)(); var parser = new (require("args").Parser)();
@@ -24,6 +25,10 @@ parser.option("-F", "--framework", "frameworks")
.push() .push()
.help("Add a frameworks directory, relative to INPUT_PROJECT (default: ['Frameworks'])"); .help("Add a frameworks directory, relative to INPUT_PROJECT (default: ['Frameworks'])");
parser.option("-P", "--path", "paths")
.push()
.help("Add a path (relative to the application root) to inline.");
parser.option("-f", "--force", "force") parser.option("-f", "--force", "force")
.def(false) .def(false)
.set(true) .set(true)
@@ -34,6 +39,16 @@ parser.option("--index", "index")
.set() .set()
.help("The root HTML file to modify (default: index.html)"); .help("The root HTML file to modify (default: index.html)");
parser.option("-s", "--split", "number", "split")
.natural()
.def(0)
.help("Split into multiple files");
parser.option("-c", "--compressor", "compressor")
.def("shrinksafe")
.set()
.help("Select a compressor to use (closure-compiler, yuicompressor, shrinksafe), or \"none\" (default: shrinksafe)");
parser.option("-v", "--verbose", "verbose") parser.option("-v", "--verbose", "verbose")
.def(false) .def(false)
.set(true) .set(true)
@@ -81,20 +96,34 @@ function main(args)
var flattener = new ObjectiveJFlattener(rootPath); var flattener = new ObjectiveJFlattener(rootPath);
flattener.options = options;
flattener.setIncludePaths(frameworks); flattener.setIncludePaths(frameworks);
flattener.setEnvironments([environment, "ObjJ"]); flattener.setEnvironments([environment, "ObjJ"]);
print("Loading application.");
flattener.load(mainPath); flattener.load(mainPath);
flattener.finishLoading();
var applicationRoot = flattener.require("objective-j").StaticResource.resourceAtURL(rootPath) print("Loading default theme.");
print(applicationRoot.toString()); flattener.require("objective-j").objj_eval("("+(function() {
var blend = [[CPThemeBlend alloc] initWithContentsOfURL:[[CPBundle bundleForClass:[CPApplication class]] pathForResource:[CPApplication defaultThemeName] + ".blend"]];
[blend loadWithDelegate:nil];
})+")")();
var applicationJS = flattener.buildApplicationJS(applicationRoot); var applicationJSs = flattener.buildApplicationJS();
FILE.copyTree(rootPath, outputPath); FILE.copyTree(rootPath, outputPath);
outputPath.join("Application.js").write(applicationJS); applicationJSs.forEach(function(applicationJS, n) {
var name = "Application"+(n||"")+".js";
if (options.compressor === "none") {
print("skipping compression: " + name);
} else {
print("compressing: " + name);
applicationJS = require("minify/"+options.compressor).compress(applicationJS, { charset : "UTF-8", useServer : true });
}
outputPath.join(name).write(applicationJS, { charset : "UTF-8" });
});
rewriteMainHTML(outputPath.join(options.index)); rewriteMainHTML(outputPath.join(options.index));
} }
@@ -103,122 +132,197 @@ function main(args)
function ObjectiveJFlattener(rootPath) { function ObjectiveJFlattener(rootPath) {
ObjectiveJRuntimeAnalyzer.apply(this, arguments); ObjectiveJRuntimeAnalyzer.apply(this, arguments);
this.resourceBuffer = []; this.filesToCache = {};
this.bundleBuffer = []; this.fileCacheBuffer = [];
this.functionsBuffer = []; this.functionsBuffer = [];
this._outputBundles = {};
} }
ObjectiveJFlattener.prototype = Object.create(ObjectiveJRuntimeAnalyzer.prototype); ObjectiveJFlattener.prototype = Object.create(ObjectiveJRuntimeAnalyzer.prototype);
ObjectiveJFlattener.prototype.buildApplicationJS = function(applicationRoot) { ObjectiveJFlattener.prototype.buildApplicationJS = function() {
this.serializeStaticResources(applicationRoot);
this.serializeStaticFileExecutables();
var buffer = [] this.setupFileCache();
this.serializeFunctions();
this.serializeFileCache();
buffer.push("(function(){"); var additions = FILE.read(FILE.join(FILE.dirname(module.path), "..", "..", "cappuccino", "lib", "cappuccino", "objj-flatten-additions.js"), { charset:"UTF-8" });
buffer.push("var appURL = new CFURL('.', ObjectiveJ.pageURL);") var applicationJSs = [];
buffer.push(this.bundleBuffer.join("\n")); if (this.options.split === 0) {
var buffer = [];
buffer.push("var baseURL = new CFURL(\".\", ObjectiveJ.pageURL);");
buffer.push(additions);
buffer.push(this.fileCacheBuffer.join("\n"));
buffer.push(this.functionsBuffer.join("\n"));
buffer.push("ObjectiveJ.bootstrap();");
applicationJSs.push(buffer.join("\n"));
} else {
var appFilesCount = this.options.split;
buffer.push("var nodeStack = [];"); var buffers = [];
buffer.push("var applicationRoot = ObjectiveJ.StaticResource.resourceAtURL(appURL, true);"); for (var i = 0; i <= appFilesCount; i++)
buffer.push("var currentNode = null;"); buffers.push([]);
buffer.push("var newNode;");
buffer.push(this.resourceBuffer.join("\n")); var chunks = this.fileCacheBuffer.concat(this.functionsBuffer).sort(function(chunkA, chunkB) {
return chunkA.length - chunkB.length;
});
buffer.push("})();"); // try to equally distribute the chunks. could be better but good enough for now.
var n = 0;
while (chunks.length) {
buffers[(n++ % appFilesCount) + 1].push(chunks.pop());
}
buffer.push(this.functionsBuffer.join("\n")); buffers[0].push("var baseURL = new CFURL(\".\", ObjectiveJ.pageURL);");
buffers[0].push(additions);
buffer.push("ObjectiveJ.bootstrap();"); buffers[0].push("var appFilesCount = " + appFilesCount +";");
buffers[0].push("for (var i = 1; i <= appFilesCount; i++) {");
buffers[0].push(" var script = document.createElement(\"script\");");
buffers[0].push(" script.src = \"Application\"+i+\".js\";");
buffers[0].push(" script.charset = \"UTF-8\";");
buffers[0].push(" script.onload = function() { if (--appFilesCount === 0) ObjectiveJ.bootstrap(); };");
buffers[0].push(" document.getElementsByTagName(\"head\")[0].appendChild(script);");
buffers[0].push("}");
return buffer.join("\n"); buffers.forEach(function(buffer) {
applicationJSs.push(buffer.join("\n"));
});
}
return applicationJSs;
} }
ObjectiveJFlattener.prototype.serializeStaticFileExecutables = function() { ObjectiveJFlattener.prototype.serializeFunctions = function() {
this.require("objective-j").FileExecutable.allFileExecutables().forEach(function(aFileExecutable) { var inlineFunctions = true;//this.options.inlineFunctions;
var deps = aFileExecutable.fileDependencies().map(function(dependency) {
return "new ObjectiveJ.FileDependency(new CFURL("+JSON.stringify(dependency.path())+"),"+JSON.stringify(dependency.isLocal())+")"
}).join(",");
var func = aFileExecutable._function.toString(); var outputFiles = {};
// HACK
func = func.replace(", require, exports, module, system, print, window", "");
this.functionsBuffer.push("var path = "+JSON.stringify(this.rootPath.relative(aFileExecutable.path()).toString())+";"); var _cachedExecutableFunctions = {};
this.functionsBuffer.push("new ObjectiveJ.FileExecutable(path,"+
"new ObjectiveJ.Executable(null, ["+deps+"], path, "+func+"));"); this.require("objective-j").FileExecutable.allFileExecutables().forEach(function(executable) {
var path = executable.path();
if (inlineFunctions)
{
// stringify the function, replacing arguments
var functionString = executable._function.toString().replace(", require, exports, module, system, print, window", ""); // HACK
var relative = this.rootPath.relative(path).toString();
this.functionsBuffer.push("ObjectiveJ.FileExecutable._cacheFunction(new CFURL("+JSON.stringify(relative)+", baseURL),\n"+functionString+");");
}
var bundle = this.context.global.CFBundle.bundleContainingURL(path);
if (bundle && bundle.infoDictionary())
{
var executablePath = bundle.executablePath(),
relativeToBundle = FILE.relative(FILE.join(bundle.path(), ""), path);
if (executablePath)
{
if (inlineFunctions)
{
// remove the code since we're inlining the functions
executable._code = "alert("+JSON.stringify(relativeToBundle)+");";
}
if (!outputFiles[executablePath])
{
outputFiles[executablePath] = [];
outputFiles[executablePath].push("@STATIC;1.0;");
}
var fileContents = executable.toMarkedString();
outputFiles[executablePath].push("p;" + relativeToBundle.length + ";" + relativeToBundle);
outputFiles[executablePath].push("t;" + fileContents.length + ";" + fileContents);
// stream.print("Adding \0green(" + this.rootPath.relative(path) + "\0) to \0cyan(" + this.rootPath.relative(executablePath) + "\0)");
}
}
else
CPLog.warn("No bundle (or info dictionary for) " + rootPath.relative(path));
}, this);
for (var executablePath in outputFiles)
{
var relative = this.rootPath.relative(executablePath).toString();
var contents = outputFiles[executablePath].join("");
this.filesToCache[relative] = contents;
}
}
ObjectiveJFlattener.prototype.serializeFileCache = function() {
for (var relative in this.filesToCache) {
var contents = this.filesToCache[relative];
print("caching: " + relative + " => " + (contents == null ? 404 : 200));
if (contents == null)
this.fileCacheBuffer.push("CFHTTPRequest._cacheRequest(new CFURL("+JSON.stringify(relative)+", baseURL), 404);");
else
this.fileCacheBuffer.push("CFHTTPRequest._cacheRequest(new CFURL("+JSON.stringify(relative)+", baseURL), 200, {}, "+JSON.stringify(contents)+");");
}
}
ObjectiveJFlattener.prototype.setupFileCache = function() {
var paths = {};
UTIL.update(paths, this.requestedURLs);
this.options.paths.forEach(function(relativePath) {
paths[this.rootPath.join(relativePath)] = true;
}, this);
Object.keys(paths).forEach(function(absolute) {
var relative = this.rootPath.relative(absolute).toString();
if (relative.indexOf("..") === 0)
{
print("skipping (parent of app root): " + absolute);
return;
}
if (FILE.isFile(absolute))
{
// if (this.options.maxCachedSize && FILE.size(absolute) > this.options.maxCachedSize)
// {
// print("skipping (larger than "+this.options.maxCachedSize+" bytes): " + absolute);
// return;
// }
var contents = FILE.read(absolute, { charset : "UTF-8" });
this.filesToCache[relative] = contents;
} else {
this.filesToCache[relative] = null;
}
}, this); }, this);
} }
ObjectiveJFlattener.prototype.serializeStaticResources = function(node, depth) {
depth = depth || 0;
var bundle = this.context.global.CFBundle.bundleContainingURL(node.URL());
var bundlePath;
if (!bundle) {
stream.print("\0yellow(Warning:\0) No bundle for path: \0cyan("+node.URL()+"\0)");
}
else if ((bundlePath = bundle.bundlePath()) && !this._outputBundles[bundlePath]) {
this._outputBundles[bundlePath] = bundle;
stream.print("Writing bundle: \0cyan("+bundlePath+"\0)");
print(bundle.infoDictionary())
var relative = this.rootPath.relative(bundlePath).toString();
this.bundleBuffer.push("var bundle = new CFBundle("+
"new CFURL("+(relative ? JSON.stringify(relative) : "appURL")+", ObjectiveJ.pageURL)"+
");");
this.bundleBuffer.push("bundle._loadStatus = " + (1<<4) + ";");
this.bundleBuffer.push("bundle._isValid = true;");
if (bundle.infoDictionary()) {
this.bundleBuffer.push("bundle._infoDictionary = CFPropertyList.propertyListFromString(" +
JSON.stringify(CPPropertyListCreateData(bundle.infoDictionary()).rawString()) + ");");
}
}
// not the root node:
if (depth > 0) {
this.resourceBuffer.push("newNode = new ObjectiveJ.StaticResource(new CFURL(" +
JSON.stringify(node.name()) + "," +
"currentNode.URL().asDirectoryPathURL()" +
"), currentNode, " +
JSON.stringify(node.isDirectory()) + ", " +
JSON.stringify(node.isResolved()) + ");");
} else {
this.resourceBuffer.push("newNode = applicationRoot;");
}
// var contents = node.contents();
// if (contents) {
// this.resourceBuffer.push("newNode._contents = " + JSON.stringify(contents) + ";");
// }
if (!node.children())
return;
this.resourceBuffer.push("nodeStack.push(currentNode);");
this.resourceBuffer.push("currentNode = newNode;");
var children = node.children();
for (var name in children) {
this.serializeStaticResources(children[name], depth+1);
}
this.resourceBuffer.push("currentNode = nodeStack.pop();");
}
// "$1" is the matching indentation // "$1" is the matching indentation
var scriptTagsBefore = '$1<script type = "text/javascript">\n$1 OBJJ_AUTO_BOOTSTRAP = false;\n$1</script>'; var scriptTagsBefore =
var scriptTagsAfter = '$1<script type = "text/javascript" src = "Application.js"></script>'; '$1<script type = "text/javascript">\n'+
'$1 OBJJ_AUTO_BOOTSTRAP = false;\n'+
'$1</script>';
var scriptTagsAfter =
'$1<script type="text/javascript" src="Application.js" charset="UTF-8"></script>';
// enable CPLog:
// scriptTagsAfter = '$1<script type="text/javascript">\n$1 CPLogRegister(CPLogConsole);\n$1</script>\n' + scriptTagsAfter;
function rewriteMainHTML(indexHTMLPath) { function rewriteMainHTML(indexHTMLPath) {
if (indexHTMLPath.isFile()) { if (indexHTMLPath.isFile()) {
var indexHTML = indexHTMLPath.read(); var indexHTML = indexHTMLPath.read({ charset : "UTF-8" });
// inline the Application.js if it's smallish
var applicationJSPath = indexHTMLPath.dirname().join("Application.js");
if (applicationJSPath.size() < 10*1024) {
// escape any dollar signs by replacing them with two
// then indent by splitting/joining on newlines
scriptTagsAfter =
'$1<script type="text/javascript">\n'+
'$1 ' + applicationJSPath.read({ charset : "UTF-8" }).replace(/\$/g, "$$$$").split("\n").join("\n$1 ")+'\n'+
'$1</script>';
}
// attempt to find Objective-J script tag and add ours // attempt to find Objective-J script tag and add ours
var newIndexHTML = indexHTML.replace(/([ \t]+)<script[^>]+Objective-J\.js[^>]+>(?:\s*<\/script>)?/, var newIndexHTML = indexHTML.replace(/([ \t]+)<script[^>]+Objective-J\.js[^>]+>(?:\s*<\/script>)?/,
@@ -226,7 +330,7 @@ function rewriteMainHTML(indexHTMLPath) {
if (newIndexHTML !== indexHTML) { if (newIndexHTML !== indexHTML) {
stream.print("\0green(Modified: "+indexHTMLPath+".\0)"); stream.print("\0green(Modified: "+indexHTMLPath+".\0)");
indexHTMLPath.write(newIndexHTML); indexHTMLPath.write(newIndexHTML, { charset : "UTF-8" });
return; return;
} }
} else { } else {
@@ -5,6 +5,8 @@ var Context = require("interpreter").Context;
ObjectiveJRuntimeAnalyzer = function(rootPath) ObjectiveJRuntimeAnalyzer = function(rootPath)
{ {
this.rootPath = rootPath; this.rootPath = rootPath;
this.rootURL = new CFURL(String(rootPath));
this.context = new Context(); this.context = new Context();
this.scope = setupObjectiveJ(this.context); this.scope = setupObjectiveJ(this.context);
@@ -28,6 +30,19 @@ ObjectiveJRuntimeAnalyzer = function(rootPath)
var url = this.executableURL(); var url = this.executableURL();
return url ? url.absoluteURL().path() : null; return url ? url.absoluteURL().path() : null;
} }
this.require("cappuccino/objj-flatten-additions");
if (!this.context.global.CFHTTPRequest._lookupCachedRequest)
print("Warning: CFHTTPRequest._lookupCachedRequest. Need to import objj-flatten-additions module.");
var requestedURLs = this.requestedURLs = {};
var _lookupCachedRequest = this.context.global.CFHTTPRequest._lookupCachedRequest;
this.context.global.CFHTTPRequest._lookupCachedRequest = function(aURL) {
var path = new CFURL(aURL, this.rootURL).absoluteURL().path();
requestedURLs[path] = true;
return _lookupCachedRequest.apply(null, arguments);
}
} }
ObjectiveJRuntimeAnalyzer.prototype.setIncludePaths = function(includePaths) { ObjectiveJRuntimeAnalyzer.prototype.setIncludePaths = function(includePaths) {
@@ -0,0 +1,57 @@
var URLCache = { };
CFHTTPRequest.prototype.open = function(/*String*/ method, /*String*/ url, /*Boolean*/ async, /*String*/ user, /*String*/ password)
{
var cachedRequest = CFHTTPRequest._lookupCachedRequest(url);
if (cachedRequest)
{
var self = this;
this._nativeRequest = cachedRequest;
this._nativeRequest.onreadystatechange = function()
{
ObjectiveJ.determineAndDispatchHTTPRequestEvents(self);
};
}
return this._nativeRequest.open(method, url, async, user, password);
}
CFHTTPRequest._cacheRequest = function(/*CFURL|String*/ aURL, /*Number*/ status, /*Object*/ headers, /*String*/ body)
{
URLCache[aURL] = new MockXMLHttpRequest(status, headers, body);
}
CFHTTPRequest._lookupCachedRequest = function(/*CFURL|String*/ aURL)
{
return URLCache[aURL];
}
function MockXMLHttpRequest(status, headers, body)
{
this.readyState = CFHTTPRequest.UninitializedState;
this.status = status || 200;
this.statusText = "";
this.responseText = body || "";
this._responseHeaders = headers || {};
};
MockXMLHttpRequest.prototype.open = function(method, url, async, user, password)
{
this.readyState = CFHTTPRequest.LoadingState;
this.async = async;
};
MockXMLHttpRequest.prototype.send = function(body)
{
var self = this;
self.responseText = self.responseText.toString();
function complete() {
for (self.readyState = CFHTTPRequest.LoadedState; self.readyState <= CFHTTPRequest.CompleteState; self.readyState++)
self.onreadystatechange();
}
(self.async ? ObjectiveJ.Asynchronous(complete) : complete)();
};
MockXMLHttpRequest.prototype.onreadystatechange = function() {};
MockXMLHttpRequest.prototype.abort = function() {};
MockXMLHttpRequest.prototype.setRequestHeader = function(header, value) {};
MockXMLHttpRequest.prototype.getAllResponseHeaders = function() { return this._responseHeaders; };
MockXMLHttpRequest.prototype.getResponseHeader = function(header) { return this._responseHeaders[header]; };
MockXMLHttpRequest.prototype.overrideMimeType = function(mimetype) {};
+11
View File
@@ -153,6 +153,12 @@
continue; continue;
var value = object[key]; var value = object[key];
if (value === null)
{
[dictionary setObject:[CPNull null] forKey:key];
continue;
}
if (recursively) if (recursively)
{ {
@@ -521,6 +527,11 @@
return self.toString(); return self.toString();
} }
- (BOOL)containsKey:(id)aKey
{
var value = [self objectForKey:aKey];
return ((value !== nil) && (value !== undefined));
}
@end @end
@implementation CPDictionary (CPCoding) @implementation CPDictionary (CPCoding)
+11 -5
View File
@@ -163,9 +163,15 @@ var CPArrayClass = Ni
@param data the data from which to read the graph @param data the data from which to read the graph
@return the unarchived object @return the unarchived object
*/ */
+ (id)unarchiveObjectWithData:(CPData)data + (id)unarchiveObjectWithData:(CPData)aData
{ {
var unarchiver = [[self alloc] initForReadingWithData:data], if (!aData)
{
CPLog.error("Null data passed to -[CPKeyedUnarchiver unarchiveObjectWithData:].");
return nil;
}
var unarchiver = [[self alloc] initForReadingWithData:aData],
object = [unarchiver decodeObjectForKey:@"root"]; object = [unarchiver decodeObjectForKey:@"root"];
[unarchiver finishDecoding]; [unarchiver finishDecoding];
@@ -200,7 +206,7 @@ var CPArrayClass = Ni
- (CPDictionary)_decodeDictionaryOfObjectsForKey:(CPString)aKey - (CPDictionary)_decodeDictionaryOfObjectsForKey:(CPString)aKey
{ {
var object = _plistObject.valueForKey(aKey), var object = _plistObject.valueForKey(aKey),
objectClass = object && object.isa; objectClass = (object != nil) && object.isa;
if (objectClass === CPDictionaryClass || objectClass === CPMutableDictionaryClass) if (objectClass === CPDictionaryClass || objectClass === CPMutableDictionaryClass)
{ {
@@ -315,7 +321,7 @@ var CPArrayClass = Ni
- (id)decodeObjectForKey:(CPString)aKey - (id)decodeObjectForKey:(CPString)aKey
{ {
var object = _plistObject.valueForKey(aKey), var object = _plistObject.valueForKey(aKey),
objectClass = object && object.isa; objectClass = (object != nil) && object.isa;
if (objectClass === CPDictionaryClass || objectClass === CPMutableDictionaryClass) if (objectClass === CPDictionaryClass || objectClass === CPMutableDictionaryClass)
return _CPKeyedUnarchiverDecodeObjectAtIndex(self, object.valueForKey(_CPKeyedArchiverUIDKey)); return _CPKeyedUnarchiverDecodeObjectAtIndex(self, object.valueForKey(_CPKeyedArchiverUIDKey));
@@ -519,7 +525,7 @@ var _CPKeyedUnarchiverDecodeObjectAtIndex = function(self, anIndex)
// If this object is a member of _CPKeyedArchiverValue, then we know // If this object is a member of _CPKeyedArchiverValue, then we know
// that it is a wrapper for a primitive JavaScript object. // that it is a wrapper for a primitive JavaScript object.
if (object && (object.isa === _CPKeyedArchiverValueClass)) if ((object != nil) && (object.isa === _CPKeyedArchiverValueClass))
object = [object JSObject]; object = [object JSObject];
return object; return object;
+1 -1
View File
@@ -61,7 +61,7 @@
- (void)forwardInvocation:(CPInvocation)anInvocation - (void)forwardInvocation:(CPInvocation)anInvocation
{ {
[CPException raise:CPInvalidArgumentException [CPException raise:CPInvalidArgumentException
reason:@"-methodSignatureForSelector: called on abstract CPProxy class."]; reason:@"-forwardInvocation: called on abstract CPProxy class."];
} }
// FIXME: This should be moved to the runtime? // FIXME: This should be moved to the runtime?
+2 -2
View File
@@ -196,8 +196,8 @@ var CPURLURLStringKey = @"CPURLURLStringKey",
- (id)initWithCoder:(CPCoder)aCoder - (id)initWithCoder:(CPCoder)aCoder
{ {
return [self initWithURLString:[aCoder decodeObjectForKey:CPURLURLStringKey] return [self initWithString:[aCoder decodeObjectForKey:CPURLURLStringKey]
baseURL:[aCoder decodeObjectForKey:CPURLBaseURLKey]]; relativeToURL:[aCoder decodeObjectForKey:CPURLBaseURLKey]];
} }
- (void)encodeWithCoder:(CPCoder)aCoder - (void)encodeWithCoder:(CPCoder)aCoder
+2 -2
View File
@@ -247,7 +247,7 @@ task ("demos", function()
// Testing // Testing
task("test", ["build", "test-only"]); task("test", ["CommonJS", "test-only"]);
task("test-only", function() task("test-only", function()
{ {
@@ -281,7 +281,7 @@ function pushPackage(path, remote, branch)
{ {
branch = branch || "master"; branch = branch || "master";
var pushPackagesPath = FILE.path(".push-package") var pushPackagesPath = FILE.path(".push-package");
pushPackagesPath.mkdirs(); pushPackagesPath.mkdirs();
+2 -1
View File
@@ -437,12 +437,13 @@ function loadSpritedImagesForBundle(/*Bundle*/ aBundle, success, failure)
CFTotalBytesLoaded += anEvent.request.responseText().length; CFTotalBytesLoaded += anEvent.request.responseText().length;
decompileStaticFile(aBundle, anEvent.request.responseText(), spritedImagesURL); decompileStaticFile(aBundle, anEvent.request.responseText(), spritedImagesURL);
aBundle._loadStatus &= ~CFBundleLoadingSpritedImages; aBundle._loadStatus &= ~CFBundleLoadingSpritedImages;
success();
} }
catch(anException) catch(anException)
{ {
failure(anException); failure(anException);
} }
success();
}, failure); }, failure);
} }
+10 -6
View File
@@ -196,9 +196,9 @@ CFHTTPRequest.prototype.overrideMimeType = function(/*String*/ aMimeType)
return this._nativeRequest.overrideMimeType(aMimeType); return this._nativeRequest.overrideMimeType(aMimeType);
} }
CFHTTPRequest.prototype.open = function(/*...*/) CFHTTPRequest.prototype.open = function(/*String*/ aMethod, /*String*/ aURL, /*Boolean*/ isAsynchronous, /*String*/ aUser, /*String*/ aPassword)
{ {
return this._nativeRequest.open(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4]); return this._nativeRequest.open(aMethod, aURL, isAsynchronous, aUser, aPassword);
} }
CFHTTPRequest.prototype.send = function(/*Object*/ aBody) CFHTTPRequest.prototype.send = function(/*Object*/ aBody)
@@ -259,7 +259,7 @@ function FileRequest(/*CFURL*/ aURL, onsuccess, onfailure)
if (aURL.pathExtension() === "plist") if (aURL.pathExtension() === "plist")
request.overrideMimeType("text/xml"); request.overrideMimeType("text/xml");
if (FileRequest.async) if (exports.asyncLoader)
{ {
request.onsuccess = Asynchronous(onsuccess); request.onsuccess = Asynchronous(onsuccess);
request.onfailure = Asynchronous(onfailure); request.onfailure = Asynchronous(onfailure);
@@ -270,12 +270,16 @@ function FileRequest(/*CFURL*/ aURL, onsuccess, onfailure)
request.onfailure = onfailure; request.onfailure = onfailure;
} }
request.open("GET", aURL.absoluteString(), FileRequest.async); request.open("GET", aURL.absoluteString(), exports.asyncLoader);
request.send(""); request.send("");
} }
#ifdef BROWSER #ifdef BROWSER
FileRequest.async = YES; exports.asyncLoader = YES;
#else #else
FileRequest.async = NO; exports.asyncLoader = NO;
#endif #endif
// FIXME: Get rid of these when we no longer need Mock requests in flatten.
exports.Asynchronous = Asynchronous;
exports.determineAndDispatchHTTPRequestEvents = determineAndDispatchHTTPRequestEvents;
+25 -7
View File
@@ -314,7 +314,7 @@ function resolveURL(aURL)
resolvedPathComponents.splice(basePathComponents.length - 1, 1); resolvedPathComponents.splice(basePathComponents.length - 1, 1);
// If this doesn't start with a "..", then we're simply appending to already standardized paths. // If this doesn't start with a "..", then we're simply appending to already standardized paths.
if (pathComponents.length && pathComponents[0] === "..") if (pathComponents.length && (pathComponents[0] === ".." || pathComponents[0] === "."))
standardizePathComponents(resolvedPathComponents, YES); standardizePathComponents(resolvedPathComponents, YES);
resolvedParts.pathComponents = resolvedPathComponents; resolvedParts.pathComponents = resolvedPathComponents;
@@ -352,19 +352,26 @@ function standardizePathComponents(/*Array*/ pathComponents, /*BOOL*/ inPlace)
var index = 0, var index = 0,
resultIndex = 0, resultIndex = 0,
count = pathComponents.length, count = pathComponents.length,
result = inPlace ? pathComponents : []; result = inPlace ? pathComponents : [],
startsWithPeriod = NO;
for (; index < count; ++index) for (; index < count; ++index)
{ {
var component = pathComponents[index]; var component = pathComponents[index];
if (component === "" || component === ".") if (component === "")
continue; continue;
if (component === ".")
{
startsWithPeriod = resultIndex === 0;
continue;
}
if (component !== ".." || resultIndex === 0 || result[resultIndex - 1] === "..") if (component !== ".." || resultIndex === 0 || result[resultIndex - 1] === "..")
{ {
//if (resultIndex !== index) result[resultIndex] = component;
result[resultIndex] = component;
resultIndex++; resultIndex++;
@@ -375,6 +382,9 @@ function standardizePathComponents(/*Array*/ pathComponents, /*BOOL*/ inPlace)
--resultIndex; --resultIndex;
} }
if (startsWithPeriod && resultIndex === 0)
result[resultIndex++] = ".";
result.length = resultIndex; result.length = resultIndex;
return result; return result;
@@ -505,10 +515,11 @@ CFURL.prototype.hasDirectoryPath = function()
var lastPathComponent = this.lastPathComponent(); var lastPathComponent = this.lastPathComponent();
hasDirectoryPath = lastPathComponent === "." || lastPathComponent === ".."; hasDirectoryPath = lastPathComponent === "." || lastPathComponent === "..";
this._hasDirectoryPath = hasDirectoryPath; this._hasDirectoryPath = hasDirectoryPath;
} }
return this._hasDirectoryPath; return hasDirectoryPath;
} }
DISPLAY_NAME(CFURL.prototype.hasDirectoryPath); DISPLAY_NAME(CFURL.prototype.hasDirectoryPath);
@@ -646,7 +657,14 @@ CFURL.prototype.asDirectoryPathURL = function()
if (this.hasDirectoryPath()) if (this.hasDirectoryPath())
return this; return this;
return new CFURL(this.lastPathComponent() + "/", this); var lastPathComponent = this.lastPathComponent();
// We do this because on Windows the path may start with C: and be
// misinterpreted as a scheme.
if (lastPathComponent !== "/")
lastPathComponent = "./" + lastPathComponent;
return new CFURL(lastPathComponent + "/", this);
} }
DISPLAY_NAME(CFURL.prototype.asDirectoryPathURL); DISPLAY_NAME(CFURL.prototype.asDirectoryPathURL);
+7
View File
@@ -357,3 +357,10 @@ function _CPLogInitPopup(logWindow)
}, false); }, false);
} }
#endif #endif
#if COMMONJS
CPLogDefault = CPLogPrint;
#else
CPLogDefault = (typeof window === "object" && window.console) ? CPLogConsole : CPLogPopup;
#endif
+1 -26
View File
@@ -148,37 +148,12 @@ exports.repl = function()
} }
} }
exports.objj_eval = function(/*String*/ aString)
{
// We need this while code still refers to window.
Executable.setCommonJSArguments(require, exports, module, system, print, window);
var executable = exports.preprocess(aString, "", 0);
if (!executable.hasLoadedFileDependencies())
executable.loadFileDependencies();
// A bit of a hack. Executable compiles the code itself into a function, but we want
// the raw code to eval here.
var code = executable._code;
// Not clear why these should be global, varing them doesn't seem to take effect with evaluateString.
global.objj_executeFile = Executable.fileExecuterForURL(FILE.cwd());
global.objj_importFile = Executable.fileImporterForURL(FILE.cwd());
if (typeof system !== "undefined" && system.engine === "rhino")
return Packages.org.mozilla.javascript.Context.getCurrentContext().evaluateString(global, code, "objj_eval", 0, NULL);
return eval(code);
}
Executable.setCommonJSParameters("require", "exports", "module", "system", "print", "window");
// creates a narwhal factory function in the objj module scope // creates a narwhal factory function in the objj module scope
exports.make_narwhal_factory = function(path) exports.make_narwhal_factory = function(path)
{ {
return function(require, exports, module, system, print) return function(require, exports, module, system, print)
{ {
Executable.setCommonJSParameters("require", "exports", "module", "system", "print", "window");
Executable.setCommonJSArguments(require, exports, module, system, print, window); Executable.setCommonJSArguments(require, exports, module, system, print, window);
Executable.fileImporterForURL(FILE.dirname(path))(path, YES); Executable.fileImporterForURL(FILE.dirname(path))(path, YES);
} }
@@ -16,8 +16,7 @@ var Task = Jake.Task,
function isImage(/*String*/ aFilename) function isImage(/*String*/ aFilename)
{ {
return FILE.isFile(aFilename) && return UTIL.has([".png", ".jpg", ".jpeg", ".gif", ".tif", ".tiff"], FILE.extension(aFilename).toLowerCase());
UTIL.has([".png", ".jpg", ".jpeg", ".gif", ".tif", ".tiff"], FILE.extension(aFilename).toLowerCase());
} }
function mimeType(/*String*/ aFilename) function mimeType(/*String*/ aFilename)
@@ -370,14 +369,17 @@ BundleTask.prototype.infoPlist = function()
return anEnvironment.name(); return anEnvironment.name();
})); }));
infoPlist.setValueForKey("CPBundleExecutable", this.productName() + ".sj"); infoPlist.setValueForKey("CPBundleExecutable", this.productName() + ".sj");
infoPlist.setValueForKey("CPBundleEnvironmentsWithImageSprites", this.environments().filter(
var environmentsWithImageSprites = this.environments().filter(
function(anEnvironment) function(anEnvironment)
{ {
return anEnvironment.spritesImages(); return anEnvironment.spritesImages() && task(this.buildProductDataURLPathForEnvironment(anEnvironment)).prerequisites().filter(isImage).length > 0;
}).map(function(anEnvironment) }, this).map(function(anEnvironment)
{ {
return anEnvironment.name(); return anEnvironment.name();
})); });
infoPlist.setValueForKey("CPBundleEnvironmentsWithImageSprites", environmentsWithImageSprites);
var principalClass = this.principalClass(); var principalClass = this.principalClass();
@@ -581,7 +583,6 @@ BundleTask.prototype.defineResourceTasks = function()
}, this); }, this);
} }
var RESOURCES_PATH = FILE.join(FILE.absolute(FILE.dirname(module.path)), "RESOURCES"), var RESOURCES_PATH = FILE.join(FILE.absolute(FILE.dirname(module.path)), "RESOURCES"),
MHTMLTestPath = FILE.join(RESOURCES_PATH, "MHTMLTest.txt"); MHTMLTestPath = FILE.join(RESOURCES_PATH, "MHTMLTest.txt");
@@ -595,27 +596,29 @@ BundleTask.prototype.defineSpritedImagesTask = function()
var folder = anEnvironment.name() + ".environment", var folder = anEnvironment.name() + ".environment",
resourcesPath = FILE.join(this.buildIntermediatesProductPath(), folder, "Resources", ""); resourcesPath = FILE.join(this.buildIntermediatesProductPath(), folder, "Resources", "");
function isDataResource(/*String*/ aFilename)
{
return FILE.isFile(aFilename) && aFilename.indexOf(resourcesPath) === 0 && isImage(aFilename);
}
var productName = this.productName(), var productName = this.productName(),
dataURLPath = this.buildProductDataURLPathForEnvironment(anEnvironment); dataURLPath = this.buildProductDataURLPathForEnvironment(anEnvironment);
filedir (dataURLPath, function(aTask) filedir (dataURLPath, function(aTask)
{ {
var prerequisites = aTask.prerequisites().filter(isImage);
if (!prerequisites.length)
{
if (FILE.exists(dataURLPath))
FILE.remove(dataURLPath);
return;
}
TERM.stream.print("Creating data URLs file... \0green(" + dataURLPath +"\0)"); TERM.stream.print("Creating data URLs file... \0green(" + dataURLPath +"\0)");
var dataURLStream = FILE.open(dataURLPath, "w+", { charset:"UTF-8" }); var dataURLStream = FILE.open(dataURLPath, "w+", { charset:"UTF-8" });
dataURLStream.write("@STATIC;1.0;"); dataURLStream.write("@STATIC;1.0;");
aTask.prerequisites().forEach(function(aFilename) prerequisites.forEach(function(aFilename)
{ {
if (!isDataResource(aFilename))
return;
var resourcePath = "Resources/" + FILE.relative(resourcesPath, aFilename); var resourcePath = "Resources/" + FILE.relative(resourcesPath, aFilename);
dataURLStream.write("u;" + resourcePath.length + ";" + resourcePath); dataURLStream.write("u;" + resourcePath.length + ";" + resourcePath);
@@ -636,17 +639,24 @@ BundleTask.prototype.defineSpritedImagesTask = function()
filedir (MHTMLPath, function(aTask) filedir (MHTMLPath, function(aTask)
{ {
var prerequisites = aTask.prerequisites().filter(isImage);
if (!prerequisites.length)
{
if (FILE.exists(MHTMLPath))
FILE.remove(MHTMLPath);
return;
}
TERM.stream.print("Creating MHTML paths file... \0green(" + MHTMLPath +"\0)"); TERM.stream.print("Creating MHTML paths file... \0green(" + MHTMLPath +"\0)");
var MHTMLStream = FILE.open(MHTMLPath, "w+", { charset:"UTF-8" }); var MHTMLStream = FILE.open(MHTMLPath, "w+", { charset:"UTF-8" });
MHTMLStream.write("@STATIC;1.0;"); MHTMLStream.write("@STATIC;1.0;");
aTask.prerequisites().forEach(function(aFilename) prerequisites.forEach(function(aFilename)
{ {
if (!isDataResource(aFilename))
return;
var resourcePath = "Resources/" + FILE.relative(resourcesPath, aFilename), var resourcePath = "Resources/" + FILE.relative(resourcesPath, aFilename),
MHTMLResourcePath = "mhtml:" + FILE.join(folder, "MHTMLData.txt!") + resourcePath; MHTMLResourcePath = "mhtml:" + FILE.join(folder, "MHTMLData.txt!") + resourcePath;
@@ -663,17 +673,24 @@ BundleTask.prototype.defineSpritedImagesTask = function()
filedir (MHTMLDataPath, function(aTask) filedir (MHTMLDataPath, function(aTask)
{ {
var prerequisites = aTask.prerequisites().filter(isImage);
if (!prerequisites.length)
{
if (FILE.exists(MHTMLDataPath))
FILE.remove(MHTMLDataPath);
return;
}
TERM.stream.print("Creating MHTML images file... \0green(" + MHTMLDataPath +"\0)"); TERM.stream.print("Creating MHTML images file... \0green(" + MHTMLDataPath +"\0)");
var MHTMLDataStream = FILE.open(MHTMLDataPath, "w+", { charset:"UTF-8" }); var MHTMLDataStream = FILE.open(MHTMLDataPath, "w+", { charset:"UTF-8" });
MHTMLDataStream.write("/*\r\nContent-Type: multipart/related; boundary=\"_ANY_STRING_WILL_DO_AS_A_SEPARATOR\"\r\n\r\n"); MHTMLDataStream.write("/*\r\nContent-Type: multipart/related; boundary=\"_ANY_STRING_WILL_DO_AS_A_SEPARATOR\"\r\n\r\n");
aTask.prerequisites().forEach(function(aFilename) prerequisites.forEach(function(aFilename)
{ {
if (!isDataResource(aFilename))
return;
var resourcePath = "Resources/" + FILE.relative(resourcesPath, aFilename); var resourcePath = "Resources/" + FILE.relative(resourcesPath, aFilename);
MHTMLDataStream.write("--_ANY_STRING_WILL_DO_AS_A_SEPARATOR\r\n"); MHTMLDataStream.write("--_ANY_STRING_WILL_DO_AS_A_SEPARATOR\r\n");
+1 -1
View File
@@ -27,7 +27,7 @@ if (typeof window !== "undefined")
window.setNativeTimeout = window.setTimeout; window.setNativeTimeout = window.setTimeout;
window.clearNativeTimeout = window.clearTimeout; window.clearNativeTimeout = window.clearTimeout;
window.setNativeInterval = window.setInterval; window.setNativeInterval = window.setInterval;
window.clearNativeInterval = window.clearNativeInterval; window.clearNativeInterval = window.clearInterval;
} }
// Objective-J Constants // Objective-J Constants
+4
View File
@@ -20,6 +20,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#ifdef BROWSER
CPLogRegister(CPLogDefault);
#endif
// formatting helpers // formatting helpers
function objj_debug_object_format(aReceiver) function objj_debug_object_format(aReceiver)
+55
View File
@@ -0,0 +1,55 @@
GLOBAL(objj_eval) = function(/*String*/ aString)
{
#if COMMONJS
var url = FILE.join(FILE.cwd(), "/");
Executable.setCommonJSParameters("require", "exports", "module", "system", "print", "window");
Executable.setCommonJSArguments(require, exports, module, system, print, window);
#else
var url = exports.pageURL;
#endif
// Temporarily switch the loader to sychronous mode since objj_eval must be synchronous
// therefore you shouldn't use @imports in objj_eval the browser
var asyncLoaderSaved = exports.asyncLoader;
exports.asyncLoader = NO;
var executable = exports.preprocess(aString, url, 0);
if (!executable.hasLoadedFileDependencies())
executable.loadFileDependencies();
// here we setup a scope object containing the free variables that would normally be arguments to the module function
global._objj_eval_scope = {};
global._objj_eval_scope.objj_executeFile = Executable.fileExecuterForURL(url);
global._objj_eval_scope.objj_importFile = Executable.fileImporterForURL(url);
#if COMMONJS
global._objj_eval_scope.require = require;
global._objj_eval_scope.exports = exports;
global._objj_eval_scope.module = module;
global._objj_eval_scope.system = system;
global._objj_eval_scope.print = print;
global._objj_eval_scope.window = window;
#endif
// A bit of a hack. Executable compiles the code itself into a function, but we want
// the raw code to eval here so we can get the result.
// No known way to get the result of a statement except via eval.
var code = "with(_objj_eval_scope){" + executable._code + "\n//*/\n}";
var result;
#if COMMONJS
if (typeof system !== "undefined" && system.engine === "rhino")
result = Packages.org.mozilla.javascript.Context.getCurrentContext().evaluateString(global, code, "objj_eval", 0, NULL);
else
#endif
result = eval(code);
// restore async loader setting
exports.asyncLoader = asyncLoaderSaved;
return result;
}
// deprecated, use global
exports.objj_eval = objj_eval;
+6 -3
View File
@@ -218,10 +218,13 @@ Executable.prototype.loadFileDependencies = function(aCallback)
{ {
var status = this._fileDependencyStatus; var status = this._fileDependencyStatus;
if (status === ExecutableLoadedFileDependencies) if (aCallback)
return aCallback(); {
if (status === ExecutableLoadedFileDependencies)
return aCallback();
this._fileDependencyCallbacks.push(aCallback) this._fileDependencyCallbacks.push(aCallback);
}
if (status === ExecutableUnloadedFileDependencies) if (status === ExecutableUnloadedFileDependencies)
{ {
+20 -5
View File
@@ -22,7 +22,7 @@
var FileExecutablesForURLStrings = { }; var FileExecutablesForURLStrings = { };
function FileExecutable(/*CFURL|String*/ aURL, /*Executable*/ anExecutable) function FileExecutable(/*CFURL|String*/ aURL)
{ {
aURL = makeAbsoluteURL(aURL); aURL = makeAbsoluteURL(aURL);
@@ -38,10 +38,7 @@ function FileExecutable(/*CFURL|String*/ aURL, /*Executable*/ anExecutable)
executable = NULL, executable = NULL,
extension = aURL.pathExtension(); extension = aURL.pathExtension();
if (anExecutable) if (fileContents.match(/^@STATIC;/))
executable = anExecutable;
else if (fileContents.match(/^@STATIC;/))
executable = decompile(fileContents, aURL); executable = decompile(fileContents, aURL);
else if (extension === "j" || !extension) else if (extension === "j" || !extension)
@@ -117,5 +114,23 @@ function decompile(/*String*/ aString, /*CFURL*/ aURL)
dependencies.push(new FileDependency(new CFURL(text), YES)); dependencies.push(new FileDependency(new CFURL(text), YES));
} }
var fn = FileExecutable._lookupCachedFunction(aURL)
if (fn)
return new Executable(code, dependencies, aURL, fn);
return new Executable(code, dependencies, aURL); return new Executable(code, dependencies, aURL);
} }
var FunctionCache = { };
FileExecutable._cacheFunction = function(/*CFURL|String*/ aURL, /*Function*/ fn)
{
aURL = typeof aURL === "string" ? aURL : aURL.absoluteString();
FunctionCache[aURL] = fn;
}
FileExecutable._lookupCachedFunction = function(/*CFURL|String*/ aURL)
{
aURL = typeof aURL === "string" ? aURL : aURL.absoluteString();
return FunctionCache[aURL];
}
+1
View File
@@ -47,6 +47,7 @@
#include "Executable.js" #include "Executable.js"
#include "FileExecutable.js" #include "FileExecutable.js"
#include "Runtime.js" #include "Runtime.js"
#include "Eval.js"
#if defined(DEBUG) || defined(COMMONJS) #if defined(DEBUG) || defined(COMMONJS)
#include "Debug.js" #include "Debug.js"
#endif #endif
+7 -1
View File
@@ -143,8 +143,14 @@ StaticResource.resourceAtURL = function(/*CFURL|String*/ aURL, /*BOOL*/ resolveA
resource = resource._children[name]; resource = resource._children[name];
else if (resolveAsDirectoriesIfNecessary) else if (resolveAsDirectoriesIfNecessary)
resource = new StaticResource(new CFURL(name, resource.URL()), resource, YES, YES); {
// We do this because on Windows the path may start with C: and be
// misinterpreted as a scheme.
if (name !== "/")
name = "./" + name;
resource = new StaticResource(new CFURL(name, resource.URL()), resource, YES, YES);
}
else else
throw new Error("Static Resource at " + aURL + " is not resolved (\"" + name + "\")"); throw new Error("Static Resource at " + aURL + " is not resolved (\"" + name + "\")");
} }
+37 -8
View File
@@ -2,6 +2,9 @@
@implementation CPDictionaryTest : OJTestCase @implementation CPDictionaryTest : OJTestCase
{ {
CPDictionary string_dict;
CPDictionary json_dict;
JSObject json;
} }
- (void)setUp - (void)setUp
@@ -54,14 +57,28 @@
- (void)testDictionaryWithJSObjectRecursive - (void)testDictionaryWithJSObjectRecursive
{ {
var dict = [CPDictionary dictionaryWithJSObject:json recursively:YES]; var dict = [CPDictionary dictionaryWithJSObject:json recursively:YES];
[self assert:[dict count] equals:3]; [self assert:[json_dict count] equals:3];
[self assert:[[dict objectForKey:@"key3"] count] equals:1]; [self assert:[[dict objectForKey:@"key3"] count] equals:1];
} }
- (void)testDictionaryWithJSObjectRecursiveWithNull
{
var json_with_nulls = {
"key1": ['1', '2', '3'],
"key2": "This is a string",
"key3": null
}
var dict = [CPDictionary dictionaryWithJSObject:json_with_nulls recursively:YES];
[self assert:3 equals:[dict count]];
[self assert:[@"key1", @"key2", @"key3"] equals:[dict allKeys]];
[self assert:[CPNull null] equals:[dict objectForKey:@"key3"]];
}
- (void)testDictionaryWithJSObjectNonRecursive - (void)testDictionaryWithJSObjectNonRecursive
{ {
var non_recursive_dict = [CPDictionary dictionaryWithJSObject:json recursively:NO]; var non_recursive_dict = [CPDictionary dictionaryWithJSObject:json recursively:NO];
[self assertThrows:[non_recursive_dict objectForKey:@"key3"]];
} }
- (void)testCopy - (void)testCopy
@@ -141,8 +158,6 @@
[json_dict removeObjectForKey:@"key1"]; [json_dict removeObjectForKey:@"key1"];
[self assert:[string_dict count] equals:1]; [self assert:[string_dict count] equals:1];
[self assert:[json_dict count] equals:2]; [self assert:[json_dict count] equals:2];
[self assertThrows:[string_dict objectForKey:@"key1"]];
[self assertThrows:[json_dict objectForKey:@"key1"]];
} }
- (void)testRemoveObjectsForKeys - (void)testRemoveObjectsForKeys
@@ -151,9 +166,6 @@
[json_dict removeObjectsForKeys:[@"key1", @"key2"]]; [json_dict removeObjectsForKeys:[@"key1", @"key2"]];
[self assert:[string_dict count] equals:1]; [self assert:[string_dict count] equals:1];
[self assert:[json_dict count] equals:1]; [self assert:[json_dict count] equals:1];
[self assertThrows:[string_dict objectForKey:@"key1"]];
[self assertThrows:[json_dict objectForKey:@"key1"]];
[self assertThrows:[json_dict objectForKey:@"key2"]];
} }
- (void)testSetObjectForKey - (void)testSetObjectForKey
@@ -173,4 +185,21 @@
[self assert:[json_dict count] equals:5]; [self assert:[json_dict count] equals:5];
} }
@end - (void)testDictionaryWithFalsyValues
{
var dict = [[CPDictionary alloc] initWithObjects:["", 0, [CPNull null]] forKeys:["1", "2", "3"]];
[self assertTrue:[dict containsKey:"1"]];
[self assertTrue:[dict containsKey:"2"]];
[self assertTrue:[dict containsKey:"3"]];
[self assertFalse:[dict containsKey:"4"]];
}
- (void)testThrowsOnNilValue
{
[self assertThrows:function(){
var dict = [[CPDictionary alloc] initWithObjects:[1, nil] forKeys:["1", "2"]];
[self assertFalse:dict];
}];
}
@end
+2 -2
View File
@@ -32,7 +32,7 @@ CPLogRegister(CPLogConsole);
- (int)numberOfRowsInTableView:(CPTableView)tableView - (int)numberOfRowsInTableView:(CPTableView)tableView
{ {
return 700000; return 100000;
} }
- (id)tableView:(CPTableView)tableView objectValueForTableColumn:(CPTableColumn)tableColumn row:(int)row - (id)tableView:(CPTableView)tableView objectValueForTableColumn:(CPTableColumn)tableColumn row:(int)row
@@ -43,4 +43,4 @@ CPLogRegister(CPLogConsole);
return String((row + 1) * [[tableColumn identifier] intValue]); return String((row + 1) * [[tableColumn identifier] intValue]);
} }
@end @end
File diff suppressed because one or more lines are too long
@@ -12,7 +12,7 @@
</object> </object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<integer value="372"/> <integer value="371"/>
</object> </object>
<object class="NSArray" key="IBDocument.PluginDependencies"> <object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
@@ -84,6 +84,7 @@
<object class="NSMutableArray" key="NSTableColumns"> <object class="NSMutableArray" key="NSTableColumns">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSTableColumn" id="534516850"> <object class="NSTableColumn" id="534516850">
<string key="NSIdentifier">1</string>
<double key="NSWidth">101</double> <double key="NSWidth">101</double>
<double key="NSMinWidth">40</double> <double key="NSMinWidth">40</double>
<double key="NSMaxWidth">1000</double> <double key="NSMaxWidth">1000</double>
@@ -142,6 +143,7 @@
<reference key="NSTableView" ref="86489736"/> <reference key="NSTableView" ref="86489736"/>
</object> </object>
<object class="NSTableColumn" id="870554271"> <object class="NSTableColumn" id="870554271">
<string key="NSIdentifier">2</string>
<double key="NSWidth">154</double> <double key="NSWidth">154</double>
<double key="NSMinWidth">40</double> <double key="NSMinWidth">40</double>
<double key="NSMaxWidth">1000</double> <double key="NSMaxWidth">1000</double>
@@ -168,6 +170,7 @@
<reference key="NSTableView" ref="86489736"/> <reference key="NSTableView" ref="86489736"/>
</object> </object>
<object class="NSTableColumn" id="192893327"> <object class="NSTableColumn" id="192893327">
<string key="NSIdentifier">3</string>
<double key="NSWidth">188</double> <double key="NSWidth">188</double>
<double key="NSMinWidth">10</double> <double key="NSMinWidth">10</double>
<double key="NSMaxWidth">3.4028234663852886e+38</double> <double key="NSMaxWidth">3.4028234663852886e+38</double>
@@ -214,8 +217,8 @@
<bytes key="NSWhite">MC41AA</bytes> <bytes key="NSWhite">MC41AA</bytes>
</object> </object>
</object> </object>
<double key="NSRowHeight">17</double> <double key="NSRowHeight">23</double>
<int key="NSTvFlags">-702545920</int> <int key="NSTvFlags">-694157312</int>
<reference key="NSDelegate"/> <reference key="NSDelegate"/>
<reference key="NSDataSource"/> <reference key="NSDataSource"/>
<int key="NSColumnAutoresizingStyle">4</int> <int key="NSColumnAutoresizingStyle">4</int>
@@ -277,7 +280,7 @@
<reference key="NSContentView" ref="331394667"/> <reference key="NSContentView" ref="331394667"/>
<reference key="NSHeaderClipView" ref="471528550"/> <reference key="NSHeaderClipView" ref="471528550"/>
<reference key="NSCornerView" ref="167646100"/> <reference key="NSCornerView" ref="167646100"/>
<bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes> <bytes key="NSScrollAmts">QSAAAEEgAABByAAAQcgAAA</bytes>
</object> </object>
</object> </object>
<string key="NSFrameSize">{558, 348}</string> <string key="NSFrameSize">{558, 348}</string>
@@ -475,9 +478,9 @@
<object class="NSMutableArray" key="dict.values"> <object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{47, 268}, {558, 348}}</string> <string>{{370, 244}, {558, 348}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{47, 268}, {558, 348}}</string> <string>{{370, 244}, {558, 348}}</string>
<integer value="1"/> <integer value="1"/>
<string>{{33, 99}, {480, 360}}</string> <string>{{33, 99}, {480, 360}}</string>
<string>{3.40282e+38, 3.40282e+38}</string> <string>{3.40282e+38, 3.40282e+38}</string>
+52 -112
View File
@@ -1,12 +1,6 @@
@import <Foundation/CPObject.j> @import <Foundation/CPObject.j>
@import <Foundation/CPIndexSet.j>
@import <AppKit/CPTableColumn.j>
@import <AppKit/CPTableView.j>
tableTestDragType = @"CPTableViewTestDragType"; tableTestDragType = @"CPTableViewTestDragType";
CPLogRegister(CPLogConsole);
@implementation AppController : CPObject @implementation AppController : CPObject
{ {
@@ -20,6 +14,7 @@ CPLogRegister(CPLogConsole);
- (void)applicationDidFinishLaunching:(CPNotification)aNotification - (void)applicationDidFinishLaunching:(CPNotification)aNotification
{ {
dataSet1 = [], dataSet1 = [],
dataSet2 = [], dataSet2 = [],
dataSet3 = []; dataSet3 = [];
@@ -31,40 +26,40 @@ CPLogRegister(CPLogConsole);
dataSet3[i - 1] = [CPNumber numberWithInt:i+20]; dataSet3[i - 1] = [CPNumber numberWithInt:i+20];
} }
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMake(50,50,400,400) styleMask:CPClosableWindowMask],
var window1 = [[CPWindow alloc] initWithContentRect:CGRectMake(50, 50, 500, 400) styleMask:CPTitledWindowMask | CPResizableWindowMask], contentView = [theWindow contentView];
view = [window1 contentView];
[view setBackgroundColor:[CPColor whiteColor]];
tableView = [[CPTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 500.0, 500.0)]; tableView = [[CPTableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 500.0, 500.0)];
[tableView setAllowsMultipleSelection:YES]; [tableView setAllowsMultipleSelection:YES];
[tableView setAllowsColumnSelection:YES]; [tableView setAllowsColumnSelection:YES];
[tableView setUsesAlternatingRowBackgroundColors:YES]; [tableView setUsesAlternatingRowBackgroundColors:YES];
[tableView setAlternatingRowBackgroundColors:[[CPColor whiteColor], [CPColor colorWithHexString:@"e4e7ff"], [CPColor colorWithHexString:@"f4e7ff"]]]; [tableView setAlternatingRowBackgroundColors:[[CPColor whiteColor], [CPColor colorWithHexString:@"e4e7ff"], [CPColor colorWithHexString:@"f4e7ff"]]];
[tableView setGridStyleMask:CPTableViewSolidHorizontalGridLineMask | CPTableViewSolidVerticalGridLineMask]; [tableView setGridStyleMask:CPTableViewSolidHorizontalGridLineMask | CPTableViewSolidVerticalGridLineMask];
[tableView setVerticalMotionCanBeginDrag:NO];
[tableView setDraggingDestinationFeedbackStyle:CPTableViewDropOn];
[tableView registerForDraggedTypes:[CPArray arrayWithObject:tableTestDragType]];
[tableView setColumnAutoresizingStyle:CPTableViewLastColumnOnlyAutoresizingStyle];
[tableView setDelegate:self];
[tableView setDataSource:self];
var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)]; var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)];
[iconView setImageScaling:CPScaleNone]; [iconView setImageScaling:CPScaleNone];
var iconColumn = [[CPTableColumn alloc] initWithIdentifier:"icons"]; var iconColumn = [[CPTableColumn alloc] initWithIdentifier:"icons"];
[iconColumn setWidth:32.0]; [iconColumn setWidth:32.0];
[iconColumn setMinWidth:32.0]; [iconColumn setMinWidth:32.0];
[iconColumn setDataView:iconView]; [iconColumn setDataView:iconView];
[tableView addTableColumn:iconColumn]; [tableView addTableColumn:iconColumn];
iconImage = [[CPImage alloc] initWithContentsOfFile:"http://cappuccino.org/images/favicon.png" size:CGSizeMake(16,16)]; iconImage = [[CPImage alloc] initWithContentsOfFile:"http://cappuccino.org/images/favicon.png" size:CGSizeMake(16,16)];
var desc = [CPSortDescriptor sortDescriptorWithKey:@"self" ascending:YES]; var desc = [CPSortDescriptor sortDescriptorWithKey:@"self" ascending:YES];
for (var i = 1; i <= 2; i++) for (var i = 1; i <= 2; i++)
{ {
var column = [[CPTableColumn alloc] initWithIdentifier:String(i)]; var column = [[CPTableColumn alloc] initWithIdentifier:String(i)];
[column setSortDescriptorPrototype:desc]; [column setSortDescriptorPrototype:desc];
[[column headerView] setStringValue:"Number "+i]; [[column headerView] setStringValue:"Number " + i];
[column setMinWidth:50.0]; [column setMinWidth:50.0];
[column setMaxWidth:500.0]; [column setMaxWidth:500.0];
@@ -74,24 +69,14 @@ CPLogRegister(CPLogConsole);
[tableView addTableColumn:column]; [tableView addTableColumn:column];
} }
[tableView setColumnAutoresizingStyle:CPTableViewLastColumnOnlyAutoresizingStyle]; var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([contentView bounds]), CGRectGetHeight([contentView bounds]))];
var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth([view bounds]), CGRectGetHeight([view bounds]))];
[tableView setRowHeight:22.0];
[scrollView setDocumentView:tableView]; [scrollView setDocumentView:tableView];
[scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; [scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[view addSubview:scrollView]; [contentView addSubview:scrollView];
[scrollView setAutohidesScrollers:YES]; [theWindow orderFront:self];
[tableView setDelegate:self];
[tableView setDataSource:self];
[tableView setVerticalMotionCanBeginDrag:NO];
[tableView setDraggingDestinationFeedbackStyle:CPTableViewDropOn];
[tableView registerForDraggedTypes:[CPArray arrayWithObject:tableTestDragType]];
[window1 setAcceptsMouseMovedEvents:YES];
[window1 orderFront:self];
[self newWindow]; [self newWindow];
[self sourceList]; [self sourceList];
} }
@@ -106,39 +91,22 @@ CPLogRegister(CPLogConsole);
[tableView2 setAllowsMultipleSelection:YES]; [tableView2 setAllowsMultipleSelection:YES];
[tableView2 setUsesAlternatingRowBackgroundColors:YES]; [tableView2 setUsesAlternatingRowBackgroundColors:YES];
[tableView2 setGridStyleMask:CPTableViewSolidHorizontalGridLineMask | CPTableViewSolidVerticalGridLineMask]; [tableView2 setGridStyleMask:CPTableViewSolidHorizontalGridLineMask | CPTableViewSolidVerticalGridLineMask];
[tableView2 setVerticalMotionCanBeginDrag:NO];
[tableView2 registerForDraggedTypes:[CPArray arrayWithObject:tableTestDragType]];
var iconView = [[CPImageView alloc] initWithFrame:CGRectMake(16,16,0,0)]; [tableView2 setDraggingDestinationFeedbackStyle:CPTableViewDropAbove];
[tableView2 setDelegate:self];
[iconView setImageScaling:CPScaleNone]; [tableView2 setDataSource:self];
var iconColumn = [[CPTableColumn alloc] initWithIdentifier:"icons"];
[iconColumn setWidth:32.0];
[iconColumn setMinWidth:32.0];
[iconColumn setDataView:iconView];
[iconColumn setResizingMask:CPTableColumnNoResizing];
//[tableView2 addTableColumn:iconColumn];
iconImage = [[CPImage alloc] initWithContentsOfFile:"http://cappuccino.org/images/favicon.png" size:CGSizeMake(16,16)];
var textDataView = [CPTextField new];
[textDataView setValue:[CPColor whiteColor] forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
[textDataView setValue:[CPFont systemFontOfSize:12] forThemeAttribute:@"font" inState:CPThemeStateSelected];
var desc = [CPSortDescriptor sortDescriptorWithKey:@"self" ascending:YES]; var desc = [CPSortDescriptor sortDescriptorWithKey:@"self" ascending:YES];
for (var i = 1; i <= 3; i++) for (var i = 1; i <= 3; i++)
{ {
var column = [[CPTableColumn alloc] initWithIdentifier:String(i)]; var column = [[CPTableColumn alloc] initWithIdentifier:String(i)];
[column setSortDescriptorPrototype:desc];
[[column headerView] setStringValue:"Number "+i]; [[column headerView] setStringValue:"Number "+i];
[column setWidth:i*75]; [column setWidth:i*75];
[column setMinWidth:50.0]; [column setMinWidth:50.0];
[column setDataView:textDataView];
[column setEditable:YES]; [column setEditable:YES];
[tableView2 addTableColumn:column]; [tableView2 addTableColumn:column];
@@ -153,14 +121,8 @@ CPLogRegister(CPLogConsole);
[[window2 contentView] addSubview:scrollView]; [[window2 contentView] addSubview:scrollView];
[scrollView setAutohidesScrollers:YES]; //[scrollView setAutohidesScrollers:YES];
[tableView2 setDelegate:self];
[tableView2 setDataSource:self];
[tableView2 setVerticalMotionCanBeginDrag:NO];
[tableView2 registerForDraggedTypes:[CPArray arrayWithObject:tableTestDragType]];
[tableView2 setDraggingDestinationFeedbackStyle:CPTableViewDropAbove];
[window2 orderFront:self]; [window2 orderFront:self];
} }
@@ -176,19 +138,19 @@ CPLogRegister(CPLogConsole);
[tableView3 setUsesAlternatingRowBackgroundColors:NO]; [tableView3 setUsesAlternatingRowBackgroundColors:NO];
[tableView3 setGridStyleMask:CPTableViewGridNone]; [tableView3 setGridStyleMask:CPTableViewGridNone];
[tableView3 setSelectionHighlightStyle:CPTableViewSelectionHighlightStyleSourceList]; [tableView3 setSelectionHighlightStyle:CPTableViewSelectionHighlightStyleSourceList];
[tableView3 setColumnAutoresizingStyle:CPTableViewUniformColumnAutoresizingStyle];
[tableView3 setVerticalMotionCanBeginDrag:NO];
[tableView3 setDelegate:self];
[tableView3 setDataSource:self];
var column = [[CPTableColumn alloc] initWithIdentifier:"sourcelist"]; var column = [[CPTableColumn alloc] initWithIdentifier:"sourcelist"];
[[column headerView] setStringValue:"Source List"]; [[column headerView] setStringValue:"Source List"];
[column setWidth:200.0]; [column setWidth:200.0];
[column setMinWidth:50.0]; [column setMinWidth:50.0];
[column setEditable:YES]; [column setEditable:YES];
[tableView3 addTableColumn:column]; [tableView3 addTableColumn:column];
[tableView3 setColumnAutoresizingStyle:CPTableViewUniformColumnAutoresizingStyle];
var scrollView3 = [[CPScrollView alloc] initWithFrame:[[window3 contentView] bounds]]; var scrollView3 = [[CPScrollView alloc] initWithFrame:[[window3 contentView] bounds]];
[tableView3 setRowHeight:32.0]; [tableView3 setRowHeight:32.0];
[scrollView3 setDocumentView:tableView3]; [scrollView3 setDocumentView:tableView3];
@@ -197,15 +159,8 @@ CPLogRegister(CPLogConsole);
[[window3 contentView] addSubview:scrollView3]; [[window3 contentView] addSubview:scrollView3];
[scrollView3 setAutohidesScrollers:YES]; [scrollView3 setAutohidesScrollers:YES];
[tableView3 setDelegate:self]; [window3 orderFront:self];
[tableView3 setDataSource:self];
[tableView3 setVerticalMotionCanBeginDrag:NO];
//[tableView3 registerForDraggedTypes:[CPArray arrayWithObject:tableTestDragType]];
//[tableView3 setDraggingDestinationFeedbackStyle:CPTableViewDropAbove];*/
[window3 orderFront:self];
} }
- (int)numberOfRowsInTableView:(CPTableView)atableView - (int)numberOfRowsInTableView:(CPTableView)atableView
@@ -218,37 +173,30 @@ CPLogRegister(CPLogConsole);
return dataSet3.length; return dataSet3.length;
} }
- (id)tableView:(CPTableView)atableView objectValueForTableColumn:(CPTableColumn)tableColumn row:(int)row - (id)tableView:(CPTableView)aTableView objectValueForTableColumn:(CPTableColumn)aColumn row:(int)aRow
{ {
if ([aColumn identifier] === "icons")
if(atableView === tableView) return iconImage;
{
if ([tableColumn identifier] === "icons") if (aTableView === tableView)
return iconImage; return String(dataSet1[aRow]);
else else if (aTableView === tableView2)
return String(dataSet1[row]); return String(dataSet2[aRow]);
} else if(aTableView === tableView3)
else if(atableView === tableView2) return String(dataSet3[row]);
{
if ([tableColumn identifier] === "icons")
return iconImage;
else
return String(dataSet2[row]);
}
else if(atableView === tableView3)
{
if ([tableColumn identifier] === "icons")
return iconImage;
else
return String(dataSet3[row]);
}
} }
- (id)tableView:(CPTableView)tableView heightOfRow:(int)row - (void)tableView:(CPTableView)aTableView sortDescriptorsDidChange:(CPArray)oldDescriptors
{ {
return 50; CPLogConsole(_cmd + [oldDescriptors description]);
var newDescriptors = [aTableView sortDescriptors];
[(aTableView === tableView) ? dataSet1:dataSet2 sortUsingDescriptors:newDescriptors];
[aTableView reloadData];
} }
- (void)tableViewSelectionIsChanging:(CPNotification)aNotification - (void)tableViewSelectionIsChanging:(CPNotification)aNotification
{ {
CPLog.debug(@"changing! %@", [aNotification description]); CPLog.debug(@"changing! %@", [aNotification description]);
@@ -261,13 +209,13 @@ CPLogRegister(CPLogConsole);
- (BOOL)tableView:(CPTableView)aTableView shouldSelectRow:(int)rowIndex - (BOOL)tableView:(CPTableView)aTableView shouldSelectRow:(int)rowIndex
{ {
//CPLog.debug(@"tableView:shouldSelectRow"); CPLog.debug(@"tableView:shouldSelectRow");
return true; return true;
} }
- (BOOL)selectionShouldChangeInTableView:(CPTableView)aTableView - (BOOL)selectionShouldChangeInTableView:(CPTableView)aTableView
{ {
//CPLog.debug(@"selectionShouldChangeInTableView"); CPLog.debug(@"selectionShouldChangeInTableView");
return YES; return YES;
} }
@@ -285,14 +233,6 @@ CPLogRegister(CPLogConsole);
{ {
CPLogConsole(_cmd + [notification description]); CPLogConsole(_cmd + [notification description]);
} }
//- (CPIndexSet)tableView:(CPTableView)tableView selectionIndexesForProposedSelection:(CPIndexSet)proposedSelectionIndexes
//{
// CPLog.debug(@"selectionIndexesForProposedSelection %@", [proposedSelectionIndexes description]);
// return proposedSelectionIndexes;
//}
- (BOOL)tableView:(CPTableView)aTableView shouldEditTableColumn:(CPTableColumn)tableColumn row:(int)row - (BOOL)tableView:(CPTableView)aTableView shouldEditTableColumn:(CPTableColumn)tableColumn row:(int)row
{ {
if(aTableView === tableView3) if(aTableView === tableView3)
@@ -405,7 +345,7 @@ CPLogRegister(CPLogConsole);
- (void)tableView:(CPTableView)aTableView didClickTableColumn:(CPTableColumn)aColumn - (void)tableView:(CPTableView)aTableView didClickTableColumn:(CPTableColumn)aColumn
{ {
console.log("table: "+aTableView+" clicked column: "+aColumn); CPLog.debug("table: "+aTableView+" clicked column: "+aColumn);
} }
@end @end
+29
View File
@@ -60,4 +60,33 @@
} }
} }
- (void)testPeriods
{
var URLStrings =
{
"." : "./",
"./" : "./",
".//" : "./",
"/." : "/",
"/./" : "/",
"/.//" : "/",
"./a/" : "a/",
"./a" : "a",
".." : "../",
"../" : "../",
"..//" : "../",
"/.." : "/",
"/../" : "/",
"/..//" : "/",
"../a/" : "../a/",
"../a" : "../a"
};
var URLString;
for (URLString in URLStrings)
if (URLStrings.hasOwnProperty(URLString))
[self assert:new CFURL(URLString).absoluteString() equals:URLStrings[URLString]];
}
@end @end
@@ -27,7 +27,7 @@ app ("__project.nameasidentifier__", function(task)
task.setEmail("__organization.email__"); task.setEmail("__organization.email__");
task.setSummary("__project.name__"); task.setSummary("__project.name__");
task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**"))); task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**")));
task.setResources(new FileList("Resources/*")); task.setResources(new FileList("Resources/**"));
task.setIndexFilePath("index.html"); task.setIndexFilePath("index.html");
task.setInfoPlistPath("Info.plist"); task.setInfoPlistPath("Info.plist");
@@ -39,9 +39,9 @@ app ("__project.nameasidentifier__", function(task)
function printResults(configuration) function printResults(configuration)
{ {
print("----------------------------") print("----------------------------");
print(configuration+" app built at path: "+FILE.join("Build", configuration, "__project.nameasidentifier__")); print(configuration+" app built at path: "+FILE.join("Build", configuration, "__project.nameasidentifier__"));
print("----------------------------") print("----------------------------");
} }
task ("default", ["__project.nameasidentifier__"], function() task ("default", ["__project.nameasidentifier__"], function()
@@ -20,7 +20,7 @@
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"]; OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
</script> </script>
<script src="Frameworks/Debug/Objective-J/Objective-J.js" type="text/javascript"></script> <script src="Frameworks/Debug/Objective-J/Objective-J.js" type="text/javascript" charset="UTF-8"></script>
<script type="text/javascript"> <script type="text/javascript">
objj_msgSend_reset(); objj_msgSend_reset();
@@ -35,6 +35,13 @@
// Uncomment (along with both above) to print backtraces on type check errors: // Uncomment (along with both above) to print backtraces on type check errors:
//objj_typecheck_prints_backtrace = true; //objj_typecheck_prints_backtrace = true;
// Uncomment to disable the default logger (CPLogConsole if window.console exists, CPLogPopup otherwise):
//CPLogUnregister(CPLogDefault);
// Uncomment to enable a specific logger:
//CPLogRegister(CPLogConsole);
//CPLogRegister(CPLogPopup);
</script> </script>
<style type="text/css"> <style type="text/css">
@@ -57,7 +64,7 @@
<body style=""> <body style="">
<div id="cappuccino-body"> <div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;"> <div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type = "text/javascript"> <script type="text/javascript">
document.write("<div id='container'><p id='content'>" + document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " + "<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading __project.name__...</p></div>"); "Loading __project.name__...</p></div>");
@@ -19,7 +19,7 @@
OBJJ_MAIN_FILE = "main.j"; OBJJ_MAIN_FILE = "main.j";
</script> </script>
<script src="Frameworks/Objective-J/Objective-J.js" type = "text/javascript"></script> <script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
<style type="text/css"> <style type="text/css">
body{margin:0; padding:0;} body{margin:0; padding:0;}
@@ -41,7 +41,7 @@
<body style=""> <body style="">
<div id="cappuccino-body"> <div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;"> <div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type = "text/javascript"> <script type="text/javascript">
document.write("<div id='container'><p id='content'>" + document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " + "<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading __project.name__...</p></div>"); "Loading __project.name__...</p></div>");
@@ -27,7 +27,7 @@ app ("__project.nameasidentifier__", function(task)
task.setEmail("__organization.email__"); task.setEmail("__organization.email__");
task.setSummary("__project.name__"); task.setSummary("__project.name__");
task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**"))); task.setSources((new FileList("**/*.j")).exclude(FILE.join("Build", "**")));
task.setResources(new FileList("Resources/*")); task.setResources(new FileList("Resources/**"));
task.setIndexFilePath("index.html"); task.setIndexFilePath("index.html");
task.setInfoPlistPath("Info.plist"); task.setInfoPlistPath("Info.plist");
task.setNib2CibFlags("-R Resources/"); task.setNib2CibFlags("-R Resources/");
@@ -40,9 +40,9 @@ app ("__project.nameasidentifier__", function(task)
function printResults(configuration) function printResults(configuration)
{ {
print("----------------------------") print("----------------------------");
print(configuration+" app built at path: "+FILE.join("Build", configuration, "__project.nameasidentifier__")); print(configuration+" app built at path: "+FILE.join("Build", configuration, "__project.nameasidentifier__"));
print("----------------------------") print("----------------------------");
} }
task ("default", ["__project.nameasidentifier__"], function() task ("default", ["__project.nameasidentifier__"], function()
@@ -20,7 +20,7 @@
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"]; OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
</script> </script>
<script src="Frameworks/Debug/Objective-J/Objective-J.js" type = "text/javascript"></script> <script type="text/javascript" src="Frameworks/Debug/Objective-J/Objective-J.js" charset="UTF-8"></script>
<script type="text/javascript"> <script type="text/javascript">
objj_msgSend_reset(); objj_msgSend_reset();
@@ -35,6 +35,13 @@
// Uncomment (along with both above) to print backtraces on type check errors: // Uncomment (along with both above) to print backtraces on type check errors:
//objj_typecheck_prints_backtrace = true; //objj_typecheck_prints_backtrace = true;
// Uncomment to disable the default logger (CPLogConsole if window.console exists, CPLogPopup otherwise):
//CPLogUnregister(CPLogDefault);
// Uncomment to enable a specific logger:
//CPLogRegister(CPLogConsole);
//CPLogRegister(CPLogPopup);
</script> </script>
<style type="text/css"> <style type="text/css">
@@ -57,7 +64,7 @@
<body style=""> <body style="">
<div id="cappuccino-body"> <div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;"> <div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type = "text/javascript"> <script type="text/javascript">
document.write("<div id='container'><p id='content'>" + document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " + "<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading __project.name__...</p></div>"); "Loading __project.name__...</p></div>");
@@ -19,7 +19,7 @@
OBJJ_MAIN_FILE = "main.j"; OBJJ_MAIN_FILE = "main.j";
</script> </script>
<script src="Frameworks/Objective-J/Objective-J.js" type = "text/javascript"></script> <script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
<style type="text/css"> <style type="text/css">
body{margin:0; padding:0;} body{margin:0; padding:0;}
@@ -41,7 +41,7 @@
<body style=""> <body style="">
<div id="cappuccino-body"> <div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;"> <div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type = "text/javascript"> <script type="text/javascript">
document.write("<div id='container'><p id='content'>" + document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " + "<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading __project.name__...</p></div>"); "Loading __project.name__...</p></div>");
@@ -20,7 +20,7 @@
OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"]; OBJJ_INCLUDE_PATHS = ["Frameworks/Debug", "Frameworks", "SomethingElse"];
</script> </script>
<script src="Frameworks/Debug/Objective-J/Objective-J.js" type = "text/javascript"></script> <script type="text/javascript" src="Frameworks/Debug/Objective-J/Objective-J.js" charset="UTF-8"></script>
<style type="text/css"> <style type="text/css">
body{margin:0; padding:0;} body{margin:0; padding:0;}
@@ -42,7 +42,7 @@
<body style=""> <body style="">
<div id="cappuccino-body"> <div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;"> <div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type = "text/javascript"> <script type="text/javascript">
document.write("<div id='container'><p id='content'>" + document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " + "<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading __project.name__...</p></div>"); "Loading __project.name__...</p></div>");
@@ -19,7 +19,7 @@
OBJJ_MAIN_FILE = "main.j"; OBJJ_MAIN_FILE = "main.j";
</script> </script>
<script src="Frameworks/Objective-J/Objective-J.js" type = "text/javascript"></script> <script type="text/javascript" src="Frameworks/Objective-J/Objective-J.js" charset="UTF-8"></script>
<style type="text/css"> <style type="text/css">
body{margin:0; padding:0;} body{margin:0; padding:0;}
@@ -41,7 +41,7 @@
<body style=""> <body style="">
<div id="cappuccino-body"> <div id="cappuccino-body">
<div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;"> <div id="loadingcontainer" style="background-color: #eeeeee; overflow:hidden; width:100%; height:100%; position: absolute; top: 0; left: 0;">
<script type = "text/javascript"> <script type="text/javascript">
document.write("<div id='container'><p id='content'>" + document.write("<div id='container'><p id='content'>" +
"<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " + "<img id='loadgraphic' width='16' height='16' src='Resources/spinner.gif' /> " +
"Loading __project.name__...</p></div>"); "Loading __project.name__...</p></div>");
+1 -1
View File
@@ -37,7 +37,7 @@
//var dataViewCell = [aCoder decodeObjectForKey:@"NSDataCell"]; //var dataViewCell = [aCoder decodeObjectForKey:@"NSDataCell"];
_dataView = [[CPTextField alloc] initWithFrame:CPRectMakeZero()]; _dataView = [[CPTextField alloc] initWithFrame:CPRectMakeZero()];
[_dataView setValue:[CPColor whiteColor] forThemeAttribute:"text-color" inState:CPThemeStateHighlighted]; [_dataView setValue:[CPColor whiteColor] forThemeAttribute:@"text-color" inState:CPThemeStateSelected];
var headerCell = [aCoder decodeObjectForKey:@"NSHeaderCell"], var headerCell = [aCoder decodeObjectForKey:@"NSHeaderCell"],
headerView = [[_CPTableColumnHeaderView alloc] initWithFrame:CPRectMakeZero()]; headerView = [[_CPTableColumnHeaderView alloc] initWithFrame:CPRectMakeZero()];
+7 -1
View File
@@ -29,7 +29,13 @@
if (self = [super NS_initWithCoder:aCoder]) if (self = [super NS_initWithCoder:aCoder])
{ {
_tableView = [aCoder decodeObjectForKey:"NSTableView"]; _tableView = [aCoder decodeObjectForKey:"NSTableView"];
[self setBackgroundColor:[CPColor colorWithPatternImage:CPAppKitImage("tableview-headerview.png", CGSizeMake(1.0, 22.0))]];
// change the default height
if (_bounds.size.height === 17)
{
_bounds.size.height = 23;
_frame.size.height = 23;
}
} }
return self; return self;
+10 -6
View File
@@ -35,18 +35,21 @@
//_dataSource = [aCoder decodeObjectForKey:CPTableViewDataSourceKey]; //_dataSource = [aCoder decodeObjectForKey:CPTableViewDataSourceKey];
//_delegate = [aCoder decodeObjectForKey:CPTableViewDelegateKey]; //_delegate = [aCoder decodeObjectForKey:CPTableViewDelegateKey];
_headerView = [aCoder decodeObjectForKey:@"NSHeaderView"];
_cornerView = [aCoder decodeObjectForKey:@"NSCornerView"];
_tableColumns = [aCoder decodeObjectForKey:@"NSTableColumns"];
[_tableColumns makeObjectsPerformSelector:@selector(setTableView:) withObject:self];
_rowHeight = [aCoder decodeFloatForKey:@"NSRowHeight"]; _rowHeight = [aCoder decodeFloatForKey:@"NSRowHeight"];
// Convert xib default to cib default // Convert xib default to cib default
if (_rowHeight == 17) if (_rowHeight == 17)
_rowHeight = 23; _rowHeight = 23;
if ([_gridColor isEqual:[CPColor colorWithRed:127.0 / 255.0 green:127.0 / 255.0 blue:127.0 / 255.0 alpha:1.0]])
_gridColor = [CPColor colorWithRed:229.0 / 255.0 green:229.0 / 255.0 blue:229.0 / 255.0 alpha:1.0];
_headerView = [aCoder decodeObjectForKey:@"NSHeaderView"];
_cornerView = [aCoder decodeObjectForKey:@"NSCornerView"];
_tableColumns = [aCoder decodeObjectForKey:@"NSTableColumns"];
[_tableColumns makeObjectsPerformSelector:@selector(setTableView:) withObject:self];
_intercellSpacing = CGSizeMake(0.0, 0.0);//CGSizeMake([aCoder decodeFloatForKey:"NSIntercellSpacingWidth"], [aCoder decodeFloatForKey:"NSIntercellSpacingHeight"]); _intercellSpacing = CGSizeMake(0.0, 0.0);//CGSizeMake([aCoder decodeFloatForKey:"NSIntercellSpacingWidth"], [aCoder decodeFloatForKey:"NSIntercellSpacingHeight"]);
@@ -54,6 +57,7 @@
_gridStyleMask = [aCoder decodeIntForKey:@"NSGridStyleMask"]; _gridStyleMask = [aCoder decodeIntForKey:@"NSGridStyleMask"];
_usesAlternatingRowBackgroundColors = (flags & 0x00800000) ? YES : NO; _usesAlternatingRowBackgroundColors = (flags & 0x00800000) ? YES : NO;
_alternatingRowBackgroundColors =[[CPColor whiteColor], [CPColor colorWithHexString:@"e4e7ff"]];
_allowsMultipleSelection = (flags & 0x08000000) ? YES : NO; _allowsMultipleSelection = (flags & 0x08000000) ? YES : NO;
_allowsEmptySelection = (flags & 0x10000000) ? YES : NO; _allowsEmptySelection = (flags & 0x10000000) ? YES : NO;
+8 -1
View File
@@ -37,7 +37,14 @@
- (id)initWithCoder:(CPCoder)aCoder - (id)initWithCoder:(CPCoder)aCoder
{ {
return [self NS_initWithCoder:aCoder]; self = [super NS_initWithCoder:aCoder];
if (self)
{
_frame.size.height = 23.0;
_bounds.size.height = 23.0;
}
return self;
} }
- (Class)classForKeyedArchiver - (Class)classForKeyedArchiver
+26
View File
@@ -78,6 +78,32 @@ function check_and_exit () {
fi fi
} }
function check_build_environment () {
# make sure user is running HotSpot JVM
java -version 2>&1 | grep HotSpot &> /dev/null
if [ ! "$?" = "0" ]; then
java_ver=`java -version 2>&1 | egrep "(Client|Server)"`
if [ "$java_ver" = "" ]; then
java_ver="your JVM"
fi
echo "Error: Narwhal is not compatible with $java_ver. Please switch to the Sun (HotSpot) JVM and re-run bootstrap.sh."
exit 1
fi
# make sure other dependencies are installed and on the $PATH
OTHER_DEPS=(gcc unzip curl)
for dep in ${OTHER_DEPS[@]}; do
which "$dep" &> /dev/null
if [ ! "$?" = "0" ]; then
echo "Error: $dep is required to build Cappuccino. Please install $dep and re-run bootstrap.sh."
exit 1
fi
done
}
check_build_environment
if [ -w "/usr/local" ]; then if [ -w "/usr/local" ]; then
default_directory="/usr/local/narwhal" default_directory="/usr/local/narwhal"
else else