5149 Commits
Author SHA1 Message Date
ricky 6255d404c3 [RTL/Batching] Make ASDisplayShouldFetchBatchForScrollView aware of flipped CV layouts (#1985)
* [RTL/Batching] Make ASDisplayShouldFetchBatchForScrollView aware of flipped CV layouts

UICollectionViewLayout has a property called `flipsHorizontallyInOppositeLayoutDirection`. If this is set to `YES` then a RTL collectionView’s contentOffset behaves like it does in LTR. In other words, the first item is at contentOffset 0. In this case, the existing logic for `ASDisplayShouldFetchBatchForScrollView` works in RTL.

If you don’t override `flipsHorizontallyInOppositeLayoutDirection` to be `YES`, then it means that in RTL languages the first item in your collectionView will actually be at x offset `collectionView.contentSize.width - collectionView.frame.size.width`. As you scroll to the right, the content offset will decrease until you reach the end of the data at a content offset of 0,0. In this case, `ASDisplayShouldFetchBatchForScrollView` needs to know that you are in RTL and the layout is not flipped. It can then use the contentOffset as the `remainingDistance` to determine when to fetch.

* fix indentation

* assert that we are on main when accessing CV layout
2021-05-03 13:40:55 -07:00
ricky 8870628f61 [Layout] Add RTL support to LayoutSpecs (#1983)
* [Layout] Add RTL support to LayoutSpecs

This is largely a slight update for https://github.com/TextureGroup/Texture/pull/1805. If RTL is enabled, `calculateLayoutLayoutSpec:` will flip the origin of all sublayouts.

The new part of the diff is that ASBatchFetching now supports proper fetching on RTL horizontal scrollViews.

* Fix build and add RTL batch fetching tests
2021-04-14 11:28:04 -07:00
ricky de115e2000 [ASTextNode2] Check that rangeOut is non-nil before dereferencing (#1980)
rangeOut is a nullable parameter, but we are treating it as though it is always not null. Make sure it is not null before dereferencing it.
2021-04-05 19:51:41 -07:00
Sylvain Defresne 3776c893c7 Remove trailing semicolons between method parameters and body (#1973)
Having a semi-colon between a method parameters list and a method
body is not not correct and is usually caused by a copy and paste
error while creating the method definition from its declaration.

Fixes the following compilation warnings when building with
-Wsemicolon-before-method-body (which is part of -Wextra):

  ASPINRemoteImageDownloader.mm:230:85: error: semicolon before method body is ignored [-Werror,-Wsemicolon-before-method-body]
  - (id <ASImageContainerProtocol>)synchronouslyFetchedCachedImageWithURL:(NSURL *)URL;
                                                                                      ^
  ASPINRemoteImageDownloader.mm:275:76: error: semicolon before method body is ignored [-Werror,-Wsemicolon-before-method-body]
                           completion:(ASImageDownloaderCompletion)completion;
                                                                             ^
  2 errors generated.

Fixes applied to both code, examples and samples in documentation.
2021-03-29 14:05:06 -07:00
rqueue 6194970dcf Expand ASExperimentalRangeUpdateOnChangesetUpdate to ASTableView (#1979)
A previous commit
(https://github.com/TextureGroup/Texture/commit/8f7444e0ece61d6ab12ecceb590be26d8d7cc99d)
aimed to fix a preloading bug for ASCollectionView. This commit expands this
fix to ASTableView as the bug occurs there too.

Previous commit message for context:

This experiment makes sure a ASCollectionView's `rangeController` updates when
a changeset WITH updates is applied. Currently it is possible for nodes
inserted into the preload range to not get preloaded when performing a batch
update.

For example, suppose a collection node has:
- Tuning parameters with a preload range of 1 screenful for the given range
  mode.
- Nodes A and B where A is visible and B is off screen.
Currently if node B is deleted and a new node C is inserted in its place, node
C will not get preloaded until the collection node is scrolled. This is because
the preloading mechanism relies on a `setNeedsUpdate` call on the range
controller as part of the `-collectionView:willDisplayCell:forItemAtIndexPath:`
delegate method when the batch update is submitted. However, in the example
outlined above, this sometimes doesn't happen automtically, causing the range
update to be delayed until the next the view scrolls.
2021-03-29 14:05:06 -07:00
Andrew Yates a4dae51d6c Remove Facebook and shift everything around, add Remix by Buffer (#1978) 2021-03-29 14:05:06 -07:00
rqueue 9b2e3532ea Add experiment to ensure ASCollectionView's range controller updates on changeset updates (#1976)
This experiment makes sure a ASCollectionView's `rangeController` updates when
a changeset WITH updates is applied. Currently it is possible for nodes
inserted into the preload range to not get preloaded when performing a batch
update.

For example, suppose a collection node has:
- Tuning parameters with a preload range of 1 screenful for the given range
  mode.
- Nodes A and B where A is visible and B is off screen.
Currently if node B is deleted and a new node C is inserted in its place, node
C will not get preloaded until the collection node is scrolled. This is because
the preloading mechanism relies on a `setNeedsUpdate` call on the range
controller as part of the `-collectionView:willDisplayCell:forItemAtIndexPath:`
delegate method when the batch update is submitted. However, in the example
outlined above, this sometimes doesn't happen automtically, causing the range
update to be delayed until the next the view scrolls.
2021-03-29 14:05:06 -07:00
ricky fc0d9a67e5 [ASTextNode2] Fix centered text shorter than container size (#1977) 2021-03-25 12:15:30 -07:00
ricky c3070cfb5c [ASTextNode2] Scale the truncation token via pointScaleFactors (#1974)
If we need to scale text in order to fit in our size, don’t forget to also scale the truncation token!

(disabled carthage so the builds will pass)
2021-03-12 16:18:46 -08:00
ricky a844f4eeae [ASTextNode] call initialize after possibly dynamically changing the superclass (#1970)
* [ASTextNode] call initialize after possibly dynamically changing the superclass

In order to experiment with ASTN2 we do some crazy obj-c voodoo to change the superclass of an object from `ASTextNode` to `ASTextNode2`. However, before we do that we set up the object’s `_flags` which, among other things, caches whether or not a class responds to certain selectors.

ASTN and ASTN2 draw themselves differently, with ASTN using `displayWithParameters:isCancelled:` and ASTN2 using `drawRect:withParameters:isCancelled:isRasterizing:`. If we are experimenting with ASTN2, if we set up `_flags` before teh swap our eventual ASTN2 class will think it responds to `displayWithParameters:isCancelled:`. If we wait until after the possible swap to setup `_flags` everything works as expected!.

* i want to run the non carthage tests…

* [ASTN2] Fix the podspec (#1971)

* [ASTN2] Fix the podspec

I was too aggressive in including everything from `TextExperiment` as a public header file. `ASTextUtilities.h` includes a file (`ASInternalHelpers.h`) that isn’t exported as a public header and causes build issues. Hopefully this is the proper includes!

* don’t test carthage

* carthage is back

* builds passed, putting carthage back in
2021-03-09 14:14:20 -08:00
ricky 3d2da5abbc [ASTN2] Fix the podspec (#1971)
* [ASTN2] Fix the podspec

I was too aggressive in including everything from `TextExperiment` as a public header file. `ASTextUtilities.h` includes a file (`ASInternalHelpers.h`) that isn’t exported as a public header and causes build issues. Hopefully this is the proper includes!

* don’t test carthage

* carthage is back
2021-03-09 13:02:40 -08:00
ricky bc11bf9bdc [ASTextNode2] Expose all of ASTextNode2 as public files in via the podspec (#1969)
There were methods like `as_setTextStrikethrough:range:` that ASTN2 uses to expose strikethrough (`NSStrikethroughStyleAttributeName` doesn’t work) that were not public because the `Utility` folder of `TextExperiment` was not exported in the pod.
2021-03-08 15:58:52 -08:00
ricky 16978e33c3 [ASTextNode2] Fixed truncation for centered text (#1968)
* [ASTextNode2] Fixed truncation for centered text

A lot of this came from the to-be merged changes that YouTube has made to ASTextNode2. My contribution was really just the line adjusting the position of the truncated line when the line is centered.

* added test

* see if this builds without carthage

* trying to skip carthage again

* snapshot changed since we properly expand textBoundingRect for additional characters
2021-03-08 15:22:05 -08:00
ricky c239cada2e [ASTextNode2] Add support for pointSizeScaleFactors (#1966)
* [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
2021-02-26 15:30:33 -08:00
ricky c3c4065227 [ASTextNode2] If a textnode's bounds match either the text container's size OR the layout's size, consider it a cache hit (#1965)
* [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
2021-02-26 12:58:37 -08:00
Christos Gkekas 17d4d13463 Exposes a new option in ASImageDownloaderProtocol to retry image downloads (#1948)
* Exposes a new option in ASImageDownloaderProtocol to retry image downloads

At the moment the ASBasicImageDownloader does not automatically retry image downloads if the remote
host is unreachable. On the contrary the ASPINRemoteImageDownloader automatically retries. Retrying is
something that ultimately clients need to be able to control, for example to fail fast to an alternative image
rather than keep retrying for more than one minute while not displaying any image. This change exposes
a new option in the ASImageDownloaderProtocol to retry image downloads. It also uses this new option
in both ASNetworkImageNode and also ASMultiplexImageNode, setting it to YES to preserve the current
behaviour.

* Fixes a failing test in ASMultiplexImageNodeTests

* Fixes ScreenNode.m

ScreenNode.m is implementing ASImageDownloaderProtocol and needs to
be fixed to reflect changes in the latter.
2021-02-19 08:23:01 -08:00
Ted Janeczko b4a4e2c150 Fix order-dependent ASTextNodeTests (#1963) 2021-02-17 10:09:09 -08:00
Mussa Charles 6e629bd29a Update asdkGram swift sample to swift version 5.3 (#1962) 2021-02-08 10:55:27 -08:00
Zev Eisenberg 9e8de03845 Fix WKWebView Accessibility (#1955)
* Return nil instead of empty array when no accessibility elements are found. Fixes #1954.

* Use nullability annotations to fix static analyzer warnings.

* Add UI test target.

* Add UI test to make sure web view stays accessible.

* Revert "Add UI test to make sure web view stays accessible."

This reverts commit 00253f49a0af329602b0d9709b58bc92dcd90147.

* Revert "Add UI test target."

This reverts commit 288b5e0f564ef3ba3fb5568baa832bc03124cdc9.

* Add unit test to make sure accessibility elements are correct when a WKWebView is wrapped in an ASDisplayNode.
2021-02-03 13:24:39 -08:00
Joseph Price 82e6a46943 fix missing hidden class (#1952) 2021-02-01 16:56:33 -08:00
Joseph Price ad70335ba4 use https for slack link (#1950) 2021-02-01 10:58:53 -08:00
Zev Eisenberg f91e733b04 Fix mutation of variable that is never read. (#1961) 2021-02-01 10:55:35 -08:00
Zev Eisenberg b2b996e761 Remove redundant assignment. (#1960) 2021-01-30 13:57:48 -08:00
Zev Eisenberg 5edf4e01cf Update CocoaPods to use the CDN instead of the old trunk repo. (#1957) 2021-01-29 12:46:55 -08:00
Douglas Poveda 823ac0a6f3 Set ASTableView isAccessibilityElement, accessibilityElementsHidden properties from its Element's node (#1941) 2020-12-16 16:11:41 -08:00
ricky 68a1bec062 [ASTextNode2] Make some ASTextNode2 layout files public (#1939)
* Trying to make ASTextLinePositionModifier public

* d’oh

* be a little more restrictive on the files we pull into the pod

* Never mind, I guess we need all of these

* update the project file as well

* try this again

* I think this will work this time.
2020-12-14 12:30:25 -08:00
Huy Nguyen ec19b928a8 Ship ASExperimentalDispatchApply (#1924)
Closes #1850.
2020-10-06 11:42:37 -07:00
Ben Dolman efdd8acd99 Fix hit point when ASCollectionNode inverted set to true (#1781)
* Account for possible inverted transform during hit test

When ASCollectionNode has the `inverted` flag set, a transform gets
set on the cell node. We need to make sure that we account for that
when dealing in the view coordinates.

* Store self.node and self.node.view in local variables for better readability.

* Add a test for hit testing in an inverted ASCollectionNode
2020-10-06 09:36:43 -07:00
Huy Nguyen 5a205d84c8 Fix failing ASConfigurationTests (#1923)
* Fix failing ASConfigurationTests

* Update configuration.json as well
2020-10-01 21:27:55 -07:00
Huy Nguyen 2758ff18d9 More on ASDataController's main-thread-only mode (#1915)
Follow up on #1911: it's not enough to execute step 3 on the main thread because -_allocateNodesFromElements: uses ASDispatchApply to offload the work to other threads. So this diff adds a flag to tell that method to do everything serially on the calling thread.
2020-09-18 10:08:21 -07:00
Huy Nguyen 32679feb84 Add an experiment that makes ASDataController to do everything on main thread (#1911)
* Add an experiment that makes ASDataController to do everything on main thread

Under this experiment, ASDataController will allocate and layout all nodes on the main thread. This helps to avoid deadlocks that would otherwise occur if some of the node allocations or layouts caused ASDataController's background queue to block on main thread. As a bonus, this experiment also helps to measure how much performance wins we get from doing the work off main.

* Remove ASSERT_ON_EDITING_QUEUE
2020-09-17 18:04:17 -07:00
Garrett Moon 35093fb2fb Disable text kit lock (#1910)
* Add experiment to disable global textkit lock

* Forgot the bang
2020-09-17 14:15:55 -07:00
Greg Bolsinga 45c0f19ae1 Do not expose tgmath.h to all clients of Texture (#1900)
* Do not expose tgmath.h to all clients of Texture

- tgmath.h #undef the `log` macro for mathematical reasons. Code that may also use a log name (such as CocoaLumberjack) will get confused by this when they try to use `NS_SWIFT_NAME` with `log` as part of the name.
- `ABS` from NSObjCRuntime.h is what is typically used for abs on `CGFloat`.
- Note: removing tgmath.h from the Texture umbrella header may expose clients that implicitly depended upon it being imported. Sources may have to be updated after this to `#import <tgmath.h>` explicitly.
2020-08-21 14:22:34 -07:00
Garrett Moon d608bb9829 Call will / did display node for ASTextNode. Fixes #1680 (#1893) 2020-08-14 11:37:44 -07:00
Greg Bolsinga 9ef97f4965 Remove background deallocation helper code (#1890)
* Remove background deallocation helper code

Last use removed in Texture with #1840, now PINS no longer uses it either. Less OOMs is so nice.

* remove methods from docs
2020-07-30 12:02:46 -07:00
ricky f56a4dd1dd [Accessibility] Ship ASExperimentalDoNotCacheAccessibilityElements (#1888)
We did not notice any effect on performance of the Pinterest app by not caching `accessibilityElements` in `_ASDisplayView`. By not caching the elements, we can be sure that the elements will be correct even when nodes change visibility state. There will be a performance impact when voice over is enabled, but providing the correct elements for the current state of a view is more important than performance in this case.

https://github.com/TextureGroup/Texture/issues/1853
2020-07-23 15:21:07 -07:00
Garrett Moon 81ecdc9032 🎉 3.0.0 (#1883) 3.0.0 2020-07-15 10:37:03 -07:00
Garrett Moon 1552c2e386 Upgrade to Xcode 11.5 (#1877) 2020-06-29 15:05:17 -07:00
Garrett Moon c5f69f0b01 Renames AS_EXTERN and ASViewController (#1876)
* Renames AS_EXTERN and ASViewController

To ASDK_EXTERN and ASDKViewController.
This is to avoid conflicting with AuthenticationServices in
Xcode 12

* Fix up examples and docs

* Add bit about updating ASViewController rename
2020-06-29 12:49:59 -07:00
Roger Oba 8e91008b8e Improve ThreeMigrationGuide.md (#1878)
* Add `ASImageCacherCompletion` breaking API change.

* Remove unnecessary trailing pounds.
2020-06-29 08:49:08 -07:00
Garrett Moon 6a3a24707e Add a 3.0 migration guide (#1875) 2020-06-25 15:57:11 -07:00
Garrett Moon 92598f5fb7 I forgot this in the last PR and I'm pushing to master, I'm a bad person. 2020-06-25 15:21:57 -07:00
Garrett Moon a7cc48293e Update for 3.0.0-rc.2 (#1874) 2020-06-25 15:19:15 -07:00
Garrett Moon f55ade187b Update RELEASE.md (#1873) 2020-06-25 13:00:05 -07:00
Garrett Moon dbb06bf58f Fix all the warnings and re-enable on CI (#1872) 2020-06-25 11:54:00 -07:00
Garrett Moon a9643e59cd Prepare for 3.0.0-rc.1 release (#1870) 2020-06-24 14:38:28 -07:00
_ivanC 5651826c05 -[ASNetworkImageNode setURL:resetToDefault:] forget to reset animatedImage (#1861)
* Fix -[ASNetworkImageNode setURL:resetToDefault:] forget to reset animatedImage

* add ASNetworkImageNodeTest for reset with animatedImage
2020-06-16 14:07:27 -07:00
ricky e16fdd67e1 [ASDisplayNode] Implement accessibilityElementsHidden (#1859)
Most of this code comes from an old PR that @fruitcoder put up https://github.com/TextureGroup/Texture/pull/795 2 years ago.

When creating our array of accessibilityElements, we need to respect the value of `accessibilityElementsHidden`. If the value of this property changes, we need to invalidate the cached accessibility elements (unless we are in the experiment that doesn’t cache `accessibilityElements`).

I created a simple test app and made sure this matched UIKit’s implementation. I also added a test case that changes the value of `accessibilityElementsHidden` and makes sure the proper accessibilityElements are returned.
2020-06-03 16:16:43 -07:00
Christos Gkekas 8b9683d02c Fix documentation for ASCornerRoundingTypeClipping (#1863) 2020-06-02 08:51:18 -07:00
_ivanC e56c047489 Add iOS13 UIContextMenu api to ASCommonCollectionDelegate (#1860) 2020-06-02 08:46:52 -07:00