142 Commits

Author SHA1 Message Date
Michael Schneider
905508e9be Factor in constrained size for final size calculation of ASTextNode (#2146) 2016-08-26 11:55:13 -07:00
Adlai Holler
9c3b688a87 Remove textStorageCreationBlock API (#2142)
* Remove textStorageCreationBlock API

* Remove layoutManagerCreationBlock also
2016-08-26 11:42:20 -07:00
Hannah Troisi
14ccb0b886 [ASTextNode] placeholder image shouldn't draw for zero area strings (#2069)
* placeholder should not draw if area is zero

* styling fix

* super precision
2016-08-16 10:20:59 -07:00
Nikita Lutsenko
2091df9607 [ASTextNode] Fix highlighting when textContainerInsets are set. (#2073)
* [ASTextNode] Fix highlighting when textContainerInsets are set.

* Add ASTextNodeSnapshotTests to xcodeproj.

* Add snapshot test for container inset and highlighting.
2016-08-16 10:18:51 -07:00
Garrett Moon
2c9e51e8f7 Add support for textContainerInset to ASTextNode (ala UITextView) (#2062)
* Add support for textContainerInset to ASTextNode (ala UITextView)

* Better comment, parens to increase readability. Thanks @schneider!

* Add textContainerInset snapshot test.
2016-08-12 12:07:00 -07:00
Hannah Troisi
893e601e81 Convert to type-generic math (#2050)
* [Optimization] Convert to type-generic math

* add std:: prefix in obj-c++ files

* more cleanup

* revert test changes

* convert min and max back to fmin/fmax
2016-08-09 15:31:37 -07:00
Michael Schneider
d9db780b0b [ASTextNode] Fix ASTextNode shadow is not rendering (#2042)
* Passing through shadow in renderer attribute

* Fix memory leak setting shadow color
2016-08-09 14:56:59 -07:00
David Rodrigues
70574243f7 Prevent API misuse at compile time (#2035)
Using Objective-C attributes, in this case `unavailable`, we can hide
unsupported APIs at compile time instead of detecting and warn about it
at runtime with a set of asserts.
2016-08-04 19:00:46 -07:00
Yue-Wang-Google
d481ce5423 [ASTextNode] Fix ascender to include line height specified in attributed string paragraph style (#1997)
* Fix ASTextNode's ascender to also include the line height specified by paragraph style in the attributed string.

* Merge conflict (original patch is for an old version)
2016-07-28 10:53:48 -07:00
Yue-Wang-Google
95bf8bbe1f Fix ASTextNode truncation string (#1992)
Initial PR to open source our internal ASDK patch list from Google Inc. :)
2016-07-27 13:18:21 -07:00
appleguy
74bf376b2f [ASDisplayNode] Rename _propertyLock to __instanceLock__ to avoid subclass naming collisions. (#1941) 2016-07-16 15:32:13 -07:00
Michael Schneider
3b09cbb845 Merge pull request #1929 from rcancro/textScaleFactors
[ASTextNode] use accessor for `pointSizeScaleFactors`
2016-07-15 16:01:02 -07:00
ricky
bd907dcffd added comment 2016-07-15 15:39:30 -07:00
ricky
c403175b91 [ASTextNode] use accessor for pointSizeScaleFactors
I have a subclass of `ASTextNode` that uses `pointSizeScaleFactors`. Currently I have to recompute the scale factors any time the font size changes. If `_rendererAttributes` used the property accesor for the scale factors I would only have to create them when asked. I hope this little change can make it in :)
2016-07-15 08:47:25 -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
Hannah Troisi
f39c2ce7e3 [ASTextNode, ASImageNode, ASVideoNode] Use ASDisplayNode base class lock for subclass property synchronization (#1877)
* [ASTextNode, ASVideoNode] Use ASDisplayNode base class lock for subclass property synchronization

* fix headers to match master

* address @appleguy, @maicki comments

* import header

* Swap lock in ASNetworkImageNode as well

* remove invalid comment

* more cleanup of locks
2016-07-09 22:08:34 -07:00
Kiel Gillard
f7b7bcebeb * Make the "Life Without Cocoapods" sample build and run.
* Properly reference headers within implementation files to avoid import cycles and redeclaration warnings.
2016-07-06 16:58:13 +10:00
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