362 Commits

Author SHA1 Message Date
Michael Schneider
a8c5ac138d [ASDisplayNode] Always layout nodes on a background thread (#1907)
* Always layout nodes on a background thread

* Remove semaphore in ASDataController for allocating nodes and layout

* Fix variable not used error

* Remove overhead to create subarray of contexts of nodes while layout nodes

* Remove extra allocation of allocatedNodes and indexPaths array
2016-07-14 21:35:58 -07:00
Michael Schneider
dc2255d5d8 Fix setNeedsLayout triggered from subnode will not trigger relayout 2016-07-12 09:26:40 -07:00
Michael Schneider
7f4737217e Change from MutexLocker / MutexUnlocker to lock() and unlock() directly on property lock (#1900)
For performance reasons change to directly lock and unlock calls on the property lock instance
2016-07-11 17:04:47 -07:00
appleguy
dc12042589 [ASDisplayNode] Do not start measurement for a transition if we have never been provided a constrainedSize. (#1844) 2016-07-09 21:16:29 -07:00
appleguy
3b2af7eb6d [Build] Remove Unused Imports across all of AsyncDisplayKit. This uses a feature of AppCode. (#1875)
Details on the tool are here: https://www.jetbrains.com/help/idea/2016.1/optimizing-imports.html
2016-07-09 17:20:59 -07:00
Adlai Holler
a2d4dc5888 Merge pull request #1839 from maicki/MSAsyncMeasure
[ASDisplayNode] Allow measure always be off the main thread
2016-07-08 15:41:05 -07:00
Adlai Holler
b3d673645d Merge pull request #1867 from maicki/MSFixXcode8Errors
Fix Xcode 8 Errors
2016-07-08 12:42:50 -07:00
Michael Schneider
f25e0f0d01 Fix Xcode 8 errors 2016-07-08 10:51:07 -07:00
Huy Nguyen
312de1a084 Make sure range controller listens to node display notifications if absolutely needed 2016-07-08 12:09:47 +07:00
Michael Schneider
9de014f179 Change applySubnodeTransition to startTransition 2016-07-03 14:38:26 -07:00
Michael Schneider
bf6fbd173d Address first comments 2016-07-03 13:33:23 -07:00
Scott Goodson
d2d8b0a1cb [ASDisplayNode] Adjust behavior of -removeFromSupernode to ensure "root" nodes are removed from their superview/superlayer.
This situation is relatively uncommon.  If a user manually uses -[UIView addSubnode:], the convenience category method,
and then calls -[ASDisplayNode removeFromSuperview] -- we would bypass performing the actual removal as no supernode pointer
is set.  After further consideration, the special handling here to support divergence between the supernode pointer and
the view / layer hierarchy is not something we need to maintain going forward, and removing it makes addressing this easy.
2016-07-01 20:11:23 -07:00
Michael Schneider
01fed69b26 Adds trampoline for inserting and deletion of nodes
Currently measurement always needs to happen on the main thread if implicit hierarchy management is enabled as adding and removing from nodes needs to happen on the main thread. We now will trampoline to the main thread to do the insertion and deletion of nodes.

This also resolves the issue that can occur if a node is already loaded deep in the layout hierarchy in the layout that the node is transforming to. Before insertion or deletion is happening we need to crawl the layout hierarchy to check that though.
2016-07-01 16:33:37 -07:00
Adlai Holler
96fb5b3261 Merge pull request #1786 from maicki/FixPlaceholderIsNotAppearing
[ASDisplayNode] Handle placeholder layer creation in case the size of the node changes after the initial placeholder layer was created
2016-07-01 13:54:01 -07:00
ricky
8c3025bb12 [ASDisplayNode] added asyncTraitCollectionDidChange method (#1831)
Subclasses can override this method to react to a trait collection change
2016-06-30 19:45:29 -07:00
Michael Schneider
5f7cdbd9ca Handle placeholder layer creation in case the size of the node changed after the initial placeholder layer was created 2016-06-30 07:30:17 -07:00
Michael Schneider
e230c69055 Improve settings flags 2016-06-20 13:34:14 -07:00
Michael Schneider
eef22074a4 Add caching for checking if ASDisplayNode can clear it contents or setNeedsDisplay: can be called on the layer 2016-06-20 13:04:44 -07:00
Michael Schneider
23736c3cf7 Fix wrapped UIKit components are disappearing
I looked into the internals of UIImageView a bit. I would recommend to not fixing this in a universal way. UIImageView is specifically optimized for performance and does not use the usual way to provide the contents of the CALayer that backs the UIImageView.

Furthermore we cannot trigger a recreation of the contents of the UIImageView layer as if it get’s cleared and we call setNeedsDisplay on it it goes trough the normal flow to assign the contents to a layer via the CALayerDelegate methods. Unfortunately UIImageView does not do it, it actually does not implement some of the methods at all, so nothing will show up. It’s getting better, by calling setNeedsDisplay on an UIImageView layer it actually clears the contents and nothing is visible anymore. So we have to be careful to not calling that too.

Unfortunately I didn’t find a way yet to trigger a recreation of the UIImageView layers content except calling the private _updateState method.

That said it’s different for layers of other UIKit components like UILabel for example. Clearing the contents of a UILabel layer and calling setNeedsDisplay on the layer usually recreates the contents of the it and it will show up again.

This commit prevents to clear the contents of a layer for all wrapped UIKit and instead only NOT clear the content if the node wraps a UIImageView otherwise we should clear the contents of the layer to reclaim memory as usual.
2016-06-20 13:04:44 -07:00
Adlai Holler
42aa52b407 [ASDisplayNode] Put the thread affinity assertion back 2016-06-17 09:51:09 -07:00
Adlai Holler
f5460a44e0 [ASDisplayNode] Reduce locking in removeFromSupernode 2016-06-16 17:10:09 -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
appleguy
c211c76c64 Merge pull request #1735 from levi/betterFlatten3
[ASLayout] Clean up flattening process of ASLayout
2016-06-11 23:15:16 -07:00
appleguy
a7128cd213 Merge pull request #1605 from lappp9/override-callback-for-display-range
[ASDisplayNode] Added callbacks for entering and exiting fetch data and display ranges
2016-06-11 22:21:20 -07:00
Levi McCallum
7e8d519a9a Introduce type property to replace layout id check 2016-06-10 12:43:46 -07:00
Levi McCallum
a3e8f556a3 Clean up flattening process in ASLayout 2016-06-10 12:43:46 -07:00
appleguy
6632b4ec5f Merge pull request #1722 from rcancro/layoutSpecTraitObject
[ASLayoutSpec] Remove cached ASTraitCollection
2016-06-08 22:29:47 -07:00
Michael Schneider
434102f988 Address comments from review
- Remove public NSMutableArray header for validators
- Add ASDISPLAYNODE_EXTERN_C_BEGIN/END
- Rename isRootLayout to isFinalLayoutable
2016-06-08 18:42:32 -07:00
Michael Schneider
9ff7223b77 Move validation code to ASLayoutValidation and add validation flag 2016-06-08 16:59:46 -07:00
Michael Schneider
197950f39b Add basic infrastructure for layout validation 2016-06-08 10:35:28 -07:00
ricky
3c34d51a19 [ASLayoutSpec] Remove cached ASTraitCollection 2016-06-07 10:50:42 -07:00
Levi McCallum
e5d7d29eb6 Fix boolean logic that prevents layout 2016-06-06 13:57:17 -07:00
Levi McCallum
20523821f9 Revert "Merge pull request #1673 from maicki/AddAutomaticMeasureBeforeLayout"
This reverts commit 2e384a32e15d34ea8f963dbc4e44aaa297ca019b, reversing
changes made to b8618d3151d9714d24ccfd935b92a99b774442f1.
2016-06-06 13:12:10 -07:00
Scott Goodson
58d7a18dd4 [Build] Tag __unused for variable only needed by an assertion. 2016-06-06 00:45:23 -07:00
Luke Parham
fc5467b110 fixed typo and added backwards compatibility for 'visibilityDidChange' 2016-06-06 02:02:23 -05:00
Luke Parham
e510120031 changed '-visibilityDidChange:' to '-visiblieStateDidChange:' to match the others 2016-06-06 00:56:21 -05:00
Luke Parham
d47059dffe updated load and display did change methods 2016-06-06 00:56:21 -05:00
Luke Parham
4b2aa1fc59 added comments to header and cleaned up interface state did change 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
Levi McCallum
3b6347c392 Update naming of dirty layout method 2016-06-05 09:33:27 -07:00
Levi McCallum
f809d4a1c9 Let ASLayout determine if a node should measure 2016-06-05 09:32:48 -07:00
Levi McCallum
19e949e02f [ASDisplayNode] Move constrainedSize to layout 2016-06-05 09:30:57 -07:00
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