30 Commits

Author SHA1 Message Date
Adlai Holler
9c3b688a87 Remove textStorageCreationBlock API (#2142)
* Remove textStorageCreationBlock API

* Remove layoutManagerCreationBlock also
2016-08-26 11:42:20 -07:00
Adlai Holler
04ecd4180e [ASTextKitRenderer] Shift TextKit Teardown onto the Deallocation Queue (#2136)
* [ASTextKitRenderer] Shift TextKit teardown onto the deallocation queue

* Import it!
2016-08-25 17:29:31 -07:00
Michael Schneider
6e573fba0d Reset _calculatedSize if a new constrained size is set on the ASTextKitRenderer (#1942) 2016-07-16 16:23:47 -07:00
Michael Schneider
bbc957bce5 Throw away all subcomponents of the text kit renderer if constraints are changing
Throw away the all subcomponents to create them with the new constrained size new as well as let the truncater do it's job again for the new constrained size. This is necessary as after a truncation did happen the context would use the truncated string and not the original string to truncate based on the new constrained size
2016-07-14 15:11:10 -07:00
Scott Goodson
bf9c142765 Revert "[ASTextNode] Fix text node truncation (#1863)"
This reverts commit 6238e5edbde55fb82982ce4a19a0cbca7fe7eb9d.

We will re-apply this change, but there are some early signs of performance impacts that need to be investigated.
2016-07-09 23:54:43 -07:00
appleguy
3b2af7eb6d [Build] Remove Unused Imports across all of AsyncDisplayKit. This uses a feature of AppCode. (#1875)
Details on the tool are here: https://www.jetbrains.com/help/idea/2016.1/optimizing-imports.html
2016-07-09 17:20:59 -07:00
Michael Schneider
6238e5edbd [ASTextNode] Fix text node truncation (#1863)
* Before truncate a text storage in ASTextKitContext reset the text storage to original value

* Fix ASTextNode tests

We should pass in the constrained size in both cases and the sizes should be the same. We adjust the calculated size in ASTextNode to be a bit narrower in the second case if we truncate again with the calculated size as constrained size it will truncate more and the resulting size will shrink.
2016-07-09 15:40:31 -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
a914e3c428 Change visibleSizeRange to return a range with 0 location and length 2016-06-04 15:40:07 -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
rcancro
ffde31a1b2 Fixed a crash in ASTextNode that I made
fixes a crash introduced by https://github.com/facebook/AsyncDisplayKit/pull/1637
2016-05-10 15:25:34 -07:00
rcancro
22e026a5e1 fix truncater method to only return the truncater. 2016-05-09 16:36:27 -07:00
rcancro
082ababda6 Fix to text shrinking
Summary: Previously the first thing we did when calculating the size of text was to truncate it. This could lead to ASFontSizeAdjuster being sent a truncated string which, obviously, never needed to shrink. If we change the order then we first shrink, then truncate if still necessary.

Reviewers: scottg, levi, garrett

Differential Revision: https://phabricator.pinadmin.com/D89780
2016-05-09 15:59:08 -07:00
Scott Goodson
daf41ebb43 [ASTextNode] Fix edge case where text truncator may not run (manually hosted nodes that are lacking the expected call to -measure).
This fixes the scenario described in https://github.com/facebook/AsyncDisplayKit/issues/1295
2016-03-26 18:19:02 -07:00
rcancro
bcb1832fcd Fixed some text shrinking issues
Previously I was multiplying the calculated height of the text by the scale factor. This fails in the case where we have a long string that doesn't fit, but it is shrunk so much that it now has more than enough room in the renderer's constrained size. In this case we fail to update the calculated size's width.

Also updated `lineCountForString` in `ASTextKitFontSizeAdjuster` to reuse a sizer layout manager and text container.
2016-03-09 15:27:33 -08:00
rcancro
8dbc8b7df4 reordered conditionals, moved beta things to beta header file 2016-02-24 08:06:10 -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
rcancro
a920e353c6 adjust font size to make text fit within constrained size
# Conflicts:
#	AsyncDisplayKit/ASTextNode.mm
2016-02-16 16:16:22 -08:00
Tom King
d0edbe809a ensure that the truncater is initialized before the context is in _calculateSize 2016-01-29 09:32:40 -05:00
appleguy
2c194fd924 Merge pull request #1140 from rcancro/textNodeWordSpacing
[ASTextNode] Added ASTextNodeWordKerner support
2016-01-28 15:38:00 -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
Luke Zhao
733c65d1eb fix bug: constraint size not updated for frontsizeadjuster 2016-01-27 13:49:00 -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
yury
313a3cc63c Create Truncater with context. So it will actually truncate string in its initializer 2016-01-25 16:48:55 +03:00
Scott Goodson
9ddf68fa96 [ASTextNode] Optimize handling of constrained size to almost never recreate NSLayoutManager
This also fixes two fairly subtle but serious bugs, #1076 and #1046.
2016-01-24 00:50:43 -08:00
Aaron Schubert
10a2984d8c Potential fix for #1076 2016-01-19 12:25:30 +00:00
Scott Goodson
99fbc97bda Optimizations for ASTextNode handling of renderer allocation and deallocation.
Optimizations for ASDisplayNode handling of bridged property "contentMode", especially for layer-backed nodes.
2015-12-25 01:36:32 -08:00
Levi McCallum
a0c05ebffc Rename CK classes to AS classes 2015-11-30 06:44:53 -08:00