192 Commits

Author SHA1 Message Date
Adlai Holler
a193a4bca4 [ASStackLayoutSpec] Create children NSArray less often (#2139) 2016-08-25 10:03:07 -07:00
Hannah Trosi
971d43ad4d [Build settings] add missing newlines at end of file 2016-08-18 15:01:41 -07:00
Hannah Troisi
2040674aed Merge pull request #1767 from facebook/AHPercentToFraction
[ASRelativeDimensionType] Replace "percent" with "fraction" Where Appropriate
2016-08-11 20:33:34 -07:00
Adlai Holler
3f77a3d46c More Percent -> Fraction 2016-08-11 10:37:48 -07:00
Michael Schneider
b84be07776 Make child and children on ASLayoutSpec a property 2016-08-10 10:33:13 -07:00
Adlai Holler
eb9f86cfdb Replace "percent" with "fraction" where appropriate 2016-08-10 10:26:21 -07:00
Hannah Troisi
893e601e81 Convert to type-generic math (#2050)
* [Optimization] Convert to type-generic math

* add std:: prefix in obj-c++ files

* more cleanup

* revert test changes

* convert min and max back to fmin/fmax
2016-08-09 15:31:37 -07:00
David Rodrigues
70574243f7 Prevent API misuse at compile time (#2035)
Using Objective-C attributes, in this case `unavailable`, we can hide
unsupported APIs at compile time instead of detecting and warn about it
at runtime with a set of asserts.
2016-08-04 19:00:46 -07:00
Michael Schneider
d5cbe33686 Revert "[ASLayoutSpec] Use childrenMap directly to prevent creating an NSArray within ASDK Part 2 (#2021)"
This reverts commit d5a7c195226925e483c74fb210120d15ff423378.
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 735b4ebd0872483044d98a5d05b43324e76fc8d4.

* 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 c90ed08d1073701e2c7f8a2677d460c140f05264.
2016-07-31 18:43:20 -07:00
Scott Goodson
589efefcf2 [ASDimension] Disable assertions for Percent values being between 0.0 and 1.0.
This triggers on existing code that needs to be updated, but also there is some investigation
needed as to whether it is a valid use case to have a >1.0 value in order to position greater-than-bounds elements.
2016-07-30 23:44:46 -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
Hannah Troisi
ff2c47c415 add assertion for ASRelativeDimensionTypePercent value to be between 0-1 (#2009) 2016-07-29 10:38:20 -07:00
Levi McCallum
304df12f71 Add recursive description debugging method to ASLayout (#1975)
* Add recursiveDescription debugging method

* Add recursive description implementation

* Add LayoutableObject to ASLayout description
2016-07-24 15:12:53 -07:00
Levi McCallum
c6b17ba7bb Add description to ASLayout (#1973)
* Add description to ASLayout

* Constrained size is a size range, print correctly

* Add missing closing bracket
2016-07-23 20:12:26 -07:00
appleguy
74bf376b2f [ASDisplayNode] Rename _propertyLock to __instanceLock__ to avoid subclass naming collisions. (#1941) 2016-07-16 15:32:13 -07:00
Michael Schneider
729766a365 Add convenience functions to create relative sizes with percentage 2016-07-15 10:51:45 -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
Scott Goodson
012c927cd8 [ASLayout] Small optimization to eliminate one method call in an extremely hot codepath.
This was observed with quantitative profiling results.  We have some opportunities to micro-optimize the layout objects.
2016-07-10 23:02:39 -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
Levi McCallum
a3e8f556a3 Clean up flattening process in ASLayout 2016-06-10 12:43:46 -07:00
Levi McCallum
4149c6b0f5 Move ASLayout frame to a computed property 2016-06-10 12:43:46 -07:00
Levi McCallum
f1f45c61a8 Copy dequeued context 2016-06-10 12:43:46 -07:00
Levi McCallum
af932e7596 Simplify ASLayout flatten BFS 2016-06-10 12:43:46 -07:00
appleguy
6632b4ec5f Merge pull request #1722 from rcancro/layoutSpecTraitObject
[ASLayoutSpec] Remove cached ASTraitCollection
2016-06-08 22:29:47 -07:00
Michael Schneider
434102f988 Address comments from review
- Remove public NSMutableArray header for validators
- Add ASDISPLAYNODE_EXTERN_C_BEGIN/END
- Rename isRootLayout to isFinalLayoutable
2016-06-08 18:42:32 -07:00
Michael Schneider
9ff7223b77 Move validation code to ASLayoutValidation and add validation flag 2016-06-08 16:59:46 -07:00
Michael Schneider
f9e13545bf Improve layout validation
- Asserts if layout is invalid
- Add better help messages if layout is invalid
2016-06-08 16:39:03 -07:00
Michael Schneider
197950f39b Add basic infrastructure for layout validation 2016-06-08 10:35:28 -07:00
ricky
3c34d51a19 [ASLayoutSpec] Remove cached ASTraitCollection 2016-06-07 10:50:42 -07:00
Levi McCallum
f809d4a1c9 Let ASLayout determine if a node should measure 2016-06-05 09:32:48 -07:00
Levi McCallum
a004cc7263 Include header 2016-06-05 09:22:46 -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