116 Commits

Author SHA1 Message Date
Adlai Holler
a7656766f9 Make Cell Node Properties Atomic (#74)
* Make ASCellNode indexPath and supplementaryElementKind atomic

* Update the change log

* Fix licenses

* Be explicit with atomic

* Rename the protocol

* And the file
2017-05-02 14:09:12 -07:00
Phil Larson
471f02daa7 Automatically resume ASVideoNode after returning from background (#13) 2017-05-02 13:13:16 -07:00
Adlai Holler
b1e1bfda20 Improve Our Handling of Subnodes (#223)
* Improve the subnodes/fast enumeration situation

* Increment changlag

* Assert our subnodes match
2017-05-02 13:02:07 -07:00
appleguy
71d5b3205d [ASNodeController+Beta] Provide an option to allow nodes to own their controllers. (#61)
* [ASNodeController+Beta] Provide an option to allow nodes to own their controllers.

We should certainly remove this before moving ASNodeController out of Beta. However, I think
it will require at least ASCollectionNode to be able to retain its top level set of node controllers.

Without this facility built in, it's very difficult for apps supporting both UIKit and ASDK to
manually manage the controllers and keep them in sync with perfect timing.

* [ASNodeController] Fix one of the #if's.
2017-05-01 10:51:59 -07:00
Adlai Holler
4d5e3ce81e Tighten Rasterization API, Undeprecate It (#82)
* Tamp down the rasterization API, and undeprecate it

* Update license header

* Update chornglorg

* Address comments
2017-05-01 08:26:37 -07:00
appleguy
03a1aa2660 [ASDisplayNode] Implement a std::atomic-based flag system for superb performance (#89)
* [ASDisplayNode] Convert isSynchronous to an Objective-C atomic BOOL.

This reduces lock contention, and should also fix a very rarely seen deadlock.

* [ASDisplayNode] Implement a std::atomic-based flag system for superb performance

Although Objective-C atomics are equally fast, or better that std::atomic when
access through method calls, for the most intense use cases it is best to avoid
method calls entirely.

In ASDisplayNode, we could benefit significantly from avoiding both method calls
(already true today) but also avoid locking the mutex, for both CPU and contention
gains.

There will still be many methods that need locking for transactional
consistency - however, there are currently dozens of accessor methods that could
avoid frequent lock / unlock cycles with use of atomics, and other usages of the
ivars directly where locking could be delayed until after early-return conditions
are checked and passed.
2017-04-29 23:10:59 -07:00
rewcraig
e18d1394e4 Fix issue with swipe to delete cell gesture. (#46)
Ensure superclass scroll view delegate methods are called when the scroll view parameter is not the current ASTableView.
2017-04-29 15:54:00 -07:00
Adlai Holler
456dc8535d Simplify Hashing Code (#86)
* Simplify hashing

* Update chingling

* Update license
2017-04-29 15:23:00 -07:00
appleguy
411817b58c [Yoga] Ensure that calculated layout is nil'd in invalidate*Layout (#87)
This is a simple additional fix to the last YOGA patch.
2017-04-29 15:06:23 -07:00
appleguy
6f82d0f059 [Yoga Beta] Improvements to the experimental support for Yoga layout. (#59)
* [Yoga Beta] Improvements to the experimental support for Yoga layout.

Yoga remains an unsupported / speculative feature, but these improvements are important for
the functionality of clients that are experimenting with it.

For example, without these changes, ASButtonNode is not able to lay out correctly. These
changes allow certain subtrees that use layout specs to coexist properly in a Yoga heirarchy.

The most significant change here is moving ASEdgeInsets into the #if YOGA gating. Although
this is technically an API change, this type was added with no known use cases and is
really only useful for flexbox layout specification. So, before usages of it are created,
it makes sense to constrain the Texture API surface until that time.

* [RTL] Bridge the UISemanticContentAttribute property for more convenient RTL support.

Although apps could handle this before by setting the view's property in didLoad, it's
useful to bridge this property for setting during off-main initialization.

This change also makes RTL fully functional / automatic for Yoga layout users.

* Remove RTL property addition and depend on PR #60 landing first.

* Fix warnings

* Add line to changelog
2017-04-27 15:43:29 -07:00
Garrett Moon
f92dd7f967 Fix documentation warning on ASCollectionLayoutState.h (#77) 2017-04-27 13:34:25 -07:00
Huy Nguyen
29d6d7df58 ASLayoutSpec to use more default implementations (#73) 2017-04-27 10:46:47 +01:00
appleguy
32c036f440 [CGPointNull] Rename globally exported C function to avoid collisions #trivial (#62)
* [CGPointNull] Rename globally exported C function to avoid collisions.

Some other frameworks also declare this. Let's try to minimize collisions
without making the name too ugly.

* Fix build errors
2017-04-26 17:21:01 -07:00
Adlai Holler
fbb14f5c7c Remove References to IGListSectionType, Now that It's Gone (#49)
* Remove references to IGListSectionType now that it’s gone

* Update changelog
2017-04-26 13:04:03 -07:00
appleguy
09ad3b79b2 [RTL] Bridge the UISemanticContentAttribute property for more convenient RTL support. (#60)
Although apps could handle this before by setting the view's property in didLoad, it's
useful to bridge this property for setting during off-main initialization.

This change also makes RTL fully functional / automatic for Yoga layout users.
2017-04-24 20:08:03 -07:00
appleguy
ce91d3cb3c [ASCollectionView] Prevent prefetching from being enabled to eliminate overhead. (#65)
Some apps explicitly enable this, which is counterproductive with ASDK.
2017-04-24 20:06:28 -07:00
Garrett Moon
8013e25524 Update license v2 (#67)
* Fixed license

* Update all licenses

* Update Dangerfile for new license

* Update already updated licenses

* Closer…

* Closer…

* Closer…

* Closer…

* Closer…

* Closer…

* Closer…

* Closer…

* Closer…

* Closer…

* Closer…
2017-04-24 16:59:57 -07:00
Garrett Moon
2d6ccdb1d9 Fixes a potential deadlock; it's not safe to message likely super nod… (#56)
* Fixes a potential deadlock; it's not safe to message likely super nodes while holding the lock.

* I think this is what @nguyenhuy is looking for :)

* Fix up CHANGELOG.md
2017-04-24 11:25:28 -07:00
Philipp Smorygo
e45c68646a Fix __has_include check in ASLog.h #trivial (#55)
* Fix __has_include check in ASLog.h

* Fix __has_include check in ASLog.h

update changelog

* Fix __has_include check in ASLog.h

Add proper copyright in comment for ASLog.h
2017-04-22 16:50:22 +01:00
Stephen
1f69274a90 GLKit workaround #trivial (#54)
* GLKit workaround:
canClearContentsOfLayer now turned off for views with CAEAGLLayer

* Nits fixed

* Missed square bracket

* Copyright added
2017-04-22 16:47:02 +01:00
Adlai Holler
67387c0978 Build a Tips system (#19) 2017-04-19 19:51:24 -07:00
Phil Larson
dca67c3d49 Use _ASCollectionReusableView inside ASIGListSupplementaryViewSourceMethods (#40) 2017-04-19 13:26:35 -07:00
Huy Nguyen
ed5a13976b ASCollectionLayout needs to set size to measured cells (#24) 2017-04-19 10:35:50 -07:00
Adlai Holler
fdb54a02d9 Fix case where we forget to unlock in ASNetworkImagenode (#17) 2017-04-17 11:38:07 -07:00
Huy Nguyen
dcf858eac1 [ASDisplayNode] Trigger a layout pass whenever a node enters preload state (#3263)
* Add a thread-safe layoutIfNeeded implementation to ASDisplayNode

* Trigger a layout pass when a display node enters preload state
- This ensures that all the subnodes have the correct size to preload their content.

* ASCollectionNode to trigger its initial data load when it enters preload state

* Minor change in _ASCollectionViewCell

* Layout sublayouts before dispatch to main for subclass hooks

* Update comments

* Don't wait until updates are committed when the collection node enters display state

* Same deal for table node

* Explain the layout trigger in ASDisplayNode
2017-04-13 16:25:17 -07:00
Phil Larson
3164d8d013 [ASCollectionNode] Add _ASCollectionReusableView container for supplementary nodes (#3255)
* Add _ASCollectionReusableView container for ASCollectionNode supplementary nodes with applyLayoutAttributes support

• Adds support for -[ASCellNode applyLayoutAttributes:] to supplementary nodes

* Ensure _ASCollectionReusableView has layoutAttributes if the collection view doesn’t set them

* Use correct layoutAttributes accessor for supplementary elements
2017-04-13 16:16:40 -07:00
Huy Nguyen
5ef1d2b541 Improve hash functions of image and text nodes (#3265)
* Improve hash functions of image and text nodes

* Move ASEqualityHashHelpers to Private/
2017-04-13 16:13:21 -07:00
Huy Nguyen
c642771e1c Remove unused initializer in ASTableNode (#3268) 2017-04-13 16:11:32 -07:00
Huy Nguyen
c325ae2cb5 Move thread ownership assertion to ASThread (#3269) 2017-04-13 15:49:32 -07:00
Adlai Holler
390d8f231c Disable event logging by default (#3272) 2017-04-13 13:07:48 -07:00
Christian Selig
3dd2da5b9f Fix incorrect argument label in function comment (#3261) 2017-04-13 18:38:44 +01:00
Huy Nguyen
7d365c7d07 Introduce ASCollectionLayout and friends (#3130)
* Introduce ASCollectionViewLayout
- `ASCollectionViewLayout` is an async `UICollectionViewLayout` that encapsulates its layout calculation logic into a separate thread-safe object which can be used ahead of time and/or on multiple threads.
- `ASDataController` now can prepare for a new layout resulted from a change set before `ASCollectionView` even knows about it. By the time the change set it ready to be consumed by `ASCollectionView`, its new layout is also ready.
- New `ASCollectionViewLayoutCalculating` protocol that is simple and generic enough that many types of calculators can be built on top. `ASCollectionViewLayoutSpecCalculator` conforms to `ASCollectionViewLayoutCalculating` protocol and can be backed by any layout spec (e.g `ASStackLayoutSpec`, `PIMasonryLayoutSpec`, etc). We can even build a `ASCollectionViewLayoutYogaCalculator` that uses Yoga internally.
- A built-in `ASCollectionViewFlowLayoutCalculator` that is a subclass of `ASCollectionViewLayoutSpecCalculator` and uses a multi-threaded multi-line `ASStackLayoutSpec` internally. The result is a performant and thread-safe flow layout calculator.
- Finally, `ASCollectionViewLayout` can be subclassed to handle a specific type of calculator with optimizations implemented based on the knowledge of such calculator. For example, `ASCollectionViewFlowLayout` can have a highly optimized implementation of `-layoutAttributesForElementsInRect:`.

Protocolize layout calculator providing and consuming

Add flex wrap documentation

Add a `multithreaded` flag to ASStackLayoutSpec that forces it to dispatch even if it's off main
- Update ASCollectionViewFlowLayoutSpecCalculator to use that flag.

Minor change in ASCollectionViewLayout

Implement Mosaic layout calculator

Minor change

Fix project file

Rename and fix project file

Skip fetching constrained size only if a layout calculator is available

Update examples/ASCollectionView

Remove unnecessary change in ASTableView

Address comments

Rename collection view calculator protocols

Minor changes after rebasing with master

Add ASLegacyCollectionLayoutCalculator for backward compatibility

Remove ASCollectionLayoutSpecCalculator

Remove ASLegacyCollectionLayoutCalculator

Introduce ASCollectionLayout
- A wrapper object that contains content size and an element to rect table.
- Collection layout calculators to return this new object instead of an ASLayout.

Before adding a content cache

Finishing hooking up ASCollectionLayoutDataSource to ASCollectionNode

Stash

Finish ASCollectionLayout

Rough impl of ASCollectionFlowLayout

Revert changes in CustomCollectionView example

Move ASRectTable back to Private

* Rename ASCollectionContentAttributes to ASCollectionLayoutState

* Address other comments

* Introduce ASCollectionLayoutDelegate and make ASCollectionLayout private

* Address comments

* API tweaks:
- Replace `-layoutContextWithElementMap:` in ASCollectionLayoutDelegate with `-additionalInfoForLayoutWithElements:`. The returned object is then stored in ASCollectionLayoutContext for later lookups.
- ASCollectionLayoutContext has no public initializer.
- ASDataControllerLayoutDelegate no longer requires a context of type ASCollectionLayoutContext but simply an `id`. This helps decouple ASDataController and ASCollectionLayout.
- Rename `elementMap` to `elements`.
- Rename `visibleMap` to `visibleElements`.
- Other minor changes.

* Rename ASCGSizeHash to ASHashFromCGSize

* Make sure to call super in -[ASCollectionLayout prepareLayout]

* Update example/ASCollectionView to use ASCollectionFlowLayoutDelegate

* Remove unnecessary change
2017-04-12 11:13:44 +01:00
Michael Schneider
ae1e299f21 Fix PINRemoteImageManagerPriority deprecation (#3258) 2017-04-11 10:52:10 -07:00
Garrett Moon
8c3775f5e2 Need to check availability before use of macros. (#3254)
* Need to check availability before use of macros.

* Get rid of PCH and enforce macro definition.

* Remove prefix

* Switch to global warning instead, much better.
2017-04-10 15:06:40 -07:00
Garrett Moon
68a8d5f468 Add download resume support (#3246)
* Adds support for resuming downloads that were canceled due to exiting preload range.

* Update to latest PINRemoteImage

* Fix warnings

* Address comments. Thanks @nguyenhuy!
2017-04-10 11:18:05 -07:00
Heberti Almeida
582bca93cb Fix failing batch fetch in some cases. (#3242)
* Fixed failed batch fetch caused by _deceleratingVelocity

* Fixed indentation
2017-04-10 09:35:44 -07:00
Adlai Holler
b41816d40d Standardize Dependency Flags for PINRemoteImage, IGListKit (#3244)
* no message

* Go further

* Make the symbols public so that apps actually build

* Move ASAvailability into the umbrella header

* Remove duplicate define

* Put the file back where it was in the list

* Revert "Put the file back where it was in the list"

This reverts commit 6a80c15b5b5efe5ff39812a018114e8bdc1dc0cf.
2017-04-07 15:04:50 -07:00
Adlai Holler
873ae64cec Remove macOS support (#3245) 2017-04-05 11:58:11 -07:00
Garrett Moon
30ad10da3c _setImage wasn't calling correct implementation (#3243)
_setImage is intended to call the super version of the method,
however with the adoption of the new _locked_ prefix, ASImageNode's
implementation would call back into ASNetworkImageNode's implementation.
This restore the intent of the _setImage method.
2017-04-04 15:13:10 -07:00
Huy Nguyen
75ad248f8c Fix failing build in XCode 8.3 (#3241) 2017-04-04 14:37:45 -07:00
Adlai Holler
e1f7b86756 Add support for IGListKit > 2.1, without IGListCollectionView (#3239) 2017-04-03 12:52:36 -07:00
Adlai Holler
42eb955d8f Range controller: do not schedule range update after rendering finishes if already in full range mode (#3236) 2017-04-03 09:57:16 -07:00
Adlai Holler
c7794a31dd Beef up the headers for ASSectionController and ASSupplementaryNodeSource (#3233) 2017-04-03 11:09:57 +01:00
appleguy
d4af736985 [ASCollectionView] Improve interop to silence invalid layout warnings, fix supplementary passthrough. (#3178)
* [ASCollectionView] Improve interop to silence invalid layout warnings, fix supplementary passthrough.

Before this change, passthrough of supplementary elements didn't work properly -- it would get rehosted into the blank ASCellNode.

* [ASCollectionView] Ensure that IGListKit-handled supplementary views are sent through ASRangeController.

* [ASCellNode] When .shouldUseUIKitCell == YES, don't remove the subviews of the .contentView
2017-04-02 12:11:44 -07:00
Huy Nguyen
6abccf5841 ASDataController can bail early if a change set is empty (#3225) 2017-03-31 10:48:11 -07:00
Huy Nguyen
3d19923731 [Trait collection] Correctly handle changes that occur mid-updates (#3224)
* Add unit test to test trait collection changes occur during updates are handles correctly

* Remove handling code in ASDataController:updateWithChangeSet. Previous test should fail

* Correctly handle trait collection changes that occur mid-updates
- Currently, when there is a new trait collection, we correctly propagate it to all visible elements. However, since the propagating block is executed on main thread immediately without waiting for the background editing queue of ASDataController, not all elements are updated.
- Then to fix that, we updated ASDataController to handle these changes inside updateWithChangeSet. This works, but it doesn’t address the underlying issue.
- We now delegate the propagating task to ASDataController which schedule a block to its main serial queue after waiting for its background editing queue.
2017-03-31 10:47:59 -07:00
Adlai Holler
fcbbea51a6 Fix the Initialization Hierarchy (#3207)
* Fix the initializers setup

* Update Swift example

* Remove incorrect comment

* Add one to ASTableNode
2017-03-28 11:48:20 -07:00
Adlai Holler
27c94069ae Add a category to _ASCollectionViewCell that makes it IGListBindable (#3226) 2017-03-28 11:27:38 -07:00
Michael Schneider
1f042e960d [ASNetworkImageNode] Improve locking (#3187)
* Locking improvements for ASNetworkImageNode

* Fix typo

* Address comments

* Address comments

* Change comment to kick build
2017-03-28 10:42:59 +01:00
Huy Nguyen
0f50cd02c9 Fix locking situation of layout transition (#3217)
- It's not safe to hold the lock of a supernode and:
  - Edit states of its subnodes
  - Call subclass hooks
  - Run completion block
  - Run animation, which can trigger layout passes on subnodes, especially if one of them is a collection view.
2017-03-24 10:35:43 -07:00