2419 Commits

Author SHA1 Message Date
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
Adlai Holler
b233122604 Check the image alpha value correctly (#2198) 2016-09-05 21:27:50 -07:00
Adlai Holler
607ec8f4a5 [ASImageNode] Use kCGBlendModeCopy when Possible (#2197)
* [ASImageNode] Use kCGBlendModeCopy when possible

* Make the blend mode logic more readable
2016-09-05 20:52:06 -07:00
Adlai Holler
e233a1cccc [Unit Testing] Add Realistic Text Data Set (#2188)
* Add a mechanism to save attributed strings given to text nodes

* Setup performance tests to have an iteration variable

* Use realistic data in new text node performance test case

* Revert temporary changes
2016-09-05 12:30:06 -07:00
Levi McCallum
5db57802b0 Add preprocessor definition for disabling container state changes (#2193) 2016-09-05 12:00:45 -07:00
Levi McCallum
76107ae466 Use NS_VALID_UNTIL_END_OF_SCOPE macro (#2192) 2016-09-04 17:44:38 -07:00
Adlai Holler
90c59e0de7 Remove completely unused layoutManagerDelegate things (#2189) 2016-09-04 12:01:42 -07:00
Levi McCallum
4dd5189f6c Remove unnecessary explicit bool check (#2190) 2016-09-04 12:00:35 -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
Michael Schneider
9b823ebdc9 Add better exception message for adding or removing ASDisplayNode's in layoutSpecThatFits: (#2183) 2016-09-02 14:58:19 -07:00
Adlai Holler
1f61dd1576 Log update validation exception messages before throwing, so user can see them before they bubble up (#2180) 2016-09-02 09:19:11 -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
Adlai Holler
5e3627a9cd [ASTextNode] Actually deprecate attributedString property (#2151) 2016-09-01 16:43:03 -07:00
Michael Schneider
f8e135a1be Add old transition API back but allow call from background thread (#2135) 2016-09-01 16:09:59 -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
6db9bf39f1 Turn on collection update validation by default (#2174) 2016-08-31 22:20:23 -07:00
Garrett Moon
0c5288d033 [ASDisplayNode] Dealloc _pendingViewState if range managed (#2155)
* Dealloc _pendingViewState if range managed

_ASPendingState objects can add up very quickly when adding
many nodes. This is especially an issue in large collection views
and table views. This needs to be weighed against the cost of
reallocing a _ASPendingState. So in range managed nodes we
delete the pending state, otherwise we just clear it.

* Adlai's comments
2016-08-31 16:47:10 -07:00
Michael Schneider
027358fc6b [Layout] Automatic measure pass in layout pass if not happened before (#2163)
* Automatic measure pass in layout pass if not happened before

If no measure pass happened or the bounds changed between layout passes we manually trigger a measurement pass for the node using a size range equal to whatever bounds were provided to the node

* Add test method that ensures that on a second layout pass with same bounds, layoutSpecThatFits: / layoutSpecBlock is not called
2016-08-31 16:45:02 -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
Michael Schneider
68d6d6f5b4 [ASDisplayNode] Add documentation for range state changes and moved deprecated header to category file (#2170)
* Add documentation for range state changes and moved deprecated header to category file

* Fix self.usesImplicitHierarchyManagement not found
2016-08-31 15:39:23 -07:00
Samuel Hsiung
72b66387d0 make inline functions in ASDisplayNodeExtras.h static (#2167)
* make inline functions in ASDisplayNodeExtras.h static to fix linker errors

* use `ASDISPLAYNODE_INLINE` in place of `static inline`
2016-08-30 10:49:29 -07:00
Adlai Holler
6bf4943204 Remove unneeded display semaphore now that thread count is limited by ASAsyncTransaction (#2124) 2016-08-30 09:45:22 -07:00
Michael Schneider
1849c41b03 Add assert for ASCollectionDataSource implementing collectionView:constrainedSizeForNodeAtIndexPath: instead of ASCollectionDelegate (#2165) 2016-08-29 16:44:11 -07:00
Michael Schneider
ba5dc984d7 Check if subnodes where modified during layoutSpecThatFits: (#2164) 2016-08-28 16:55:42 -07:00
Adlai Holler
578ac4c48d [Unit Tests] Add Text Layout Performance Tests (#2161)
* Add single-threaded text node performance testing

* Relax test a bit
2016-08-28 16:47:03 -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
Garrett Moon
8032758176 Fixes a deadlock caused by walking up the heirarchy. (#2147)
* Fixes a deadlock caused by walking up the heirarchy.

* Use scope locker / unlocker and add a comment.

* Add comment about calling __setNeedsLayout without the lock.
2016-08-26 14:09:38 -07:00
Garrett Moon
e6e5c346de I wrote a bunch of code with the Mutex::Unlocker and didn't understand it. (#2150) 2016-08-26 14:07:18 -07:00
Michael Schneider
905508e9be Factor in constrained size for final size calculation of ASTextNode (#2146) 2016-08-26 11:55:13 -07:00
Adlai Holler
9c3b688a87 Remove textStorageCreationBlock API (#2142)
* Remove textStorageCreationBlock API

* Remove layoutManagerCreationBlock also
2016-08-26 11:42:20 -07:00
Adlai Holler
6a482dc153 [ASDataController] Use 2 Threads Per CPU When Measuring Nodes (#2145)
* [ASDataController] Use custom apply function to control thread count

* Relax the test for stupid Travis CI

* Remove unneeded import
2016-08-26 10:54:55 -07:00
Adlai Holler
480ba8c3fa [ASViewController] Remeasure node with new constrained size when propagating trait collection (#2143) 2016-08-25 21:21:44 -07:00
Garrett Moon
e3091737ca Enable ASRangeControllerUpdateRangeProtocol by default if view controller or node support it. (#2133) 2016-08-25 21:18:04 -07:00
Adlai Holler
04ecd4180e [ASTextKitRenderer] Shift TextKit Teardown onto the Deallocation Queue (#2136)
* [ASTextKitRenderer] Shift TextKit teardown onto the deallocation queue

* Import it!
2016-08-25 17:29:31 -07:00
ricky
b5b9eefe44 [ASViewController] Layout root node AFTER propagating all the traits (#2137)
Wait until all subnodes have the new trait collection before laying out the root node. The way I’m using `asyncTraitCollectionDidChange`, I sometimes call methods that call `setNeedsLayout` which causes a new layout pass to begin before the new trait collection has been propagated to all nodes. This leads to weird behavoir, like nodes being laid out twice in the same call stack!

This change won’t stop possibly unnecessary layout passes because of `asyncTraitCollectionDidChange`, but it will at least do a complete layout pass once we have propagated all traits.

Ultimately the solution to this problem (as Adlai pointed out) is to wait until the CA transaction commit to perform the actual layout.
2016-08-25 11:52:43 -07:00
Adlai Holler
a193a4bca4 [ASStackLayoutSpec] Create children NSArray less often (#2139) 2016-08-25 10:03:07 -07:00
Michael Schneider
370d0597df Fix compiler warning in Xcode 8 2016-08-24 15:56:21 -07:00
Garrett Moon
dfe4585cec Add ability to force the size which an image node is rendered. (#2107)
* Add ability to force the size which an image node is rendered.

* Add unit tests for forced scaling.

* Whoops, need results!

* Round forced scaling.

* Check size of contents too.

* Remove unnecessary container node.
2016-08-23 16:01:43 -07:00
Adlai Holler
b21742c3c9 [ASCollectionView] Relayout Nodes as Soon as Bounds Changes (#2121)
* Add failing test case for ASCollectionView rotation

* [ASCollectionView] Relayout nodes immediately on bounds change
2016-08-23 14:33:45 -07:00
Adlai Holler
8edc9fe08f Ensure supplementary section count tracks item section count (#2118) 2016-08-22 20:50:09 -07:00
Michal Ziman
873bae2eed [ASMapNode] Add custom pin annotation for static maps (#1890)
* Adds possibility to have custom annotation pins on static map. This resolves #1889.

* Removes wrong example for map annotations and adds some annotations to correct map example. #1889

* Static map node now uses specific property block to get annotation views.

* Changes self to strongSelf inside of the snapshotters completion block.

* MapNode: Adds statement in documentation.

* MapNode: Block for annotation view/image now returns UIImage and center offset is returned in inout param.

* MapNode and map example: Fixes from review.

* MapNode example: Gets image directly from custom annotation, without creating annotation view.
2016-08-22 10:44:29 -07:00
ricky
c0be871812 [ASViewController] Propagate the traits on willTransitionToTraitCollection (#2115)
Previously we were only propagating the trait collection on `viewWillTransitionToSize` since it is called shortly after `willTransitionToTraitCollection`. However, some important things can happen in that time “shortly after” (like collection view layout). As long as nothing changes from `willTransitionToTraitCollection` to `viewWillTransitionToSize` (which it shouldn’t) the traits will not be re-propagated anyhow.

Also make sure to use the `ASEnvironmentTraitCollectionMakeDefault` method when creating new envTraitCollection so the struct isn’t filled with junk.
2016-08-22 10:06:53 -07:00
Yue-Wang-Google
a38f3db6b0 set the right attributes for block properties. (#2113)
* set the right attributes for block properties.

* oops. should remove strong.

* Update ASImageNode.mm

* revert to use copy for blocks. See apple documentation below

https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/WorkingwithBlocks/WorkingwithBlocks.html#//apple_ref/doc/uid/TP40011210-CH8-SW12

* make the block properties nonatomic.
2016-08-21 13:06:21 -07:00