Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow up on the ASRangeController fix in #1418 #1419

Merged
merged 2 commits into from
Mar 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions Source/Details/ASRangeController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -351,25 +351,34 @@ - (void)_updateVisibleNodeIndexPaths
} else {
// If selfInterfaceState isn't visible, then visibleIndexPaths represents either what /will/ be immediately visible at the
// instant we come onscreen, or what /will/ no longer be visible at the instant we come offscreen.
// So, preload and display all of those things, but don't waste resources preloading others.
// We handle this as a separate case to minimize set operations, including -containsObject:.
// So, preload and display all of those things, but don't waste resources displaying others.
//
// DO NOT set Visible: even though these elements are in the visible range / "viewport",
// our overall container object is itself not yet, or no longer, visible.
// The moment it becomes visible, we will run the condition above.

BOOL shouldUpdateInterfaceState = NO;
if (ASActivateExperimentalFeature(ASExperimentalFixRangeController)) {
shouldUpdateInterfaceState = [visibleIndexPaths containsObject:indexPath];
} else {
shouldUpdateInterfaceState = [allCurrentIndexPaths containsObject:indexPath];
ASInterfaceState interfaceStateBeforeFix = interfaceState;
if ([allCurrentIndexPaths containsObject:indexPath]) {
interfaceStateBeforeFix |= ASInterfaceStatePreload;
if (rangeMode != ASLayoutRangeModeLowMemory) {
interfaceStateBeforeFix |= ASInterfaceStateDisplay;
}
}

if (shouldUpdateInterfaceState) {
interfaceState |= ASInterfaceStatePreload;

ASInterfaceState interfaceStateAfterFix = interfaceState;
if ([visibleIndexPaths containsObject:indexPath]) {
interfaceStateAfterFix |= ASInterfaceStatePreload;
if (rangeMode != ASLayoutRangeModeLowMemory) {
interfaceState |= ASInterfaceStateDisplay;
interfaceStateAfterFix |= ASInterfaceStateDisplay;
}
} else if ([displayIndexPaths containsObject:indexPath]) {
interfaceStateAfterFix |= ASInterfaceStatePreload;
}

if (interfaceStateBeforeFix != interfaceStateAfterFix && ASActivateExperimentalFeature(ASExperimentalFixRangeController)) {
interfaceState = interfaceStateAfterFix;
} else {
interfaceState = interfaceStateBeforeFix;
}
}

Expand Down