40 Commits

Author SHA1 Message Date
Michael Schneider
a71a1d8519 Address comments 2016-11-19 06:43:46 -08:00
Michael Schneider
5d84f21fda Add sizeThatFits: to _ASDisplayView 2016-11-19 06:43:46 -08:00
Adlai Holler
88d588d590 [ASDisplayNode] Use Weak Proxy to Avoid Dangling CALayer.delegate (#2249)
* Add weak proxy between node and layer to avoid dangling layer problem

* Add failing test case for dangling CALayer.delegate pointer issue

* Add docs

* Remove asynctransactioncontainer forwarding preprocessor macro

* Improve comments

* Remove asyncTransactionContainerStateDidChange callback
2016-09-15 10:49:31 -07:00
Adlai Holler
84e633137b [Layout] Use _addSubnode / _removeFromSupernode methods in _ASDisplayView 2 (#2232)
* Use `_addSubnode` / `_removeFromSupernode` methods in _ASDisplayView

* Change name
2016-09-12 10:46:43 -07:00
John Engelhart
8c2f3f666f Fixes unsafe use of asyncdisplaykit_node. (#2207)
The previous code used either a `@property` with `assign, nonatomic` semantics, or a `__unsafe_unretained` (non-atomic) ivar pointer to an instance for `asyncdisplaykit_node`.

This commit changes those access so that they have the equivalent of `weak, atomic` semantics.

- `_ASDisplayView.mm`
  - Removes the `_node` ivar that was qualified with `__unsafe_unretained`.
  - Removes `@synthesize asyncdisplaykit_node = _node;`.
  - All direct uses of `_node` were replaced with:
    - Creates a strong reference via `ASDisplayNode *node = _asyncdisplaykit_node;`.
    - `s/_node/node/`.
    - These changes were made even if there's a single use of `_asyncdisplaykit_node` as a consistency / defensive measure so that anyone editing this code in the future does not accidentally use a `weak` reference twice.

- `ASDisplayNode.mm`
  - Getters and setters for `asyncdisplaykit_node` were changed from `nonatomic, assign` semantics to the equivalent of `atomic, weak` semantics.
  - `weak` semantics were implemented by using a `ASWeakProxy` object.
  - `objc_setAssociatedObject` was changed from `OBJC_ASSOCIATION_ASSIGN` to `OBJC_ASSOCIATION_RETAIN` (the `atomic` version of retain).

- `ASDisplayNode+FrameworkPrivate.h`
  - Changed the `@property` declarations for `asyncdisplaykit_node` from `nonatomic, assign` to `atomic, weak`.
    - The actual getters and setters are implemented in `ASDisplayNode.mm`, which were changed accordingly.
2016-09-08 17:27:49 -07:00
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
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
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
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
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
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
Eric Jensen
527397ba7e Replace id with instancetype in initializers 2016-04-13 11:20:05 -07:00
Michael Schneider
2fade63f1b Add handling layer backed accessibility elements within layer backed nodes 2016-04-11 12:59:04 -07:00
Michael Schneider
14ca529911 Moving accessibility related code to _ASDisplayViewAccessibility 2016-04-09 11:23:25 -07:00
Michael Schneider
3b91c22fdf Recreate the accessibleElements if accessed 2016-04-09 11:23:25 -07:00
Michael Schneider
34df512eeb Remove ASNodeValidForAccessibility 2016-04-09 11:23:25 -07:00
Michael Schneider
ef31c3abf0 Copy accessibilityIdentifier to UIAccessibilityElement if a node is assigned 2016-04-09 11:23:25 -07:00
Michael Schneider
4056bf9ef3 Return NO if node i not valid for accessibility 2016-04-09 11:23:25 -07:00
Michael Schneider
03a7c55d59 Add accessibility support for shouldRasterizeDescendants and layerBacked nodese 2016-04-09 11:23:25 -07:00
Michael Schneider
9c29d0efa8 Initial commit for improved accessibility support 2016-04-09 11:23:25 -07:00
Scott Goodson
3e2414da6f [ASInterfaceState] Fix for an edge case of exiting Visible state before node deallocation. 2016-03-27 18:15:40 -07:00
Eric Jensen
33fda7ab49 - Use modern Objective-C syntax.
-  Simplify comparisons.
-  Remove dead stores.
2016-03-15 22:34:29 -07:00
Huy Nguyen
9162d7b2df Implement thread-safe bounds and use it in ASTextNode 2016-03-02 22:42:53 -08:00
Aaron Schubert
28b03e3a28 [tvOS] Expose UIFocusEnvironment Protocol methods to ASDisplayNode 2016-01-13 10:09:44 +00:00
Scott Goodson
df3ce787f7 Ensure that the uncommon __unloadNode codepath does not unintentionally trigger node removal. 2015-12-29 23:11:33 -08:00
Scott Goodson
92126f0d66 Support surprisingly nice automatic behavior for the unsupported case of view-backed nodes as children of layer-backed ones. 2015-12-19 20:33:28 -08:00
Scott Goodson
bbc0452a7a Improve UIView & CALayer handling of -addSubnode:, and ensure node hierarchies are hooked up even when addSubview: is used directly. 2015-12-19 18:29:05 -08:00
Scott Goodson
840884272d Introduced ASHierarchyState. Created ASDisplayNode+FrameworkPrivate.h. Fixed deadlock. 2015-12-05 22:20:16 -08:00
Jack Flintermann
0b14d42033 add UIResponder methods to ASDisplayNode 2015-06-27 03:19:51 -04:00
Scott Goodson
904905189c Remove -[_ASDisplayView layoutSubviews] and use only -[_ASDisplayLayer layoutSublayers].
This helps us support special cases such as ASScrollNode correctly driving the -layout
method for subclasses even though it is based on UIScrollView & can't use _ASDisplayView.

I suspect this will be useful for ASCollectionNode and ASTableNode as well, which would
allow nesting those classes inside of other collections / tables (e.g. horizontal
unit within a vertical unit).
2015-06-20 19:40:01 -07:00
Ryan Nystrom
b6715b5cf9 Forward touches to super instead of the superview
fixes #402
2015-03-26 21:11:13 -07:00
Brian Amerige
9019233c68 Support Forwarding Responder-Chain Actions to Node from its View
Summary:
What it says on the tin. This allows Nodes to effectively participate in the responder chain.

Caveat: see note in implementation below. Would have been nice to use `-targetForAction:withSender:` the way the docs imply you can, but alas.

Test Plan: Observe a node in the responder chain get invoked to handle an action it implements.

Reviewers: bcunning, zsh, sma, jpasqualini, suv, nyn531, b3ll, aaronpang, kimon, grp, jonathan, rnystrom, nadi

Reviewed By: nadi

Subscribers: trunkagent, rnystrom

Differential Revision: https://phabricator.fb.com/D1894023

Signature: t1:1894023:1426026643:203945b6a7c318f6d2c9b94d876da61da31327bd
2015-03-11 14:37:17 -07:00
Ryan Nystrom
7b86303f20 Forward touch events to either the node or super
`_ASDisplayView` now forwards touch events to either super or it's node, depending on whether or not the node implements the methods.

fixes #199
2015-01-06 16:06:59 -08:00
Ryan Nystrom
f3be4ee041 Call touch methods on _ASDisplayView super
Currently we miss calling `-[super touches*]` on `_ASDisplayView` touch events. We delegate handling to the node which then forwards all touch events to the *superview*, skipping the current view. This seems to have some side effects with `UITableView` and it's cells/content views.

fixes #188
2014-12-30 09:47:05 -08:00
Nadine Salter
51f3073c33 ASDisplayNode.inWindow -> .inHierarchy.
This is a remnant from before `willAppear` and `didDisappear` were
renamed to better reflect their hierarchy-change status (being added to
the hierarchy != being visible).  May be useful for turians.
2014-12-02 18:06:11 -08:00
David Beck
4ed2120cfa Added tintColor convenience methods
tintColor is now forwarded to the underlying view, and much more importantly, the node is notified when the tintColor changes on the view.
2014-10-23 19:51:10 -07:00
Scott Goodson
f7d91bb877 Implement -reclaimMemory API and switch to manually controlled content clearing.
ASDisplayNode and several subclasses had previously cleared memory-heavy
objects like the backing store and text layout manager when the node's
view
or layer is removed from a visible heirarchy.  This works great in any
system
that uses a "working range", where exiting the range removes the node
from
the hierarchy and reclaiming memory at that time is important.
However, for
standard UIViewController patterns (unused in Paper), this behavior
causes
highly undesirable thrashing (leading to visible flashes & wasteful
re-rendering of content).

After this change, node subclasses should implement -reclaimMemory if
they
need to perform any other cleanup besides backing store destruction
when they
leave a working range or other scenario where memory reduction is
valuable.

To trigger this behavior, calling code should use
-recursivelyReclaimMemory.

r=nadi
2014-10-14 18:45:56 -07:00
Nadine Salter
803585164c Convert AsyncDisplayKit to ARC. 2014-09-23 15:30:30 -07:00
Nadine Salter
15565873c9 Initial commit. 2014-06-26 22:32:55 -07:00