* [Yoga + AsyncDisplayKit] Initial commit for supporting Yoga-powered layout calculation.
Because this results in ASLayout objects, it preserve support for automaticallyManagesSubnodes
as well as the animated transition system. More work remains to vet performance of the new mode,
and it will remain in +Beta for the forseeable future.
I'm not sure that this should ever be used as the primary ASDK layout system, but it should remain an
option for some apps to experiment with if they require an implementation that more strictly mirrors
W3C standard Flexbox.
* [Yoga] Improve usage of ASHierarchyState to ensure simultaneous yoga layouts can't happen.
* [Yoga] Strictly minimize the impact of the Yoga integration on existing code.
Created new file ASDisplayNode+Yoga.mm, reduced size and number of integration points in core code.
* [Yoga] Figured out how to further reduce ASDisplayNode.mm impact by allocating _yogaNode in property accessor, and changing all accesses to use the property.
* [ASNodeController] initial commit for node controller class
* create <ASInterfaceState> protocol, -[ASDisplayNode interfaceDelegate], and use these to forward to ASNodeController
* rename ASInterfaceStateDelegate, fix setting in it ASNodeController.mm
* Implement mutex ownership and use it to check potential upward lock gathering
* Don't hold instance lock and call willEnterHierarchy/didExitHierarchy of ASDisplayNode
- This can cause deadlocks (e.g #2605) if subsequent methods, that are implemented by developers, walk up the node tree.
- This is a way to keep the optimizations introduced in 9e87813 while making sure the locking situation is a bit safer.
* More lock ownership assertions in ASDisplayNode
* Document main thread contract of -clearContents
* ASNetworkImageNode shoud not call setNeedsPreload while holding instance lock
- This helps to avoid potentially deadlocks caused if the node (esp in case it's a subclass of ASNetworkImageNode) walks up the tree in didEnterPreloadState, for example to build logging context.
* ASVideoNode should not call setNeedsPreload while holding instance lock
- This helps to avoid potentially deadlocks caused if the node (esp. if it's a subclass of ASVideoNode) walks up the tree in didEnterPreloadState, for example to build logging context.
* Don't hold instance lock for the entire insert subnode operation
- The recursive lock should not be held throughout `_insertSubnode:atSubnodeIndex:sublayerIndex:andRemoveSubnode:`. The method instead should manage the lock itself and acquire it as shortly as possible. The reason is that this method calls many methods outside the scope of `self`. `[subnode __setSupernode:self]` is especially troublesome because it causes the subnode to migrate to new hierarchy and interface states, which triggers `didEnter/Exit(.*)State` methods. These methods are meant to be overriden by subclasses. Thus they might walk up the node tree and potentially cause deadlocks, or they perform expensive tasks and cause the lock to be held for too long.
- Other methods that call this method should release the lock before doing so.
* Lock getter and setter of `synchronous` flag
* Address comment in ASVideoNode
* Add main thread assertions to methods that change asset and assetURL of ASVideoNode
* Explain CHECK_LOCKING_SAFETY flag
* More thread and locking assertions in ASVideNode
- It's not safe to call `-[subnode __setSupernode:self]` while holding instance lock of soon-to-be supernode (e.g `self`).
- It's also not safe to call `[subnode __setSupernode:nil]` while holding the instance lock of the old supernode (e.g `self`).
- did(Enter|Exit)(.*)State methods are always called on main. Add main thread assertions to indicate that.
* Minor change in explanation of CHECK_LOCKING_SAFETY flag
* Replace fetch data with preload terminology
- Deprecate `-fetchData` and `-clearFetchedData` in favor of `-preload` and `-clearPreloadedData`
- Move `-setNeedsPreload`, `-recursivelyPreload` and `-recursivelyClearPreloadedData` to ASDisplayNode+FrameworkPrivate.h
- Update internal implementation, comments and tests
* Folllow up on #2642:
- Remove -preload and -clearPreloadedData in favor of -didEnterPreloadState and -didExitPreloadState.
- -didEnterPreloadState and -didExitPreloadState call the deprecated -fetchData and -clearFetchedData methods if they are overriden.
* Missed one in a test
* Get rid of behavior change for now.
* Revert more behavior changes, fix tests.
* Don't need these anymore.
* [Layout API] Rename ASLayoutable to ASLayoutElement
* arg
* fix wrapperWithLayoutElement
* [Layout API] Rename ASLayoutable to ASLayoutElement
* arg
* address Michael's comments
* Remove ASLayoutValidation files that were deleted on master since this diff was created.
* Initial commit for adding a size constraint to ASLayoutable's
* Some more commits
* Fix sample projects in extra/
* Remove preferredFrameSize test of ASEditableTextNode
* Remove preferredFrameSize from examples_extra
* Add deprecation warning to -[ASDisplayNode preferredFrameSize]
* Add deprecation warning to -[ASDisplayNode measureWithSizeRange:]
* Commit
* Commit
* Remove ASRelativeSizeRange
* Make ASRelativeSize private
* Adjust examples
* Improve setting of -[ASLayoutable size] with points or fractions
* Add ASWrapperLayoutSpec
* Improve creation of ASRelativeDimension
* Add `preferredFrameSize` back and add deprecated logging
* Add `layoutSpecBlock` setter and getter and add locking for it
* Add better documentation and fix macros to create ASRelativeDimension
* Create new ASSizeRangeMake with just a CGSize as parameter
* Update Kitten and Social App Layout example
* Add layoutThatFits: and deprecate measure:
* Rename ASRelativeDimension to ASDimension
* Fix examples for ASDimension renaming
* Remove fancy height and width setter
* Fix ASDimension helper
* Rename -[ASLayout layoutableObject] to -[ASLayout layoutable]
* Update layout related methods and more clearer documentation around how to use it
* Deprecate old ASLayout class constructors
* Don't unnecessary recalculate layout if constrained or parent size did not change
* Use shared pointer for ASDisplayNodeLayout
* Fix rebase conflicts
* Add documentation and move implementation in mm file of ASDisplayNodeLayout
* Fix test errors
* Rename ASSize to ASLayoutableSize
* Address comments
* Rename setSizeFromCGSize to setSizeWithCGSize
* Improve inline functions in ASDimension
* Fix rebase conflicts
* Renamed range update callbacks
We finally settled on
didEnter/ExitDisplayState
didEnter/ExitPreloadState
didEnter/ExitVisibleState
This change is meant to unify the range update methods to relate to each
other and hopefully be a bit more self explanatory.
* Guarantee interface callbacks happen on main.
* move fetchData / clearFetchedData to default implementations
* Move deprecated methods to new deprecated category
* Don't bring in cocoapod change.
* Nits
* Capetalize
This should fix a deadlock in ASDisplayNode and it's caused by displayWillStart: and where one thread is recursing down the tree and another thread is recursing up the tree. We remove the lock in _pendingDisplayNodes for the property, but need to guarantee that we only modify the _pendingDisplayNodes state on the main thread.
Furthermore add documentation on what thread displayWillStart and displayDidFinish will be called
This allows the change in size for the NSTextContainer to occur off the main thread, whenever that size change
is necessary. Then the text relayout can occur earlier, during the process of computing ASLayoutSpecs.
This provides internal features on _ASAsyncTransaction and ASDisplayNode to facilitate
implementing public API that allows clients to choose if they would prefer to block
on the completion of unfinished rendering, rather than allow a placeholder state to
become visible.
The internal features are:
-[_ASAsyncTransaction waitUntilComplete]
-[ASDisplayNode recursivelyEnsureDisplay]
Also provided are two such implementations:
-[ASCellNode setNeverShowPlaceholders:], which integrates with both Tables and Collections
-[ASViewController setNeverShowPlaceholders:], which should work with Nav and Tab controllers.
Lastly, on ASDisplayNode, a new property .shouldBypassEnsureDisplay allows individual node types
to exempt themselves from blocking the main thread on their display.
By implementing the feature at the ASCellNode level rather than ASTableView & ASCollectionView,
developers can retain fine-grained control on display characteristics. For example, certain
cell types may be appropriate to display to the user with placeholders, whereas others may not.
Follow-up work will include unit tests, revisiting names, and the header locations of definitions.
- -layoutSpecThatFits: must return an ASLayoutSpec.
- Move ASDisplayNode's -measureWithSizeRange: redeclaration to ASDisplayNode.h.
- Rename ASStackLayoutChild.h to ASStackLayoutDefines.h.
- Rename ASStaticLayoutSpecDimension.h to ASRelativeSize.h.
- Don't import ASLayout.h in other headers to prevent circular inclusions.
- Explain use cases of ASLayout's initializers.
- Clean up ASInternalHelpers.h.
- constrainedSizeForCalculatedLayout is of type ASSizeRange.
- calculatedLayout is better explained.
- Since ASLayout is cached and reused, its position property is mutable.
- Both ASDisplayNode and ASLayoutNode conforms to this protocol.
- ASDisplayNode can be embeded directly into layout graph.
- Eliminate ASCompositeNode.
- Fix ASStaticSizeDisplayNode not recpect min constrained size.
- Updated tests.
- Introduce ASLayoutNode and its subclasses.
- ASDisplayNode measures its ASLayoutNode and cache the result (ASLayout). Calculated size and position of each subnode can be retrieved from the calculated layout.
- Custom nodes need to override -layoutNodeThatFits:(CGSize) instead of -calculateSizeThatFits:(CGSize).
- Custom nodes do not need to layout its subnodes (in -layout:) anymore. ASDisplayNode can handle the job most of the time, by walking through its layout tree.
- ASCompositeNode is used to embed (display) subnodes to a node's layout. That way, each subnode will also be measured while the parent node is measuring. And the parent node knows where its subnodes are within its layout.