420 Commits

Author SHA1 Message Date
Levi McCallum
c469ad273b [ASLayout] Cache constrained size range 2016-06-05 09:22:46 -07:00
appleguy
8801b61707 Merge pull request #1438 from Adlai-Holler/AvoidMutatingSublayersAgain
[ASDisplayNode] Copy Sublayers in recursivelyTriggerDisplayForLayer to Avoid NSFastEnumerationMutation Exception
2016-06-04 21:36:05 -07:00
Michael Schneider
4f493c4ad3 Fix placeholder image is not appearing if size of node changed after initial placement 2016-06-04 15:04:52 -07:00
appleguy
2e384a32e1 Merge pull request #1673 from maicki/AddAutomaticMeasureBeforeLayout
[ASDisplayNode] Add automatic measure before layout
2016-06-04 00:36:18 -07:00
appleguy
e5eed560e1 Merge pull request #1693 from rcancro/traitUpdate
[ASTraitCollection] Bug fixing/LayoutSpec propagation
2016-06-03 22:01:13 -07:00
Hannah Troisi
c9ac554889 [ASDisplayNode] Add assertion to +initialize warning developers who override and do not call super.
If a developer makes this error, it would prevent calls to key lifecycle methods, such as -layoutSpecThatFits:.
Although the superclasses of ASDisplayNode do not implement +initialize, a super call is added here for consistency.
2016-06-03 20:18:12 -07:00
Michael Schneider
691749d098 Address comments 2016-06-03 14:18:49 -07:00
Michael Schneider
b4d490848f Add measure: call for nodes without host on themselves if developer does not
Normally measure will be called before layout occurs. If this doesn't happen, nothing is going to call it at all.  An experimenting developer probably added a node to the hierarchy directly. We simply call measureWithSizeRange: using a size range equal to whatever bounds were provided to that element. This make initial experimentation using layoutSpecs much easier. Furthermore added logging if no size is given for the node before layout occurs.
2016-06-03 13:24:47 -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
c42b0dd33a Remove explicit passing of trait collection to setChild/Children 2016-05-25 10:49:42 -07:00
Levi McCallum
95f1ab4902 [ASDisplayNode] Rename ASDisplayNodeTransitionContext to ASLayoutTransition (#1680)
* [ASDisplayNode] Rename ASDisplayNodeTransitionContext to ASLayoutTransition

* Rename internal ivar to fit new naming

* Fix tabbing
2016-05-25 10:10:27 +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
Garrett Moon
94bb3b79cb May as well use the existing visibility function. (#1684) 2016-05-22 14:12:29 +08: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
d1054d6ed9 Move from ASSentinel to a atomic int 2016-05-05 20:25:07 -07:00
Michael Schneider
dc6d2e7660 Improve Transition ID handling 2016-05-05 20:25:07 -07:00
Garrett Moon
025dd55312 Dang, message local var, not ivar 2016-05-03 15:59:21 -07:00
Garrett Moon
938ecd9b6f Fix deadlock when laying out on multiple threads
Summary:
We observed a deadlock which occurred when two threads were laying out the same set of nodes.

On one thread, layout would occur on a leaf node. It would lock and as part of this layout
process, ASDK walks up the node tree and calls __setNeedsLayout on its supernode until it
reaches the supernode with no supernode. When the supernode gets its call to __setNeedsLayout
it also locks. So leaf node locks and then awaits supernode lock.

On another thread, we're doing a layout pass on the supernode in the above thread. This locks
the supernode and attempts to lock the leaf node. This deadlocks (remember the above thread
is holding onto the leaf lock and awaiting the supernode lock. This thread is holding onto
the supernode lock and awaiting the leaf lock).

This is all exacerbated by the use of recursive locks.
2016-05-03 15:56:38 -07:00
Wendy
0b55df9649 Add the ability for ASNetworkImageNodes to keep track of their progressive image quality 2016-04-26 18:33:59 -07:00
Michael Schneider
79e5337948 Fix setter override for setLayoutSpecBlock: 2016-04-22 11:22:01 -07:00
Michael Schneider
fde8f1af0e Change layoutSpecBlock against NULL 2016-04-22 11:21:42 -07:00
Michael Schneider
5afce83241 Adjust indention of comment 2016-04-21 07:07:17 -07:00
Michael Schneider
87a37a283e Add a block API to provide an ASLayoutSpec without having to subclass ASDisplayNode 2016-04-20 19:16:54 -07:00
appleguy
dd4853bf3a Merge pull request #1273 from aaronschubert0/tvOS
[tvOS] Add default focus states to ASControlNode & ASImageNode.
2016-04-20 13:29:31 -07:00
Michael Schneider
42174210c5 Follow up for ASCollectionNode and ASTableNode background color fix 2016-04-19 16:07:42 -07:00
Michael Schneider
3793dc024e Improve setting special properties for certain classes directly to the UIView
- Remove duplicated code in ASCollectionNode and ASTableNode
- Fix setting the pending state to the view if applying the pending state to the view
2016-04-19 10:50:22 -07:00
Aaron Schubert
21abe8f899 Fix merge conflicts 2016-04-19 09:02:07 +01:00
appleguy
30a0c471ca Merge pull request #1528 from ejensen/instancetype
[Refactoring] Replace id with instancetype in initializers
2016-04-16 20:53:41 -07:00
Huy Nguyen
5a677915ba ASDisplayNode should bail early if a scheduled transition was invalidated before its block executes
- Idea borrowed from _enqueueAsyncSizingWithSentinel
2016-04-15 22:08:48 +03:00
Huy Nguyen
a35647b200 Remove unused _enqueueAsyncSizingWithSentinel and asyncSizingQueue methods of ASDisplayNode 2016-04-15 22:08:21 +03:00
Eric Jensen
527397ba7e Replace id with instancetype in initializers 2016-04-13 11:20:05 -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
Scott Goodson
ccddb36ed9 [ASDisplayNode] Ensure that Visible interfaceState is cleared on removal from hierarchy for rasterized elements. 2016-04-07 14:10:34 -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
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
Huy Nguyen
387f3bf634 Properly lock layoutableContextMap
Signed-off-by: Huy Nguyen <huy@pinterest.com>
2016-03-29 13:40:57 -07:00
Scott Goodson
1ea1560694 [ASDisplayNode] Rasterized subnodes require special handling for __exitHierarchy. 2016-03-28 17:58:35 -07:00
Adlai Holler
f205a6cc28 Copy sublayers in recursivelyTriggerDisplayForLayer to avoid NSFastEnumerationMutation exception 2016-03-28 16:54:50 -07:00
Scott Goodson
096df7b385 [ASDisplayNode] Remove #if gating of ASDisplayNode hitTest: (I'd misread this as _ASDisplayView's implementation, and both are needed). 2016-03-28 07:49:14 -07:00
Scott Goodson
cd493358cc [ASControlNode] Upgrades to +setEnableHitTestDebug: to intersect hitTestSlop with parents' bounds+slop, to accurately predict and visualize UIKit event delivery edge cases. 2016-03-27 22:02:13 -07:00
appleguy
97798010cb Merge pull request #1443 from nguyenhuy/layoutable_context
[ASLayoutable] Introduce ASLayoutableContext, thread-local storage for layout passes.
2016-03-27 17:40:42 -07:00