65 Commits
Author SHA1 Message Date
Michael Schneider d5cbe33686 Revert "[ASLayoutSpec] Use childrenMap directly to prevent creating an NSArray within ASDK Part 2 (#2021)"
This reverts commit d5a7c19522.
2016-08-02 10:10:36 -07:00
Michael Schneider d5a7c19522 [ASLayoutSpec] Use childrenMap directly to prevent creating an NSArray within ASDK Part 2 (#2021)
* Revert "Revert "[ASLayoutSpec] Use childrenMap directly to prevent creating an NSArray within ASDK (#1937)""

This reverts commit 735b4ebd08.

* Fix crash and add exception for mutating while using fast enumeration of ASLayoutSpec children

NSFastEnumeration is potentially quite dangerous in the wrong hands. In particular, it does not provide a safe mechanism for you to return temporary objects directly, and it does not provide any guarantee that you will be called when the enumeration has completed; therefore if we generate temporaries and store them in an instance variable, we will not necessarily be able to clean them up! This means fast enumeration methods should never be called within an autorelease pool or the autorelease pool be drained within the fast enumeration loop.

The reason is we store references to objects in the stackBuf struct by casting the child pointer to __autoreleasing id. If we pop the autorelease pool between calls to -countByEnumeratingWithState:objects:count:, it will die in a messy explosion of pointer dereferences and EXC_BAD_ACCESS.

* Add tests for ASDisplayNode and ASLayoutSpec fast enumeration
2016-08-01 18:08:48 -07:00
Scott Goodson 735b4ebd08 Revert "[ASLayoutSpec] Use childrenMap directly to prevent creating an NSArray within ASDK (#1937)"
Something interesting going on here with ARC / Objective-C++ that we are investigating and will re-land.

This reverts commit c90ed08d10.
2016-07-31 18:43:20 -07:00
Michael Schneider c90ed08d10 [ASLayoutSpec] Use childrenMap directly to prevent creating an NSArray within ASDK (#1937)
* Use childrenMap directly to prevent creating an NSArray in ASDK for ASLayoutSpec children

* Add locking for parent property in ASLayoutSpec

* Remove unnecessary import

* Add newline

* Add NSFastEnumeration to ASEnvironment and ASDisplayNode / ASLayoutSpec

* Change NSMutableArray initializer to arrayWithCapacity:

* Move ASLayoutSpec+Private.h into Private folder

Fixes building with Swift

* Remove lock for ASLayoutSpec parent
2016-07-29 10:53:31 -07:00
appleguy 74bf376b2f [ASDisplayNode] Rename _propertyLock to __instanceLock__ to avoid subclass naming collisions. (#1941) 2016-07-16 15:32:13 -07:00
Adlai Holler 2e19d11350 Reduce block invocations, other small performance bumps 2016-07-12 15:11:13 -07:00
ricky 57ece0f46e [ASLayoutSpec] Bug where finalLayoutable was not being called for setChildren 2016-07-11 09:54:03 -07:00
appleguy 3b2af7eb6d [Build] Remove Unused Imports across all of AsyncDisplayKit. This uses a feature of AppCode. (#1875)
Details on the tool are here: https://www.jetbrains.com/help/idea/2016.1/optimizing-imports.html
2016-07-09 17:20:59 -07:00
Michael Schneider 01fed69b26 Adds trampoline for inserting and deletion of nodes
Currently measurement always needs to happen on the main thread if implicit hierarchy management is enabled as adding and removing from nodes needs to happen on the main thread. We now will trampoline to the main thread to do the insertion and deletion of nodes.

This also resolves the issue that can occur if a node is already loaded deep in the layout hierarchy in the layout that the node is transforming to. Before insertion or deletion is happening we need to crawl the layout hierarchy to check that though.
2016-07-01 16:33:37 -07:00
ricky af98d23bf0 michael's comments 2016-06-21 14:49:47 -07:00
ricky eb715e5836 hold children in a map instead of vector 2016-06-21 14:22:49 -07:00
ricky 2675204d50 [ASLayoutSpec.mm] Remove use of dictionary to hold children
Converted the backing store of children to a std::vector. Subclass now have defined indexes instead of string keys to add children.
2016-06-21 14:22:44 -07:00
Hannah Troisi c857e809f4 Clean up header comments (for consistent Facebook licensing info) (#1741)
[Licensing] Clean up header comments (for consistent Facebook licensing info)
2016-06-11 23:31:39 -07:00
Levi McCallum 7e8d519a9a Introduce type property to replace layout id check 2016-06-10 12:43:46 -07:00
ricky 3c34d51a19 [ASLayoutSpec] Remove cached ASTraitCollection 2016-06-07 10:50:42 -07:00
Levi McCallum c469ad273b [ASLayout] Cache constrained size range 2016-06-05 09:22:46 -07:00
ricky 13a35c5f2f more comments
* allow nil for setChild/children
* moved examples out of examples/
2016-06-03 13:59:59 -07:00
ricky 01dbc86778 First pass of comments
* make variable naming reflect ASEnvironmentTraitCollection vs ASTraitCollection
* move trait propagation to cell allocation instead of via a nested block
* move trait propagation when setting a displaynode's supernode instead of when adding a subnode
* fixed misspelling of "colection"
2016-06-03 09:59:24 -07:00
ricky b66b519bd6 assert that child is not nil
Summary:

Test Plan:

Reviewers:

Subscribers:

JIRA Issue(s):

Service(s):
2016-05-31 10:29:46 -07:00
rcancro cf2d9aef5c fix crash when setting layoutSpec's child to nil 2016-05-26 15:44:21 -07:00
ricky bebc4c604c remove _child from ASLayoutSpec.mm. Store all children in the children array. 2016-05-25 13:30:35 -07:00
ricky c42b0dd33a Remove explicit passing of trait collection to setChild/Children 2016-05-25 10:49:42 -07:00
ricky a33966d4ae Actually propagate the traits down on layout spec 2016-05-24 11:15:41 -07:00
ricky 59a26ee111 [ASTraitCollection] Bug fixing/LayoutSpec propagation
* Fixed bug in `ASEnvironmentMergeObjectAndState`
* New ASLayoutSpec methods for `setChild`/`setChildren`/`setChild:forIdentifier:` have been added to take in a trait collection.
* Added `setChild:`-like methods for ASLayoutSpecs take a traitCollection
* Fixed instances where nodes in a data controller were not getting their trait collections
* propagate traitCollection in ASDisplayNode on insertSubnode or addSubnode
2016-05-23 16:37:40 -07:00
rcancro 8e444092be [ASEnvironment] Remove unneeded locking on environmentState 2016-05-12 13:13:30 -07:00
rcancro 4b54144f55 Levi's comments 2016-05-11 10:21:11 -07:00
rcancro 9d622c7eac changed DisplayTraits to TraitCollection 2016-05-10 14:45:03 -07:00
rcancro f828d079fa added nsobject based ASDisplayTraits class 2016-05-10 14:44:43 -07:00
rcancro b4a6f87ca6 addressed some comments 2016-05-10 14:44:32 -07:00
rcancro 8bb4eba080 Initial attempt at implementing Display Traits
Initial attempt to get display traits working with ASEnvironment.

To get proper ASDisplayTraits support, you must use an ASViewController. The ASViewController implements UITraitCollection-related methods (`traitCollectionDidChange:`, `willTransitionToTraitCollection:withTransitionCoordinator:`, viewWillTransitionToSize:withTransitionCoordinator`) to update the internal ASDisplayTraits and propagate them to subnodes.

ASTableNode and ASCollectionNode don't actually have their cells as subnodes, so a little bit of trickery is involved (on `setEnvironment:` the table/collection node gets its data controllers completedNodes and propagates the new traits. see `ASDisplayTraitsCollectionTableSetEnvironmentState`). The data controller also passes the current display traits when creating new cells.

ASViewController also supports the ability to return a custom set of display traits. So if you have a modal dialog that should always be told it is in a compact size class, you can set the override block before displaying the VC.

A new example, called Display Traits, has been added. It shows how display traits can be used in a ASViewController with a normal ASDisplayNode as its root, as well as in ASViewControllers hosting table nodes and collection nodes. There is also an example of overriding the default display traits of a VC.

Please provide feedback!
2016-05-10 14:44:22 -07:00
Michael Schneider 9fdce828c1 Small improvements for ASLayoutSpec
- Add nullable for returning children
- Store default child and children as properties
- Use vector for creating final children
2016-04-15 07:11:24 -07:00
Scott Goodson 8ccef1e99f [ASEnvironment] Fix incomplete gating of upward propagation of layout properties (disabled for now). 2016-04-11 20:34:24 -07:00
Michael Schneider 45d50624d1 Fix disabled state propagation for final layoutable 2016-04-11 17:41:48 -07:00
Hannah Troisi dbad1c38e5 [ASEnvironment - Layout] Fixes to upward propagation of ASLayoutable properties. 2016-04-02 15:03:43 -07:00
Michael Schneider 20ee9bca8d Rename ASEnvironmentStateCreate to ASEnvironmentStateMakeDefault 2016-03-31 20:43:20 -07:00
Michael Schneider 5baab95506 Add up propagation of ASEnvironmentLayoutOptionsState in ASLayoutSpec while setting a child 2016-03-31 20:43:20 -07:00
Michael Schneider f46f5640ff Add improvements
- Remove defaults for ASEnvironmentLayoutOptionsState and ASEnvironmentHierarchyState
- Add locking for ASEnvironmentLayoutExtensibilityForwarding
- Other smaller improvements
2016-03-31 20:43:20 -07:00
Michael Schneider 4e757f0969 General improvements
- Refactor naming of ASEnvironmentCollection to ASEnvironmentState
- Remove struct pointers
- Move ASEnvironmentStatePropagation to a enum class
- Move merge functions to pure functions
- Move ASLayoutOptionsForwarding and ASLayoutableExtensibility into ASLayoutSpec and ASDisplayNode
- Remove ASLayoutableSetValuesForLayoutable and move into explicit classes (ASDisplayNode, ASTextNode)
2016-03-31 20:43:20 -07:00
Michael Schneider 65b4961802 Add extensibility support for ASEnvironmentLayoutOptionsState 2016-03-31 20:43:20 -07:00
Michael Schneider 96df35e41a Initial commit for ASEnvironment 2016-03-31 20:43:20 -07:00
Scott Goodson 0feaa2a368 Improvements to the efficiency of recursivelySetInterfaceState: and the beta range controller. 2016-01-10 02:40:47 -08:00
Scott Goodson a2cf2a88e6 Overhaul header files / includes to eliminate circular references that Xcode 7 is angry about. 2015-12-25 19:22:00 -08:00
Scott Goodson 6d8bad13c0 Fix crash in ASCII art creator for one-element children arrays 2015-11-08 19:04:16 -08:00
rcancro 050160e6bb fixed the build again (removed all generic collections) 2015-10-19 10:04:49 -07:00
rcancro f164b97700 Put all ascii box methods into a Debugging category. 2015-10-19 08:32:14 -07:00
rcancro 3b983c5a50 Ascii art for layoutables 2015-10-16 16:15:29 -07:00
rcancro 7e3a0b3223 Changed copyIntoOptions to copyFromOptions
I thought I already did this. I think copyFrom is a better name.
2015-09-16 14:33:54 -07:00
rcancro 2d30a81a75 added documentation 2015-09-15 11:05:30 -07:00
rcancro 2e3d59a73e spelling 2015-09-11 16:13:18 -07:00
rcancro b14e189bfb Addressed comments to LayoutOptions PR 2015-09-11 16:07:18 -07:00