230 Commits

Author SHA1 Message Date
Michael Schneider
4e580b96dc Add support for multiple children to ASWrapperLayoutSpec (#2469) 2016-10-24 09:59:44 -07:00
Scott Goodson
30a7edf30f [ASLayout] Remove new ASLayoutPrivate.h file and put contents into ASLayoutSpec+Subclasses.h 2016-10-21 13:23:05 -07:00
appleguy
2c6f8b0506 [AsyncDisplayKit 2] Final changes to ease migration of clients to 2.0 APIs. (#2460) 2016-10-21 13:12:13 -07:00
Hannah Troisi
9719357901 [ASLayoutElement] Move ASDisplayNode's .name property to ASLayoutElement (renamed to .debugName) (#2395)
* Move ASDisplay .name property to ASLayoutElement

* keep ASDisplayNode.name deprecated

* address @appleguy's comments
2016-10-20 17:27:31 -07:00
Hannah Troisi
84d1a637d7 [2.0] add helpful deprecation messages (#2437)
[2.0] add helpful deprecation messages
2016-10-19 14:48:06 -07:00
Michael Schneider
4b914f8e15 Add preferredSize as getter to ASLayoutElementStyle (#2427) 2016-10-19 12:55:19 -07:00
Michael Schneider
abd80494c7 [ASLayoutElementStyle] ASLayoutElementStyle improvements (#2413)
* Use std::atomic for properties in ASLayoutElementStyle

* Remove setter calls for min / max width and height in ASLayoutElementStyle
2016-10-18 15:55:55 -07:00
Michael Schneider
56d50e6d5e Add ASAbsoluteLayoutSpecSizing (#2394)
Add ability for ASAbsoluteLayoutSpec to grow as far as possible or shrink to fit it's children
2016-10-18 13:55:13 -07:00
Michael Schneider
ba80b83695 [ASRelativeLayoutSpec] Fix ASRelatativeLayoutSpec behavior for ASRelativeLayoutSpecPositionStart (#2393)
* Fix ASRelatativeLayoutSpec behavior for ASRelativeLayoutSpecPositionStart

* Add updated images for snapshot tests
2016-10-18 12:00:01 -07:00
Adlai Holler
6e76daf279 [Layout] Check Layout Spec Tree for Duplicated Elements (#2408)
* Check layout spec tree for duplicated elements

* Enable layout spec tree dedupe only in debug
2016-10-18 09:33:37 -07:00
Michael Schneider
9f1643ebfd Final size should always be in constrainedSize in ratio spec (#2403) 2016-10-18 09:18:40 -07:00
Michael Schneider
d407663e3f [ASLayout] Improve ASLayout (#2404)
* Add internal header for ASLayout and change position to readonly publicly

* Don't copy sublayouts during tree filtering

* Revert "Don't copy sublayouts during tree filtering"

This reverts commit 6b0d54d5ffe5bb3941ec13696c9c45b0098b6ba1.
2016-10-18 08:36:38 -07:00
appleguy
11293d545a [ASLayout - Performance] Avoid weak ivar access & method call to check layoutElementType. (#2397)
* [ASLayout - Performance] Avoid weak ivar access & method call to check layoutElementType.

This shows up in benchmarking profiles for layout-bound workloads.

* Add comment
2016-10-17 12:23:45 -07:00
Michael Schneider
3f11c67c82 Return CGSizeZero in case a ASNetworkImageNode is asked for the size and the image did not load yet (#2378) 2016-10-13 14:03:15 -07:00
Michael Schneider
8491155fb4 Add locking for ASStackLayoutElement and ASAbsoluteLayoutElement (#2371) 2016-10-12 13:40:53 -07:00
Michael Schneider
8f8df537d2 Rename ASRelativeSize to ASLayoutSize (#2369) 2016-10-11 16:36:40 -07:00
Michael Schneider
507bc55504 [Layout] Add ASLayoutElementStylability protocol (#2366)
* Add ASLayoutElementStylability protocol

* Rename to styledWithBlock:, add instancetype and add noescape
2016-10-11 09:16:18 -07:00
Adlai Holler
c72b2b212c Tiny change to the doc for ASDimensionMake (#2362) 2016-10-07 10:00:58 -07:00
Hannah Troisi
a79e0be016 quick renaming (#2358) 2016-10-07 09:32:38 -07:00
Michael Schneider
bb7118a26a Fix ASAbsoluteLayoutSpec creation children protocol (#2357) 2016-10-06 20:37:12 -07:00
Michael Schneider
6f2c7caac3 [Layout] Improve ASDimensionMake via NSString (#2351)
* Improve ASDimensionMake via NSString

- ASXCTAssertEqualDimensions
- Add support for "auto"
- Assert if given an empty or invalid string

* Address comments

* Add ASCGFloatFromString and ASCGFloatFromNumber

* Rename CGRect+ASConvenience to CoreGraphics+ASConvenience
2016-10-06 16:29:33 -07:00
Michael Schneider
166414dfc9 [Layout] Lazy initialize ASLayoutElementStyle in ASDisplayNode and ASLayoutSpec (#2352)
* Lazy initialize `ASLayoutElementStyle` in `ASDisplayNode`

* Lazy initialize `ASLayoutElementStyle` in `ASLayoutSpec`
2016-10-06 16:53:40 -04:00
Adlai Holler
124234fef8 [Umbrella] Add warn_unused_result Attribute to Public Headers (#2353)
* Add some warn_unused_result attributes

* Add more

* Add some more
2016-10-06 16:44:49 -04:00
Michael Schneider
271ab20de5 Fix ASDimension creation of type ASDimensionUnitFraction via a NSString (#2347) 2016-10-05 18:30:24 -07:00
Michael Schneider
d6e5e27c39 [Layout] Add helper properties for setting sizes via CGSize and ASRelativeSize (#2324)
* Remove set layout style size helper

* Update API to set and get a CGSize / ASRelativeSize from an ASLayoutElementStyle

- Expose ASRelativeSize type
- Add new helper properties to set a size / relative size to ASLayoutElementStyle
- Don't expose the size in ASLayoutElementStyle anymore and move into ASLayoutElementStylePrivate

* Update examples

* Update comments for size helpers
2016-10-04 12:35:45 -04:00
Hannah Troisi
47f73576ef [Layout] Rename ASStackLayoutable to ASStackLayoutElement (#2322)
* redo all renaming, push new branch

* rename a few missed occurances of static
2016-09-29 12:29:21 -07:00
Hannah Troisi
7551627b58 [Layout] Rename ASLayoutable to ASLayoutElement (#2290)
* [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.
2016-09-29 00:02:47 -07:00
Michael Schneider
1abc1a833c Remove legacy layout validation code (#2311) 2016-09-28 16:46:31 -07:00
Hannah Troisi
87595c7d3b [Layout API] Rename ASStaticLayoutSpec to ASAbsoluteLayoutSpec (#2288)
* Rename static to absolute

* Fix examples, rename ASAbsoluteLayoutSpec class method

* rename +staticLayoutSpecWithChildren to +absoluteLayoutSpecWithChildren

* address Michael's comments
2016-09-28 13:05:31 -04:00
Michael Schneider
2f99951732 [Layout] Move [ASLayoutSpec children] from std::map to NSMutableArray (#2253)
* Initial commit to move [ASLayoutSpec children] from std::map to NSMutableArray

* Add NSFastEnumeration to ASLayoutable

* ASNullLayoutSpec is a Singleton now

* Move ASLayoutSpecPrivate in Private folder

* Move to NSArrayPointer and remove ASNullLayoutSpec

* Revert "Move to NSArrayPointer and remove ASNullLayoutSpec"

This reverts commit 9ab9cf7024b1f6e1984d84fe58af2b84e84cdf94.

* Move to childAtIndex: and setChild:atIndex:
2016-09-27 19:41:45 -04:00
Michael Schneider
e85583523f [Layout] Add support for flex factor (#2298)
* Add support for flex factor

* Add snapshot tests

* Respect child specified size from ASLayoutable

* Add new snapshot test images

* Fix rebase conflict
2016-09-27 18:39:50 -04:00
Michael Schneider
416d8f92e1 [Layout] Add delegate to ASLayoutableStyle for property changes (#2283)
* Add delegate to ASLayoutableStyle for property changes

* Moving ASLayoutableStyle delegate to readonly

* Add ASLayoutableStyleTests

* Fix property stirngs

* Fix video example

* Address comments of Adlai
2016-09-27 16:50:36 -04:00
Michael Schneider
9f55de2c6c Remove styleClass property from ASLayoutable for now (#2279) 2016-09-23 09:30:17 -07:00
Michael Schneider
75dca556e6 [Layout] Add style property to ASLayoutable (#2261)
* Add style property to ASLayoutable

* Add styles property to further layout specs

* Adjust some examples

* Add `loadStyle` to create the style object in a ASLayoutable

* Revert "Add `loadStyle` to create the style object in a ASLayoutable"

This reverts commit 2b7240f2c7dc993e38cadf290cfdf08482dd70c7.

* Revert "Adjust some examples"

This reverts commit 3254ae0a321e75db3ecfa80adee9d96bde93a33d.

* Revert "Add styles property to further layout specs"

This reverts commit c779dcb876ead27122c1af1300146a6ad36912cb.

* Rename ASLayoutableStyleDeclaration to ASLayoutableStyle

* Add styleClass class property for extensibility support of the ASLayoutable style object

* flexShrink should not be YES by default
2016-09-22 16:00:52 -07:00
Michael Schneider
a9857f9963 Add assertions for creating an invalid ASDimension from type ASDimensionUnitAuto and ASDimensionUnitFraction (#2268) 2016-09-22 15:48:36 -07:00
Adlai Holler
5593bfa4d1 [ASDisplayNode] Majorly Improve Descriptions (#2208)
* Up our description game big time

* Couple tweaks

* Explain logic

* Fix indentation
2016-09-07 20:11:27 -07:00
Michael Schneider
8897614f0e [Layout] Layout API based on content area (#2110)
* 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
2016-09-07 08:44:48 -07:00
Michael Schneider
37416f1696 Set alignItems to ASStackLayoutAlignItemsStretch in ASStackLayoutSpec (#2187)
To align with the CSS `align-items` property we should set alignItems to `ASStackLayoutAlignItemsStretch` instead of `ASStackLayoutAlignItemsStart`: https://drafts.csswg.org/css-flexbox-1/#propdef-align-items
2016-09-03 21:05:59 -07:00
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