diff --git a/AppKit/CPApplication.j b/AppKit/CPApplication.j index e23aab878..41d8d6dee 100644 --- a/AppKit/CPApplication.j +++ b/AppKit/CPApplication.j @@ -615,7 +615,11 @@ CPRunContinuesResponse = -1002; */ - (CPArray)orderedWindows { +#if PLATFORM(DOM) return CPWindowObjectList(); +#else + return []; +#endif } - (void)hide:(id)aSender diff --git a/AppKit/CPBrowser.j b/AppKit/CPBrowser.j index 77e3700f8..6387738e9 100644 --- a/AppKit/CPBrowser.j +++ b/AppKit/CPBrowser.j @@ -96,7 +96,7 @@ _prototypeView = [[CPTextField alloc] initWithFrame:CGRectMakeZero()]; [_prototypeView setVerticalAlignment:CPCenterVerticalTextAlignment]; - [_prototypeView setValue:[CPColor whiteColor] forThemeAttribute:"text-color" inState:CPThemeStateSelected]; + [_prototypeView setValue:[CPColor whiteColor] forThemeAttribute:"text-color" inState:CPThemeStateSelectedDataView]; [_prototypeView setLineBreakMode:CPLineBreakByTruncatingTail]; _horizontalScrollView = [[CPScrollView alloc] initWithFrame:[self bounds]]; @@ -860,7 +860,7 @@ var _CPBrowserResizeControlBackgroundImage = nil; - (CPDragOperation)tableView:(CPTableView)aTableView validateDrop:(id)info proposedRow:(int)row proposedDropOperation:(CPTableViewDropOperation)operation { if ([_delegate respondsToSelector:@selector(browser:validateDrop:proposedRow:column:dropOperation:)]) - [_delegate browser:_browser validateDrop:info proposedRow:row column:_index dropOperation:operation]; + return [_delegate browser:_browser validateDrop:info proposedRow:row column:_index dropOperation:operation]; else return CPDragOperationNone; } @@ -923,7 +923,7 @@ var _CPBrowserResizeControlBackgroundImage = nil; positioned:CPWindowAbove relativeToEphemeralSubviewNamed:nil]; - var isHighlighted = [self themeState] & CPThemeStateSelected; + var isHighlighted = [self themeState] & CPThemeStateSelectedDataView; [imageView setImage: _isLeaf ? (isHighlighted ? _highlightedBranchImage : _branchImage) : nil]; [imageView setImageScaling:CPScaleNone]; } diff --git a/AppKit/CPControl.j b/AppKit/CPControl.j index 2f03926c1..7de6719c4 100644 --- a/AppKit/CPControl.j +++ b/AppKit/CPControl.j @@ -332,6 +332,9 @@ var CPControlBlackColor = [CPColor blackColor]; - (void)performClick:(id)sender { + if (![self isEnabled]) + return; + [self highlight:YES]; [self setState:[self nextState]]; [self sendAction:[self action] to:[self target]]; diff --git a/AppKit/CPOutlineView.j b/AppKit/CPOutlineView.j index df90c688d..06812521a 100644 --- a/AppKit/CPOutlineView.j +++ b/AppKit/CPOutlineView.j @@ -50,12 +50,30 @@ var CPOutlineViewDataSource_outlineView_setObjectValue_forTableColumn_byItem_ CPOutlineViewDataSource_outlineView_sortDescriptorsDidChange_ = 1 << 10; - var CPOutlineViewDelegate_outlineView_dataViewForTableColumn_item_ = 1 << 1, - CPOutlineViewDelegate_outlineView_shouldSelectItem_ = 1 << 2, - CPOutlineViewDelegate_outlineView_heightOfRowByItem_ = 1 << 3, - CPOutlineViewDelegate_outlineView_willDisplayView_forTableColumn_item_ = 1 << 4, - CPOutlineViewDelegate_outlineView_isGroupItem_ = 1 << 5; + CPOutlineViewDelegate_outlineView_didClickTableColumn_ = 1 << 2, + CPOutlineViewDelegate_outlineView_didDragTableColumn_ = 1 << 3, + CPOutlineViewDelegate_outlineView_heightOfRowByItem_ = 1 << 4, + CPOutlineViewDelegate_outlineView_isGroupItem_ = 1 << 5, + CPOutlineViewDelegate_outlineView_mouseDownInHeaderOfTableColumn_ = 1 << 6, + CPOutlineViewDelegate_outlineView_nextTypeSelectMatchFromItem_toItem_forString_ = 1 << 7, + CPOutlineViewDelegate_outlineView_selectionIndexesForProposedSelection_ = 1 << 8, + CPOutlineViewDelegate_outlineView_shouldCollapseItem_ = 1 << 9, + CPOutlineViewDelegate_outlineView_shouldEditTableColumn_item_ = 1 << 10, + CPOutlineViewDelegate_outlineView_shouldExpandItem_ = 1 << 11, + CPOutlineViewDelegate_outlineView_shouldReorderColumn_toColumn_ = 1 << 12, + CPOutlineViewDelegate_outlineView_shouldSelectItem_ = 1 << 13, + CPOutlineViewDelegate_outlineView_shouldSelectTableColumn_ = 1 << 14, + CPOutlineViewDelegate_outlineView_shouldShowOutlineViewForItem_ = 1 << 15, + CPOutlineViewDelegate_outlineView_shouldShowViewExpansionForTableColumn_item_ = 1 << 16, + CPOutlineViewDelegate_outlineView_shouldTrackView_forTableColumn_item_ = 1 << 17, + CPOutlineViewDelegate_outlineView_shouldTypeSelectForEvent_withCurrentSearchString_ = 1 << 18, + CPOutlineViewDelegate_outlineView_sizeToFitWidthOfColumn_ = 1 << 19, + CPOutlineViewDelegate_outlineView_toolTipForView_rect_tableColumn_item_mouseLocation_ = 1 << 20, + CPOutlineViewDelegate_outlineView_typeSelectStringForTableColumn_item_ = 1 << 21, + CPOutlineViewDelegate_outlineView_willDisplayOutlineView_forTableColumn_item_ = 1 << 22, + CPOutlineViewDelegate_outlineView_willDisplayView_forTableColumn_item_ = 1 << 23, + CPOutlineViewDelegate_selectionShouldChangeInOutlineView_ = 1 << 24; CPOutlineViewDropOnItemIndex = -1; @@ -79,10 +97,10 @@ CPOutlineViewDropOnItemIndex = -1; CPArray _disclosureControlsForRows; CPData _disclosureControlData; CPArray _disclosureControlQueue; - + BOOL _shouldRetargetItem; id _retargetedItem; - + BOOL _shouldRetargetChildIndex; CPInteger _retargedChildIndex; CPTimer _dragHoverTimer; @@ -107,7 +125,7 @@ CPOutlineViewDropOnItemIndex = -1; _retargetedItem = nil; _shouldRetargetItem = NO; - + _retargedChildIndex = nil; _shouldRetargetChildIndex = NO; _startHoverTime = nil; @@ -238,7 +256,7 @@ CPOutlineViewDropOnItemIndex = -1; { var children = itemInfo.children, childIndex = children.length; - + while (childIndex--) [self expandItem:children[childIndex] expandChildren:YES]; } @@ -374,7 +392,7 @@ CPOutlineViewDropOnItemIndex = -1; return nil; var parent = itemInfo.parent; - + // Check if the parent is the root item because we never return the actual root item if (itemInfo[[parent UID]] === _rootItemInfo) parent = nil; @@ -396,10 +414,10 @@ CPOutlineViewDropOnItemIndex = -1; - (void)_performSelection:(BOOL)select forRow:(CPInteger)rowIndex context:(id)context { [super _performSelection:select forRow:rowIndex context:context]; - + var control = _disclosureControlsForRows[rowIndex], selector = select ? @"setThemeState:" : @"unsetThemeState:"; - + [control performSelector:CPSelectorFromString(selector) withObject:CPThemeStateSelected]; } @@ -469,20 +487,42 @@ CPOutlineViewDropOnItemIndex = -1; _outlineViewDelegate = aDelegate; _implementedOutlineViewDelegateMethods = 0; - if ([_outlineViewDelegate respondsToSelector:@selector(outlineView:dataViewForTableColumn:item:)]) - _implementedOutlineViewDelegateMethods |= CPOutlineViewDelegate_outlineView_dataViewForTableColumn_item_; - - if ([_outlineViewDelegate respondsToSelector:@selector(outlineView:shouldSelectItem:)]) - _implementedOutlineViewDelegateMethods |= CPOutlineViewDelegate_outlineView_shouldSelectItem_; - - if ([_outlineViewDelegate respondsToSelector:@selector(outlineView:heightOfRowByItem:)]) - _implementedOutlineViewDelegateMethods |= CPOutlineViewDelegate_outlineView_heightOfRowByItem_; + var delegateMethods = [ + CPOutlineViewDelegate_outlineView_dataViewForTableColumn_item_ , @selector(outlineView:dataViewForTableColumn:item:), + CPOutlineViewDelegate_outlineView_didClickTableColumn_ , @selector(outlineView:didClickTableColumn:), + CPOutlineViewDelegate_outlineView_didDragTableColumn_ , @selector(outlineView:didDragTableColumn:), + CPOutlineViewDelegate_outlineView_heightOfRowByItem_ , @selector(outlineView:heightOfRowByItem:), + CPOutlineViewDelegate_outlineView_isGroupItem_ , @selector(outlineView:isGroupItem:), + CPOutlineViewDelegate_outlineView_mouseDownInHeaderOfTableColumn_ , @selector(outlineView:mouseDownInHeaderOfTableColumn:), + CPOutlineViewDelegate_outlineView_nextTypeSelectMatchFromItem_toItem_forString_ , @selector(outlineView:nextTypeSelectMatchFromItem:toItem:forString:), + CPOutlineViewDelegate_outlineView_selectionIndexesForProposedSelection_ , @selector(outlineView:selectionIndexesForProposedSelection:), + CPOutlineViewDelegate_outlineView_shouldCollapseItem_ , @selector(outlineView:shouldCollapseItem:), + CPOutlineViewDelegate_outlineView_shouldEditTableColumn_item_ , @selector(outlineView:shouldEditTableColumn:item:), + CPOutlineViewDelegate_outlineView_shouldExpandItem_ , @selector(outlineView:shouldExpandItem:), + CPOutlineViewDelegate_outlineView_shouldReorderColumn_toColumn_ , @selector(outlineView:shouldReorderColumn:toColumn:), + CPOutlineViewDelegate_outlineView_shouldSelectItem_ , @selector(outlineView:shouldSelectItem:), + CPOutlineViewDelegate_outlineView_shouldSelectTableColumn_ , @selector(outlineView:shouldSelectTableColumn:), + CPOutlineViewDelegate_outlineView_shouldShowOutlineViewForItem_ , @selector(outlineView:shouldShowOutlineViewForItem:), + CPOutlineViewDelegate_outlineView_shouldShowViewExpansionForTableColumn_item_ , @selector(outlineView:shouldShowViewExpansionForTableColumn:item:), + CPOutlineViewDelegate_outlineView_shouldTrackView_forTableColumn_item_ , @selector(outlineView:shouldTrackView:forTableColumn:item:), + CPOutlineViewDelegate_outlineView_shouldTypeSelectForEvent_withCurrentSearchString_ , @selector(outlineView:shouldTypeSelectForEvent:withCurrentSearchString:), + CPOutlineViewDelegate_outlineView_sizeToFitWidthOfColumn_ , @selector(outlineView:sizeToFitWidthOfColumn:), + CPOutlineViewDelegate_outlineView_toolTipForView_rect_tableColumn_item_mouseLocation_, @selector(outlineView:toolTipForView:rect:tableColumn:item:mouseLocation:), + CPOutlineViewDelegate_outlineView_typeSelectStringForTableColumn_item_ , @selector(outlineView:typeSelectStringForTableColumn:item:), + CPOutlineViewDelegate_outlineView_willDisplayOutlineView_forTableColumn_item_ , @selector(outlineView:willDisplayOutlineView:forTableColumn:item:), + CPOutlineViewDelegate_outlineView_willDisplayView_forTableColumn_item_ , @selector(outlineView:willDisplayView:forTableColumn:item:), + CPOutlineViewDelegate_selectionShouldChangeInOutlineView_ , @selector(selectionShouldChangeInOutlineView:) + ], + delegateCount = [delegateMethods count]; - if ([_outlineViewDelegate respondsToSelector:@selector(outlineView:willDisplayView:forTableColumn:item:)]) - _implementedOutlineViewDelegateMethods |= CPOutlineViewDelegate_outlineView_willDisplayView_forTableColumn_item_; + for (var i=0; i < delegateCount; i += 2) + { + var bitMask = delegateMethods[i], + selector = delegateMethods[i+1]; - if ([_outlineViewDelegate respondsToSelector:@selector(outlineView:isGroupItem:)]) - _implementedOutlineViewDelegateMethods |= CPOutlineViewDelegate_outlineView_isGroupItem_; + if ([_outlineViewDelegate respondsToSelector:selector]) + _implementedOutlineViewDelegateMethods |= bitMask; + } if ([_outlineViewDelegate respondsToSelector:@selector(outlineViewColumnDidMove:)]) [defaultCenter @@ -600,10 +640,10 @@ CPOutlineViewDropOnItemIndex = -1; _dropItem = theItem; _retargetedItem = theItem; _shouldRetargetItem = YES; - + _retargedChildIndex = theIndex; _shouldRetargetChildIndex = YES; - + // set CPTableView's _retargetedDropRow based on retargetedItem and retargetedChildIndex var retargetedItemInfo = (_retargetedItem !== nil) ? _itemInfosForItems[[_retargetedItem UID]] : _rootItemInfo, retargetedChildItem = (_retargedChildIndex !== CPOutlineViewDropOnItemIndex) ? retargetedItemInfo.children[_retargedChildIndex] : _retargetedItem; @@ -623,7 +663,7 @@ CPOutlineViewDropOnItemIndex = -1; { if (_shouldRetargetItem) return _retargetedItem; - + var lowerLevel = [self levelForRow:theLowerRowIndex] upperItem = [self itemAtRow:theUpperRowIndex]; upperLevel = [self levelForItem:upperItem]; @@ -642,7 +682,7 @@ CPOutlineViewDropOnItemIndex = -1; // Check the next parent upperItem = [self parentForItem:upperItem]; } - + return [self parentForItem:[self itemAtRow:theLowerRowIndex]]; } @@ -652,10 +692,10 @@ CPOutlineViewDropOnItemIndex = -1; var rect = [super _rectForDropHighlightViewBetweenUpperRow:theUpperRowIndex andLowerRow:theLowerRowIndex offset:theOffset], parentItem = [self _parentItemForUpperRow:theUpperRowIndex andLowerRow:theLowerRowIndex atMouseOffset:theOffset], level = [self levelForItem:parentItem]; - - rect.origin.x = (level + 1) * [self indentationPerLevel]; + + rect.origin.x = (level + 1) * [self indentationPerLevel]; rect.size.width -= rect.origin.x; // This assumes that the x returned by super is zero - + return rect; } @@ -823,7 +863,7 @@ CPOutlineViewDropOnItemIndex = -1; @end -// FIX ME: We're using with() here because Safari fails if we use anOutlineView._itemInfosForItems or whatever... +// FIX ME: We're using with() here because Safari fails if we use anOutlineView._itemInfosForItems or whatever... var _reloadItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anItem) { if (!anItem) @@ -836,55 +876,55 @@ var _reloadItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anItem) dataSource = _outlineViewDataSource, itemUID = [anItem UID], itemInfo = itemInfosForItems[itemUID]; - + // If we're not in the tree, then just bail. if (!itemInfo) return []; - + // See if the item itself can be swapped out. var parent = itemInfo.parent, parentItemInfo = parent ? itemInfosForItems[[parent UID]] : _rootItemInfo, parentChildren = parentItemInfo.children, index = [parentChildren indexOfObjectIdenticalTo:anItem], newItem = [dataSource outlineView:anOutlineView child:index ofItem:parent]; - + if (anItem !== newItem) { itemInfosForItems[[anItem UID]] = nil; itemInfosForItems[[newItem UID]] = itemInfo; - + parentChildren[index] = newItem; _itemsForRows[itemInfo.row] = newItem; } - + itemInfo.isExpandable = [dataSource outlineView:anOutlineView isItemExpandable:newItem]; itemInfo.isExpanded = itemInfo.isExpandable && itemInfo.isExpanded; } } -// FIX ME: We're using with() here because Safari fails if we use anOutlineView._itemInfosForItems or whatever... +// FIX ME: We're using with() here because Safari fails if we use anOutlineView._itemInfosForItems or whatever... var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anItem, /*BOOL*/ isIntermediate) { with(anOutlineView) { var itemInfosForItems = _itemInfosForItems, dataSource = _outlineViewDataSource; - + if (!anItem) var itemInfo = _rootItemInfo; - + else { // Get the existing info if it exists. var itemUID = [anItem UID], itemInfo = itemInfosForItems[itemUID]; - + // If we're not in the tree, then just bail. if (!itemInfo) return []; - + itemInfo.isExpandable = [dataSource outlineView:anOutlineView isItemExpandable:anItem]; - + // If we were previously expanded, but now no longer expandable, "de-expand". // NOTE: we are *not* collapsing, thus no notification is posted. if (!itemInfo.isExpandable && itemInfo.isExpanded) @@ -893,72 +933,72 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt itemInfo.children = []; } } - + // The root item does not count as a descendant. var weight = itemInfo.weight, descendants = anItem ? [anItem] : []; - + if (itemInfo.isExpanded && (!(_implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_shouldDeferDisplayingChildrenOfItem_) || ![dataSource outlineView:anOutlineView shouldDeferDisplayingChildrenOfItem:anItem])) { var index = 0, count = [dataSource outlineView:anOutlineView numberOfChildrenOfItem:anItem], level = itemInfo.level + 1; - + itemInfo.children = []; - + for (; index < count; ++index) { var childItem = [dataSource outlineView:anOutlineView child:index ofItem:anItem], childItemInfo = itemInfosForItems[[childItem UID]]; - + if (!childItemInfo) { childItemInfo = { isExpanded:NO, isExpandable:NO, children:[], weight:1 }; itemInfosForItems[[childItem UID]] = childItemInfo; } - + itemInfo.children[index] = childItem; - + var childDescendants = _loadItemInfoForItem(anOutlineView, childItem, YES); - + childItemInfo.parent = anItem; childItemInfo.level = level; descendants = descendants.concat(childDescendants); } } - + itemInfo.weight = descendants.length; - + if (!isIntermediate) { // row = -1 is the root item, so just go to row 0 since it is ignored. var index = MAX(itemInfo.row, 0), itemsForRows = _itemsForRows; - + descendants.unshift(index, weight); - + itemsForRows.splice.apply(itemsForRows, descendants); - + var count = itemsForRows.length; - + for (; index < count; ++index) itemInfosForItems[[itemsForRows[index] UID]].row = index; - + var deltaWeight = itemInfo.weight - weight; - + if (deltaWeight !== 0) { var parent = itemInfo.parent; - + while (parent) { var parentItemInfo = itemInfosForItems[[parent UID]]; - + parentItemInfo.weight += deltaWeight; parent = parentItemInfo.parent; } - + if (anItem) _rootItemInfo.weight += deltaWeight; } @@ -1003,16 +1043,16 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt { if (!(_outlineView._implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_writeItems_toPasteboard_)) return NO; - + var rowIndexes = []; [theIndexes getIndexes:rowIndexes maxCount:[theIndexes count] inIndexRange:nil]; - + var rowIndex = [rowIndexes count], items = []; - + while (rowIndex--) [items addObject:[_outlineView itemAtRow:[rowIndexes objectAtIndex:rowIndex]]]; - + return [_outlineView._outlineViewDataSource outlineView:_outlineView writeItems:items toPasteboard:thePasteboard]; } @@ -1020,15 +1060,15 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt { if (_outlineView._shouldRetargetChildIndex) return _outlineView._retargedChildIndex; - + var childIndex = CPNotFound; - + if (theDropOperation === CPTableViewDropAbove) { var parentItem = [_outlineView _parentItemForUpperRow:theRow - 1 andLowerRow:theRow atMouseOffset:theOffset], itemInfo = (parentItem !== nil) ? _outlineView._itemInfosForItems[[parentItem UID]] : _outlineView._rootItemInfo, children = itemInfo.children; - + childIndex = [children indexOfObject:[_outlineView itemAtRow:theRow]]; if (childIndex === CPNotFound) @@ -1043,12 +1083,12 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt - (void)_parentItemForDropOperation:(CPTableViewDropOperation)theDropOperation row:(int)theRow offset:(CPPoint)theOffset { if (theDropOperation === CPTableViewDropAbove) - return [_outlineView _parentItemForUpperRow:theRow - 1 andLowerRow:theRow atMouseOffset:theOffset] - + return [_outlineView _parentItemForUpperRow:theRow - 1 andLowerRow:theRow atMouseOffset:theOffset] + return [_outlineView itemAtRow:theRow]; } -- (CPDragOperation)tableView:(CPTableView)aTableView validateDrop:(id < CPDraggingInfo >)theInfo +- (CPDragOperation)tableView:(CPTableView)aTableView validateDrop:(id < CPDraggingInfo >)theInfo proposedRow:(int)theRow proposedDropOperation:(CPTableViewDropOperation)theOperation { if (!(_outlineView._implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_validateDrop_proposedItem_proposedChildIndex_)) @@ -1069,14 +1109,14 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt } - (BOOL)tableView:(CPTableView)aTableView acceptDrop:(id )theInfo row:(int)theRow dropOperation:(CPTableViewDropOperation)theOperation -{ +{ if (!(_outlineView._implementedOutlineViewDataSourceMethods & CPOutlineViewDataSource_outlineView_acceptDrop_item_childIndex_)) return NO; var location = [_outlineView convertPoint:[theInfo draggingLocation] fromView:nil], parentItem = [self _parentItemForDropOperation:theOperation row:theRow offset:location]; childIndex = [self _childIndexForDropOperation:theOperation row:theRow offset:location]; - + _outlineView._retargetedItem = nil; _outlineView._shouldRetargetItem = NO; @@ -1106,15 +1146,15 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt - (CPView)tableView:(CPTableView)theTableView dataViewForTableColumn:(CPTableColumn)theTableColumn row:(int)theRow { var dataView = nil; - + if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_dataViewForTableColumn_item_)) - dataView = [_outlineView._outlineViewDelegate outlineView:_outlineView - dataViewForTableColumn:theTableColumn + dataView = [_outlineView._outlineViewDelegate outlineView:_outlineView + dataViewForTableColumn:theTableColumn item:[_outlineView itemAtRow:theRow]]; if (!dataView) - dataView = [theTableColumn dataViewForRow:theRow]; - + dataView = [theTableColumn dataViewForRow:theRow]; + return dataView; } @@ -1122,7 +1162,7 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt { if ((_outlineView._implementedOutlineViewDelegateMethods & CPOutlineViewDelegate_outlineView_shouldSelectItem_)) return [_outlineView._outlineViewDelegate outlineView:_outlineView shouldSelectItem:[_outlineView itemAtRow:theRow]]; - + return YES; } @@ -1209,7 +1249,7 @@ var _loadItemInfoForItem = function(/*CPOutlineView*/ anOutlineView, /*id*/ anIt CGContextClosePath(context); var isHighlighted = [self hasThemeState:CPThemeStateHighlighted]; var color = [self hasThemeState:CPThemeStateSelected] ? (isHighlighted ? [CPColor lightGrayColor] : [CPColor whiteColor]) : (isHighlighted ? [CPColor blackColor] : [CPColor grayColor]); - + CGContextSetFillColor(context, color); CGContextFillPath(context); } diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 346301121..d3873e524 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -536,12 +536,12 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); CPTextFieldInputIsActive = NO; if (document.attachEvent) - { - CPTextFieldCachedSelectStartFunction = nil; - CPTextFieldCachedDragFunction = nil; - + { [[self window] platformWindow]._DOMBodyElement.ondrag = CPTextFieldCachedDragFunction; [[self window] platformWindow]._DOMBodyElement.onselectstart = CPTextFieldCachedSelectStartFunction; + + CPTextFieldCachedSelectStartFunction = nil; + CPTextFieldCachedDragFunction = nil; } #endif @@ -574,20 +574,46 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); // Don't track! (ever?) if ([self isEditable] && [self isEnabled]) return [[self window] makeFirstResponder:self]; + else if ([self isSelectable]) + { + if (document.attachEvent) + { + CPTextFieldCachedSelectStartFunction = [[self window] platformWindow]._DOMBodyElement.onselectstart; + CPTextFieldCachedDragFunction = [[self window] platformWindow]._DOMBodyElement.ondrag; + + [[self window] platformWindow]._DOMBodyElement.ondrag = function () {}; + [[self window] platformWindow]._DOMBodyElement.onselectstart = function () {}; + } + return [[[anEvent window] platformWindow] _propagateCurrentDOMEvent:YES]; + } else return [[self nextResponder] mouseDown:anEvent]; } - (void)mouseUp:(CPEvent)anEvent { - if (![self isEditable] || ![self isEnabled]) + if (![self isSelectable] && (![self isEditable] || ![self isEnabled])) [[self nextResponder] mouseUp:anEvent]; + else if ([self isSelectable]) + { + if (document.attachEvent) + { + [[self window] platformWindow]._DOMBodyElement.ondrag = CPTextFieldCachedDragFunction; + [[self window] platformWindow]._DOMBodyElement.onselectstart = CPTextFieldCachedSelectStartFunction; + + CPTextFieldCachedSelectStartFunction = nil + CPTextFieldCachedDragFunction = nil; + } + return [[[anEvent window] platformWindow] _propagateCurrentDOMEvent:YES]; + } } - (void)mouseDragged:(CPEvent)anEvent { - if (![self isEditable] || ![self isEnabled]) + if (![self isSelectable] && (![self isEditable] || ![self isEnabled])) [[self nextResponder] mouseDragged:anEvent]; + else if ([self isSelectable]) + return [[[anEvent window] platformWindow] _propagateCurrentDOMEvent:YES]; } - (void)keyUp:(CPEvent)anEvent diff --git a/AppKit/CPWindow/CPWindow.j b/AppKit/CPWindow/CPWindow.j index f06953ab1..a28ecf2a6 100644 --- a/AppKit/CPWindow/CPWindow.j +++ b/AppKit/CPWindow/CPWindow.j @@ -742,8 +742,10 @@ CPTexturedBackgroundWindowMask */ - (void)orderFront:(id)aSender { +#if PLATFORM(DOM) [_platformWindow orderFront:self]; [_platformWindow order:CPWindowAbove window:self relativeTo:nil]; +#endif if (_firstResponder === self || !_firstResponder) [self makeFirstResponder:[self initialFirstResponder]]; @@ -771,13 +773,17 @@ CPTexturedBackgroundWindowMask */ - (void)orderOut:(id)aSender { +#if PLATFORM(DOM) if ([self _sharesChromeWithPlatformWindow]) [_platformWindow orderOut:self]; +#endif if ([_delegate respondsToSelector:@selector(windowWillClose:)]) [_delegate windowWillClose:self]; +#if PLATFORM(DOM) [_platformWindow order:CPWindowOut window:self relativeTo:nil]; +#endif [self _updateMainAndKeyWindows]; } @@ -789,7 +795,9 @@ CPTexturedBackgroundWindowMask */ - (void)orderWindow:(CPWindowOrderingMode)aPlace relativeTo:(int)otherWindowNumber { +#if PLATFORM(DOM) [_platformWindow order:aPlace window:self relativeTo:CPApp._windows[otherWindowNumber]]; +#endif } /*! diff --git a/AppKit/Platform/CPPlatformWindow.j b/AppKit/Platform/CPPlatformWindow.j index a0f46cc52..baaab6396 100644 --- a/AppKit/Platform/CPPlatformWindow.j +++ b/AppKit/Platform/CPPlatformWindow.j @@ -160,7 +160,9 @@ var PrimaryPlatformWindow = NULL; _contentRect = _CGRectMakeCopy(aRect); - [self updateNativeContentRect]; +#if PLATFORM(DOM) + [self updateNativeContentRect]; +#endif } - (void)updateFromNativeContentRect diff --git a/Objective-J/CPLog.js b/Objective-J/CPLog.js index b4d69c84f..473ccfd88 100644 --- a/Objective-J/CPLog.js +++ b/Objective-J/CPLog.js @@ -105,7 +105,7 @@ var _CPFormatLogMessage = function(aString, aLevel, aTitle) if (typeof exports.sprintf == "function") return exports.sprintf("%4d-%02d-%02d %02d:%02d:%02d.%03d %s%s: %s", - now.getFullYear(), now.getMonth(), now.getDate(), + now.getFullYear(), now.getMonth() + 1, now.getDate(), now.getHours(), now.getMinutes(), now.getSeconds(), now.getMilliseconds(), aTitle, aLevel, aString); else diff --git a/Objective-J/Debug.js b/Objective-J/Debug.js index 9c1df6cd6..1df4bd179 100644 --- a/Objective-J/Debug.js +++ b/Objective-J/Debug.js @@ -93,7 +93,7 @@ GLOBAL(objj_backtrace_decorator) = function(msgSend) return function(aReceiverOrSuper, aSelector) { var aReceiver = aReceiverOrSuper && (aReceiverOrSuper.receiver || aReceiverOrSuper); - + // push the receiver and selector onto the backtrace stack objj_backtrace.push({ receiver: aReceiver, selector : aSelector }); try @@ -105,6 +105,9 @@ GLOBAL(objj_backtrace_decorator) = function(msgSend) // print the exception and backtrace CPLog.warn("Exception " + anException + " in " + objj_debug_message_format(aReceiver, aSelector)); objj_backtrace_print(CPLog.warn); + + // re-throw the exception + throw anException; } finally { @@ -114,6 +117,24 @@ GLOBAL(objj_backtrace_decorator) = function(msgSend) } } +GLOBAL(objj_supress_exceptions_decorator) = function(msgSend) +{ + return function(aReceiverOrSuper, aSelector) + { + var aReceiver = aReceiverOrSuper && (aReceiverOrSuper.receiver || aReceiverOrSuper); + + try + { + return msgSend.apply(NULL, arguments); + } + catch (anException) + { + // print the exception and backtrace + CPLog.warn("Exception " + anException + " in " + objj_debug_message_format(aReceiver, aSelector)); + } + } +} + // type checking decorator var objj_typechecks_reported = {}, diff --git a/Tools/capp/Resources/Templates/Application/index-debug.html b/Tools/capp/Resources/Templates/Application/index-debug.html index efc533581..644616e6d 100644 --- a/Tools/capp/Resources/Templates/Application/index-debug.html +++ b/Tools/capp/Resources/Templates/Application/index-debug.html @@ -37,6 +37,9 @@ // Uncomment to enable printing of backtraces on exceptions: //objj_msgSend_decorate(objj_backtrace_decorator); + + // Uncomment to supress exceptions that take place inside a message + //objj_msgSend_decorate(objj_supress_exceptions_decorator) // Uncomment to enable runtime type checking: //objj_msgSend_decorate(objj_typecheck_decorator); diff --git a/Tools/capp/Resources/Templates/NibApplication/index-debug.html b/Tools/capp/Resources/Templates/NibApplication/index-debug.html index b5e9fc417..78c59cd69 100644 --- a/Tools/capp/Resources/Templates/NibApplication/index-debug.html +++ b/Tools/capp/Resources/Templates/NibApplication/index-debug.html @@ -37,6 +37,9 @@ // Uncomment to enable printing of backtraces on exceptions: //objj_msgSend_decorate(objj_backtrace_decorator); + + // Uncomment to supress exceptions that take place inside a message + //objj_msgSend_decorate(objj_supress_exceptions_decorator) // Uncomment to enable runtime type checking: //objj_msgSend_decorate(objj_typecheck_decorator); @@ -51,7 +54,7 @@ //CPLogRegister(CPLogConsole); //CPLogRegister(CPLogPopup); - +