[ASRangeController] Ensure that even if the collection view layout is inconsistent, it is impossible for a visible item to not be in the display range.

This commit is contained in:
Scott Goodson
2016-03-12 16:26:33 -08:00
parent fe8cc9328c
commit f97a509541
4 changed files with 23 additions and 14 deletions

View File

@@ -120,11 +120,6 @@ typedef NS_OPTIONS(NSUInteger, ASControlState) {
*/ */
- (void)sendActionsForControlEvents:(ASControlNodeEvent)controlEvents withEvent:(nullable UIEvent *)event; - (void)sendActionsForControlEvents:(ASControlNodeEvent)controlEvents withEvent:(nullable UIEvent *)event;
/**
Class method to enable a visualization overlay of the tapable area on the ASControlNode. For app debugging purposes only.
@param enable Specify YES to make this debug feature enabled when messaging the ASControlNode class.
*/
+ (void)setEnableHitTestDebug:(BOOL)enable;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END

View File

@@ -2003,6 +2003,8 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock)
- (void)setInterfaceState:(ASInterfaceState)newState - (void)setInterfaceState:(ASInterfaceState)newState
{ {
// It should never be possible for a node to be visible but not be allowed / expected to display.
ASDisplayNodeAssertFalse(ASInterfaceStateIncludesVisible(newState) && !ASInterfaceStateIncludesDisplay(newState));
ASInterfaceState oldState = ASInterfaceStateNone; ASInterfaceState oldState = ASInterfaceStateNone;
{ {
ASDN::MutexLocker l(_propertyLock); ASDN::MutexLocker l(_propertyLock);

View File

@@ -6,9 +6,19 @@
// Copyright © 2016 Facebook. All rights reserved. // Copyright © 2016 Facebook. All rights reserved.
// //
#import <Foundation/Foundation.h> #import "ASControlNode.h"
#import "ASImageNode.h" #import "ASImageNode.h"
@interface ASControlNode (Debugging)
/**
Class method to enable a visualization overlay of the tapable area on the ASControlNode. For app debugging purposes only.
@param enable Specify YES to make this debug feature enabled when messaging the ASControlNode class.
*/
+ (void)setEnableHitTestDebug:(BOOL)enable;
@end
@interface ASImageNode (Debugging) @interface ASImageNode (Debugging)
/** /**
@@ -20,4 +30,4 @@
+ (void)setShouldShowImageScalingOverlay:(BOOL)show; + (void)setShouldShowImageScalingOverlay:(BOOL)show;
+ (BOOL)shouldShowImageScalingOverlay; + (BOOL)shouldShowImageScalingOverlay;
@end @end

View File

@@ -238,6 +238,7 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
[self registerForNotificationsForInterfaceStateIfNeeded:selfInterfaceState]; [self registerForNotificationsForInterfaceStateIfNeeded:selfInterfaceState];
#if ASRangeControllerLoggingEnabled #if ASRangeControllerLoggingEnabled
ASDisplayNodeAssertTrue([visibleIndexPaths isSubsetOfSet:displayIndexPaths]);
NSMutableArray<NSIndexPath *> *modifiedIndexPaths = (ASRangeControllerLoggingEnabled ? [NSMutableArray array] : nil); NSMutableArray<NSIndexPath *> *modifiedIndexPaths = (ASRangeControllerLoggingEnabled ? [NSMutableArray array] : nil);
#endif #endif
@@ -247,14 +248,15 @@ static UIApplicationState __ApplicationState = UIApplicationStateActive;
ASInterfaceState interfaceState = ASInterfaceStateMeasureLayout; ASInterfaceState interfaceState = ASInterfaceStateMeasureLayout;
if (ASInterfaceStateIncludesVisible(selfInterfaceState)) { if (ASInterfaceStateIncludesVisible(selfInterfaceState)) {
if ([fetchDataIndexPaths containsObject:indexPath]) {
interfaceState |= ASInterfaceStateFetchData;
}
if ([displayIndexPaths containsObject:indexPath]) {
interfaceState |= ASInterfaceStateDisplay;
}
if ([visibleIndexPaths containsObject:indexPath]) { if ([visibleIndexPaths containsObject:indexPath]) {
interfaceState |= ASInterfaceStateVisible; interfaceState |= (ASInterfaceStateVisible | ASInterfaceStateDisplay | ASInterfaceStateFetchData);
} else {
if ([fetchDataIndexPaths containsObject:indexPath]) {
interfaceState |= ASInterfaceStateFetchData;
}
if ([displayIndexPaths containsObject:indexPath]) {
interfaceState |= ASInterfaceStateDisplay;
}
} }
} else { } else {
// If selfInterfaceState isn't visible, then visibleIndexPaths represents what /will/ be immediately visible at the // If selfInterfaceState isn't visible, then visibleIndexPaths represents what /will/ be immediately visible at the