85 Commits

Author SHA1 Message Date
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
Levi McCallum
de66819286 Implement functioning isTruncated API on ASTextNode 2015-11-30 06:41:41 -08:00
Levi McCallum
74435fb584 Convert ASTextNode to support CKTextKitRenderer 2015-11-30 06:41:41 -08:00
Alexey Glushkov
c501e46b5d removed wrong conditions in _needInvalidateRenderer 2015-11-24 11:35:20 +03:00
Alexey Glushkov
01a2fd90d4 removed displaySize method, added condition to skip _invalidateRendererIfNeeded if there are no view and no layer 2015-11-24 11:12:36 +03:00
Alexey Glushkov
e859f9a870 fixed brace style 2015-11-24 10:10:34 +03:00
Alexey Glushkov
38ded30da9 add layer backed text node support for the fix 2015-11-24 10:01:02 +03:00
Alexey Glushkov
42f56defbf ASTextNode wrong text layout fix 2015-11-22 11:56:12 +03:00
Scott Goodson
3416450f11 Adding ASButtonNode. Simple but flexible, add features as desired! 2015-10-31 15:12:05 -07:00
Scott Goodson
3175ce2fe7 Fix retain cycle in basic, cache-less ASNetworkImageNodes
This should not directly affect more complex apps that don't use the ASBasicImageDownloader.

Also disables the default-on text placeholders, as they churn memory during the measurement pass.
These were intended to be written with pure layers (without using backing stores), so I don't
think it is a reasonable default-on behavior until that is fixed.
2015-10-30 22:42:05 -07:00
ricky cancro
89a216b90d Fixes to baseline stack alignment
1) Set the ascender/descender of an ASTextNode when the attributeString is set. Previously ascender/descender were only being computed in `setValuesFromLayoutable` and only when the attribute string was not nil. May make sense to remove the computation from `setValuesFromLayoutable` entirely.
2) Remove ability to allow different children of a stack spec to aling to different baselines. This wasn't working before and I'm not convinced it is possible to do properly/useful enough to invest the time.
3) Have all stack spec run `ASStackBaselinePositionedLayout::compute` to compute the stack's ascender and descender. Even if the stack isn't aligning its children to a baseline, the stack itself may be a child of another stack that IS aligning to a baseline.
2015-10-06 21:41:39 -07:00
Adlai Holler
1801620094 Make ASTextNode copy exclusionPaths and attributedString 2015-10-06 00:46:20 -07:00
Adlai Holler
ae3eb70f6a Public API fast paths in ASTextNode 2015-10-06 00:40:33 -07:00
Adlai Holler
4ef2e572e6 Elevate ceilPixel functions to ASTextNodeTextKitHelpers.h, add ceilSize 2015-09-20 21:17:24 -07:00
rcancro
2f3562fa09 scott's comments 2015-09-15 09:11:19 -07:00
rcancro
01be5acece added a callback for initWithViewBlock/initWithLayerBlock 2015-09-14 20:36:08 -07:00
rcancro
15b3fd6eab Moved ASLayoutable* properties into ASLayoutOptions class 2015-09-08 09:50:27 -07:00
rcancro
9036ab8e7d new stack layout spec for text 2015-08-22 19:03:54 -07:00
ricky cancro
ef89f758bc flailing 2015-08-22 19:03:54 -07:00
ricky cancro
cf428831a4 Added baseline spacing for vertical stack views. 2015-08-22 19:03:54 -07:00
ricky cancro
f289b3345a Add baseline support to ASStackLayoutSpec 2015-08-22 19:03:54 -07:00
Ethan Nagel
f7fb6dc4e7 Node init performance: Use share instances of UIColor and NSAttributedString for defaults. 2015-08-17 12:23:25 -07:00