Fix scroll node in yoga (#1435)

* 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 child not fit to full scroll node's bounds when flex_grow = 1.0 is used on child
This commit is contained in:
Max Wang
2019-04-02 08:11:25 -07:00
committed by Adlai Holler
parent 442317b8ab
commit d970dc3548
2 changed files with 49 additions and 0 deletions
+15
View File
@@ -111,6 +111,21 @@
if (ASPointsValidForLayout(selfSize.height) == NO) {
selfSize.height = _contentCalculatedSizeFromLayout.height;
}
// The side effect for layout with CGFLOAT_MAX is that the min-height/width on the child of
// ScrollNode may not be applied correctly. Resulting in the contentSize less than the
// scrollNode's bounds which may not be what the child want (e.g. The child want to fill
// ScrollNode's bounds). In that case we need to give it a chance to layout with ScrollNode's
// bound in case children want to fill the ScrollNode's bound.
if ((ASScrollDirectionContainsVerticalDirection(_scrollableDirections) &&
layout.size.height < selfSize.height) ||
(ASScrollDirectionContainsHorizontalDirection(_scrollableDirections) &&
layout.size.width < selfSize.width)) {
layout = [super calculateLayoutThatFits:constrainedSize
restrictedToSize:size
relativeToParentSize:parentSize];
}
// Don't provide a position, as that should be set by the parent.
layout = [ASLayout layoutWithLayoutElement:self
size:selfSize
+34
View File
@@ -104,6 +104,40 @@
ASXCTAssertEqualSizes(self.scrollNode.view.contentSize, subnodeSize);
}
- (void)testAutomaticallyManagesContentSizeWithSizeRangeSmallerThanParentSizeFillContainer
{
CGSize subnodeSize = CGSizeMake(100, 200);
CGSize parentSize = CGSizeMake(100, 500);
ASSizeRange sizeRange = ASSizeRangeMake(CGSizeMake(100, 200), CGSizeMake(100, 200));
self.subnode.style.flexGrow = 1.0;
self.subnode.style.minHeight = ASDimensionMake(ASDimensionUnitPoints, 50.0);
self.subnode.style.width = ASDimensionMake(ASDimensionUnitPoints, 100.0);
[self.scrollNode layoutThatFits:sizeRange parentSize:parentSize];
[self.scrollNode layout];
ASXCTAssertEqualSizes(self.scrollNode.calculatedSize, sizeRange.max);
ASXCTAssertEqualSizes(self.scrollNode.view.contentSize, subnodeSize);
}
// It's expected that the contentSize is 100x100 when ScrollNode's bounds is 100x200, which currently
// not the case for LayoutSepc but work in Yoga.
- (void)disable_testAutomaticallyManagesContentSizeWithSizeRangeSmallerThanParentSizeKeepChildSize
{
CGSize subnodeSize = CGSizeMake(100, 100);
CGSize parentSize = CGSizeMake(100, 200);
ASSizeRange sizeRange = ASSizeRangeMake(CGSizeMake(100, 200), CGSizeMake(100, 200));
self.subnode.style.width = ASDimensionMake(ASDimensionUnitPoints, 100.0);
self.subnode.style.height = ASDimensionMake(ASDimensionUnitPoints, 100.0);
[self.scrollNode layoutThatFits:sizeRange parentSize:parentSize];
[self.scrollNode layout];
ASXCTAssertEqualSizes(self.scrollNode.calculatedSize, sizeRange.max);
ASXCTAssertEqualSizes(self.scrollNode.view.contentSize, subnodeSize);
}
- (void)testAutomaticallyManagesContentSizeWithSizeRangeBiggerThanParentSize
{
CGSize subnodeSize = CGSizeMake(100, 200);