156 Commits

Author SHA1 Message Date
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
yury
f2012df3af Fix Out of bounds error
Actually it is possible that truncated string is longer then original
string.

For example, original string:

```
hello
this is
very long
message here
and there
```

with maximumNumberOfLines=4, truncationAttributedString = ' ...' and
additionalTruncationMessage = 'read more'

will give

```
hello
this is
very long
message here ... read more
```

So `[attributedString attribute:attributeName atIndex:characterIndex
longestEffectiveRange:&range inRange:visibleRange]` will crash.
2016-01-25 22:25:12 +03:00
Scott Goodson
2713bdd72e [ASTextNode, ASDisplayNode] Create -calculatedLayoutDidChange and use it in text node.
This allows the change in size for the NSTextContainer to occur off the main thread, whenever that size change
is necessary.  Then the text relayout can occur earlier, during the process of computing ASLayoutSpecs.
2016-01-24 17:14:14 -08: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
Adlai Holler
db18724d5b If they set attributedString to nil twice, ignore the second one. 2016-01-20 14:00:46 -08:00
Scott Goodson
aee7b3b77a Remove padding workaround from old CoreText days.
This is a vestige from Paper.  Discussion: https://github.com/facebook/AsyncDisplayKit/issues/1013
2015-12-31 01:52:08 -08: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
Scott Goodson
928c440b4c Several small optimizations, especially to _ASPendingState and other hot paths. 2015-12-23 16:38:33 -08:00
Scott Goodson
1872ac07aa [ASTextNode] Renderer should not be invalidated if bounds size matches calculatedSize, even if it doesn't match constrainedSize. 2015-12-17 22:12:29 -08:00
appleguy
d56a53d9aa Merge pull request #941 from samhsiung/fix_truncation
Fix ASTextNode truncated size calculation ignoring attributes in the last line, by syncing the truncationString's attributes with the primary attributedString.
2015-12-17 18:17:48 -08:00
Scott Goodson
f44c829564 ASTextNode shouldn't create a long press gesture recognizer unless the delegate cares about the callback. 2015-12-16 17:20:08 -08:00
Samuel Hsiung
f9d476e170 Fix ASTextNode truncated size calculation ignoring attributes in the last line 2015-12-15 10:09:03 -08:00
Alexey Glushkov
ad282132ff merge master 2015-12-08 22:04:34 +03:00
Adlai Holler
835acd6a25 Change assumed value for text node highlighting delegate method to YES and don't consult it unless highlighting. 2015-12-03 20:52:02 -08:00
Adlai Holler
f39105a8f4 Optimize 2015-12-03 09:45:45 -08:00
Adlai Holler
f723452756 Allow link taps to continue if touches move within the same link 2015-12-03 09:25:37 -08:00
Levi McCallum
2cf4b22c96 Include correct TextKit headers 2015-11-30 06:46:53 -08:00
Levi McCallum
c1f4456fd5 Use composed attributed truncation string for underlying drawing text 2015-11-30 06:44:53 -08:00
Levi McCallum
397e5b15e9 Fix tabbing on initializer 2015-11-30 06:44:53 -08:00
Levi McCallum
a0c05ebffc Rename CK classes to AS classes 2015-11-30 06:44:53 -08:00