125 Commits

Author SHA1 Message Date
Adlai Holler
45ef91171d [ASTextNode] Release Lock Sooner in -setAttributedText: (#1828)
* [ASTextNode] Release lock sooner in -setAttributedText:

* [ASTextNode] Expand the critical scope a bit
2016-06-28 20:18:30 -07:00
Michael Schneider
3fb0e18504 [ASTextNode] Further locking improvements for ASTextNode (#1813)
* Further locking improvements for ASTextNode

* Remove tighter holding of lock as this operation needs to complete with the lock held
2016-06-24 16:49:05 -07:00
Michael Schneider
36e48cf340 Remove caching of _drawParameter and use bounds instead of threadSafeBounds 2016-06-21 13:11:38 -07:00
Michael Schneider
74b9b6b49e Use threadSafeBounds instead of bounds to create drawing parameters 2016-06-21 13:11:38 -07:00
Michael Schneider
e7f2edd183 Add updating drawing parameter in ASTextNode
Update drawing on demand if properties change and not on every drawing cycle. This should reduce the overhead to access properties from the view / layer for the drawing parameters.
2016-06-21 13:11:38 -07:00
Michael Schneider
fc7cff333e Prevent subclassing of ASTextNode and ASImageNode 2016-06-21 13:11:38 -07:00
Michael Schneider
3384297c58 Move drawing parameters in ASTextNode and ASImageNode to structs 2016-06-21 13:11:38 -07:00
Michael Schneider
6bde8cdcf3 Adress review comments
- Add locking to _linkAttributeValueAtPoint:attributeName:range:inAdditionalTruncationMessage:forHighlighting: as we access the attributed text in there
- Add locking to touchesBegan:withEvent: as we are accessing the [ASTextKitRenderer firstVisibleRange]
- Add locking for highlightStyle
- Move accessing delegate property access to instance variable access
2016-06-20 13:42:17 -07:00
Michael Schneider
f3a909324d Add lock to _rendererAttributes 2016-06-20 13:42:17 -07:00
Michael Schneider
3d72a6b7e5 Cleanup ASTextNode and add locking
For now we use a big recursive lock. This needs to be revisited as we revisit the whole ASDK locking strategy.
2016-06-20 13:42:17 -07:00
Michael Schneider
aa5d730eab Deallocate objects on a serial queue specific for deallocation (#1737)
[Performance] Prevent GCD thread explosion due to object deallocation workloads (serial deallocation queue).
2016-06-16 18:18:43 -07:00
Michael Schneider
efab1a4855 Move modifier to __weak for the highlighted layer in ASTextNode (#1756) 2016-06-16 18:12:57 -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
Michael Schneider
19bb6519ed Fix crash truncating a string of a node with a zero size
The crash happens in the placeholderImage of ASTextNode. The node is not visible in the time it try to get the `placeholderImage` and so the `visibleRange` has count 0 and a crash happens while accessing the first object of an empty array.
2016-06-03 09:53:59 -07:00
Michael Schneider
29ab87a1e4 Fix API ASTextNode API inconsistencies
- Deprecate attributedString in ASTextNode in favor of attributedText to be aligned with UILabel
- Deprecate truncationAttributedString in ASTextNode in favor of truncationAttributedText to be aligned with attributedText
2016-05-04 21:03:31 -07:00
Hannah Troisi
1b3ca72877 Fix preexisting code - missing super call 2016-04-17 22:49:14 -07:00
appleguy
6d1c52b042 Merge pull request #1456 from maicki/ASEnvironment
[ASEnvironment] Add support for ASEnvironment, supporting generalized state propagation both up and down node and layout spec trees.
2016-03-31 21:05:38 -07:00
Michael Schneider
4e757f0969 General improvements
- Refactor naming of ASEnvironmentCollection to ASEnvironmentState
- Remove struct pointers
- Move ASEnvironmentStatePropagation to a enum class
- Move merge functions to pure functions
- Move ASLayoutOptionsForwarding and ASLayoutableExtensibility into ASLayoutSpec and ASDisplayNode
- Remove ASLayoutableSetValuesForLayoutable and move into explicit classes (ASDisplayNode, ASTextNode)
2016-03-31 20:43:20 -07:00
Eric Jensen
387abbff5d Rename ASTextKitHelpers to ASTextKitComponents and make the header public 2016-03-26 15:31:53 -07:00
Eric Jensen
6739a3a4ab Condition logic simplification 2016-03-17 11:22:53 -07:00
Eric Jensen
17aebcbaba Add a space between the ? and : in ternarys 2016-03-17 10:38:51 -07:00
Eric Jensen
33fda7ab49 - Use modern Objective-C syntax.
-  Simplify comparisons.
-  Remove dead stores.
2016-03-15 22:34:29 -07:00
Aaron Schubert
71eb9582fb [ASTextNode] Fix default ellipsis not showing for line breaks 2016-03-09 15:10:26 +00:00
appleguy
1ce3834e0e Merge pull request #1343 from rcancro/cacheFontScale
[ASTextNode] Improvements to the implementation of the font scale adjuster.
2016-03-09 02:41:13 -08:00
rcancro
3ebdf5928c Made a few changes to font scale adjustment
1) cache the scale in the font adjuster. The adjuster will be dealloc'ed when the renderer that owns it is dealloc'ed (or invalidated). Until that time we can trust the scale that the adjuster has computed.
2) When measuring line count, make sure that we are not bounding the height of the container's size. This will cause the wrong number of lines to be returned.
3) Instead of setting the ascender/descender on an ASTextNode when an attributed string is added, wait until after the renderer calculates size. This way, if there is any need to scale the font to fit we can apply that scale to the ascender/descender.
2016-03-08 12:05:26 -08:00
Tom King
1457e97c59 create local variables for performance and clarity 2016-03-08 08:54:07 -05:00
Tom King
f4d5791717 in ASTextNode, bail from touchesMoved:withEvent: if the previousLocationInView is the same as the locationInView. On 3D Touch enabled phones, this gets fired with chages in force, and will usually get fired immediately after touchedBegan:withEvent, causing touches to usually be cancelled 2016-03-07 17:15:30 -05:00
Huy Nguyen
5154573ae7 Finish replacing bounds with threadSafeBounds in ASTextNode 2016-03-03 08:51:44 -08:00
Huy Nguyen
9162d7b2df Implement thread-safe bounds and use it in ASTextNode 2016-03-02 22:42:53 -08:00
rcancro
d4bced1fb5 Fix bug when rendering text the second time
A text node's renderer is often invalidated. Save the renderer's constrained size locally so we can use it when creating a new renderer after invalidation.
2016-03-01 08:57:43 -08:00
rcancro
878fedd8f3 Stopped trying to cache the currentScaleFactor
Was running into issues where the scale factor would get cleared when setting a new atributedString on a textNode.

I was clearing out the currentScaleFactor when setting an attributedString into a textNode. It appears that `_calculateSize` isn't always called when setting a new string into a ASTextNode. It can be the case that only `drawInContext:bounds:` is called. With _currentScaleFactor cleared out the renderer that calls`drawInContext...` was being called with a scaleFactor of 0.

It could be the case that the fix could be to remove the clearing of `currentScaleFactor` from `setAttributedString`, but this seems like a safer fix to me. It does, however, require an extra run through the font adjuster when enabled.
2016-02-23 16:51:10 -08:00
rcancro
00b0968bf7 Add ability to customize NSLayoutManager and NSTextStorage when created in the ASTextKitContext 2016-02-22 13:00:02 -08:00
Adlai Holler
b47c2d5ecf [ASTextNode] Remove more thread affinity dispatches 2016-02-20 15:43:00 -08:00
Adlai Holler
12d5c73325 [ASTextNode] Remove thread affinity dispatch 2016-02-20 15:43:00 -08:00
rcancro
a62de38670 currentScaleFactor management 2016-02-18 20:01:23 -08:00
rcancro
2adc30440f Exposing currentScaleFactor 2016-02-18 16:41:58 -08:00
rcancro
070982a50b fixed tests??? (it did locally anyway) 2016-02-17 13:08:16 -08:00
rcancro
a920e353c6 adjust font size to make text fit within constrained size
# Conflicts:
#	AsyncDisplayKit/ASTextNode.mm
2016-02-16 16:16:22 -08:00
rcancro
23019cbbea Remove wordkerner in ASTextNode to fix jumbled text bug 2016-02-16 09:34:38 -08:00
Connor Montgomery
800aa05c35 Revert "Merge pull request #1162 from maicki/controlnode-init-optimization"
This reverts commit 35a4b268d64e922b3928f247614b664a9413ad3b, reversing
changes made to 4201df5f31077ea31bf014fc01828c065bd31c1c.
2016-02-05 13:49:00 -05:00
Michael Schneider
d1c2da07e7 No need to set userInteractionEnabled in the ASTextNode init method
The userInteractionEnabled state will be set by ASControlNode in viewDidLoad to the fitting value.
2016-02-01 20:11:37 -08:00
appleguy
8d9d5a0cc3 Merge pull request #1132 from garrettmoon/switchToInstanceDrawAndDisplay
[ASDisplayNode+AsyncDisplay] Implement instance methods of draw and display, use for text and image performance boost.
2016-01-28 16:17:31 -08:00
Garrett Moon
1ecfd81e3e Address comments 2016-01-28 16:05:49 -08:00
rcancro
715a678829 scott's comments 2016-01-28 15:18:45 -08:00
rcancro
7f6f2fed11 Added ASTextNodeWordKerner support to ASTextNode
* Added a member to `ASTextKitAttributes` that is an optional delegate to the struct's NSLayoutManager.
* Changed ASTextNode to set this delegate to an instance of ASTextNodeWordKerner.
* Updated init method of `ASTextKitContext` to take an optional NSLayoutManager delegate
* Added the files in TextKit folder to the public headers (so we can include ASTextNodeTypes.h)
2016-01-28 08:38:22 -08:00
Garrett Moon
01c1680904 Switch to instance methods of draw and display
This patch switches to instance methods of draw and display for
ASTextNode and ASImageNode to attempt to increase their performance.

It also fixes some thread safety issues in ASImageNode which appear
to have been regressions (though probably not hit very often).

And it sets up work for allowing modification of CGContexts before
and after a node's contents are drawn.
2016-01-27 20:08:02 -08:00
appleguy
fb60acbecc Merge pull request #1113 from lkzhao/ASTextKitFontSizeAdjuster
[ASTextNode] Fix test build for font size adjuster
2016-01-25 20:03:01 -08:00
Luke Zhao
70be4c96ba import ASTextNode+Beta.h 2016-01-25 19:59:16 -08:00
appleguy
508e3db8ee Merge pull request #1091 from lkzhao/ASTextKitFontSizeAdjuster
[ASTextNode] Support iteratively shrinking font size in order to ensure no single words are wrapped.
2016-01-25 19:36:39 -08:00
Luke Zhao
f413a618e0 add ASTextKitFontSizeAdjuster 2016-01-25 19:07:28 -08:00