* [ASTextNode2] Add support for pointSizeScaleFactors
Implements `pointSizeScaleFactors` in ASTextNode2. If you provide and array of `pointSizeScaleFactors` and set a `maximumNumberOfLines` > 0, text layout will check if your text fit in the max number of lines. If not, it will scale your text by the scale factors in `pointSizeScaleFactors` until it either finds the first scale that allows the text to fit, or it runs out of scale factors.
* put this back where it was
* [ASTextNode2] Don’t update the text container’s size before drawing
While working in `ASTextNode2` I noticed we don’t seem to use cached `ASTextLayout` when drawing the text. Here is what I’m seeing:
When `ASTextNode2` calculates its size it calls `layoutWithContainer:text:range:`. The container passed into `layoutWithContainer:text:range:` holds the input information for attributes like size, insets, exclusion paths, etc that will help create the layout. When the layout is computed it is passed back to `ASTextNode2` via an `ASTextLayout` object. This layout is placed into a cache using the container's size for the key.
When the text is actually drawn via `drawRect`, `drawParametersForAsyncLayer` provides us with a container that we use to look for the cached layout. However, after copying `ASTextNode2's` `_textContainer` it changes its size to `self.bounds.size` :
```
copiedContainer = [_textContainer copy];
copiedContainer.size = self.bounds.size;
[copiedContainer makeImmutable];
```
We then take this container and look in the cache for a related `ASTextLayout`. Of course, we don’t find the layout we just created since we are using a different `size` as a key into the cache. It seems like this behavior guarantees that we will always have a cache miss unless our original constrained size and the final size of the layout happen to be the same.
Am I missing something? Do we really want to change the container’s bounds here?
* Change logic around when to use a cached text layout
Previously we’d use a cached text layout if the container’s size is the same size as it was when the text layout was first computed. However, because we change the container’s size before the draw to be the text node’s bounds NOT its constrained size, this would often end in us having a cache miss.
This change checks to see if the container’s size is the same as the textLayout’s textBoundingSize. If so, we will use the cached layout even if the container’s size is not the same as when the text layout was computed.
The one trick in this is that if the text was truncated, we don’t use the layout’s textBoundingSize as the layout size. Instead, there is some logic in `ASTextNode2::calculateSizeThatFits` that will use the layout’s `truncatedLine` to determine the layout height. I moved this logic to `ASTextLayout` so it can be used in both `calculateSizeThatFits` and when checking the cache. I’m not sure if this is the best place for this method. Let me know if you have a different idea!
* remove unused parameter from method
includeTruncatedLine is always YES, so let’s take it out
* Update snapshot test
- Address various issues with tint color on text nodes
- Avoid accessing `self.tintColor` off-main since this will trigger an
assertion and might be undefined behavior
- Trigger setNeedsDisplay in cases of hierarchy change and
tintColorDidChange in ASButtonNode, ASTextNode{1,2}
- Fix bug in _ASTableViewCell where we were overwriting the tint color
instead of inheriting the correct value
- Add tests for new logic in changing hierarchy
- Add the ability to specify a tintColor for images / buttons that behave similarly to how they would under UIKit.
- Add flag to control if tint color is applied to ASTextNode to match how
UIKit controls if it is .applied to UILabel.
- Update tests for not-tinting automatic render mode for UIImage.
- Add property on ASTextNode2.
- Add tint color support to ASTextNode2.
If the alwaysHandleTapTruncationAction is YES, the ASTextNode and ASTextNode2 can handle touches on additional attributed message even passthrough is YES.
`[NSAttributedString enumerateAttribute:inRange:options:usingBlock]` can be called multiple times with a value of nil. The current logic didn't consider this to find out if a links is present within the attributed string.
* Add support for basic ASTextNode2 link highlighting
* Add approach to fix line highlighting
* Enable proper highlighting for first row
* Fix snapshot highlighting test for ASTextNode2
* Update screenshot again
* Address comments
Running in iPhone SE Simulator:
- ASTextNode: 1360 to 1352 bytes .6% reduction
- ASTextNode2: 1360 to 1304 bytes 4.3% redction
Shrink stored enum sizes. Group BOOLs near these smaller enums. Override -usingExperiment to return constant instead of never set, but allocated ivar.
* fix SIMULATE_WEB_RESPONSE not imported #449
* Fix to make rangeMode update in right time
* remove uncessary assert
* Fix collection cell editing bug for iOS 9 & 10
* Revert "Fix collection cell editing bug for iOS 9 & 10"
This reverts commit 06e18a1059.
* Fix dealloc long gesture in background
* Rename ASDN C++ namespace to "AS." Referring to the framework as ASDisplayNode is pretty out-dated and verbose. See CoreAnimation which usees CA for their internal namespace.
More using
* More cases
Found by Clang Static Analyzer:
~/Texture/Source/ASTextNode2.mm:663:39: warning: Potential leak of an object stored into 'truncationTokenLine'
CTLineRef truncationTokenLine = CTLineCreateWithAttributedString((CFAttributedStringRef)_truncationAttributedText);
^
~/Texture/Source/ASTextNode2.mm:666:49: warning: Potential leak of an object stored into 'additionalTruncationTokenLine'
CTLineRef additionalTruncationTokenLine = CTLineCreateWithAttributedString((CFAttributedStringRef)_additionalTruncationMessage);
^
2 warnings generated.
* Make ASTextNode2 more forgiving when searching for links by searching a 44x44 square around the touch
* Trailing whitespace
* Safely handle end-of-line
After 5c9815f, some Mutexes are used as global C++ variables which are loaded before main(). Since the Mutex constructor checks for unfair lock experiment, it triggers an experiment configuration load, and our app isn't ready to respond that early in the process.
* Newline character support and truncated line sizing improvement.
For purposes of truncating text, respect explicit newlines.
Don't size to smaller than truncated line width unless we have to.
* Update CHANGELOG.md
* Expose textLayoutForConstraint:
- Expose textLayoutForConstraint:, but make unavailable on ASTextNode
- Refactor compatibleLayoutWithContainer:text: into a static method
* Instead of textLayoutForConstraint: expose shouldTruncateForConstrainedSize: in ASTextNode
* ASTextNode2 rendering corrections.
ASTextNode2 was only setting truncationMode (lineBreakMode) on existing paragraph styles in attributedString (thus having no effect for the two non-truncating modes if there were not any existing paragraph style runs).
ASTextLayout (essentially YYTextLayout) was not rendering the two non-tail truncation lineBreakModes correctly. There's not much history on github but it appears to me that it was set up correctly at one time and then some additional code was added for unclear reasons that assumed any truncation was at the end of the string.
This commit corrects both issues.
* Update CHANGELOG.md
ASTextNode2 uses ASTextLayout to calculate its layout and bounding rect. When the constrained width that is used for layout calculation is inf/max (e.g when the node is inside a horizontal stack), ASTextLayout doesn't ignore its right/center/natural text alignment but takes it into account. That results in an unreasonable size (and position).
Fix by detecting when the node is calculating intrinsic size and force its layout alignment to be left. Other alignments should still work when the max width is finite/reasonable.
* [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 ffa0fbbba9.
* [License] Update all Texture source files to be pure Apache 2, maintaining copyrights.
* [License] Update CONTRIBUTING, README, Podspec & Dangerfile.
* Remove copying in text stack, make text container have an optional immutable mode
* Changelog
* Comment
* Update CHANGELOG.md
* Use new name
* Import header
- 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.