* Add snapshot tests for interitem and interline spacings of stack spec
* Improve comment
* Make sure item spacings are properly considered and reset on new lines, snapshot tests included
* ASStackUnpositionedLayout: Take spacing into account when laying out a wrapped stack.
* ASStackLayoutSpec: Add the lineSpacing property.
* Update CHANGELOG.md.
With these changes, I'd also like to propose that we move ASNodeController
out of Beta (renaming the files without +Beta). Let me know what you think!
Because we don't support ASNodeController directly in ASCV / ASTV, it is still
important to allow flipping the ownership in certain cases (in particular, for
root CellNodeController objects that should follow the lifecycle of the
ASCellNode rather than owning the ASCellNode).
* Be more aggressive at invalidating layouts during transitions, add a debug method, fix some build errors when verbose logging
* Add a changelog entry
* Invalidate the calculated layout transitioning using the same size range
- It's possible that -transitionLayoutWithSizeRange: can be called with the same size range used for previous layout passes. In that case, it's necessary to invalidate the current layout to avoid it being reused later on in the process.
* Fix CHANGELOG
* Fix infinite layout loop
- The problem will occur if a node does either of the followings:
1. Keeps using a stale pending layout over a calculated layout
2. Doesn't update the next layout's version after calling _setNeedsLayoutFromAbove.
* Update CHANGELOG
* Add ASCollectionGalleryLayoutSizeProviding
- This allows users to return different sizes based on certain conditions, such as the collection node's bounds or grid constants.
- ASPagerNode will also act as a size provider to ensure all pages have an up-to-date size that is its bounds.
* Update CHANGELOG
* ASPagerNode to use gallery layout delegate if told to
* Merge willUpdateWithChangeSet and didUpdateWithChangeSet delegate methods into one
- After #420, there is no change occurs between those 2 methods. Having them separately doesn't achieve anything and can cause confusions.
* Minor change
* Clean up ASDataController
- Parameters passed to ASDataControllerCompletionBlock are no longer used. Remove them.
- The value returned by _allocateNodesFromElements:andLayout:completion is not used. Remove it.
- Elements are not allocated and measured in batches anymore. Remove the code that does batch allocation.
- Remove RETURN_IF_NO_DATASOURCE. It's used only once and is not worth it.
* Remove +parallelProcessorCount
* Update CHANGELOG
* [ASCollectionView] Add delegate bridging and index space translation for missing UICollectionViewLayout properties
This is a first attempt at resolving #438.
I know there is already one similar method to do indexPath conversions, and that the #define for
accessing properties on the UICollectionViewFlowLayout should probably be moved somewhere else.
Looking for feedback on the general direction here. In particular, I'm a bit surprised that so much
has changed in how these calls occur, as I believe especially constrainedSizeForNodeAtIndexPath: is
now called with inconsistent index path spaces (but was not before this PR landed in March:
https://github.com/facebookarchive/AsyncDisplayKit/pull/3136/files)
Since the impact of mixing the spaces is fairly serious (can cause crashes), I'm also wondering if
I am misinterpreting some aspects of the code, or if maybe the crashing impact wasn't noticed yet.
* [ASCollectionView] Cleanup and final changes for UIKit passthrough fixes.
* Implement ASCollectionGalleryLayoutDelegate
- It arranges items of the same size into a multi-line stack (say photo gallery or pager). It takes advantage of the fact that its items always have a fixed size to measure as few items as possible while still being able to track their positions at all time. This helps reduce startup/reloadData time, as well as memory footprint.
- It then uses a measure range, which also works as a allocate range, to figure out which items to measure ahead of time. And it guarantees that each item is scheduled to measure only once.
- Lastly, ASCollectionLayoutDelegate has some new methods that allow delegates to hook up and stay ahead of layout attributes requests from the backing view. ASCollectionGalleryLayoutDelegate for example uses these methods to ensure elements that have their layout attributes requested are always ready for consumption, and to measure more elements in the background.
* Handle items that span multiple pages and other improvements in gallery delegate
* Minor fixes
* Fix failing tests
* Fix custom collection example
* Implement missing method in gallery layout delegate
* Fix warnings
* Some improvements
- Collection layout delegates must have a crollable directions property.
- Simplify gallery delegate by not storing unmeasured attributes since calling measure on already measured elements should be cache hits and super fast.
- Abstact some code in gallery delegate to ASCollectionLayoutState+Private and _ASCollectionGalleryLayoutItem.
- Other improvements in gallery delegate
* Fix file licenses
* Move measure range logic to ASCollectionLayout
* Track unmeasured elements
* Remove pending layout in ASCollectionLayout
* Get back pending layout because the timing to latch new data is not ideal
* Add ASCollectionLayoutCache
* Fix file licenses
* Fix xcodeproj
* Add async collection layout to examples/ASCollectionView
* Measure method in ASCollectionLayout to be a class method
* Encourage more immutable states
- Make -calculateLayoutWithContext: to be class methods in ASDataControllerLayoutDelegate and ASCollectionLayoutDelegate.
- Add layout delegate class and layout cache to ASCollectionLayoutContext+Private, to be use by ASCollectionLayout only.
- ASDataController no longer allocates all nodes but lets ASCollectionLayout determine.
- Add scrollableDirections to the layout context since it's often needed by the layout pass. Otherwise users have to wrap it in an info object.
- Update built-in layout delegates and CustomCollectionView example.
- Publish ASHashing. It might be helpful for clients that implement custom collection info objects.
* Remove additionalInfo property in ASCollectionLayoutState
* ASCollectionLayoutState to correctly filter unmeasured elements
* Add ASHashing to umbrella header
* Fix file licenses
* Add ASDispatchAsync and use it in ASCollectionLayout
* Improve code comment in ASCollectionLayoutState
I audited this more carefully and found some gaps in my PR from yesterday.
This also ensures the grouping and ordering of all the contents properties
is consistent across all of the places they appear.
In the future, it would be great to make the #define macros more sophisticated
so that we can add property bridging with fewer lines changed, and for
objects besides ASDisplayNode too!
This makes it much easier to use the ASCoreAnimationExtras method which offers by
far the most efficient way to display a stretchable image.
In the future, we should move that function to UIImage+ASConvenience or another
header where it can be more easily found and enjoyed!
Texture fails to build with this error on clang 4.0:
```
external/Texture/pod_support/Headers/Public/AsyncDisplayKit/ASDispatch.h:32:35: error: illegal initializer type 'atomic_size_t' (aka '_Atomic(size_t)')
__block atomic_size_t counter = ATOMIC_VAR_INIT(0);
^
In module 'std' imported from external/Texture/pod_support/Headers/Public/AsyncDisplayKit/ASStackUnpositionedLayout.h:18:
/private/var/tmp/_bazel_bkase/a00d4cbe29902fb63d5778cc19944cd2/external/clang40/bin/../include/c++/v1/atomic:1839:30: note: expanded from macro 'ATOMIC_VAR_INIT'
^
1 error generated.
```
See
http://techqa.info/programming/question/38233019/Initializing-an--atomic-int--with-a-braced-constant--Is-this-valid-C-code--If-so-why-does-it-not-compile-in-clang-
Replacing the intialization with just 0 (and not the macro fixes the
error). For now this is safe because the macro just expands to the
value.
* Minor refactors in ASCollectionView and its private cell classes
- `_ASCollectionReusableView` and `_ASCollectionViewCell` no longer expose getters for their collection element and cell node properties. This is to make sure that clients can only obtain elements from the visible map which is always the source of truth.
- Since the map can return `nil` for an element request, it's much safer to check and avoid adding/removing a nil pointer to an `NSArray`.
- Since we use a special way to check whether an object of kind of `_ASCollectionViewCell` or `_ASCollectionReusableView`, based on the assumption that these classes are subclass restricted, I added cast-or-return macros in the header files, closer to where the restrictions are declared.
* Add ASDynamicCastStrict
* Add element and node properties back to _ASCollectionReusableView and _ASCollectionViewCell
* Assert unexpected nil elements
* Always mark an element visible even if it is backed by an UIKit / non-_ASCollection* view
* Fix typo
* Remove unnecessary changes
* Dump mistakes
* Update CHANGELOG
* Can't track visibility of elements backed by non-_AS views
This was originally added for ASCollectionNode and ASTableNode preloading to work
as intended when nested inside of another ASRangeController-powered node. Indeed,
it is still necessary to trigger layout on these UIKit-backed components in order
for their own ASRangeControllers to start preparing content within them.
However, unlike the comment suggests, it is *not* necessary to do this for image
nodes. ASNetworkImageNode has only one .URL, and does not use the .bounds or
.calculatedLayout at all during loading. Even the ASMultiplexImageNode does not
use the .bounds, and the ASMapNode uses .calculatedLayout instead of .bounds.
This change has important performance benefits. In particular, it avoids
layouts that would occur on the main thread, often including text sizing,
and also can result in redundant layout passes (even during a layout pass that
triggers a node to enter the preload range, it may force its own layout early).
It would be great to test this change with Pinterest to confirm its safety, but
based on a full audit of the framework codebase, the only possibility that I
see for a regression is if app implementations of -didEnterPreloadState make
direct use of .bounds instead of .calculatedLayout (which is easy to fix).
* Fix a crash in table view caused by executing an empty change set during layoutSubviews
- Previously, when a change set is empty, `ASDataController` forwards the change set to its delegate right away, without dispatching to its editing queue and then back to main.
- This behaviour can potentially cause bad internal states in UITableView which trigger a crash reported in https://github.com/TextureGroup/Texture/issues/83.
- Fix by still reusing the existing pending map, because the data source's state has not changed, but go through the editing queue and main queue tunnel.
* Update CHANGELOG
I believe this check is supposed to be here. Unit tests pass with it in place.
Without it, calling layoutThatFits: (as ASDataController does) and then calling
it again later (as ASCollectionNode does when answering the sizeForItem: call)
will recompute the layout, potentially on main.
This seems to have more of an impact / benefit for Yoga layouts, but I don't think
its benefit is exclusive to them.
* [ASTextNode2] Provide compiler flag to enable ASTextNode2 for all usages.
The runtime switch is helpful, but is too slow to be shipped in a large
production application where startup time is carefully optimized.
Although this doesn't pass text-related snapshot tests when enabled, it
does allow apps to rely on built-in components like ASButtonNode using
the same text stack as when they are manually creating ASTextNode2
instances.
A simpler approach would be to use a #define ASTextNode ASTextNode2,
but this would create unusual keyword highlighting in code referencing
ASTextNode. However, because it would be less invasive and this is
not on by default, we could do that instead if preferred.
* Update AsyncDisplayKit.h
* [ASTextNode2] Improve naming and documentation of ASTEXTNODE_EXPERIMENT_GLOBAL_ENABLE
* [ASTextNode2] CHANGELOG.md for #410.
* [ASTextNode2] Add initial implementation for link handling.
This is a fairly basic first step to achieving feature parity between ASTextNode2
and ASTextNode. It does not yet do the 9-box detection of links, and there is
other code from ASTextNode that could be shared to improve this.
However, in the interest of getting a shippable implementation running as soon
as possible, I'm hoping to quickly refine this. Then we can continue improving
it based on the original ASTextNode with the benefit of testing UI against it.
* [ASTextNode2] Refine implementation of link handling.
This ensures that measure funcs are not set for container / empty spacer
nodes, because Yoga has more internal capabilities than layoutThatFits:
knows about.
Avoid need for the main layout pass to directly call setup for measure
funcs, by making it an implicit part of .yogaLayoutInProgress =.
Tear down the measure func after the layout pass to avoid retain cycle.
* Implement tests for the layout flattening process
* Refactor the flattening algorithm
- Remove flattened flag
- No more self check
- Stop traversing a layout tree branch when hits a displaynode node.
- Reuse as many existing ASLayout objects as possible
* Update changelog
* Ceil position values before comparing
* Explain why sublayout elements must be retained