45 Commits

Author SHA1 Message Date
Garrett Moon
9b80eabd8f Adds support for using UIGraphicsImageRenderer in ASTextNode. (#1384)
* Adds support for using UIGraphicsImageRenderer in ASTextNode.

In many cases this reduces the backing store of text nodes by 1/2.

* Guard for UIGraphicsRenderer availability.

* Comma
2019-03-09 07:55:46 -08:00
Adlai Holler
2a4b77b6d5
Remove let and var macros now that we're all-C++ (#1312)
* Remove let and var macros now that we're all-C++

* Another fix

* More!

* And more!
2019-01-17 10:16:53 -08:00
dmaclach
7cddc2b1be Reduce startup time. (#1288)
Make global static a function local static. This stops it from being
initialized premain and affecting startup time.
2018-12-18 16:45:00 -08:00
Michael Schneider
f2bc63f05a
Add way to compile out ASTextNode + TextKit dependencies (#1242)
* Add way to compile out ASTextNode + TextKit dependencies

* Compile out ASExperimentalTextNode and fix tests
2018-11-23 09:13:15 -08:00
Adlai Holler
0380b270bb
Address Xcode warnings about unguarded availability and implicit self retains (#1207) 2018-11-01 19:40:16 -07:00
Michael Schneider
25a3d331ee
Correct linePositionModifier behavior (#1192) 2018-10-26 07:43:22 -07:00
Michael Schneider
dab3281afa
Don’t handle touches on additional attributed message if passthrough is enabled (#1184)
* Don’t handle touches on additional attributed message if passthrough is enabled

* Cleanup

* Don't handle extra inAdditionalTruncationMessage within pointInside:withEvent:

* Update changelog

* Address comments
2018-10-24 07:49:58 -07:00
Michael Schneider
776e475558
Expose a way to determine if a text node will truncate for a given constrained size #trivial (#1177)
* Expose textLayoutForConstraint:

- Expose textLayoutForConstraint:, but make unavailable on ASTextNode
- Refactor compatibleLayoutWithContainer:text: into a static method

* Instead of textLayoutForConstraint: expose shouldTruncateForConstrainedSize: in ASTextNode
2018-10-21 09:33:26 -07:00
Jia Wern Lim
e6964d1ade [ASDisplayNode] Expose default Texture-set accessibility values as properties (#1170)
* Expose default Texture-set accessibility values as properties in ASDisplayNode.

Added relevant overrides and tests.

* Quick style fixes & add default a11y overrides to ASTextNode too.
2018-10-19 07:39:21 -07:00
Michael Schneider
a3763c9c91
Fix crash if setting attributed text on multiple threads (#1141) 2018-10-09 07:39:38 -07:00
Eric Jensen
565da7d493 Add missing NS_NOESCAPE in overwritten methods (#1139)
Fixes -Wmissing-noescape warnings
2018-10-04 09:33:08 -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
78be342e77
[ASTextNode2] Simplify allocWithZone: + initialize implementation #trivial (#1059)
* Simplify ASTextNode2 alloc + initialize implementation

* Kick the CI by marking two methods as NO_ESCAPE for Xcode 10
2018-08-02 07:36:26 -07:00
Flatout73
4b5b90f7a0 [ASTextNode] One more check variables before calling delegate method #trivial (#922) 2018-07-20 15:15:50 -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
55abeed743
Introduce let / var macros and some further cleanup (#1012)
* Introduce let / var and some further cleanup

* Address first comments

* Update changelog

* Move the const before auto
2018-07-10 09:37:53 -07:00
Michael Schneider
b82128ee4e
Add missing instance variables in ASTextNode and warnings cleanup #trivial (#984)
* Add missing instance variables in ASTextNode and warnings cleanup

* Re-add drain
2018-06-24 08:56:10 -07:00
Adlai Holler
a11506564a
Reduce usage of autorelease pools (#968)
* Reduce reliance on the autorelease pool

* changelog

* A few more places

* Use it in another place
2018-06-15 10:15:25 -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
Abdurahim Jauzee
382f624d83 [ASTextNode] Check variables before calling delegate method #trivial (#898) 2018-05-11 17:24:26 +01:00
appleguy
9de33361dc [ASTextNode] Fix a deadlock that could occur when enabling experimental ASTextNode2 via ASConfiguration (#903)
Because multiple threads can enter this allocWithZone: method around the same time, it is possible for one of them to setSuperclass first, and then the second thread would get stuck in an infinite loop. When climbing the inheritance heirarchy, ASTextNode2 would be encountered by this second thread, and it would continue until reaching c == Nil. Since there was no case to catch this, an infinite loop would result. Then the main thread can be deadlocked if a method like waitUntilAllUpdatesAreProcessed is called on ASCollectionView.
2018-05-03 03:51:59 -07:00
Adlai Holler
27fac9f586
Create a centralized configuration API (#747)
* Update the dangerfile

* Make a trivial change to test new dangerfile

* Try out the new value with another trivial change

* Add a configuration API to make a unified place for pulling config from clients safely

* Specify properties for delegate

* Finish removing text experiment global enable

* Generate the config file

* Clean up configuration to fix tests

* Work on making it serializable

* Finish it up

* Fix example code

* Update sample project

* Clean up a few things

* Align with new project order

* Make it faster and update license header

* Add an option to specify your config at compile time

* Update another license header

* Add a version field, and bring interface state coalescing into configuration

* Update CA queue code

* Update CATransactionQueue tests

* Turn transaction queue on by default (for now, see comment)

* Update the tests

* Update the tests AGAIN

* Remove unused ordered set
2018-03-25 12:52:57 -07: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
Adlai Holler
9bffd88134
Fix Text Node Thread Sanitizer Warning (#830)
* Fix thread sanitizer warning in ASTextNodeRendererKey

* Update changelog

* Comment on missing class check
2018-03-12 10:42:24 -07:00
Alex Hill
d9d9a29365 [tvOS] Fixes errors when building against tvOS SDK (#728)
* [tvOS] Fixes errors when building against tvOS SDK

* Update CHANGELOG.md

* [tvOS] Fixes implicit conversion between UIViewAnimationCurve +
UIViewAnimationOptions

* Enable tvOS deployment target in Texture.podspec (for CI)

* [ASMultiplexImageNode] Fixes typo

* [tvOS] Fixes warnings related to @available guards in Xcode 9
[ASMultiplexImageNode] Enables support for Photos framework on tvOS 10+

[ASMultiplexImageNode] Fixes comment depth

[ASAvailability] Adjust logic in AS_AVAILABLE_IOS_TVOS to account for
both versions
Adjusts API_AVAILABLE to minimum deployment target

* [ASAvailability] Update AS_AVAILABLE_XXX fallbacks to function more like
the built-in solution (more accurately target OS by checking target)
Change AS_AVAILABLE_IOS -> AS_AVAILABLE_IOS_TVOS in places that shoud
allow for both

[ASAvailability] Simplify AS_AVAILABLE_IOS_TVOS

* [ASControlNode] Adds missing 'super' call in -[ASControlNode didLoad]
when targeting tvOS

* Fix API_AVAILABLE iOS requirement

* [ASDisplayNode] Fixes last of the linker warnings related to category
overrides. Removes methods already implemented in
ASDisplayNode+UIViewBridge category.
[ASControlNode] Moves tvOS category declaration to ASControlNode header
[ASImageNode] Moves tvOS category declaration to ASImageNode header
[ASControlNode+Private] Adds private category for ASControlNode to
access private selectors

* [NSParagraphStyle+ASText] Fixes typo related to testing

* [ASControlNode] Re-add helpful comment

* [ASTextKitCoreTextAdditions] Adds mappings for kCTParagraphStyleSpecifierMinimumLineSpacing, kCTParagraphStyleSpecifierMaximumLineSpacing, kCTParagraphStyleSpecifierLineSpacingAdjustment when mapping CTParagraphStyle onto NSParagraphStyle
[ASTextNode] Uses CoreText-cleansed attributed string when assigning ascender/descender to avoid crash when a CTParagraphStyle is passed as an attribute

* [AsyncDisplayKit] Update project file to include new/deleted files

* [ASControlNode+tvOS] Add missing Foundation import (whoops!)
[ASImageNode+tvOS] Add missing Foundation import (whoops!)

* Update podspec to only link AssetsLibrary framework on iOS

* [ASTextKitCoreTextAdditions] If kCTParagraphStyleAttributeName key-value
evaluates to an NSParagraphStyle, pass through to cleansed attributes. This
fixes a bug that would occur if a CTParagraphStyle was passed as an
attribute _alone_ (would not be caught by unsupported attributes
check)

* [ASMultiplexImageNode] Bump availability check to support < Xcode 9

* [ASTraitCollection] Fixes typo that was causing build to fail

* Clean up formatting to adhere to character/line limit + braces
2018-03-11 16:37:27 -07:00
Huy Nguyen
e0d07d07ef ASTextNode should avoid acquiring its lock multiple times #trivial (#820)
Since the lock was acquire before we try to access the renderer, we should call `-_locked_renderer` to avoid re-acquiring the same (recursive) lock.
2018-03-09 14:23:41 -08:00
Adlai Holler
6f1d2d1f1d
[ASTextNode] Fix locking, add test for issue #trivial (#825)
* A few small fixes plus a failing test for ASTextNode

* Change the approach

* Update changelog

* Eh screw null_resettable

* No need for changelog now
2018-03-09 14:23:27 -08:00
Adlai Holler
61dade6bda Raise deployment target to iOS 9 (#743)
https://github.com/TextureGroup/Texture/pull/743

Manually merged since I forgot to retarget that diff onto master before merge
2018-01-15 15:13:05 -08:00
Adlai Holler
1d105c2056
Add an experimental "no-copy" renderer (#741)
* Add "ASGraphicsContext" to skip copying our rendered images

* Zero the buffer before making a context

* Update license header

* Update dangerfile

* Make it a runtime flag

* Restore GState for good measure

* Free buffer if end without image

* Enable the experiment, and cut out the middle-man

* Fix typo
2018-01-13 19:19:08 -08:00
Erekle
d8cda8d74a [iOS11] Update project settings and fix errors (#676)
* [iOS11] Update project settings and fix errors

* update changelog

* resolve comments
2017-11-30 12:25:06 +00:00
Huy Nguyen
8e0aa1ea73 Fix crashes caused by failing to unlock or destroy a static mutex while the app is being terminated (#577)
* Fix crashes caused by failing to unlock or destroy a static mutex while the app is being terminated

* Allocate static mutexes on the heap memory to avoid destruction at app exit

* ASThread to use ASDisplayNodeCAssert() instead of assert()
2017-09-22 11:53:41 +01:00
Adlai Holler
8ec4b312cf Overhaul our logging, add activity tracing support. (#399)
* Improve the os_log and os_activity integration

* Address feedback from Scott and Huy
2017-07-03 19:03:26 -07:00
appleguy
2cda73a334 [ASTextNode2] Provide compiler flag to enable ASTextNode2 for all usages. (#410)
* [ASTextNode2] Provide compiler flag to enable ASTextNode2 for all usages.

The runtime switch is helpful, but is too slow to be shipped in a large
production application where startup time is carefully optimized.

Although this doesn't pass text-related snapshot tests when enabled, it
does allow apps to rely on built-in components like ASButtonNode using
the same text stack as when they are manually creating ASTextNode2
instances.

A simpler approach would be to use a #define ASTextNode ASTextNode2,
but this would create unusual keyword highlighting in code referencing
ASTextNode. However, because it would be less invasive and this is
not on by default, we could do that instead if preferred.

* Update AsyncDisplayKit.h

* [ASTextNode2] Improve naming and documentation of ASTEXTNODE_EXPERIMENT_GLOBAL_ENABLE

* [ASTextNode2] CHANGELOG.md for #410.
2017-07-02 21:40:51 -07:00
Adlai Holler
d30c35787c Fix Alignment of Hashed Structs (#287)
* Fix alignment of ASImageNodeContentsKey struct to fix hashing

* Change the change log by logging a change

* Add the world's stupidest explicit cast

* Actually its simpler
2017-05-17 18:08:50 -07:00
Adlai Holler
d4725a51f2 Add Experimental Text Node Implementation (#259)
* Add experimental text node implementation, based on YYText

* Fix warnings and alert when unimplemented experimental features are used.

* Address feedback from review

* Extend the cthulog

* Update license headers
2017-05-14 12:02:07 -07:00
Michael Schneider
4dbbba7d32 Remove instance method of -drawRect:withParameters:isCancelled:isRasterizing: (#232) 2017-05-09 14:02:33 -07:00
Adlai Holler
456dc8535d Simplify Hashing Code (#86)
* Simplify hashing

* Update chingling

* Update license
2017-04-29 15:23:00 -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
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
Adlai Holler
9129fa73d0 Simplify composedTruncationText Logic (#3211)
* Clean up the logic around composed truncation text

* Update comment
2017-03-22 13:03:09 -07:00
ricky
43f39bc2e3 [ASTextNode] Reset _composedTruncationText when attributedText is updated (#3210)
* [ASTextNode] Reset _composedTruncationText when attributedText is updated

Current issue:
1) Set `attributedText` in `ASTextNode` with whiteColor
2) `_composedTruncationText` gets updated to take on this new color attribute
3) Set the `attributedText` with greenColor
4) The `_composedTruncationText` gets updated with the new attributes, but does NOT overwrite any existing attributes — i.e., does not overwrite the white color with green. Comment from `_locked_prepareTruncationStringForDrawing:`:
`
// Add any of the original string's attributes to the truncation string,
// but don't overwrite any of the truncation string's attributes
`

* michael’s suggestion
2017-03-22 10:55:25 -07:00
Michael Schneider
39a2d7eebb Fix shadowing variable in [ASTextNode setTextContainerInset] (#3188) 2017-03-15 16:44:50 -07:00
Michael Schneider
0540c863ca Improve locking situation in ASDisplayNode subclasses (#3159)
* Improve locking situation in ASDisplayNode subclasses

* Adress first number of comments

* Don’t hold the lock while calling _updateComposedTruncationText
2017-03-10 17:29:09 +00:00
Adlai Holler
73ca6ab514 Shuffle & Cleanup Stuff (#3080) 2017-02-26 18:14:13 -08:00