48 Commits

Author SHA1 Message Date
Adlai Holler
9cd0d58373
Rename ASDN C++ namespace to AS (#1366)
* Rename ASDN C++ namespace to "AS." Referring to the framework as ASDisplayNode is pretty out-dated and verbose. See CoreAnimation which usees CA for their internal namespace.

More using

* More cases
2019-03-09 12:14:58 -08:00
Michael Schneider
d4efe95ec5
Improve separation of code for layout method types (#1305)
* Improve separation of code for layout method types

* Address PR comments

- Delegate to layout spec engine if the node is a layout spec node but yoga engine was asked for calculate the layout
- Change ASLayoutType to ASLayoutEngineType
- Improve layout engine fall through code
2019-01-28 07:41:49 -08:00
Michael Schneider
a3763c9c91
Fix crash if setting attributed text on multiple threads (#1141) 2018-10-09 07:39:38 -07:00
Eric Jensen
696f344301 Fix compilation warnings #trivial (#1132)
* Apply recommended warnings

* Squelch designated initializer warning in ASViewController

* Remove unused compiler flag

clang: warning: argument unused during compilation: '-fno-objc-arc-exceptions' [-Wunused-command-line-argument]

* Fix warning about overriding an instance variable within a category

Instance method 'methodOverrides' in category from _ASDisplayView.o overrides method from class in ASDisplayNode.o
2018-09-20 07:54:10 -07:00
Adlai Holler
ceed2d2008 Remove reliance on shared_ptr for ASDisplayNodeLayouts (#1131)
* Remove reliance on shared_ptr for ASDisplayNodeLayouts

* Fix up

* Fix in yoga

* Back to let

* Returns inner pointer

* Trivial change to kick the CI
2018-09-19 11:23:19 -07:00
Adlai Holler
9bcafefa33
Remove use of NSHashTable for interface state delegates #trivial (#1122)
* Remove use of NSHashTable for interface state delegates #trivial

* Stray line

* One more case

* Add code to let people have more delegates

* Do it more
2018-09-17 14:29:22 -07:00
Max Wang
bf8d268573 Interface state not update correctly during layer thrash. (#1111)
* fix SIMULATE_WEB_RESPONSE not imported #449

* Fix to make rangeMode update in right time

* remove uncessary assert

* Fix collection cell editing bug for iOS 9 & 10

* Revert "Fix collection cell editing bug for iOS 9 & 10"

This reverts commit 06e18a10596622ff8a68835c95a23986d7bf61ea.

* Fix interface state not update correctly during layer thrash

* add change log
2018-09-17 10:11:04 -07:00
Adlai Holler
395fbd1302 Reuse interface state delegates when calling out #trivial (#1099)
* Reuse interface state delegates when calling out instead of always copying
2018-09-05 22:52:41 -07:00
appleguy
465abb1ded [License] Simplify the Texture license to be pure Apache 2 (removing ASDK-Licenses). (#1077)
* [License] Simplify the Texture license to be pure Apache 2 (removing ASDK-Licenses)

With permission of the Facebook Open Source team, we are simplifying the Texture
license so that clients can rely on the Apache 2 terms that most of Texture is
already covered by. This means that code originally forked from AsyncDisplayKit
will be re-licensed from "BSD 3-clause + PATENTS v2" to Apache 2 without a
PATENTS file.

After getting confirmation that the updates to these core files look good, we'll
propagate this new license header to all files (in this same PR) and get sign-off
from all parties before landing.

* [License] Update all Texture source files to be pure Apache 2.

* Changelog entry for Apache 2 license update.

* Revert "[License] Update all Texture source files to be pure Apache 2."

This reverts commit ffa0fbbba9717d871dd16c4b07539f2f8208fc2b.

* [License] Update all Texture source files to be pure Apache 2, maintaining copyrights.

* [License] Update CONTRIBUTING, README, Podspec & Dangerfile.
2018-08-28 07:39:18 -07:00
Adlai Holler
c5b1d09b49
Remove direct ivar access on non-self object to fix mocking case #trivial (#1066)
* Remove direct ivar access on non-self object to prevent issues when the object is actually a mock

* Comment

* Remove lock to avoid deadlock risk
2018-08-03 16:35:24 -07:00
Adlai Holler
40e3bf8952
Remove objc association & weak proxy from node -> controller pointer (#1061)
* Remove objc association & weak proxy from node -> controller relationship

* Rename ASNodeController+Beta.m to ASNodeControllerx+Beta.mm

Currently we can't import ASDisplayNodeInternal from C

* Update project pointers

* Rename ASNodeControllerx+Beta.mm to ASNodeController+Beta.mm
2018-08-03 10:24:37 -07:00
Michael Schneider
b1f6030e86 Create and set delegate for clip corner layers within ASDisplayNode (#1029)
* Create and use ASDisplayNodeCornerLayerDelegate

* Return kCFNull for actionForLayer:forKey:
2018-07-18 02:56:37 -07:00
Huy Nguyen
0dc97fbb2f
Stricter locking assertions (#1024)
- Rename `ASDisplayNodeAssertLockUnownedByCurrentThread` to `ASAssertUnlocked`, and `ASDisplayNodeAssertLockOwnedByCurrentThread` to `ASAssertLocked` -> shorter and hopefully easier to distinguish between the two.
- Add assertions to `_locked_` and `_u_` (i.e "unlocked") methods.
- Turn `CHECK_LOCKING_SAFETY` flag on by default. After #1022 and #1023, we're in a good shape to actually enforce locked/unlocked requirements of internal methods. Our test suite passed, and we'll test more at Pinterest after the sync this week.
- Fix ASVideoNode to avoid calling `play` while holding the lock. That method inserts a subnode and must be called lock free.
- Simplify `_loaded(node)` to only nil-check `_layer` because regardless of whether the node is view or layer backed, the layer should always be set if loaded. Use it throughout.
- Other minor changes.
2018-07-13 14:58:16 -07:00
Michael Schneider
6c487dd26c
Properly consider node for responder methods (#1008)
* Properly consider node for responder methods

* Add changelog
2018-07-06 08:32:03 -07:00
Garrett Moon
a4f78ad3e0
Adds support for having multiple interface state delegates. (#979)
* Adds support for having multiple interface state delegates.

Hopefully in a performant way.

* Switch to respondsToSelector for int del instead of separate object

* Add CHANGELOG

* Make ASDisplayNode+InterfaceState.h public

* Huy's comments

* Don't even bother removing since it's a weak hash table.
2018-06-27 16:52:40 -07:00
Adlai Holler
dbe469a94a
Standardize "extern" decls on AS_EXTERN (#972)
* Standardize "extern" decls on AS_EXTERN

* Rebase & remove from implementation files
2018-06-18 15:53:34 -07:00
Adlai Holler
cac14e0bce
Standardize Property Declaration Style in Core Classes (#870)
* Audit property attributes for core classes

* Update style guide

* Go crazy

* Update changelog
2018-05-24 14:42:43 -07:00
Yevgen Pogribnyi
7f01b89ddc [ASDisplayNode] Provide safeAreaInsets and layoutMargins bridge (#685)
* [ASDisplayNode] Add safeAreaInsets, layoutMargins and related properties to ASDisplayNode

* Add layoutMargins bridged to the underlying view

* Add safeAreaInsets bridged to the underlying view

* Add fallback calculation of safeAreaInsets for old iOS versions

* Add automaticallyRelayoutOnSafeAreaChanges and automaticallyRelayoutOnLayoutMarginsChanges properties

* Add additionalSafeAreaInsets property to ASViewController for compatibility with old iOS versions

* Provide safeAreaInsets for layer-backed nodes.

This also fixes tests.

* Fix crash when insetsLayoutMarginsFromSafeArea is set from a background thread

* Changes requested at code review:
* Update documentation for layoutMargins and safeAreaInsets properties. Suggest that users set the automaticallyRelayout* flags to ensure that their layout is synchronized to the margin's values.
* Fix accessing ASDisplayNode internal structures without a lock.
* Add shortcut in -[ASDisplayNode _fallbackUpdateSafeAreaOnChildren] to skip a child when possible.
* Add shortcut in ASViewController to avoid fallback safe area insets recalculation in iOS 11. Fix fallback safe area insets recalculation when the additionalSafeAreaInsets are set.
* Add debug check that a view controller's node is never reused without its view controller, so the viewControllerRoot flag value is always consistent.
* Use getters instead of reading ivars directly in -layoutMarginsDidChange and -safeAreaInsetsDidChange.

* Minor change in CHANGELOG

* Minor change in ASDisplayNodeTests.mm
2018-03-27 14:29:17 +01:00
Adlai Holler
0f9b1e6789
Make objects conform to NSLocking (#851)
* Make display node, layout spec, and style conform to NSLocking so that users/subclasses can access their locks

* Update the changelog

* Align slashes

* Put it back, when we're in ASDisplayNode

* Go a little further

* Put back the changes I didn't mean to commit

* Kick the CI

* Fix yoga build

* Put back non-locking change

* Address comments from Scott
2018-03-25 10:46:04 -07:00
Michael Schneider
236cdd799c
Fix UIResponder handling with view backing ASDisplayNode (#789)
* Add failing tests

* Fix responder chain handling in Texture

* Add mores tests that horrible fail

* Add Changelog.md entry

* Some fixes

* Update logic

* Add tests that prevents infinite loops if a custom view is overwriting UIResponder methods

* Add macro to forward methods in ASDisplayNode

* Add macro for forwarding responder methods in _ASDisplayView

* Remove junk

* Address first comments

* Update _ASDisplayView to cache responder forwarding methods

* Use XCTAssertEqual
2018-02-23 09:10:09 -08:00
Max Wang
2618c50073 New runloop queue to coalesce Interface state update calls. (#788)
* fix SIMULATE_WEB_RESPONSE not imported #449

* Coalesce interface state updates to ASCATransactionQueue before CATransaction commit.

This will avoid duplicate interface state delegate calls caused by view repeatly added/removed to/from hierarchy during controller animation transition.

* fix tests for new run loop queue

* Support for disabling ASCATransactionQueue

* Fix didExitHierarchy to use ASCATransactionQueue.

* merge range managed and none range managed for didExitHierarchy

* Revert "merge range managed and none range managed for didExitHierarchy"

This reverts commit f807efaa65ed5dbdb6622d06da542e01a53715fa.

* merge range managed and none range managed for didExitHierarchy

* remove metadata

* abstract queue to impl class methods

* Add tests

* Fix test fail because of shared object.

* guard _pendingInterfaceState access with lock

* name refactor

* Refactor from comments https://github.com/TextureGroup/Texture/pull/788/\#pullrequestreview-94849919

* Apply InterfaceState immediately after ASCATranactionQueue is processed and before next runloop started.

* refactor

* no op to start CI build

* remove unused var and kick off tests

* change lisence

* remove code for weak ref

* add change log and adjust license
2018-02-13 12:10:20 -08:00
Alex Hüllmandel
76eccbf269 Added attributed versions of accessibilityLabel, accessibilityHint, accessibilityValue (#554)
* Added attributed versions of accessibilityLabel, accessibilityHint and accessibilityValue

* Follow conventions for property types

* Use curly braces

* Update changelog

* Follow conventions for property types in UIView+ASConvenience.h

* Add compatibility for Xcode 8

* Use isEqualToString instead of pointer comparison

* Only allocate attributed strings once. Use _setAttributedAccessibilityToViewAndProperty only for attributed properties.
2017-09-18 18:07:01 +01:00
appleguy
e330e57668 [ASCornerRounding] Introduce .cornerRoundingType: CALayer, Precomposited, or Clip Corners. (#465)
* [ASCornerRounding] Initial (untested) implementation of ASCornerRounding features.

* [ASCornerRounding] Working version of both clip corners and precomposited corners.

* [ASCornerRounding] Improve factoring and documentation of corner rounding features.

* [ASCornerRounding] Some final fixups.

* Add entry to changelog for .cornerRoundingType
2017-09-18 13:02:51 +01:00
Huy Nguyen
4ba6f451f6 [Cleanup] Remove deprecated APIs (#529)
* Remove preferredFrameSize

* Remove -measure:

* Remove -measureWithSizeRange:

* Remove ASLayoutable

* Remove .name

* Remove deprecated style forwardings

That includes following properties that are declared on ASDisplayNode and ASLayoutSpec: spacingBefore, spacingAfter, flexGrow, flexShrink, flexBasis, alignSelf, ascender, descender, sizeRange and layoutPosition.

* Remove usesImplicitHierarchyManagement

* Remove deprecated range update callbacks:
-visibilityDidChange:
-visibleStateDidChange:
-displayStateDidChange:
-loadStateDidChange:

* Remove -clearFetchedData

* Remove -cancelLayoutTransitionsInProgress

* Remve ASDisplayNode+Deprecated.h

* Remove ASLayoutRangeTypeRender and ASLayoutRangeTypeFetchData

* Remove -[ASTableView clearContents]

* Remove reloadDataImmediately

* Remove ASStaticLayoutSpec

* Remove ASDimensionDeprecated

* Remove optional -pagerNode:constrainedSizeForNodeAtIndex: delegate method in ASPagerDelegate

* Remove suppressesInvalidCollectionUpdateExceptions

* Remove -[ASCollectionViewLayoutInspector initWithCollectionView]

* Remove ASVideoPlayerNode.loadAssetWhenNodeBecomesVisible

* Update CHANGELOG

* Update license of ASLayoutSpecTests.m

* Update examples/PagerNode

* Remove ASEnvironmentTraitCollection

* Remove -ASViewController.nodeConstrainedSize

* More on removing ASLayoutable
2017-09-07 19:25:42 +01:00
appleguy
5cf05f3c17 [Accessibility] Add .isAccessibilityContainer property, allowing automatic aggregation of children's a11y labels. (#468)
After consulting Apple documentation and working with some a11y experts,
we've found that aggregating objects that have a11y labels but are not
themselves interactable is significantly preferred for these users.

It makes it much quicker to navigate scrolling content if VoiceOver only
stops to select entire cells, and then allows drilling down into the cell
to select individual components. This implementation achieves that behavior.

We should consider enabling isAccessibilityContainer by default on ASCellNode.
This would be an improvement for 95% of a11y use cases. Aggregation can be
enabled or disabled on any node.
2017-08-20 13:17:05 -07:00
Adlai Holler
1fa498873e Use a sentinel NSUInteger for node layout data #trivial (#428)
* Use a sentinel NSUInteger for node layout data

* Add a comment

* Address feedback from @appleguy
2017-07-10 12:10:04 +00:00
appleguy
8c33a617ed [Yoga] Delete YOGA_TREE_CONTIGOUS gating and permanently enable. (#370)
[Yoga] Delete YOGA_TREE_CONTIGOUS gating and permanently enable. #trivial
2017-06-18 18:18:59 -07:00
appleguy
486410d7d6 [Yoga] Minimize number of nodes that have MeasureFunc set on them. (#369)
This has one important benefit: fixing the stretching behavior of spacer nodes.

In addition, it should help efficiency of Yoga and certainly minimize calls
to layoutThatFits:.

Next up for Yoga is a mostly-red diff, deleting the non-Contiguous code branches.
2017-06-18 18:18:12 -07:00
appleguy
55928f343d [Yoga] Rewrite YOGA_TREE_CONTIGUOUS mode with improved behavior and cleaner integration (#343)
* [Yoga] Rewrite YOGA_TREE_CONTIGUOUS mode with support for mixing with ASLayoutSpec.

After experimentation with the ASYogaLayoutSpec (or non-contiguous) approach to
integrating Yoga, test results and feedback from the authors of Yoga have shown
that this approach can't be made completely correct,

There are issues with some of the features required to represent Web-style
flexbox; in particular: padding, margins, and border handling have varience.

This diff is a first step towards a truly correct and elegant implementation of
Yoga integration with Texture. In addition to reducing the footprint of
the integration, which is an explicit goal of work at this stage, these changes
already support improved behavior - including mixing between ASLayoutSpecs
even as subnodes of Yoga layout-driven nodes, in addition to above them. Yoga
may be used for any set of nodes.

Because Yoga usage is limited at this time, it's safe to merge this diff and
further improvements will be refinements in this direction.

* [ASDKgram] Add Yoga layout implementation for PhotoCellNode.

* [Yoga] Final fixes for the upgraded implementation of the Contiguous layout mode.

* [Yoga] Add CHANGELOG.md entry and fix for Yoga rounding to screen scale.

* [Yoga] Minor cleanup to remove old comments and generalize utility methods.
2017-06-14 19:36:13 -07:00
appleguy
81def94f6f [ASTraitCollection] Convert ASPrimitiveTraitCollection from lock to atomic. (#355)
* [ASTraitCollection] Convert ASPrimitiveTraitCollection from lock to atomic.

This resolves a deadlock case: https://github.com/TextureGroup/Texture/issues/353

* [ASTraitCollection] Use assignment operator instead of .store() for C++ atomic.
2017-06-14 13:55:52 -07:00
Huy Nguyen
05e9bdd092 Small changes required by the coming layout debugger (#337)
* Small changes required by the layout debugger
- `ASDisplayNode` can be told to not flatten its layout immediately but later on. The unflattened layout is also stored in a separate property. It's needed for inspecting not only display nodes but also layout specs used to compute a layout tree.
- `ASLayout` can be told to always retain its sublayout elements. This is needed especially for layout specs since they are usually not retained after an ASLayout was computed.

* Update CHANGELOG

* Address comments
2017-06-08 10:47:50 -07:00
appleguy
b285ece35f [Yoga] Implement ASYogaLayoutSpec, a simplified integration strategy for Yoga. (#270)
* [Yoga] Implement ASYogaLayoutSpec, an experimental alternative to full-tree integration.

This approach allows us to avoid any ASDisplayNode.mm integration points.
However, it is not yet proven to be possible to achieve correctness with this approach.

The entry point (to start calculating), and the measurement function inputs, lack
the full expressiveness of ASSizeRange; we need to make sure that workarounds like
using style.minSize are successful in simulating the behavior of a full Yoga tree.

* [Yoga] Fix file comments, move towards <ASLayoutElement> support.

* [Yoga] Important fix for simplified, non-contiguous Yoga integration.

* [Yoga] Complete implementation of manual memory management (__bridge_transfer, YGNodeFree)
2017-05-29 15:39:24 -07:00
Huy Nguyen
6aa5ad7703 Only call -layout and -layoutDidFinish if the node is already loaded (#285)
* Only call -layout and -layoutDidFinish if the node is already loaded

* Minor change

* Update CHANGELOG
2017-05-19 15:06:26 +01:00
Adlai Holler
7df1a20c5f Simplify Layout Transition State #trivial (#269)
* Port the changes to the latest master

* Remove extra s
2017-05-15 16:33:44 -07:00
Michael Schneider
b32e69d64b [Layout] Extract layout implementation code into it's own subcategories (#272)
* Extract layout code into ASDisplayNode categories

* Category renaming and documentation

* Changelog

* Change header
2017-05-15 11:10:59 -07:00
Michael Schneider
4dbbba7d32 Remove instance method of -drawRect:withParameters:isCancelled:isRasterizing: (#232) 2017-05-09 14:02:33 -07:00
Michael Schneider
3738f1f6e2 [ASImageNode] Move to class method of displayWithParameters:isCancelled: for drawing (#244)
* Remove instance displayWithParameters:isCancelled:

* Address comments
2017-05-09 13:03:30 -07:00
Adlai Holler
80357b1c7c Don't use associated objects for ASDisplayNode.drawingPriority (#239) 2017-05-05 08:22:30 -07:00
Michael Schneider
b6734faa3b Extract ASLayoutElement and ASLayoutElementStylability into categories #trivial (#131)
* Initial move of code into layout category

* Cleanup

* Some more
2017-05-02 14:38:06 -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
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
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
Adlai Holler
67387c0978 Build a Tips system (#19) 2017-04-19 19:51:24 -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
Michael Schneider
bc05227631 Check in layout transition if the supernode is still the node that is executing the transition (#3181)
We have to check in this case if the supernode of the subnode is indeed the _node that executes a layout transition. It can happen that a node already did a layout transition and added this subnode, in this case the subnode would would be removed from the new node instead of _node.
2017-03-15 13:20:01 -07:00
Michael Schneider
e6ee24debc [ASDisplayNode] Improve locking in ASDisplayNode (#3172)
* Improve locking in ASDisplayNode

* Address first bunch of comments

* Changed `view` and `layer` methods for locking

* Adress comments
2017-03-14 07:27:34 -07:00
Adlai Holler
73ca6ab514 Shuffle & Cleanup Stuff (#3080) 2017-02-26 18:14:13 -08:00