2462 Commits

Author SHA1 Message Date
Michael Schneider
1abc1a833c Remove legacy layout validation code (#2311) 2016-09-28 16:46:31 -07:00
Garrett Moon
5cd8f28ad5 @return is recognized by the syntax highlighter. (#2313) 2016-09-28 14:40:05 -07:00
Michael Schneider
4aa7c9631d Disable ASTextKitRenderer cache (#2315) 2016-09-28 16:42:06 -04: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
Adlai Holler
8a4d4e3b5c Simplify/optimize rounded image generation (#2292) 2016-09-27 18:42:46 -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
Adlai Holler
f421787cd3 Add some nullability specifiers to our public headers (#2291) 2016-09-27 18:15:04 -04:00
Adlai Holler
ec64b9b229 [ASDataController] Call All Completion Handlers after Nested Batch Updates (#2274)
* Add tests for batch update completion handler calling

* Ensure we call all completion handlers after collection view updates

* Tweak it

* Fix the doc

* Minor improvements

* Document addCompletionHandler better
2016-09-27 17:21:28 -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
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
Garrett Moon
d909a8af01 I don't believe it's safe to return a vector by reference created in a function. (#2286) 2016-09-26 17:41:58 -04:00
Adlai Holler
4326fc90bf Pass the cell node through in willDisplay: table/collection callbacks (#2282) 2016-09-23 19:50:53 -04:00
Adlai Holler
ce1d21dc63 [ASCellNode] Document cell node event callback behavior for plain-node cases (#2281) 2016-09-23 13:30:30 -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
Michael Schneider
9f1a387ba0 [ASTableView / ASCollectionView] Improve assertion messages if necessary data source methods are not implemented (#2269)
* Improve assertion message if tableView:nodeBlockForRowAtIndexPath: or tableView:nodeForRowAtIndexPath: is not implemented

* Improve assertion message if collectionView:nodeForItemAtIndexPath: or collectionView:nodeBlockForItemAtIndexPath: is not implemented
2016-09-22 13:35:04 -07:00
Michael Schneider
8427083ddb Set default value of flexShrink to NO (#2270) 2016-09-21 13:17:35 -07:00
Rocir Santiago
7dd997d442 Minor tweaks around image alignment in ASButtonNode (#2271) 2016-09-20 19:47:13 -04:00
Harry Shamansky
71fc2dd18d Revise performance measurement naming and structure (#2265)
* Revise performance measurement naming and structure

- Revises naming from LayoutSpecGeneration to LayoutSpecComputation
- Adds a struct instead of an NSDictionary to retrieve performance metrics
- Includes ASEnvironmentStatePropagateDown in LayoutSpecComputation measurements

* Revise SumScopeTimer to include enable flag

* Make struct a typedef
2016-09-20 15:39:09 -04:00
Rocir Santiago
5990376f68 Add support to image alignment in ASButtonNode (#2266) 2016-09-19 17:16:49 -07:00
appleguy
3e5b8c3096 [ASDisplayNode] Ensure ASHierarchyState propagation does not jump discontinuities in the node hierarchy. (#2263)
Scenario: An ASCollectionNode is a subnode of an ASCellNode.  A layout transition is started, resulting in
the removal of the ASCollectionNode as a subnode.  As it is removed, the hierarchy state is cleared - including
the "range managed" bit - on the ASCollectionNode.  However, the deep recursion traverses the layer hierarchy
too, and clears this bit on the ASCellNodes inside the ASCollectionNode.  A moment later, the collection performs
its final ASRangeController update to mark its cells as invisible and free memory.  Then an assertion is triggered
in ASRangeController, because it is operating on nodes that do not have the "range managed" bit set.

It turns out that ASInterfaceState also propogates in this way, but that behavior is efficient and beneficial in
its current configuration (it assists how multi-dimensional preloading works).  However, hierarchy state should
never need to jump discontinuities in the node hierarchy.  For now, disabling that case and will revisit
other use cases soon.
2016-09-19 12:04:39 -07:00
Adlai Holler
48f76c40d5 Fix ASViewController accessing traitCollection on iOS 7 (#2259) 2016-09-16 08:52:09 -07:00
Adlai Holler
25de53bb13 [ASDisplayNode] Add Event Tracing to Help Debugging (#2243)
* Add some simple event logging for ASDisplayNode

Improve the tracing

* Add header to copy files phase

* Make event header public
2016-09-15 13:24:19 -07:00
Adlai Holler
8459c1e825 Remove some thread affinity assertions that we no longer need (#2251) 2016-09-15 12:13:24 -07:00
Adlai Holler
1e86dcdbe2 [ASDisplayNode] Use kCGBlendModeCopy in a Couple More Places (#2250)
* Use blend mode copy in a couple more places

* Add some tests
2016-09-15 11:56:46 -07: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
4cf571c830 [ASCollectionView] Add Support for Interactive Reordering (#2221)
[ASTableView] Add Support for Interactive Reordering
2016-09-14 22:31:04 -07:00
Adlai Holler
d1d25a770c Don't beginUpdates/endUpdates on cell relayout if data source is gone (#2248) 2016-09-14 16:21:05 -07:00
Adlai Holler
bba71d05f0 Set .flexShrink to YES by default (#2247)
To align with the CSS flex-shrink spec, set the default value of flexShrink to YES: http://www.w3.org/TR/css-flexbox-1/#propdef-flex-shrink
2016-09-14 11:24:24 -07:00
gazreese
025af5d594 [ASVideoNode] Maintain playback position between visibility changes (#2120)
* [ASVideoNode] Maintain playback position between visibility changes

* [ASVideoNode] Code style changes and moved the pause to be before caching the current playback time.
2016-09-13 20:44:26 -07:00
Adlai Holler
337e908390 Make Description Functions Dealloc-Safe (#2241)
* Make description functions dealloc-safe

* Make -debugDescription also dealloc-safe
2016-09-13 17:48:31 -07:00
Adlai Holler
84e633137b [Layout] Use _addSubnode / _removeFromSupernode methods in _ASDisplayView 2 (#2232)
* Use `_addSubnode` / `_removeFromSupernode` methods in _ASDisplayView

* Change name
2016-09-12 10:46:43 -07:00
Adlai Holler
8c380d1601 Don't crash in production on invalid subnode insert (#2231) 2016-09-12 10:29:31 -07:00
Harry Shamansky
59fbfb682d Measure performance for ASCellNode layout (#2209)
* Measure performance for ASCellNode layout

* Address Adlai and Levi's feedback:
* Move to ASDisplayNode level
* Lock around setting/getting measurement options and results
* Record all measurement passes and report times as an array
* Only add relevant entries to the performanceMetrics dictionary
* Rebase

* Store sum and count instead of array

* Rename ScopeTimerDataPoint to ScopeTimerSum

* Address Levi's feedback

* Address Adlai's feedback
2016-09-09 10:38:13 -07:00
John Engelhart
8c2f3f666f Fixes unsafe use of asyncdisplaykit_node. (#2207)
The previous code used either a `@property` with `assign, nonatomic` semantics, or a `__unsafe_unretained` (non-atomic) ivar pointer to an instance for `asyncdisplaykit_node`.

This commit changes those access so that they have the equivalent of `weak, atomic` semantics.

- `_ASDisplayView.mm`
  - Removes the `_node` ivar that was qualified with `__unsafe_unretained`.
  - Removes `@synthesize asyncdisplaykit_node = _node;`.
  - All direct uses of `_node` were replaced with:
    - Creates a strong reference via `ASDisplayNode *node = _asyncdisplaykit_node;`.
    - `s/_node/node/`.
    - These changes were made even if there's a single use of `_asyncdisplaykit_node` as a consistency / defensive measure so that anyone editing this code in the future does not accidentally use a `weak` reference twice.

- `ASDisplayNode.mm`
  - Getters and setters for `asyncdisplaykit_node` were changed from `nonatomic, assign` semantics to the equivalent of `atomic, weak` semantics.
  - `weak` semantics were implemented by using a `ASWeakProxy` object.
  - `objc_setAssociatedObject` was changed from `OBJC_ASSOCIATION_ASSIGN` to `OBJC_ASSOCIATION_RETAIN` (the `atomic` version of retain).

- `ASDisplayNode+FrameworkPrivate.h`
  - Changed the `@property` declarations for `asyncdisplaykit_node` from `nonatomic, assign` to `atomic, weak`.
    - The actual getters and setters are implemented in `ASDisplayNode.mm`, which were changed accordingly.
2016-09-08 17:27:49 -07:00
ricky
6bef1e129a [ASViewController] fix layout recursion (#2218)
I don’t think this `setNeedsLayout` is required since we call `measure` now.
2016-09-08 16:01:14 -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
Hannah Troisi
593f13d800 Improve crash logging [@johnepinterest] (#2210) 2016-09-08 14:06:49 -07:00
Adlai Holler
12ab2e3759 Fix equality in ASTextKitRendererKey (#2215) 2016-09-08 12:59:03 -07:00
Michael Schneider
0d8518912e Initial commit to throw an exception if manually adding / removing subnodes if node has automaticallyManagesSubnodes enabled (#2214) 2016-09-08 11:59:57 -07:00
Michael Schneider
53a6743908 Don't use automaticallyManageSubnodes in ASTextCellNode (#2212) 2016-09-08 11:17:50 -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
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
ricky
180fcbbc5e [ASViewController] stop propagating traits in the viewWill... methods (#2202)
* [ASTraitCollection] Fix 2 bugs dealing with trait propagation

* Don’t propagate on `viewWillTransitionToTraitCollection`. This is too early
* Pass the size from `viewWillTransitionToSize` as the container size in `traitCollectionDidChange`

* using the old trait collection’s size doesn’t actually make sense.

* Instead of propagating on viewWillTransitionToSize, do it in viewWillLayoutSubviews
2016-09-06 15:23:32 -07:00
Michael Schneider
2388f67474 [ASTextNode] Add NSCache based cache for ASTextKitRenderer (#2199)
* Add cache implementation

* Remove old ASEqualityHashHelpers

* Some more ASEquality and ASEqualityHashHelper cleanup

* Add cache for text renderer in ASTextNode

* Move from C++ LRU renderer cache to NSCache based renderer cache
2016-09-06 15:23:21 -07:00
Huy Nguyen
6124830b23 Fix assertion messages in ASCollectionViewFlowLayoutInspector (#2196) 2016-09-06 11:43:13 -07:00
Hannah Troisi
03c21830a5 improve layoutSpecThatFits: assertion message (#2201) 2016-09-06 11:42:59 -07:00