AppKit: convert instance-state macros to private methods

- CPScrollView _shouldShowCornerView, CPSplitView
  _maybePostWillResizeNotification/_maybePostDidResizeNotification/
  _didSuppressResizeNotifications/_setResizeNotificationsSuppressed:,
  CPTableView _numberOfColumns/_updateColumnRangesIfNecessary/
  _fullRowHeight/_rowBottomOfHeightInfo:/_hasVariableRowHeights,
  CPMenuItem _decodeValueForKey:defaultValue:coder:/
  _encodeValue:forKey:ifNotEqualTo:coder:, CALayer
  _adjustContentsZIndexForLayer: and DOM: macros that referenced
  ivars, self or the enclosing method's coder become private instance
  methods; call sites rewritten from macro form to message form
This commit is contained in:
David Richardson committed 2026-10-06 17:42:56 -06:00
1 parent 315ed7f2df
commit adec5f6c04
5 files changed
+147 -103

No files matched your search

+26 -17
View File
@@ -895,6 +895,17 @@ CPControlKeyMask
return [super description] + @" target: " + [self target] + @" action: " + CPStringFromSelector([self action]);
}
- (id)_decodeValueForKey:(CPString)aKey defaultValue:(id)aDefaultValue coder:(CPCoder)aCoder
{
return [aCoder containsValueForKey:aKey] ? [aCoder decodeObjectForKey:aKey] : aDefaultValue;
}
- (void)_encodeValue:(id)aValue forKey:(CPString)aKey ifNotEqualTo:(id)aDefaultValue coder:(CPCoder)aCoder
{
if (aValue !== aDefaultValue)
[aCoder encodeObject:aValue forKey:aKey];
}
@end
// MARK: -
@@ -940,9 +951,6 @@ var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey",
CPMenuItemRepresentedObjectKey = @"CPMenuItemRepresentedObjectKey",
CPMenuItemViewKey = @"CPMenuItemViewKey";
#define DEFAULT_VALUE(aKey, aDefaultValue) [aCoder containsValueForKey:(aKey)] ? [aCoder decodeObjectForKey:(aKey)] : (aDefaultValue)
#define ENCODE_IFNOT(aKey, aValue, aDefaultValue) if ((aValue) !== (aDefaultValue)) [aCoder encodeObject:(aValue) forKey:(aKey)];
@implementation CPMenuItem (CPCoding)
/*!
Initializes the menu item from a coder.
@@ -965,7 +973,7 @@ var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey",
_target = [aCoder decodeObjectForKey:CPMenuItemTargetKey];
_action = [aCoder decodeObjectForKey:CPMenuItemActionKey];
_isEnabled = DEFAULT_VALUE(CPMenuItemIsEnabledKey, YES);
_isEnabled = [self _decodeValueForKey:CPMenuItemIsEnabledKey defaultValue:YES coder:aCoder];
_isHidden = [aCoder decodeBoolForKey:CPMenuItemIsHiddenKey];
_tag = [aCoder decodeIntForKey:CPMenuItemTagKey];
_state = [aCoder decodeIntForKey:CPMenuItemStateKey];
@@ -1012,20 +1020,20 @@ var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey",
[aCoder encodeObject:_target forKey:CPMenuItemTargetKey];
[aCoder encodeObject:_action forKey:CPMenuItemActionKey];
ENCODE_IFNOT(CPMenuItemIsEnabledKey, _isEnabled, YES);
ENCODE_IFNOT(CPMenuItemIsHiddenKey, _isHidden, NO);
[self _encodeValue:_isEnabled forKey:CPMenuItemIsEnabledKey ifNotEqualTo:YES coder:aCoder]
[self _encodeValue:_isHidden forKey:CPMenuItemIsHiddenKey ifNotEqualTo:NO coder:aCoder]
ENCODE_IFNOT(CPMenuItemTagKey, _tag, 0);
ENCODE_IFNOT(CPMenuItemStateKey, _state, CPOffState);
[self _encodeValue:_tag forKey:CPMenuItemTagKey ifNotEqualTo:0 coder:aCoder]
[self _encodeValue:_state forKey:CPMenuItemStateKey ifNotEqualTo:CPOffState coder:aCoder]
ENCODE_IFNOT(CPMenuItemImageKey, _image, nil);
ENCODE_IFNOT(CPMenuItemAlternateImageKey, _alternateImage, nil);
ENCODE_IFNOT(CPMenuItemOnStateImageKey, _onStateImage, nil);
ENCODE_IFNOT(CPMenuItemOffStateImageKey, _offStateImage, nil);
ENCODE_IFNOT(CPMenuItemMixedStateImageKey, _mixedStateImage, nil);
[self _encodeValue:_image forKey:CPMenuItemImageKey ifNotEqualTo:nil coder:aCoder]
[self _encodeValue:_alternateImage forKey:CPMenuItemAlternateImageKey ifNotEqualTo:nil coder:aCoder]
[self _encodeValue:_onStateImage forKey:CPMenuItemOnStateImageKey ifNotEqualTo:nil coder:aCoder]
[self _encodeValue:_offStateImage forKey:CPMenuItemOffStateImageKey ifNotEqualTo:nil coder:aCoder]
[self _encodeValue:_mixedStateImage forKey:CPMenuItemMixedStateImageKey ifNotEqualTo:nil coder:aCoder]
ENCODE_IFNOT(CPMenuItemSubmenuKey, _submenu, nil);
ENCODE_IFNOT(CPMenuItemMenuKey, _menu, nil);
[self _encodeValue:_submenu forKey:CPMenuItemSubmenuKey ifNotEqualTo:nil coder:aCoder]
[self _encodeValue:_menu forKey:CPMenuItemMenuKey ifNotEqualTo:nil coder:aCoder]
if (_keyEquivalent && _keyEquivalent.length)
[aCoder encodeObject:_keyEquivalent forKey:CPMenuItemKeyEquivalentKey];
@@ -1036,8 +1044,9 @@ var CPMenuItemIsSeparatorKey = @"CPMenuItemIsSeparatorKey",
if (_indentationLevel > 0)
[aCoder encodeInt:_indentationLevel forKey:CPMenuItemIndentationLevelKey];
ENCODE_IFNOT(CPMenuItemRepresentedObjectKey, _representedObject, nil);
ENCODE_IFNOT(CPMenuItemViewKey, _view, nil);
[self _encodeValue:_representedObject forKey:CPMenuItemRepresentedObjectKey ifNotEqualTo:nil coder:aCoder]
[self _encodeValue:_view forKey:CPMenuItemViewKey ifNotEqualTo:nil coder:aCoder]
}
@end
+8 -4
View File
@@ -35,7 +35,6 @@
@class CPTableView
@class CPRulerView
#define SHOULD_SHOW_CORNER_VIEW() (_scrollerStyle === CPScrollerStyleLegacy && _verticalScroller && ![_verticalScroller isHidden])
@protocol CPScrollViewDelegate <CPObject>
@@ -999,7 +998,7 @@ Notifies the delegate when the scroll view has finished scrolling.
if (_cornerView)
{
[_cornerView setHidden:!SHOULD_SHOW_CORNER_VIEW()];
[_cornerView setHidden:![self _shouldShowCornerView]];
[self addSubview:_cornerView];
}
}
@@ -1042,7 +1041,7 @@ Notifies the delegate when the scroll view has finished scrolling.
frame.size.height = CGRectGetHeight([headerView frame]);
if (SHOULD_SHOW_CORNER_VIEW())
if ([self _shouldShowCornerView])
frame.size.width -= CGRectGetWidth([self _cornerViewFrame]);
return frame;
@@ -1405,7 +1404,7 @@ Notifies the delegate when the scroll view has finished scrolling.
[_headerClipView setFrame:[self _headerClipViewFrame]];
[[_headerClipView documentView] setNeedsDisplay:YES];
if (SHOULD_SHOW_CORNER_VIEW())
if ([self _shouldShowCornerView])
{
[_cornerView setFrame:[self _cornerViewFrame]];
[_cornerView setHidden:NO];
@@ -1729,6 +1728,10 @@ Notifies the delegate when the scroll view has finished scrolling.
[_headerClipView scrollToPoint:CGPointMake(contentBounds.origin.x, 0)];
}
- (BOOL)_shouldShowCornerView
{
return (_scrollerStyle === CPScrollerStyleLegacy && _verticalScroller && ![_verticalScroller isHidden]);
}
@end
// MARK: -
@@ -1905,4 +1908,5 @@ var CPScrollViewContentViewKey = @"CPScrollViewContentView",
[aCoder encodeObject:_horizontalRuler forKey:CPScrollViewHRulerKey];
}
@end
+40 -31
View File
@@ -62,28 +62,6 @@ var CPSplitViewDelegate_splitView_canCollapseSubview_
CPSplitViewDelegate_splitViewDidResizeSubviews_ = 1 << 9,
CPSplitViewDelegate_splitViewWillResizeSubviews_ = 1 << 10;
#define SPLIT_VIEW_MAYBE_POST_WILL_RESIZE() \
if ((_suppressResizeNotificationsMask & DidPostWillResizeNotification) === 0) \
{ \
[self _postNotificationWillResize]; \
_suppressResizeNotificationsMask |= DidPostWillResizeNotification; \
}
#define SPLIT_VIEW_MAYBE_POST_DID_RESIZE() \
if ((_suppressResizeNotificationsMask & ShouldSuppressResizeNotifications) !== 0) \
_suppressResizeNotificationsMask |= DidSuppressResizeNotification; \
else \
[self _postNotificationDidResize];
#define SPLIT_VIEW_DID_SUPPRESS_RESIZE_NOTIFICATION() \
((_suppressResizeNotificationsMask & DidSuppressResizeNotification) !== 0)
#define SPLIT_VIEW_SUPPRESS_RESIZE_NOTIFICATIONS(shouldSuppress) \
if (shouldSuppress) \
_suppressResizeNotificationsMask |= ShouldSuppressResizeNotifications; \
else \
_suppressResizeNotificationsMask = 0;
CPSplitViewDidResizeSubviewsNotification = @"CPSplitViewDidResizeSubviewsNotification";
CPSplitViewWillResizeSubviewsNotification = @"CPSplitViewWillResizeSubviewsNotification";
@@ -733,7 +711,7 @@ var CPThemeStatesForSplitViewDivider = @[@"dummy one as CPSplitViewDividerStyle
*/
- (void)adjustSubviews
{
SPLIT_VIEW_MAYBE_POST_WILL_RESIZE();
[self _maybePostWillResizeNotification];
[self _postNotificationWillResize];
// 2 possibilities : we have, or not, enough flexible space to accomodate fixed size subviews
@@ -815,7 +793,7 @@ var CPThemeStatesForSplitViewDivider = @[@"dummy one as CPSplitViewDividerStyle
[self _distribute:remainingSpace amoung:fixedCount onFlexible:NO fromIndex:0 toIndex:nbSubviews-1];
}
SPLIT_VIEW_MAYBE_POST_DID_RESIZE();
[self _maybePostDidResizeNotification];
[self layoutSubviews];
}
@@ -1211,7 +1189,7 @@ var CPThemeStatesForSplitViewDivider = @[@"dummy one as CPSplitViewDividerStyle
// autosave.
_shouldRestoreFromAutosaveUnlessFrameSize = nil;
SPLIT_VIEW_SUPPRESS_RESIZE_NOTIFICATIONS(YES);
[self _setResizeNotificationsSuppressed:YES];
var realPosition = [self _realPositionForPosition:position ofDividerAtIndex:dividerIndex],
viewA = _arrangedSubviews[dividerIndex],
@@ -1228,9 +1206,9 @@ var CPThemeStatesForSplitViewDivider = @[@"dummy one as CPSplitViewDividerStyle
if (preSize !== frameA.size[_sizeComponent])
{
SPLIT_VIEW_MAYBE_POST_WILL_RESIZE();
[self _maybePostWillResizeNotification];
[_arrangedSubviews[dividerIndex] setFrame:frameA];
SPLIT_VIEW_MAYBE_POST_DID_RESIZE();
[self _maybePostDidResizeNotification];
}
preSize = frameB.size[_sizeComponent];
@@ -1245,9 +1223,9 @@ var CPThemeStatesForSplitViewDivider = @[@"dummy one as CPSplitViewDividerStyle
if (preSize !== frameB.size[_sizeComponent] || preOrigin !== frameB.origin[_originComponent])
{
SPLIT_VIEW_MAYBE_POST_WILL_RESIZE();
[self _maybePostWillResizeNotification];
[_arrangedSubviews[dividerIndex + 1] setFrame:frameB];
SPLIT_VIEW_MAYBE_POST_DID_RESIZE();
[self _maybePostDidResizeNotification];
}
if (preCollapsePosition)
@@ -1260,10 +1238,10 @@ var CPThemeStatesForSplitViewDivider = @[@"dummy one as CPSplitViewDividerStyle
[self _updateRatios];
if (SPLIT_VIEW_DID_SUPPRESS_RESIZE_NOTIFICATION())
if ([self _didSuppressResizeNotifications])
[self _postNotificationDidResize];
SPLIT_VIEW_SUPPRESS_RESIZE_NOTIFICATIONS(NO);
[self _setResizeNotificationsSuppressed:NO];
}
/*!
@@ -1483,6 +1461,36 @@ var CPThemeStatesForSplitViewDivider = @[@"dummy one as CPSplitViewDividerStyle
return @"CPSplitView Subview Precollapse Positions " + theAutosaveName;
}
- (void)_maybePostWillResizeNotification
{
if ((_suppressResizeNotificationsMask & DidPostWillResizeNotification) === 0)
{
[self _postNotificationWillResize];
_suppressResizeNotificationsMask |= DidPostWillResizeNotification;
}
}
- (void)_maybePostDidResizeNotification
{
if ((_suppressResizeNotificationsMask & ShouldSuppressResizeNotifications) !== 0)
_suppressResizeNotificationsMask |= DidSuppressResizeNotification;
else
[self _postNotificationDidResize];
}
- (BOOL)_didSuppressResizeNotifications
{
return ((_suppressResizeNotificationsMask & DidSuppressResizeNotification) !== 0);
}
- (void)_setResizeNotificationsSuppressed:(BOOL)shouldSuppress
{
if (shouldSuppress)
_suppressResizeNotificationsMask |= ShouldSuppressResizeNotifications;
else
_suppressResizeNotificationsMask = 0;
}
@end
// MARK: -
@@ -1896,5 +1904,6 @@ var CPSplitViewDelegateKey = @"CPSplitViewDelegateKey",
[self setDividerStyle:(shouldBePaneSplitter ? CPSplitViewDividerStylePaneSplitter : CPSplitViewDividerStyleThin)];
}
@end
+61 -44
View File
@@ -119,15 +119,6 @@ CPTableViewReverseSequentialColumnAutoresizingStyle = 3;
CPTableViewLastColumnOnlyAutoresizingStyle = 4;
CPTableViewFirstColumnOnlyAutoresizingStyle = 5;
#define NUMBER_OF_COLUMNS() (_tableColumns.length)
#define UPDATE_COLUMN_RANGES_IF_NECESSARY() \
if (_dirtyTableColumnRangeIndex !== CPNotFound) \
[self _recalculateTableColumnRanges];
#define FULL_ROW_HEIGHT() (_rowHeight + _intercellSpacing.height)
#define ROW_BOTTOM(__heightInfo) (__heightInfo.y + __heightInfo.height + _intercellSpacing.height)
#define HAS_VARIABLE_ROW_HEIGHTS() (_implementedDelegateMethods & CPTableViewDelegate_tableView_heightOfRow_)
@protocol CPTableViewDataSource <CPObject>
@optional
@@ -1105,9 +1096,9 @@ NOT YET IMPLEMENTED
[aTableColumn setTableView:self];
if (_dirtyTableColumnRangeIndex < 0)
_dirtyTableColumnRangeIndex = NUMBER_OF_COLUMNS() - 1;
_dirtyTableColumnRangeIndex = [self _numberOfColumns] - 1;
else
_dirtyTableColumnRangeIndex = MIN(NUMBER_OF_COLUMNS() - 1, _dirtyTableColumnRangeIndex);
_dirtyTableColumnRangeIndex = MIN([self _numberOfColumns] - 1, _dirtyTableColumnRangeIndex);
if ([[self sortDescriptors] count] > 0)
{
@@ -1280,7 +1271,7 @@ NOT YET IMPLEMENTED
- (CPInteger)columnWithIdentifier:(CPString)anIdentifier
{
var index = 0,
count = NUMBER_OF_COLUMNS();
count = [self _numberOfColumns];
for (; index < count; ++index)
if ([_tableColumns[index] identifier] === anIdentifier)
@@ -1625,7 +1616,7 @@ NOT YET IMPLEMENTED
*/
- (int)numberOfColumns
{
return NUMBER_OF_COLUMNS();
return [self _numberOfColumns];
}
/*!
@@ -1744,7 +1735,7 @@ NOT YET IMPLEMENTED
_numberOfHiddenColumns = 0;
var index = _dirtyTableColumnRangeIndex,
count = NUMBER_OF_COLUMNS(),
count = [self _numberOfColumns],
x = index === 0 ? 0.0 : CPMaxRange(_tableColumnRanges[index - 1]);
for (; index < count; ++index)
@@ -1784,13 +1775,13 @@ NOT YET IMPLEMENTED
// Coerce aColumnIndex to a number in case it is a string.
aColumnIndex = +aColumnIndex;
if (aColumnIndex < 0 || aColumnIndex >= NUMBER_OF_COLUMNS())
if (aColumnIndex < 0 || aColumnIndex >= [self _numberOfColumns])
return CGRectMakeZero();
if ([[_tableColumns objectAtIndex:aColumnIndex] isHidden])
return CGRectMakeZero();
UPDATE_COLUMN_RANGES_IF_NECESSARY();
[self _updateColumnRangesIfNecessary];
var range = _tableColumnRanges[aColumnIndex];
@@ -1819,7 +1810,7 @@ NOT YET IMPLEMENTED
height,
fixedHeightRows = 0;
if (HAS_VARIABLE_ROW_HEIGHTS())
if ([self _hasVariableRowHeights])
{
[self _populateRowHeightCacheIfNeeded];
@@ -1835,12 +1826,12 @@ NOT YET IMPLEMENTED
}
else
{
height = FULL_ROW_HEIGHT();
height = [self _fullRowHeight];
if (_numberOfRows > 0)
{
heightInfo = _cachedRowHeights[lastIndex];
y = ROW_BOTTOM(heightInfo);
y = [self _rowBottomOfHeightInfo:heightInfo];
// y is now at the top of the first row beyond the last valid row.
// Add the height of any rows beyond that.
@@ -1851,10 +1842,10 @@ NOT YET IMPLEMENTED
else
{
fixedHeightRows = aRowIndex;
height = FULL_ROW_HEIGHT();
height = [self _fullRowHeight];
}
y += fixedHeightRows * FULL_ROW_HEIGHT();
y += fixedHeightRows * [self _fullRowHeight];
return CGRectMake(0.0, y, CGRectGetWidth([self bounds]), height);
}
@@ -1921,7 +1912,7 @@ NOT YET IMPLEMENTED
if (bottomOfRealRows >= rectBottom)
return rowRange;
var numberOfSynthesizedRows = CEIL((rectBottom - bottomOfRealRows) / FULL_ROW_HEIGHT());
var numberOfSynthesizedRows = CEIL((rectBottom - bottomOfRealRows) / [self _fullRowHeight]);
rowRange.length += numberOfSynthesizedRows;
@@ -1943,7 +1934,7 @@ NOT YET IMPLEMENTED
lastColumn = [self columnAtPoint:CGPointMake(CGRectGetMaxX(aRect), 0.0)];
if (lastColumn === CPNotFound)
lastColumn = NUMBER_OF_COLUMNS() - 1;
lastColumn = [self _numberOfColumns] - 1;
// Don't bother doing the expensive removal of hidden indexes if we have no hidden columns.
if (_numberOfHiddenColumns <= 0)
@@ -1978,7 +1969,7 @@ NOT YET IMPLEMENTED
if (!CGRectContainsPoint(bounds, aPoint))
return CPNotFound;
UPDATE_COLUMN_RANGES_IF_NECESSARY();
[self _updateColumnRangesIfNecessary];
var x = aPoint.x,
low = 0,
@@ -2031,13 +2022,13 @@ NOT YET IMPLEMENTED
// aPoint.x is in bounds, now we just have to check aPoint.y
if (HAS_VARIABLE_ROW_HEIGHTS())
if ([self _hasVariableRowHeights])
{
// First make sure aPoint.y is above the bottom of the last row, otherwise we might
// search the (potentially large number of) rows for nothing.
var heightInfo = [_cachedRowHeights lastObject];
if (!heightInfo || aPoint.y >= ROW_BOTTOM(heightInfo))
if (!heightInfo || aPoint.y >= [self _rowBottomOfHeightInfo:heightInfo])
return -1;
return [_cachedRowHeights indexOfObject:aPoint
@@ -2048,7 +2039,7 @@ NOT YET IMPLEMENTED
if (aPoint.y < heightInfo.y)
return CPOrderedAscending;
if (aPoint.y > ROW_BOTTOM(heightInfo))
if (aPoint.y > [self _rowBottomOfHeightInfo:heightInfo])
return CPOrderedDescending;
return CPOrderedSame;
@@ -2056,7 +2047,7 @@ NOT YET IMPLEMENTED
}
else
{
var row = FLOOR(aPoint.y / FULL_ROW_HEIGHT());
var row = FLOOR(aPoint.y / [self _fullRowHeight]);
return row >= _numberOfRows ? -1 : row;
}
@@ -2163,7 +2154,7 @@ NOT YET IMPLEMENTED
*/
- (CGRect)frameOfDataViewAtColumn:(CPInteger)aColumn row:(CPInteger)aRow
{
UPDATE_COLUMN_RANGES_IF_NECESSARY();
[self _updateColumnRangesIfNecessary];
if (aColumn > [self numberOfColumns] || aRow > [self numberOfRows])
return CGRectMakeZero();
@@ -2225,9 +2216,9 @@ NOT YET IMPLEMENTED
if (!superview)
return;
UPDATE_COLUMN_RANGES_IF_NECESSARY();
[self _updateColumnRangesIfNecessary];
var count = NUMBER_OF_COLUMNS(),
var count = [self _numberOfColumns],
columnToResize = nil,
totalWidth = 0,
i = 0;
@@ -2271,10 +2262,10 @@ NOT YET IMPLEMENTED
if (!superview || ![superview isKindOfClass:[CPClipView class]])
return;
UPDATE_COLUMN_RANGES_IF_NECESSARY();
[self _updateColumnRangesIfNecessary];
var superviewWidth = [superview bounds].size.width,
count = NUMBER_OF_COLUMNS(),
count = [self _numberOfColumns],
resizableColumns = [CPIndexSet indexSet],
remainingSpace = 0.0,
i = 0;
@@ -2370,9 +2361,9 @@ NOT YET IMPLEMENTED
var superviewSize = [superview bounds].size;
UPDATE_COLUMN_RANGES_IF_NECESSARY();
[self _updateColumnRangesIfNecessary];
var count = NUMBER_OF_COLUMNS();
var count = [self _numberOfColumns];
// Decrement the counter until we get to the last column that's not hidden
while (count-- && [_tableColumns[count] isHidden]);
@@ -2440,7 +2431,7 @@ NOT YET IMPLEMENTED
*/
- (void)_noteHeightOfRowsWithIndexesChanged:(CPIndexSet)anIndexSet
{
if (!HAS_VARIABLE_ROW_HEIGHTS())
if (![self _hasVariableRowHeights])
return;
// Update the height of the given rows by calling the delegate. Since the row height cache also contains
@@ -2482,21 +2473,21 @@ NOT YET IMPLEMENTED
*/
- (void)tile
{
UPDATE_COLUMN_RANGES_IF_NECESSARY();
[self _updateColumnRangesIfNecessary];
var width = _tableColumnRanges.length > 0 ? CPMaxRange([_tableColumnRanges lastObject]) : 0.0,
superview = [self superview],
height = 0;
if (!HAS_VARIABLE_ROW_HEIGHTS())
height = FULL_ROW_HEIGHT() * _numberOfRows;
if (![self _hasVariableRowHeights])
height = [self _fullRowHeight] * _numberOfRows;
else if (_numberOfRows > 0)
{
[self _populateRowHeightCacheIfNeeded];
var heightInfo = _cachedRowHeights[_cachedRowHeights.length - 1];
height = ROW_BOTTOM(heightInfo);
height = [self _rowBottomOfHeightInfo:heightInfo];
}
if ([superview isKindOfClass:[CPClipView class]])
@@ -3606,7 +3597,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
if (![rowIndexes count] || ![columnIndexes count])
return;
UPDATE_COLUMN_RANGES_IF_NECESSARY();
[self _updateColumnRangesIfNecessary];
if (_numberOfHiddenColumns > 0)
columnIndexes = [columnIndexes indexesPassingTest:function(idx, stop)
@@ -3829,9 +3820,9 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
[CPException raise:CPInvalidArgumentException
reason:@"Row " + row + " out of row range [0-" + (_numberOfRows - 1) + "] for rowViewAtRow:createIfNeeded:"];
if (column > (NUMBER_OF_COLUMNS() - 1))
if (column > ([self _numberOfColumns] - 1))
[CPException raise:CPInvalidArgumentException
reason:@"Column " + column + " out of row range [0-" + (NUMBER_OF_COLUMNS ()- 1) + "] for rowViewAtRow:createIfNeeded:"];
reason:@"Column " + column + " out of row range [0-" + ([self _numberOfColumns]- 1) + "] for rowViewAtRow:createIfNeeded:"];
var dataViewsForRow = _dataViewsForRows[row],
tableColumn = _tableColumns[column],
@@ -4207,7 +4198,7 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
if (_rowHeight > 0.0)
{
var rowHeight = FULL_ROW_HEIGHT(),
var rowHeight = [self _fullRowHeight],
totalHeight = CGRectGetMaxY(aRect) - lineThickness / 2;
while (rowY < totalHeight)
@@ -5615,6 +5606,31 @@ Your delegate can implement this method to avoid subclassing the tableview to ad
[self scrollRowToVisible:i];
}
- (int)_numberOfColumns
{
return _tableColumns.length;
}
- (void)_updateColumnRangesIfNecessary
{
if (_dirtyTableColumnRangeIndex !== CPNotFound)
[self _recalculateTableColumnRanges];
}
- (CGFloat)_fullRowHeight
{
return (_rowHeight + _intercellSpacing.height);
}
- (CGFloat)_rowBottomOfHeightInfo:(JSObject)heightInfo
{
return (heightInfo.y + heightInfo.height + _intercellSpacing.height);
}
- (BOOL)_hasVariableRowHeights
{
return (_implementedDelegateMethods & CPTableViewDelegate_tableView_heightOfRow_);
}
@end
@@ -6532,4 +6548,5 @@ var CPTableViewDataSourceKey = @"CPTableViewDataSourceKey",
return "<" + [self className] + " 0x" + [CPString stringWithHash:[self UID]] + " identifier=" + [self identifier] + ">";
}
@end
+12 -7
View File
@@ -33,7 +33,10 @@
@import "CAMediaTimingFunction.j"
#define DOM(aLayer) aLayer._DOMElement
function DOM(aLayer)
{
return aLayer._DOMElement;
}
var CALayerGeometryBoundsMask = 1,
CALayerGeometryPositionMask = 2,
@@ -667,10 +670,6 @@ var CALayerRegisteredRunLoopUpdates = nil;
return _superlayer;
}
#define ADJUST_CONTENTS_ZINDEX(aLayer)\
if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)\
_DOMContentsElement.style.zIndex -= 100.0;\
/*!
Adds the specified layer as a sublayer of the receiver.
*/
@@ -723,7 +722,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
else if (superlayer != nil)
[aLayer removeFromSuperlayer];
ADJUST_CONTENTS_ZINDEX(aLayer);
[self _adjustContentsZIndexForLayer:aLayer];
[_sublayers insertObject:aLayer atIndex:anIndex];
@@ -786,7 +785,7 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
return;
}
ADJUST_CONTENTS_ZINDEX(aLayer);
[self _adjustContentsZIndexForLayer:aLayer];
[_sublayers replaceObjectAtIndex:[_sublayers indexOfObjectIdenticalTo:aSublayer] withObject:aLayer];
_DOMElement.replaceChild(DOM(aSublayer), DOM(aLayer));
@@ -1271,6 +1270,12 @@ if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
window.loop = false;
}
- (void)_adjustContentsZIndexForLayer:(CALayer)aLayer
{
if (_DOMContentsElement && aLayer._zPosition > _DOMContentsElement.style.zIndex)
_DOMContentsElement.style.zIndex -= 100.0;
}
@end
function _CALayerUpdateSublayerTransformForSublayers(aLayer)