664 Commits

Author SHA1 Message Date
Michael Schneider
370d0597df Fix compiler warning in Xcode 8 2016-08-24 15:56:21 -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
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
Adlai Holler
69e73065e5 Avoid accessing itemCountsFromDataSource off-main (#2106) 2016-08-19 12:10:19 -07:00
Adlai Holler
0bd664f9ed Remove numberOfSectionsForSupplementaryNodeOfKind: Method (#2102)
* Add unit test to confirm that supplementary items must be contained within actual sections

* [ASLayoutInspecting] Deprecate collectionView:numberOfSectionsForSupplementaryNodeOfKind:

* Add another test to dig deeper into UICollectionView
2016-08-19 11:18:31 -07:00
Hannah Trosi
971d43ad4d [Build settings] add missing newlines at end of file 2016-08-18 15:01:41 -07:00
Michael Schneider
c409e79714 Fix accessibleElements warning in _ASDisplayView (#2100) 2016-08-18 13:12:19 -07:00
Adlai Holler
f61b7d5d5d [ASDisplayView] Remove some gunk (#2095) 2016-08-18 10:16:09 -07:00
Garrett Moon
86d2ab617e I didn't really understand NSProxy (#2089)
* I didn't really understand NSProxy

But I think I do now :)

Previously I inherited from NSObject because I didn't think I needed
anything fancy, but it turns out NSProxy is *less* fancy than NSObject
and allows for overriding more methods. This change is probably purely
academic in that we don't use this class to forward NSObject specific
messages, but I believe this is the 'right thing'.

* Update comment, thanks @maicki!
2016-08-17 17:59:28 -07:00
Garrett Moon
7d21ccc184 [_ASDisplayViewAccessiblity] Fix accessibility in scroll views (#2079)
* Fixes issues with accessibility elements in scroll views

There are two changes here:

1. Because we can't reliably update the screen positions of accessibility elements
contained within a scroll view, we need to calculate them on demand, so we override
the accessibilityFrame method to do that.

2. Throwing away our calculated accessibility elements on frame change seemed to
cause the accessibility system to be confused.

Combining these two fixes together results in success, yay!

* Don't set the accessibilityFrame, getter is overridden.
2016-08-16 17:01:06 -07:00
Adlai Holler
05dba2263c Make ASWeakSet and NSArray+Diffing public, add support for large arrays (#2078) 2016-08-16 16:47:26 -07:00
Michael Schneider
c65b2efed7 [_ASDisplayViewAccessiblity] Improve accessibility support (#2060)
* First approach to improve accessiblity

* Clear accessibleElements in addSubview: and willRemoveSubview:

* Adjust comments and rename viewNode to node

* Create new accessible elements if screen coordinates of view changes

* Remove legacy clearing of accessibleElements

* Performance improvements

* Use bounds for screenFrame calculation and indexOfObjectIdentical: in indexOfAccessiblityElement:

* Add ASDK_ACCESSIBILITY_DISABLE compiler flag to disable custom accessibility code in ASDK

* No need to set a frame if a subnode view is an accessibility element and not layer backed
2016-08-16 10:27:14 -07:00
Hannah Troisi
14ccb0b886 [ASTextNode] placeholder image shouldn't draw for zero area strings (#2069)
* placeholder should not draw if area is zero

* styling fix

* super precision
2016-08-16 10:20:59 -07:00
Michael Schneider
067e4998e2 Fix methods from ASCollectionDelegate are not passed through to pager delegate (#2074) 2016-08-15 17:23:39 -07:00
Michael Schneider
93be894e0c [ASCollectionView / ASPagerNode] Move constrainedSizeForNodeAtIndexPath from the DataSource to the Delegate (#2065)
* Move constrainedSizeForNodeAtIndexPath from the DataSource to the Delegate in ASCollectionView and ASPagerNode

* Fix ASPagerNode declaration of dataSource and delegate

As ASPagerDataSource does not inherit from ASCollectionDataSource it's not possible to declare it as property.

* Update comment
2016-08-12 15:37:23 -07:00
Adlai Holler
aedb83cfe3 [ASDataController] Remove Unused Batch Update Processing Code (#2054)
* [ASDataController] Remove dead batch updating code

* Address PR comments
2016-08-11 11:48:17 -07:00
Hannah Troisi
2afd063b10 [ASRangeController] Debug overlay to show the size and direction of display + fetchData ranges during scrolling. (#2008)
* Rebase ASRangeController diff with master.

* fix Table / CollectionNode debug label names
- now returns class names rather than generic ASTableNode, ASPagerNode
- ASPagerNode will be labeled as ASPagerNodeProxy (not sure how to get around this)

* refactor layout code: use ASDk's own resizeableRoundedCorner... methods

* Fixes and cleanup for manual layout version of range controller debug overlay.

I am working on a layout spec-based version, but it has some issues, so landing this to get the near-term value is probably the best next step.

* Remove .orig and .rej files.

* One last .orig file to remove.

* Final project file cleanup and tweaks to implementation for ASTableNode.

* fix build issues

* fix arrow directions
2016-08-11 11:23:07 -07:00
Adlai Holler
e80a82f832 [ASDataController] Bail on waitUntilUpdatesAreCommitted if batch updating (#2053) 2016-08-10 14:51:10 -07:00
Hannah Troisi
893e601e81 Convert to type-generic math (#2050)
* [Optimization] Convert to type-generic math

* add std:: prefix in obj-c++ files

* more cleanup

* revert test changes

* convert min and max back to fmin/fmax
2016-08-09 15:31:37 -07:00
Michael Schneider
aba05a747c [ASThread] Add SharedLocker and SharedUnlocker that uses a shared pointer for the mutex (#2047)
* Add SharedLocker and SharedUnlocker that uses a shared pointer for the mutex

* Move ASTextKitContext to use Shared Locker
2016-08-09 15:20:31 -07:00
Adlai Holler
1fbf8ad073 [ASDataController] Cancel if we lose our data source, fix bugs (#1987)
[ASRangeController] We're already on main thread, remove blocks

Make data source read-only, clarify what's asynchronous

[ASDataController] Clean up some interfaces

[ASDataController] A little more cleanup

[ASDataController] Cleanup

[ASDataController] Restore some changes, exit more often

[ASDataController] Use item counts that we already have rather than requerying them

[ASDataController] Revert weakifications

[ASDataController] Add a mechanism to measure how much work we avoided
2016-08-05 15:39:33 -07:00
David Rodrigues
70574243f7 Prevent API misuse at compile time (#2035)
Using Objective-C attributes, in this case `unavailable`, we can hide
unsupported APIs at compile time instead of detecting and warn about it
at runtime with a set of asserts.
2016-08-04 19:00:46 -07:00
Michael Schneider
d5cbe33686 Revert "[ASLayoutSpec] Use childrenMap directly to prevent creating an NSArray within ASDK Part 2 (#2021)"
This reverts commit d5a7c195226925e483c74fb210120d15ff423378.
2016-08-02 10:10:36 -07:00
Michael Schneider
d5a7c19522 [ASLayoutSpec] Use childrenMap directly to prevent creating an NSArray within ASDK Part 2 (#2021)
* Revert "Revert "[ASLayoutSpec] Use childrenMap directly to prevent creating an NSArray within ASDK (#1937)""

This reverts commit 735b4ebd0872483044d98a5d05b43324e76fc8d4.

* Fix crash and add exception for mutating while using fast enumeration of ASLayoutSpec children

NSFastEnumeration is potentially quite dangerous in the wrong hands. In particular, it does not provide a safe mechanism for you to return temporary objects directly, and it does not provide any guarantee that you will be called when the enumeration has completed; therefore if we generate temporaries and store them in an instance variable, we will not necessarily be able to clean them up! This means fast enumeration methods should never be called within an autorelease pool or the autorelease pool be drained within the fast enumeration loop.

The reason is we store references to objects in the stackBuf struct by casting the child pointer to __autoreleasing id. If we pop the autorelease pool between calls to -countByEnumeratingWithState:objects:count:, it will die in a messy explosion of pointer dereferences and EXC_BAD_ACCESS.

* Add tests for ASDisplayNode and ASLayoutSpec fast enumeration
2016-08-01 18:08:48 -07:00
Scott Goodson
735b4ebd08 Revert "[ASLayoutSpec] Use childrenMap directly to prevent creating an NSArray within ASDK (#1937)"
Something interesting going on here with ARC / Objective-C++ that we are investigating and will re-land.

This reverts commit c90ed08d1073701e2c7f8a2677d460c140f05264.
2016-07-31 18:43:20 -07:00
Michael Schneider
c90ed08d10 [ASLayoutSpec] Use childrenMap directly to prevent creating an NSArray within ASDK (#1937)
* Use childrenMap directly to prevent creating an NSArray in ASDK for ASLayoutSpec children

* Add locking for parent property in ASLayoutSpec

* Remove unnecessary import

* Add newline

* Add NSFastEnumeration to ASEnvironment and ASDisplayNode / ASLayoutSpec

* Change NSMutableArray initializer to arrayWithCapacity:

* Move ASLayoutSpec+Private.h into Private folder

Fixes building with Swift

* Remove lock for ASLayoutSpec parent
2016-07-29 10:53:31 -07:00
Hannah Troisi
79e44207e8 Merge pull request #1993 from Yue-Wang-Google/patch-2
[ASRangeController] Fix import misspelling
2016-07-28 15:15:54 -07:00
Yue-Wang-Google
93a5c36a39 Fixed typo in ASCollectionViewFlowLayoutInspector.m pertaining to supplementary node layout. (#1996)
Patch from iOS teams at Google Inc.
2016-07-28 10:13:49 -07:00
ricky
f0b1f12160 [ASEnvironmentTraitCollection] default user interface idiom to UIUserInterfaceIdiomUnspecified (#1998)
* [ASEnvironmentTraitCollection] default user interface idiom to ASEnvironmentTraitCollection

UIUserInterfaceIdiomUnspecified is -1 so we were actually defaulting our trait collection to UIUserInterfaceIdiomPhone (which is 0).

* Fix a few places where we weren’t using the default method to create the base traits
2016-07-28 10:03:32 -07:00
Yue-Wang-Google
b59e368b71 [PATCH] Fix capitalizations in imports. 2016-07-27 14:17:56 -07:00
Hannah Troisi
f5b3a282af Fix Pinterest Xcode 7.3.1 Analyzer Warnings (#1988) 2016-07-27 08:23:16 -07:00
Adlai Holler
aeec0b1a14 [ASChangeSetDataController] Enable some assertions (#1984) 2016-07-25 17:28:24 -07:00
Alice Chang
2bf1b56f55 fixed potential ASPINRemoteImageDownloader crash (#1972) 2016-07-24 16:01:15 -07:00
Tim Johnsen
a6e03e8d93 Fix issue causing ASPINRemoteImageDownloader to return incorrect progress values. (#1966) 2016-07-23 20:09:58 -07:00
Adlai Holler
7ec6f07953 [General] Remove dead code, check optional protocol selector before calling (#1970) 2016-07-22 13:09:28 -07:00
Adlai Holler
3bfa60c445 Move ASDataController+Subclasses.h to fix Swift build 2016-07-21 15:52:24 -07:00
Michael Schneider
9b47a9114a Fix compiler warning in as_smallDescription on 32 bit (#1964) 2016-07-21 14:52:21 -07:00
Adlai Holler
8cde594de3 [ASDataController] Add validation logic to the change set to throw exceptions on invalid updates (#1894)
[_ASHierarchyChangeSet] Oopsy daisy

[ASDataController] Tweak our update validation

[ASHierarchyChangeSet] Fix bugs

Finish up some stuff

[ASDataController] Put some stuff back

[ASChangeSetDataController] Always use changeset

[ASDataController] Put other stuff back

[_ASHierarchyChangeSet] Use fast enumeration

[_ASHierarchyChangeSet] Fix assertion format strings, return on fail so we don't crash in production

[ASDataController] Store data source item counts as vector rather than NSArray

[ASDataController] Build some tests for the update validation

[ASDataController] Fix issues with update validation

Get rid of new file

[ASDataController] Suppress changeset validation before initial reload

[ASDataController] Make invalid update log vs. exception publicly toggleable
2016-07-21 14:37:51 -07:00
Adlai Holler
1777dae300 [ASDataController] Set context variable value 2016-07-18 18:41:51 -07:00
Adlai Holler
46a911ecf4 [ASDataController] Clean up by using a dispatch_group 2016-07-18 15:01:22 -07:00
Adlai Holler
fa34888d98 [ASDataController] Migrate to GCD queue to make debugging easier 2016-07-18 12:15:27 -07:00
appleguy
74bf376b2f [ASDisplayNode] Rename _propertyLock to __instanceLock__ to avoid subclass naming collisions. (#1941) 2016-07-16 15:32:13 -07:00
Hannah Troisi
4baf9bdbfe [Infer] Fix Infer errors/warnings (#1938)
* [Infer] Fix 11 Infer errors/warnings

* fix build error
2016-07-16 15:29:24 -07:00
Hannah Troisi
abf8d5b9aa [Infer] change atomic properties to nonatomic (#1932) 2016-07-16 10:46:55 -07:00
Adlai Holler
dda7accd8e [ASCollectionView] When resizing, invalidate after remeasuring all nodes (#1931) 2016-07-15 16:32:23 -07:00
Michael Schneider
20a49f037b Comment adjustment for laying out nodes 2016-07-15 11:41:10 -07:00
Adlai Holler
cc8e0049c5 Merge pull request #1921 from facebook/AHRangeModeUpdatingIssues
[ASRangeController] Fix Major Range Mode Updating Issues
2016-07-15 10:22:36 -07:00
Adlai Holler
e7fc5a98f2 Merge pull request #1906 from facebook/AHReduceBlockInvocations
[Performance] Various Easy Performance Wins
2016-07-15 10:14:22 -07:00
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