156 Commits

Author SHA1 Message Date
Michael Schneider
c61ba65ba3 Some commit 2016-11-19 06:43:45 -08:00
Adlai Holler
f09b92641c Invalidate TextNode Renderer Instead of Changing constrainedSize (#2516)
* Instead of changing its constrained size, just invalidate renderer. It's virtually the same.

* Check constrained size before invalidating renderer
2016-10-31 14:14:21 -07:00
Adlai Holler
3eb7a307fa Share a singleton shadower for all cases when shadow isn't drawn, fix issues (#2511) 2016-10-30 15:34:29 -07:00
Adlai Holler
0d439a43b6 [ASTextNode] Add Fast-Paths For Text Measurement and Drawing (#2392)
* Add test case for TextKit truncation style

* Add fast path for text node measurement with default truncation

* Use fast path more often

* Reverse options order

* Simplify implementation – no functional change

* Share "isScaled" variable

* Intersect with constrained rect

* Add a failing test case for fast-path truncation

* Add some more truncation tests, using slow path as reference image

* Update the tests

* In ASTextKitRenderer, intersect bounds with constrained rect

* Add test case for TextKit truncation style

* Add fast path for text node measurement with default truncation

* Use fast path more often

* Reverse options order

* Simplify implementation – no functional change

* Share "isScaled" variable

* Intersect with constrained rect

* Add a failing test case for fast-path truncation

* Add some more truncation tests, using slow path as reference image

* Update the tests

* In ASTextKitRenderer, intersect bounds with constrained rect

* Use maximumNumberOfLines property in text kit fast path

Add reference images

Disable fast-path for max-one-line case

* Remove unneeded snapshot files
2016-10-24 17:05:59 -07:00
appleguy
0a5c1f43a8 [ASRunLoopQueue - Performance] Add ASDeallocQueue for efficient object teardown. (#2399)
* [ASRunLoopQueue - Performance] Add ASDeallocQueue for efficient object teardown.

This measurably reduces block overhead and context switching.  In the layout benchmark,
it increases ops/s while actually reducing CPU utilization.  This suggests that we are
now at a lock-bounded local maximum, at least for tri-core devices.

* [ASDeallocQueue] Update convenience helper method and adopt in ASImageNode etc.

* [ASDeallocQueue] Reimplement the queue using a timer-based runloop.

* [Debugging] Re-enable ASDisplayNode Event Log.

* [ASDeallocQueue] Final refinements, comments, code minimization.

* [ASDeallocQueue] Fix for lock release needed in early return (refactoring typo from last commit)
2016-10-17 12:24:11 -07:00
Adlai Holler
cb838664aa [ASTextNode] Go Back to Having Renderer as Ivar (#2376)
* Revert "Disable ASTextKitRenderer cache (#2315)"

This reverts commit 4aa7c9631d3a03b1542fac168f1a74531755392a.

* Revert "[ASTextNode] Add NSCache based cache for ASTextKitRenderer (#2199)"
2016-10-13 11:37:56 -07:00
Michael Schneider
6f2c7caac3 [Layout] Improve ASDimensionMake via NSString (#2351)
* Improve ASDimensionMake via NSString

- ASXCTAssertEqualDimensions
- Add support for "auto"
- Assert if given an empty or invalid string

* Address comments

* Add ASCGFloatFromString and ASCGFloatFromNumber

* Rename CGRect+ASConvenience to CoreGraphics+ASConvenience
2016-10-06 16:29:33 -07:00
Michael Schneider
4aa7c9631d Disable ASTextKitRenderer cache (#2315) 2016-09-28 16:42:06 -04:00
Michael Schneider
75dca556e6 [Layout] Add style property to ASLayoutable (#2261)
* Add style property to ASLayoutable

* Add styles property to further layout specs

* Adjust some examples

* Add `loadStyle` to create the style object in a ASLayoutable

* Revert "Add `loadStyle` to create the style object in a ASLayoutable"

This reverts commit 2b7240f2c7dc993e38cadf290cfdf08482dd70c7.

* Revert "Adjust some examples"

This reverts commit 3254ae0a321e75db3ecfa80adee9d96bde93a33d.

* Revert "Add styles property to further layout specs"

This reverts commit c779dcb876ead27122c1af1300146a6ad36912cb.

* Rename ASLayoutableStyleDeclaration to ASLayoutableStyle

* Add styleClass class property for extensibility support of the ASLayoutable style object

* flexShrink should not be YES by default
2016-09-22 16:00:52 -07:00
Adlai Holler
12ab2e3759 Fix equality in ASTextKitRendererKey (#2215) 2016-09-08 12:59:03 -07:00
Adlai Holler
5593bfa4d1 [ASDisplayNode] Majorly Improve Descriptions (#2208)
* Up our description game big time

* Couple tweaks

* Explain logic

* Fix indentation
2016-09-07 20:11:27 -07:00
Michael Schneider
2388f67474 [ASTextNode] Add NSCache based cache for ASTextKitRenderer (#2199)
* Add cache implementation

* Remove old ASEqualityHashHelpers

* Some more ASEquality and ASEqualityHashHelper cleanup

* Add cache for text renderer in ASTextNode

* Move from C++ LRU renderer cache to NSCache based renderer cache
2016-09-06 15:23:21 -07:00
Adlai Holler
e233a1cccc [Unit Testing] Add Realistic Text Data Set (#2188)
* Add a mechanism to save attributed strings given to text nodes

* Setup performance tests to have an iteration variable

* Use realistic data in new text node performance test case

* Revert temporary changes
2016-09-05 12:30:06 -07:00
Adlai Holler
90c59e0de7 Remove completely unused layoutManagerDelegate things (#2189) 2016-09-04 12:01:42 -07:00
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