Commit Graph
723 Commits
Author SHA1 Message Date
Vlad Solomenchuk a1c827b4cb deprecate ASGraphicsCreateImageWithOptions 2019-09-25 11:28:32 -07:00
Rahul Malik ee18b9cd6c Use backgroundColor ivar instead of property access in traitCollectionDidChange (#1678)
traitCollectionDidChange isn't necessarily called on Main, but our self.backgroundColor property access must be done on main once the view is loaded.

I originally opted to use self.backgroundColor rather than _backgroundColor in #1674, but I think we should use the ivar here. This could get out-of-sync if someone modified the UIView's background color instead of updating the node, but I think that's unlikely, so we should be safe to use the ivar here.
2019-09-18 09:15:32 -07:00
Hanton Yang 06ab67a3aa Using emplace_back, it avoids the move operation requires when using push_back (#1658) 2019-09-18 00:07:03 -07:00
Rahul Malik 618f21e28a Fix main thread assertion for tint color on text nodes, re-render tint-able nodes on hierarchy changes (#1670)
- 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
2019-09-16 14:38:50 -07:00
vovasty e5eba118a3 introduction of ASGraphicsCreateImageWithTraitCollectionAndOptions (#1675)
* initial `ASGraphicsCreateImageWithTraitCollectionAndOptions`

* comments
2019-09-16 14:14:53 -07:00
Harry Shamansky 0b02e8bdf8 #1673 - Re-render Clipping Corners when User Interface Style Changes (#1674)
* This PR addresses an issue I raised with #1673 where the clipping corner layer doesn't get re-rendered when going from a dark to light user interface style. The fix is to add code in the `-asyncTraitCollectionDidChangeWithPreviousTraitCollection:` method that calls through to `-_updateClipCornerLayerContentsWithRadius:backgroundColor:` if the user interface style changes.

I've also added snapshot tests to verify that using clipping corners with a dynamic background color updates when the user interface style changes.
2019-09-16 14:14:10 -07:00
Hanton Yang 712efc434f Fix _ASAsyncTransaction initialization method (#1656)
- Invoke the superclass (super) initializer
2019-09-15 23:33:29 -07:00
Mike Donahue 3bb64bc1cc Fix CFRelease crash in ASTextNode2 (#1669)
- Add null check before CFRelease
2019-09-11 22:07:21 -07:00
Greg Bolsinga 368aa3aadf ASImageNode tintColor improvements. (#1668)
* ASImageNode tintColor improvements.

When ASImageNodes changes tintColor or enters the hierarchy, ensure -setNeedsDisplay is called if the image is templated.

Add unit tests to ensure this behavior works.
2019-09-11 20:18:04 -07:00
Greg Bolsinga 492da8a95b Node TintColor Tweaks (#1666)
* Node TintColor Tweaks

- If the tint color changes, be sure to call -setNeedsDisplay on the view.
- Explictly declare tintColor ivar and getter method.
- If the tintColor is the same as the existing one, early-exit.
- Use the ivar and not the property when setting the tintColor, just as is done for background color.
- Add tests (for non iOS13 and iOS13) that the tintColor will call -setNeedsDisplay
- Backfill tests to document/verify the tintColor behavior on a node.
2019-09-11 14:22:39 -07:00
Hanton Yang c99bcb02f8 Use CAEdgeAntialiasingMask instead of unsigned int (#1667) 2019-09-11 10:38:06 -07:00
Michael Zuccarino 5e7fbf2ff9 Defer image asset regeneration to draw loop (#1663)
There is a potential dealloc race condition that can occur when attempting to perform work with image asset out of the main thread. Moving that work into the image node draw loop if necessary
2019-09-07 03:37:43 -07:00
Greg Bolsinga c24a21a5a9 lock to access the image renderingMode (#1661) 2019-09-06 13:11:10 -07:00
Greg Bolsinga a403160930 Use MutexLocker for safe locking and then access the ivars directly so that another lock access is not required (#1662) 2019-09-06 13:02:16 -07:00
Greg Bolsinga 00c03e8fcb Use standard ivar _ prefix for userInterfaceStyle (#1660) 2019-09-06 12:59:15 -07:00
vovasty 4d6532ccc8 use lock to avoid crash when image might be changed during the trait collection change (#1651) 2019-08-30 12:45:58 -07:00
Rahul Malik 6464153489 Cleanup from recent changes (#1647)
- Fix availability warnings for usage of userInterfaceLevel
- Deprecate `asyncTraitCollectionDidChange` in favor of the new method
- Remove old compiler warning flag added for Xcode 9 building
- Access `textColorFollowsTintColor` with a locked scope
2019-08-28 12:24:03 -07:00
Rahul Malik caa0d8de54 Fix issue where UIGraphicsRendererFormat is mutated (#1645)
* Fix issue where UIGraphicsRendererFormat is mutated

As part of https://github.com/TextureGroup/Texture/pull/1629, we use the
preferred or default UIGraphicsRendererFormat. This was pointing to a
static variable which content scale was mutated across several graphic
render passes and lead to pixelated views.

* Update reference images with iOS 10.3
2019-08-27 13:51:38 -07:00
Rahul Malik bda0a5b22b Track backgroundColor in ASDisplayNode (#1640)
To preserve dynamic color capabilities for layer-backed
nodes, we need to track backgroundColor as a UIColor. In layer backed nodes we lose the dynamic color logic since we
extract a CGColor from the UIColor applied to ASDisplayNode. With this
change we can respond to changes in UITraitCollection.userInterfaceStyle
for backgroundColor.
2019-08-26 17:58:53 -07:00
vovasty 1961a5a948 Add support for loading image variants through Asset catalogs (#1630)
Currently ASImageNode would initially load the correct asset from the asset catalog but would not respond to changes in trait collections that would require loading a different asset from the asset catalog. This change allows use to use `-[UIImage imageAsset]` to reference the asset catalog entry for the current image and load the appropriate version based on the current trait collection
2019-08-23 14:42:05 -07:00
Hanton Yang 762c8e8bff Keep using unowned macro (#1626) 2019-08-22 17:02:50 -07:00
Rahul Malik e0d5cedd23 Dark Mode dynamic rendering preparation, adding experiment to propagate older trait collections (#1637)
- Adding experiment to propagate older trait collections when trait
collections change
- Re-render nodes when user interface style changes (dark mode)
- Snapshot testing examples for dark mode
- Fixes for applying trait collection overrides in XCTest
- Create new define for gating Xcode 11 / iOS 13 features until CI is running it
2019-08-22 15:53:17 -07:00
Jessie Alvarez ccee5666dd Allow full color tinting on grayscale template images. (#1629)
* Allow full color tinting on grayscale template images.

* Signing a commit with the correct email address.

* Add snapshot test for a grayscale image with ASExperimentalDrawingGlobal enabled.
2019-08-22 12:53:49 -07:00
Hanton Yang 1467319ec3 Minor code improvements (#1622)
* Simplify code logic

* Keep using user-defined type
2019-08-20 22:14:15 -07:00
Huy Nguyen ab0a14c8ab Minor changes to tint color support (#1620) 2019-08-15 12:59:10 -07:00
Rahul Malik b9903a4155 Add support for tinting layer-backed ASDisplayNode (#1617)
* Add support for tinting layer-backed ASImageNode's

* Move tint color support ASDisplayNode

* Address comments, unlock before calling "tintColorDidChange" on
subclasses

* Address comments
2019-08-15 10:03:15 -07:00
Huy Nguyen b721a911c8 Remove _ASDisplayLayer's delegateDidChangeBounds flag (#1618)
We rely on the delegate setter to be called to set the flag. However, recent change on iOS 13 causes the setter to not be called at all and thus we had to put up a workaround (https://github.com/TextureGroup/Texture/pull/1609). While the workaround works, the perf benefit of that the flag provides doesn't warranty the extra complexity IMO. So I think we should just remove everything.
2019-08-15 10:01:36 -07:00
Hanton Yang ad1ed9f6b6 Remove unused headers (#1615)
* Improve compilation time by reducing unnecessary compilation dependencies
* More clean code
2019-08-15 05:42:26 -07:00
Rahul Malik 4caf9511f4 Avoid querying for NSAttributedString attributes on empty string (#1614) 2019-08-13 14:39:27 -07:00
Michael Schneider 0c78681cdc Cleanup for cgFloatForYogaFloat (#1571)
- Return CGFloat
- Proper check for YGUndefined
- Add YGUndefined default return value
2019-08-12 14:05:23 -07:00
Rahul Malik 540f1344ab Add support for tintColor on ASImageNode and ASButtonNode (#1603)
- 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.
2019-08-12 09:14:54 -07:00
Rahul Malik ae00a9053d Force -[_ASDisplayLayer setDelegate:] to evaluate delegateFlags in iOS13. (#1609)
It appears that UIKit might be setting the delegate ivar directly which bypasses establishing the `_delegateFlags` ivar on `ASDisplayLayer`. This is critical for things like ASPagerNode, ASCollectionNode that depend on layer delegateFlags to forward bounds changes.
Radar filed: FB6956185
2019-08-08 10:15:22 -07:00
Hanton 3a3e574ef0 Update periodicTimeObserverTimescale's comment default value, according to the real value set in the implementation (#1604) 2019-08-04 10:08:38 -07:00
Ray Sang Hyuk Cho ecd0ef7374 [ASImageNode] Stop setting frameInterval for animated image optimization (#1607)
We previously tried to optimize showing animated images (e.g. GIF) by calling
display link for updating the frame just when when we need the next frame, but
this resulted in some frames dropping when `frameInterval` wasn't respected like
you can find from this GIF:
https://i.pinimg.com/originals/58/9c/e8/589ce828d2ef0797da0e85b1c6d2f2b3.gif

Since the the display link fire method continues if we detect we're
at the same image index as before, let's just remove this optimization.
2019-08-04 10:07:17 -07:00
dirtmelon a88e3cfc5f Add new property alwaysHandleTapTruncationAction to ASTextNode2 and ASTextNode. (#1520)
If the alwaysHandleTapTruncationAction is YES, the ASTextNode and ASTextNode2 can handle touches on additional attributed message even passthrough is YES.
2019-07-30 10:50:01 -07:00
Hanton b933f661b9 Use AS_ARRAY_SIZE for array counting (#1600) 2019-07-28 13:07:54 -07:00
Wu Zhong 9cedd4e3e6 Add download progress support to ASNetworkImageNode (#1489) 2019-07-24 22:44:16 -07:00
Rahul Malik 4ebd38c316 Update ASPendingState type for backgroundColor to UIColor
Given that UIColor is now a dynamic provider we can no longer rely on the fact that there is a 1:1 mapping between UIColor <-> CGColorRef.

I've updated the UIViewBridge and ASPendingState accordingly to use UIColor and translate to CGColorRef only when interacting with layers. This should preserve any dynamic capabilities we might need in the future when trying to re-render layer backed nodes.
2019-07-20 18:53:37 -07:00
Rahul Malik d4d6897a97 Set background color directly to view if not layer backed (#1588)
* Set background color directly to view or layer depending on if the node
is layerBacked.

Summary:
UIColor can now be a dynamic color provider to support capabilities like Dark Mode in applications. UIKit is able to re-render views when a user enters dark mode but this dynamic capabilities is not handled at the layer level.

Currently this takes the recommendation in facebookarchive/AsyncDisplayKit#1537 (comment) to set background color on the view directly or layer depending on if the node is layer backed. This change allows UIKit to track these colors and update the UI when the UITraitCollection.userInterfaceStyle changes.

* Updates to UIViewBridge to fix tests

* Remove opaque

* Test fixes

* Revert change to test checker method

* Fix strange issue where setting UIView backgroundColor sets the layer to
opaque to false

* Address Huy comments

* Address last comment
2019-07-19 19:17:01 -07:00
ernestmama 9c537ead5d Add a new networking image delegate method when a network image node failed to load from cache (#1590) 2019-07-19 11:45:37 -07:00
Greg Bolsinga 7da85c5008 Run Import Optimizer on Texture (#1580)
* Run Import Optimizer on Texture
2019-07-11 19:19:13 -07:00
Hanton b7d64a0917 Fix the build warning in ASRangeController.mm (#1575) 2019-07-11 12:14:14 -07:00
Rahul Malik 6176aa4bc9 Bridge CTFontRef directly to UIFont when converting attributes on NSAttributedString (#1579)
In iOS13, there is an issue with the font returned from "-[UIFontj fontWithName:size:]". When asking for "SFUI-Regular" returns "Times New Roman" font.

It isn't clear why we were trying to create a new font instance when CTFontRef toll-free bridges to UIFont. This appears to pass tests both internally at Pinterest and Texture so I feel like the change is pretty safe and should also solve the iOS 13 regression users are experiencing.
2019-07-11 11:54:33 -07:00
Sterlingster 901f4dd97f Fixes accessibilityLabel bug on ASButtonNode that has no title (#1573) 2019-07-10 20:03:39 -07:00
Michael Schneider 18e55277dc Fix truncation token is wrong after attributed string is changing with different foreground color (#1550) 2019-07-02 06:56:50 -07:00
Huy Nguyen 6e46d9bcd5 [ASDataController] Add an experiment that avoids flushing editing queue before starting the data pipeline pipeline (#1564)
* [ASDataController] Avoid flushing editing queue before starting data controller pipeline

Step 1 of the pipeline is on main thread and needs pendingMap which was updated by the end of step 1 of the run. And step 1 operates on data source index space. So it should be ok to start it ASAP -- without waiting for any running work on the background editing queue.

One potential race condition after this change is that it's possible for main thread to query the data source (step 1) while the editing queue consumes the last change set (step 3). However, as long as the client's each nodeBlock and the node's layout code capture/reference an individual model object (as opposed to the whole data set) -- which is what clients are supposed to do anyways, then everything should be fine.

The benefit of this diff is that the pipeline will be able to accept many more change sets within a short time window, for example when clients submit a burst of separate small updates.

I tested this diff against our test suite several times and smoke tested it in our code base without any issues.

* Wrap in an experiment

* Enable experiment in tests

* Minor change
2019-06-30 21:08:06 -07:00
LiuJian 59ab0e8773 Fix placeholder (#1555)
* Fix placeholder

* [Unit Tests] Add Placeholder Test (#1555)
2019-06-28 10:40:45 -07:00
Michael Schneider d7239baaa4 Fix ASTextNode2 supportsLayerBacking (#1545)
`[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.
2019-06-25 15:03:12 -07:00
Huy Nguyen e274e5dac5 Remove ivar of ASCellNode.owningNode (#1559) 2019-06-25 10:58:43 -07:00
Huy Nguyen ba1e0acb1e Restore call pattern where UIView methods drive __enterHierarchy and __exitHierarchy for view-backed nodes (#1561)
After #1396, some view-backed nodes in our app stop responding to tap events. I tracked it down to [this change](https://github.com/TextureGroup/Texture/pull/1396/files#diff-7fbc7d84a259cbfbee7546a5310dddcfR162) which suggests that the order of execution matters.

This diff attempts to fix the issue by restoring the previous call order where `__enterHierarchy` and `__exitHierarchy` are driven by `_ASDisplayView`'s `-willMoveToWindow:` and `-didMoveToWindow` if the node is view-backed. Layer-backed nodes will still call `__enterHierarchy`/`__exitHierarchy` when they get `kCAOnOrderIn`/`kCAOnOrderOut`.

This maintains the layer-action support introduced in #1396.
2019-06-25 10:58:13 -07:00