69 Commits

Author SHA1 Message Date
Adlai Holler
171cc2f527 Improve Automatic Subnode Management Node Ordering (#2589)
* Add failing tests for subnode ordering

* Ensure that subnode ordering matches layout spec tree ordering
2016-11-10 09:22:53 +09:00
Michael Schneider
4464b7de60 Improve deprecation situation for 2.0 (#2514)
* Improve deprecations for 2.0

- Add deprecations for node / layoutSpec style properties
- Implement missing methods on ASDisplay from deprecation header
- Cleanup all of the deprecation categories

* Remove DeprecatedProtocolMethods

* Fix "Life without Cocoapods"

* Update comments
2016-10-31 16:46:21 -07:00
Michael Schneider
c4451edab1 Add assertion for invalid constrainedSize in calculateSizeThatFits: (#2507) 2016-10-28 16:45:22 -07:00
Michael Schneider
fb92b448e0 [ASDisplayNode] Proper handling of constrainedSize (#2505)
* Check in ASLayout if size is valid for sizing instead of valid for layout

* Return constrainedSize from calculateSizeThatFits:

Remove invalid constrainedSize check within ASNetworkImageNode. Furthermore as ASDisplayNode does not return CGSizeZero anymore we have to give the display nodes we use in tests and are involving a stack spec an intrinsic content size.

* Remove extra constrainedSize handling in ASNetworkImageNode handling

* Change test to use FLT_MAX
2016-10-28 15:39:03 -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
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
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
Michael Schneider
4692e25204 Add allowsGroupOpacity property to ASDisplayNode (#2320) 2016-09-29 14:30:05 -07:00
Adlai Holler
37d9d401b3 [ASDisplayNode] Failing Test Case: Rasterized Nodes Should Get Interface State Updates (#2242)
* Add new failing test cases for dealloc-while-visible

* Disable the new tests for the time being
2016-09-27 19:54:52 -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
f574f2c54e [Layout] Further deprecation steps for preferredFrameSize (#2255)
* Deprecate preferredFrameSize

- Remove all support for preferredFrameSize in ASDK
- preferredFrameSize setter calls through and sets the width and height of the node
- preferredFrameSize getter tries to return a CGSize based on the width and height properties otherwise if this is not possible it throws

* Address comments

* Return CGSizeZero for preferredFrameSize unless width and height are ASDimensionUnitPoints

* Better comment for preferredFrameSize and remove lock in calculateSizeThatFits:
2016-09-27 16:07:36 -04:00
Adlai Holler
88d588d590 [ASDisplayNode] Use Weak Proxy to Avoid Dangling CALayer.delegate (#2249)
* Add weak proxy between node and layer to avoid dangling layer problem

* Add failing test case for dangling CALayer.delegate pointer issue

* Add docs

* Remove asynctransactioncontainer forwarding preprocessor macro

* Improve comments

* Remove asyncTransactionContainerStateDidChange callback
2016-09-15 10:49:31 -07:00
Adlai Holler
0d3b31dc2d Fix tests that failed due to merging an old PR (#2217) 2016-09-08 14:37:53 -07:00
Adlai Holler
85fee6b609 Fix the dealloc test (#2216) 2016-09-08 14:25:00 -07:00
Adlai Holler
bc59b96ca9 [ASDisplayNode] Add onDidLoad Method to Perform Work When Loaded (#2128)
* [ASDisplayNode] Add `onDidLoad:` method

* Prevent user from rasterizing wrapper nodes – they can't be reloaded in the future
2016-09-08 14:18:35 -07:00
Michael Schneider
0aeefaf25f [Layout] Automatic measurement on layout fixes (#2206)
* Don't measure range managed nodes automatically in the layout pass

* Fix auto measure a node mid transition
2016-09-07 12:46:05 -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
Adlai Holler
2bfeb6de92 Add a failing unit test for automeasuring a node mid-transition (#2204) 2016-09-06 17:58:12 -07:00
Adlai Holler
33a680255c [ASDisplayNode] Add Convenience Interface State Accessors (#2168)
* Finish renaming fetchData range, add convenience accessors

* Update example

* Update new tests
2016-09-01 16:44:16 -07:00
Michael Schneider
7ef6c0ff2c Fix using ASDisplayNodePerformBlockOnEveryNode if node is loaded and has shouldRasterizeDescendants enabled (#2179)
We don't call the block on every subnode if the node that is passed in ASDisplayNodePerformBlockOnEveryNode has shouldRasterizeDescendants enabled as it tries to iterate through the sublayer hierarchy, but there are no sublayers
2016-09-01 12:04:21 -07:00
Adlai Holler
284975ecec Fix Case Where Node Is Deallocated While Visible (#2171)
* Attempt to reproduce supplementary crash

* Get closer with supplementary issue testing

* Alright! We have a repro!

* The investigation continues

* Fixed!
2016-08-31 15:50:39 -07:00
Adlai Holler
ff37535140 [Testing] Migrate Unit Tests to ARC (#2156)
* Migrate ASDisplayNodeTests to ARC

* Migrate ASDisplayNodeAppearanceTests to ARC

* Migrate ASDisplayLayerTests to ARC

* Migrate ASMultiplexImageNodeTests to ARC

* Address Garrett's feedback
2016-08-27 15:09:59 -07:00
Garrett Moon
645aa6f24b [ASDisplayNode] Renamed range update callbacks (#2130)
* 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
2016-08-26 20:18:38 -07:00
Adlai Holler
f542e8d458 [ASDisplayNode] If We Skipped Rendering Due to Zero-Area, Re-Render When We Get a Real Area (#2149)
* Add failing test case

* [_ASDisplayLayer] If we skipped render due to being zero-size, enqueue a render when we get a real size

* Remove pointless import
2016-08-26 15:51:49 -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
Michael Schneider
bbe2fe5f4c Add and fix tests for adding a nil subnode 2016-07-21 14:54:39 -07:00
Hannah Troisi
abf8d5b9aa [Infer] change atomic properties to nonatomic (#1932) 2016-07-16 10:46:55 -07:00
Michael Schneider
f25e0f0d01 Fix Xcode 8 errors 2016-07-08 10:51:07 -07:00
John Engelhart
ea64d7d09b Pr/fix unit tests memory leaks (#1795)
* Fix some concurrency problems detected by Xcode 8's new Thread Sanitizer.

Some of these changes are arguably just to silence the warnings from Thread Sanitizer.

* Fix several memory leaks in the unit tests.

A number of the unit test source files are compield with `-fno-objc-arc`.  This was clearly overlooked when writing several of the unit tests.

Fixed by (mostly) switching to use of `-autorelease` for the problem code.

NOTE: This commit doesn't fix all the memory leaks found.  There's still at least one leak in `-[ASDisplayNodeTests testSetNeedsDataFetchImmediateState]`, and several leaks in `ASBasicImageDownloader.mm`.  I wasn't able to find a trivial cause to these, unfortunately.
2016-06-22 16:56:53 -07:00
Adlai Holler
0002d333f0 [ASDisplayNodeTests] Add some removeFromSupernode tests 2016-06-16 17:59:50 -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
Luke Parham
d47059dffe updated load and display did change methods 2016-06-06 00:56:21 -05:00
Luke Parham
8526171b30 reenabled new tests 2016-06-06 00:56:21 -05:00
Luke Parham
449a2cc517 added callbacks for entering and exiting fetch data and display ranges 2016-06-06 00:56:21 -05:00
Huy Nguyen
a35647b200 Remove unused _enqueueAsyncSizingWithSentinel and asyncSizingQueue methods of ASDisplayNode 2016-04-15 22:08:21 +03:00
Michael Schneider
28c4fede57 Add support for newly added a11y properties in iOS 8 / 9 and tvOS
New a11y properties:
- accessibilityNavigationStyle
- accessibilityHeaderElements
- accessibilityActivationPoint
- accessibilityPath
2016-04-09 11:23:25 -07:00
Michael Schneider
b284d3f606 Enable tests for accessibility properties for layer backed nodes 2016-04-09 11:23:25 -07:00
Scott Goodson
cdd1bd1e39 [ASRangeController] Ensure that visibilityDidChange: is always called on app launch for all initial cells. 2016-03-11 17:18:32 -08:00
Rahul Malik
19cc368d15 In addition to allocating nodes in the background, perform that operation concurrently in ASDataController 2016-02-17 22:30:58 -08:00
Levi McCallum
411d0b3deb Add tests for setNeedsDataFetch and out of range fetch behavior 2016-01-27 18:24:59 -08:00
Scott Goodson
55861b3de1 Update the expectations of the tests now that the clearContents behavior is corrected. 2015-12-27 16:37:33 -08:00
Adlai Holler
69767d558e Merge branch 'master' into update-objc
Conflicts:
	AsyncDisplayKit/Private/ASDisplayNode+FrameworkPrivate.h
2015-12-22 00:28:21 -05:00
Scott Goodson
92126f0d66 Support surprisingly nice automatic behavior for the unsupported case of view-backed nodes as children of layer-backed ones. 2015-12-19 20:33:28 -08:00
Scott Goodson
ee152eadf1 Remove CALayer and UIView implementations of "name" property.
This avoids CoreAnimation from capturing the name from a background thread deep within the internals
of AVPlayerLayer, which commits transactions off the main thread.  If the main thread is also accessing
properties that require the lock, in very specific app architectures relying on AVPlayerLayer, this
can cause a deadlock.

The "name" property is primarily used by ASDK's unit test infrastructure, so I'm leaving it in place for
that purpose - and it may still be used for debugging, if someone wants to set it.  It will remain
possible to get the node from a layer or view with asyncdisplaykit_node, and access name from there.
2015-12-18 16:01:19 -08:00
Adlai Holler
7079a9cc79 Merge branch 'master' into update-objc
Conflicts:
	AsyncDisplayKit/ASDisplayNode+Subclasses.h
2015-12-13 10:05:03 -08:00
Scott Goodson
271f288a19 Polish ASHierarchyState implementation, fix old comment typos, work on test breakages. 2015-12-06 15:04:47 -08:00
Adlai Holler
b16a9e294e Merge branch 'master' into update-objc
Conflicts:
	AsyncDisplayKit/ASDisplayNode+Subclasses.h
2015-12-06 12:25:13 -08:00
Adlai Holler
34c487de5b Fix test 2015-12-04 13:01:15 -08:00
Adlai Holler
05ff0e40ec Add test case for non-cell node interface state 2015-12-04 12:46:34 -08:00