Remove ASLayoutNodeSize:

- ASLayoutNode no longer has 'size' constraint during its initialization..
- ASLayoutNode no longer needs parentSize to calculate its layout.
This commit is contained in:
Huy Nguyen 2015-06-23 17:34:24 +07:00
parent 90a78684c9
commit 64e2323a4e
25 changed files with 76 additions and 406 deletions

View File

@ -310,8 +310,6 @@
ACF6ED251B17843500DA7C62 /* ASLayout.mm in Sources */ = {isa = PBXBuildFile; fileRef = ACF6ED0C1B17843500DA7C62 /* ASLayout.mm */; };
ACF6ED261B17843500DA7C62 /* ASLayoutNode.h in Headers */ = {isa = PBXBuildFile; fileRef = ACF6ED0D1B17843500DA7C62 /* ASLayoutNode.h */; settings = {ATTRIBUTES = (Public, ); }; };
ACF6ED271B17843500DA7C62 /* ASLayoutNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = ACF6ED0E1B17843500DA7C62 /* ASLayoutNode.mm */; };
ACF6ED281B17843500DA7C62 /* ASLayoutNodeSize.h in Headers */ = {isa = PBXBuildFile; fileRef = ACF6ED0F1B17843500DA7C62 /* ASLayoutNodeSize.h */; settings = {ATTRIBUTES = (Public, ); }; };
ACF6ED291B17843500DA7C62 /* ASLayoutNodeSize.mm in Sources */ = {isa = PBXBuildFile; fileRef = ACF6ED101B17843500DA7C62 /* ASLayoutNodeSize.mm */; };
ACF6ED2A1B17843500DA7C62 /* ASLayoutNodeSubclass.h in Headers */ = {isa = PBXBuildFile; fileRef = ACF6ED111B17843500DA7C62 /* ASLayoutNodeSubclass.h */; settings = {ATTRIBUTES = (Public, ); }; };
ACF6ED2B1B17843500DA7C62 /* ASOverlayLayoutNode.h in Headers */ = {isa = PBXBuildFile; fileRef = ACF6ED121B17843500DA7C62 /* ASOverlayLayoutNode.h */; settings = {ATTRIBUTES = (Public, ); }; };
ACF6ED2C1B17843500DA7C62 /* ASOverlayLayoutNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = ACF6ED131B17843500DA7C62 /* ASOverlayLayoutNode.mm */; };
@ -410,13 +408,13 @@
058D09D5195D050800B7D73C /* ASControlNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASControlNode.h; sourceTree = "<group>"; };
058D09D6195D050800B7D73C /* ASControlNode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASControlNode.m; sourceTree = "<group>"; };
058D09D7195D050800B7D73C /* ASControlNode+Subclasses.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASControlNode+Subclasses.h"; sourceTree = "<group>"; };
058D09D8195D050800B7D73C /* ASDisplayNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASDisplayNode.h; sourceTree = "<group>"; };
058D09D9195D050800B7D73C /* ASDisplayNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = ASDisplayNode.mm; sourceTree = "<group>"; };
058D09D8195D050800B7D73C /* ASDisplayNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = ASDisplayNode.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
058D09D9195D050800B7D73C /* ASDisplayNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = ASDisplayNode.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
058D09DA195D050800B7D73C /* ASDisplayNode+Subclasses.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = "ASDisplayNode+Subclasses.h"; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
058D09DB195D050800B7D73C /* ASDisplayNodeExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASDisplayNodeExtras.h; sourceTree = "<group>"; };
058D09DC195D050800B7D73C /* ASDisplayNodeExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASDisplayNodeExtras.mm; sourceTree = "<group>"; };
058D09DD195D050800B7D73C /* ASImageNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASImageNode.h; sourceTree = "<group>"; };
058D09DE195D050800B7D73C /* ASImageNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = ASImageNode.mm; sourceTree = "<group>"; };
058D09DE195D050800B7D73C /* ASImageNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = ASImageNode.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
058D09DF195D050800B7D73C /* ASTextNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASTextNode.h; sourceTree = "<group>"; };
058D09E0195D050800B7D73C /* ASTextNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = ASTextNode.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
058D09E2195D050800B7D73C /* _ASDisplayLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _ASDisplayLayer.h; sourceTree = "<group>"; };
@ -527,30 +525,28 @@
B35061DE1B010EDF0018CF92 /* AsyncDisplayKit-iOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AsyncDisplayKit-iOS.h"; sourceTree = "<group>"; };
AC6456071B0A335000CF11B8 /* ASCellNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASCellNode.mm; sourceTree = "<group>"; };
ACF6ED011B17843500DA7C62 /* ASBackgroundLayoutNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASBackgroundLayoutNode.h; path = AsyncDisplayKit/Layout/ASBackgroundLayoutNode.h; sourceTree = "<group>"; };
ACF6ED021B17843500DA7C62 /* ASBackgroundLayoutNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASBackgroundLayoutNode.mm; path = AsyncDisplayKit/Layout/ASBackgroundLayoutNode.mm; sourceTree = "<group>"; };
ACF6ED021B17843500DA7C62 /* ASBackgroundLayoutNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; name = ASBackgroundLayoutNode.mm; path = AsyncDisplayKit/Layout/ASBackgroundLayoutNode.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
ACF6ED031B17843500DA7C62 /* ASCenterLayoutNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASCenterLayoutNode.h; path = AsyncDisplayKit/Layout/ASCenterLayoutNode.h; sourceTree = "<group>"; };
ACF6ED041B17843500DA7C62 /* ASCenterLayoutNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASCenterLayoutNode.mm; path = AsyncDisplayKit/Layout/ASCenterLayoutNode.mm; sourceTree = "<group>"; };
ACF6ED041B17843500DA7C62 /* ASCenterLayoutNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; name = ASCenterLayoutNode.mm; path = AsyncDisplayKit/Layout/ASCenterLayoutNode.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
ACF6ED051B17843500DA7C62 /* ASCompositeNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASCompositeNode.h; path = AsyncDisplayKit/Layout/ASCompositeNode.h; sourceTree = "<group>"; };
ACF6ED061B17843500DA7C62 /* ASCompositeNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASCompositeNode.mm; path = AsyncDisplayKit/Layout/ASCompositeNode.mm; sourceTree = "<group>"; };
ACF6ED071B17843500DA7C62 /* ASDimension.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASDimension.h; path = AsyncDisplayKit/Layout/ASDimension.h; sourceTree = "<group>"; };
ACF6ED081B17843500DA7C62 /* ASDimension.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASDimension.mm; path = AsyncDisplayKit/Layout/ASDimension.mm; sourceTree = "<group>"; };
ACF6ED091B17843500DA7C62 /* ASInsetLayoutNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASInsetLayoutNode.h; path = AsyncDisplayKit/Layout/ASInsetLayoutNode.h; sourceTree = "<group>"; };
ACF6ED0A1B17843500DA7C62 /* ASInsetLayoutNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASInsetLayoutNode.mm; path = AsyncDisplayKit/Layout/ASInsetLayoutNode.mm; sourceTree = "<group>"; };
ACF6ED0A1B17843500DA7C62 /* ASInsetLayoutNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; name = ASInsetLayoutNode.mm; path = AsyncDisplayKit/Layout/ASInsetLayoutNode.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
ACF6ED0B1B17843500DA7C62 /* ASLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASLayout.h; path = AsyncDisplayKit/Layout/ASLayout.h; sourceTree = "<group>"; };
ACF6ED0C1B17843500DA7C62 /* ASLayout.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASLayout.mm; path = AsyncDisplayKit/Layout/ASLayout.mm; sourceTree = "<group>"; };
ACF6ED0D1B17843500DA7C62 /* ASLayoutNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASLayoutNode.h; path = AsyncDisplayKit/Layout/ASLayoutNode.h; sourceTree = "<group>"; };
ACF6ED0E1B17843500DA7C62 /* ASLayoutNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASLayoutNode.mm; path = AsyncDisplayKit/Layout/ASLayoutNode.mm; sourceTree = "<group>"; };
ACF6ED0F1B17843500DA7C62 /* ASLayoutNodeSize.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASLayoutNodeSize.h; path = AsyncDisplayKit/Layout/ASLayoutNodeSize.h; sourceTree = "<group>"; };
ACF6ED101B17843500DA7C62 /* ASLayoutNodeSize.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASLayoutNodeSize.mm; path = AsyncDisplayKit/Layout/ASLayoutNodeSize.mm; sourceTree = "<group>"; };
ACF6ED0E1B17843500DA7C62 /* ASLayoutNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; name = ASLayoutNode.mm; path = AsyncDisplayKit/Layout/ASLayoutNode.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
ACF6ED111B17843500DA7C62 /* ASLayoutNodeSubclass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASLayoutNodeSubclass.h; path = AsyncDisplayKit/Layout/ASLayoutNodeSubclass.h; sourceTree = "<group>"; };
ACF6ED121B17843500DA7C62 /* ASOverlayLayoutNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASOverlayLayoutNode.h; path = AsyncDisplayKit/Layout/ASOverlayLayoutNode.h; sourceTree = "<group>"; };
ACF6ED131B17843500DA7C62 /* ASOverlayLayoutNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASOverlayLayoutNode.mm; path = AsyncDisplayKit/Layout/ASOverlayLayoutNode.mm; sourceTree = "<group>"; };
ACF6ED131B17843500DA7C62 /* ASOverlayLayoutNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; name = ASOverlayLayoutNode.mm; path = AsyncDisplayKit/Layout/ASOverlayLayoutNode.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
ACF6ED141B17843500DA7C62 /* ASRatioLayoutNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASRatioLayoutNode.h; path = AsyncDisplayKit/Layout/ASRatioLayoutNode.h; sourceTree = "<group>"; };
ACF6ED151B17843500DA7C62 /* ASRatioLayoutNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASRatioLayoutNode.mm; path = AsyncDisplayKit/Layout/ASRatioLayoutNode.mm; sourceTree = "<group>"; };
ACF6ED151B17843500DA7C62 /* ASRatioLayoutNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; name = ASRatioLayoutNode.mm; path = AsyncDisplayKit/Layout/ASRatioLayoutNode.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
ACF6ED161B17843500DA7C62 /* ASStackLayoutNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASStackLayoutNode.h; path = AsyncDisplayKit/Layout/ASStackLayoutNode.h; sourceTree = "<group>"; };
ACF6ED171B17843500DA7C62 /* ASStackLayoutNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASStackLayoutNode.mm; path = AsyncDisplayKit/Layout/ASStackLayoutNode.mm; sourceTree = "<group>"; };
ACF6ED181B17843500DA7C62 /* ASStaticLayoutNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASStaticLayoutNode.h; path = AsyncDisplayKit/Layout/ASStaticLayoutNode.h; sourceTree = "<group>"; };
ACF6ED191B17843500DA7C62 /* ASStaticLayoutNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASStaticLayoutNode.mm; path = AsyncDisplayKit/Layout/ASStaticLayoutNode.mm; sourceTree = "<group>"; };
ACF6ED191B17843500DA7C62 /* ASStaticLayoutNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; name = ASStaticLayoutNode.mm; path = AsyncDisplayKit/Layout/ASStaticLayoutNode.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
ACF6ED431B17847A00DA7C62 /* ASInternalHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASInternalHelpers.h; sourceTree = "<group>"; };
ACF6ED441B17847A00DA7C62 /* ASInternalHelpers.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASInternalHelpers.mm; sourceTree = "<group>"; };
ACF6ED451B17847A00DA7C62 /* ASLayoutNodeUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASLayoutNodeUtilities.h; sourceTree = "<group>"; };
@ -558,13 +554,13 @@
ACF6ED471B17847A00DA7C62 /* ASStackPositionedLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASStackPositionedLayout.h; sourceTree = "<group>"; };
ACF6ED481B17847A00DA7C62 /* ASStackPositionedLayout.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASStackPositionedLayout.mm; sourceTree = "<group>"; };
ACF6ED491B17847A00DA7C62 /* ASStackUnpositionedLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASStackUnpositionedLayout.h; sourceTree = "<group>"; };
ACF6ED4A1B17847A00DA7C62 /* ASStackUnpositionedLayout.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASStackUnpositionedLayout.mm; sourceTree = "<group>"; };
ACF6ED4A1B17847A00DA7C62 /* ASStackUnpositionedLayout.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; path = ASStackUnpositionedLayout.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
ACF6ED531B178DC700DA7C62 /* ASCenterLayoutNodeSnapshotTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASCenterLayoutNodeSnapshotTests.mm; sourceTree = "<group>"; };
ACF6ED541B178DC700DA7C62 /* ASDimensionTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASDimensionTests.mm; sourceTree = "<group>"; };
ACF6ED551B178DC700DA7C62 /* ASInsetLayoutNodeSnapshotTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASInsetLayoutNodeSnapshotTests.mm; sourceTree = "<group>"; };
ACF6ED561B178DC700DA7C62 /* ASLayoutNodeSizeTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASLayoutNodeSizeTests.mm; sourceTree = "<group>"; };
ACF6ED571B178DC700DA7C62 /* ASLayoutNodeSnapshotTestsHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASLayoutNodeSnapshotTestsHelper.h; sourceTree = "<group>"; };
ACF6ED581B178DC700DA7C62 /* ASLayoutNodeSnapshotTestsHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASLayoutNodeSnapshotTestsHelper.m; sourceTree = "<group>"; };
ACF6ED581B178DC700DA7C62 /* ASLayoutNodeSnapshotTestsHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = ASLayoutNodeSnapshotTestsHelper.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
ACF6ED591B178DC700DA7C62 /* ASOverlayLayoutNodeSnapshotTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASOverlayLayoutNodeSnapshotTests.mm; sourceTree = "<group>"; };
ACF6ED5A1B178DC700DA7C62 /* ASRatioLayoutNodeSnapshotTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASRatioLayoutNodeSnapshotTests.mm; sourceTree = "<group>"; };
ACF6ED5B1B178DC700DA7C62 /* ASStackLayoutNodeSnapshotTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASStackLayoutNodeSnapshotTests.mm; sourceTree = "<group>"; };
@ -933,8 +929,6 @@
ACF6ED0C1B17843500DA7C62 /* ASLayout.mm */,
ACF6ED0D1B17843500DA7C62 /* ASLayoutNode.h */,
ACF6ED0E1B17843500DA7C62 /* ASLayoutNode.mm */,
ACF6ED0F1B17843500DA7C62 /* ASLayoutNodeSize.h */,
ACF6ED101B17843500DA7C62 /* ASLayoutNodeSize.mm */,
ACF6ED111B17843500DA7C62 /* ASLayoutNodeSubclass.h */,
ACF6ED121B17843500DA7C62 /* ASOverlayLayoutNode.h */,
ACF6ED131B17843500DA7C62 /* ASOverlayLayoutNode.mm */,
@ -977,7 +971,6 @@
ACF6ED241B17843500DA7C62 /* ASLayout.h in Headers */,
ACF6ED1E1B17843500DA7C62 /* ASCompositeNode.h in Headers */,
ACF6ED2F1B17843500DA7C62 /* ASStackLayoutNode.h in Headers */,
ACF6ED281B17843500DA7C62 /* ASLayoutNodeSize.h in Headers */,
ACF6ED1A1B17843500DA7C62 /* ASBackgroundLayoutNode.h in Headers */,
291B63FB1AA53A7A000A71B3 /* ASScrollDirection.h in Headers */,
464052221A3F83C40061C0BA /* ASFlowLayoutController.h in Headers */,
@ -1378,7 +1371,6 @@
292C59A11A956527007E5DD6 /* ASRangeHandlerPreload.mm in Sources */,
058D0A20195D050800B7D73C /* ASTextNodeWordKerner.m in Sources */,
058D0A1A195D050800B7D73C /* ASHighlightOverlayLayer.mm in Sources */,
ACF6ED291B17843500DA7C62 /* ASLayoutNodeSize.mm in Sources */,
464052231A3F83C40061C0BA /* ASFlowLayoutController.mm in Sources */,
058D0A28195D050800B7D73C /* ASDisplayNode+AsyncDisplay.mm in Sources */,
0587F9BE1A7309ED00AFF0BA /* ASEditableTextNode.mm in Sources */,

View File

@ -1271,7 +1271,7 @@ static NSInteger incrementIfFound(NSInteger i) {
{
ASDisplayNodeAssertThreadAffinity(self);
ASLayoutNode *layoutNode = [self layoutNodeThatFits:constrainedSize];
ASLayout *layout = [layoutNode layoutThatFits:{CGSizeZero, constrainedSize} parentSize:constrainedSize];
ASLayout *layout = [layoutNode computeLayoutThatFits:{CGSizeZero, constrainedSize}];
return layout;
}

View File

@ -27,7 +27,6 @@
#import <AsyncDisplayKit/ASLayout.h>
#import <AsyncDisplayKit/ASDimension.h>
#import <AsyncDisplayKit/ASLayoutNodeSize.h>
#import <AsyncDisplayKit/ASCompositeNode.h>
#import <AsyncDisplayKit/ASLayoutNode.h>
#import <AsyncDisplayKit/ASBackgroundLayoutNode.h>

View File

@ -20,7 +20,6 @@
returns nil.
@param background A child that is laid out behind it. May be nil, in which case the background is omitted.
*/
+ (instancetype)newWithNode:(ASLayoutNode *)node
background:(ASLayoutNode *)background;
+ (instancetype)newWithNode:(ASLayoutNode *)node background:(ASLayoutNode *)background;
@end

View File

@ -24,19 +24,18 @@
@implementation ASBackgroundLayoutNode
+ (instancetype)newWithNode:(ASLayoutNode *)node
background:(ASLayoutNode *)background
+ (instancetype)newWithNode:(ASLayoutNode *)node background:(ASLayoutNode *)background
{
if (node == nil) {
return nil;
}
ASBackgroundLayoutNode *n = [super newWithSize:{}];
ASBackgroundLayoutNode *n = [super new];
n->_node = node;
n->_background = background;
return n;
}
+ (instancetype)newWithSize:(ASLayoutNodeSize)size
+ (instancetype)new
{
ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER();
}
@ -45,20 +44,13 @@
First layout the contents, then fit the background image.
*/
- (ASLayout *)computeLayoutThatFits:(ASSizeRange)constrainedSize
restrictedToSize:(ASLayoutNodeSize)size
relativeToParentSize:(CGSize)parentSize
{
ASDisplayNodeAssert(ASLayoutNodeSizeEqualToNodeSize(size, ASLayoutNodeSizeZero),
@"ASBackgroundLayoutNode only passes size {} to the super class initializer, but received size %@ "
"(node=%@, background=%@)", NSStringFromASLayoutNodeSize(size), _node, _background);
ASLayout *contentsLayout = [_node layoutThatFits:constrainedSize parentSize:parentSize];
ASLayout *contentsLayout = [_node computeLayoutThatFits:constrainedSize];
NSMutableArray *children = [NSMutableArray arrayWithCapacity:2];
if (_background) {
// Size background to exactly the same size.
ASLayout *backgroundLayout = [_background layoutThatFits:{contentsLayout.size, contentsLayout.size}
parentSize:contentsLayout.size];
ASLayout *backgroundLayout = [_background computeLayoutThatFits:{contentsLayout.size, contentsLayout.size}];
[children addObject:[ASLayoutChild newWithPosition:{0,0} layout:backgroundLayout]];
}
[children addObject:[ASLayoutChild newWithPosition:{0,0} layout:contentsLayout]];

View File

@ -38,11 +38,9 @@ typedef NS_OPTIONS(NSUInteger, ASCenterLayoutNodeSizingOptions) {
/**
@param centeringOptions, see ASCenterLayoutNodeCenteringOptions.
@param child The child to center.
@param size The node size or {} for the default which is for the layout to take the maximum space available.
*/
+ (instancetype)newWithCenteringOptions:(ASCenterLayoutNodeCenteringOptions)centeringOptions
sizingOptions:(ASCenterLayoutNodeSizingOptions)sizingOptions
child:(ASLayoutNode *)child
size:(ASLayoutNodeSize)size;
child:(ASLayoutNode *)child;
@end

View File

@ -23,9 +23,8 @@
+ (instancetype)newWithCenteringOptions:(ASCenterLayoutNodeCenteringOptions)centeringOptions
sizingOptions:(ASCenterLayoutNodeSizingOptions)sizingOptions
child:(ASLayoutNode *)child
size:(ASLayoutNodeSize)size
{
ASCenterLayoutNode *n = [super newWithSize:size];
ASCenterLayoutNode *n = [super new];
if (n) {
n->_centeringOptions = centeringOptions;
n->_sizingOptions = sizingOptions;
@ -34,14 +33,16 @@
return n;
}
+ (instancetype)new
{
ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER();
}
- (ASLayout *)computeLayoutThatFits:(ASSizeRange)constrainedSize
{
// If we have a finite size in any direction, pass this so that the child can
// resolve percentages agains it. Otherwise pass kASLayoutNodeParentDimensionUndefined
// as the size will depend on the content
CGSize size = {
isinf(constrainedSize.max.width) ? kASLayoutNodeParentDimensionUndefined : constrainedSize.max.width,
isinf(constrainedSize.max.height) ? kASLayoutNodeParentDimensionUndefined : constrainedSize.max.height
constrainedSize.max.width,
constrainedSize.max.height
};
// Layout the child
@ -49,7 +50,7 @@
(_centeringOptions & ASCenterLayoutNodeCenteringX) != 0 ? 0 : constrainedSize.min.width,
(_centeringOptions & ASCenterLayoutNodeCenteringY) != 0 ? 0 : constrainedSize.min.height,
};
ASLayout *childLayout = [_child layoutThatFits:ASSizeRangeMake(minChildSize, constrainedSize.max) parentSize:size];
ASLayout *childLayout = [_child computeLayoutThatFits:ASSizeRangeMake(minChildSize, constrainedSize.max)];
// If we have an undetermined height or width, use the child size to define the layout
// size

View File

@ -16,7 +16,6 @@
@property (nonatomic, readonly) ASDisplayNode *displayNode;
+ (instancetype)newWithSize:(ASLayoutNodeSize)size displayNode:(ASDisplayNode *)displayNode;
+ (instancetype)newWithDisplayNode:(ASDisplayNode *)displayNode;
@end

View File

@ -18,23 +18,18 @@
@implementation ASCompositeNode
+ (instancetype)newWithDisplayNode:(ASDisplayNode *)displayNode
{
return [self newWithSize:ASLayoutNodeSizeZero displayNode:displayNode];
}
+ (instancetype)newWithSize:(ASLayoutNodeSize)size displayNode:(ASDisplayNode *)displayNode
{
if (displayNode == nil) {
return nil;
}
ASCompositeNode *n = [super newWithSize:size];
ASCompositeNode *n = [super new];
if (n) {
n->_displayNode = displayNode;
}
return n;
}
+ (instancetype)newWithSize:(ASLayoutNodeSize)size
+ (instancetype)new
{
ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER();
}

View File

@ -33,7 +33,6 @@
@param insets The amount of space to inset on each side.
@param node The wrapped child layout node to inset. If nil, this method returns nil.
*/
+ (instancetype)newWithInsets:(UIEdgeInsets)insets
node:(ASLayoutNode *)node;
+ (instancetype)newWithInsets:(UIEdgeInsets)insets node:(ASLayoutNode *)node;
@end

View File

@ -43,13 +43,12 @@ static CGFloat centerInset(CGFloat outer, CGFloat inner)
@implementation ASInsetLayoutNode
+ (instancetype)newWithInsets:(UIEdgeInsets)insets
node:(ASLayoutNode *)node
+ (instancetype)newWithInsets:(UIEdgeInsets)insets node:(ASLayoutNode *)node
{
if (node == nil) {
return nil;
}
ASInsetLayoutNode *n = [super newWithSize:{}];
ASInsetLayoutNode *n = [super new];
if (n) {
n->_insets = insets;
n->_node = node;
@ -57,7 +56,7 @@ static CGFloat centerInset(CGFloat outer, CGFloat inner)
return n;
}
+ (instancetype)newWithSize:(ASLayoutNodeSize)size
+ (instancetype)new
{
ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER();
}
@ -67,13 +66,7 @@ static CGFloat centerInset(CGFloat outer, CGFloat inner)
the child to respect the inset.
*/
- (ASLayout *)computeLayoutThatFits:(ASSizeRange)constrainedSize
restrictedToSize:(ASLayoutNodeSize)size
relativeToParentSize:(CGSize)parentSize
{
ASDisplayNodeAssert(ASLayoutNodeSizeEqualToNodeSize(size, ASLayoutNodeSizeZero),
@"ASInsetLayoutNode only passes size {} to the super class initializer, but received size %@ "
"(node=%@)", NSStringFromASLayoutNodeSize(size), _node);
const CGFloat insetsX = (finiteOrZero(_insets.left) + finiteOrZero(_insets.right));
const CGFloat insetsY = (finiteOrZero(_insets.top) + finiteOrZero(_insets.bottom));
@ -92,21 +85,13 @@ static CGFloat centerInset(CGFloat outer, CGFloat inner)
MAX(0, constrainedSize.max.height - insetsY),
}
};
const CGSize insetParentSize = {
MAX(0, parentSize.width - insetsX),
MAX(0, parentSize.height - insetsY)
};
ASLayout *childLayout = [_node layoutThatFits:insetConstrainedSize parentSize:insetParentSize];
ASLayout *childLayout = [_node computeLayoutThatFits:insetConstrainedSize];
const CGSize computedSize = ASSizeRangeClamp(constrainedSize, {
finite(childLayout.size.width + _insets.left + _insets.right, parentSize.width),
finite(childLayout.size.height + _insets.top + _insets.bottom, parentSize.height),
finite(childLayout.size.width + _insets.left + _insets.right, constrainedSize.max.width),
finite(childLayout.size.height + _insets.top + _insets.bottom, constrainedSize.max.height),
});
ASDisplayNodeAssert(!isnan(computedSize.width) && !isnan(computedSize.height),
@"Inset node computed size is NaN; you may not specify infinite insets against a NaN parent size\n"
"parentSize = %@, insets = %@", NSStringFromCGSize(parentSize), NSStringFromUIEdgeInsets(_insets));
const CGFloat x = finite(_insets.left, constrainedSize.max.width -
(finite(_insets.right,
centerInset(constrainedSize.max.width, childLayout.size.width)) + childLayout.size.width));

View File

@ -8,17 +8,9 @@
*
*/
#import <AsyncDisplayKit/ASLayoutNodeSize.h>
#import <AsyncDisplayKit/ASDimension.h>
/** A layout node is an immutable object that describes a layout, loosely inspired by React. */
@interface ASLayoutNode : NSObject
/**
@param size A size constraint that should apply to this layout node. Pass {} to specify no size constraint.
@example A layout node of a square:
[ASLayoutNode newWithSize:{100, 100}]
*/
+ (instancetype)newWithSize:(ASLayoutNodeSize)size;
@end

View File

@ -17,75 +17,10 @@
#import "ASInternalHelpers.h"
#import "ASLayout.h"
CGFloat const kASLayoutNodeParentDimensionUndefined = NAN;
CGSize const kASLayoutNodeParentSizeUndefined = {kASLayoutNodeParentDimensionUndefined, kASLayoutNodeParentDimensionUndefined};
@implementation ASLayoutNode
{
ASLayoutNodeSize _size;
}
#if DEBUG
+ (void)initialize
{
ASDisplayNodeConditionalAssert(self != [ASLayoutNode class],
!ASSubclassOverridesSelector([ASLayoutNode class], self, @selector(layoutThatFits:parentSize:)),
@"%@ overrides -layoutThatFits:parentSize: which is not allowed. Override -computeLayoutThatFits: "
"or -computeLayoutThatFits:restrictedToSize:relativeToParentSize: instead.",
NSStringFromClass(self));
}
#endif
+ (instancetype)newWithSize:(ASLayoutNodeSize)size
{
return [[self alloc] initWithLayoutNodeSize:size];
}
+ (instancetype)new
{
return [self newWithSize:{}];
}
- (instancetype)init
{
ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER();
}
- (instancetype)initWithLayoutNodeSize:(ASLayoutNodeSize)size
{
if (self = [super init]) {
_size = size;
}
return self;
}
#pragma mark - Layout
- (ASLayout *)layoutThatFits:(ASSizeRange)constrainedSize parentSize:(CGSize)parentSize
{
ASLayout *layout = [self computeLayoutThatFits:constrainedSize
restrictedToSize:_size
relativeToParentSize:parentSize];
ASDisplayNodeAssert(layout.node == self, @"Layout computed by %@ should return self as node, but returned %@",
[self class], [layout.node class]);
ASSizeRange resolvedRange = ASSizeRangeIntersect(constrainedSize, ASLayoutNodeSizeResolve(_size, parentSize));
ASDisplayNodeAssert(layout.size.width <= resolvedRange.max.width
&& layout.size.width >= resolvedRange.min.width
&& layout.size.height <= resolvedRange.max.height
&& layout.size.height >= resolvedRange.min.height,
@"Computed size %@ for %@ does not fall within constrained size %@",
NSStringFromCGSize(layout.size), [self class], NSStringFromASSizeRange(resolvedRange));
return layout;
}
- (ASLayout *)computeLayoutThatFits:(ASSizeRange)constrainedSize
restrictedToSize:(ASLayoutNodeSize)size
relativeToParentSize:(CGSize)parentSize
{
ASSizeRange resolvedRange = ASSizeRangeIntersect(constrainedSize, ASLayoutNodeSizeResolve(_size, parentSize));
return [self computeLayoutThatFits:resolvedRange];
}
- (ASLayout *)computeLayoutThatFits:(ASSizeRange)constrainedSize
{
return [ASLayout newWithNode:self size:constrainedSize.min];

View File

@ -1,52 +0,0 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#import <AsyncDisplayKit/ASDimension.h>
#import <AsyncDisplayKit/ASBaseDefines.h>
/**
A struct specifying a layout node's size. Example:
ASLayoutNodeSize size = {
.width = Percent(0.5),
.maxWidth = 200,
.minHeight = Percent(0.75)
};
// <ASLayoutNodeSize: exact={50%, Auto}, min={Auto, 75%}, max={200pt, Auto}>
size.description();
*/
typedef struct {
ASRelativeDimension width;
ASRelativeDimension height;
ASRelativeDimension minWidth;
ASRelativeDimension minHeight;
ASRelativeDimension maxWidth;
ASRelativeDimension maxHeight;
} ASLayoutNodeSize;
extern ASLayoutNodeSize const ASLayoutNodeSizeZero;
ASDISPLAYNODE_EXTERN_C_BEGIN
extern ASLayoutNodeSize ASLayoutNodeSizeMakeWithCGSize(CGSize size);
extern ASLayoutNodeSize ASLayoutNodeSizeMake(CGFloat width, CGFloat height);
extern ASSizeRange ASLayoutNodeSizeResolve(ASLayoutNodeSize nodeSize, CGSize parentSize);
extern BOOL ASLayoutNodeSizeEqualToNodeSize(ASLayoutNodeSize lhs, ASLayoutNodeSize rhs);
extern NSString *NSStringFromASLayoutNodeSize(ASLayoutNodeSize nodeSize);
ASDISPLAYNODE_EXTERN_C_END

View File

@ -1,86 +0,0 @@
/*
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#import "ASLayoutNodeSize.h"
#import "ASAssert.h"
ASLayoutNodeSize const ASLayoutNodeSizeZero = {};
ASLayoutNodeSize ASLayoutNodeSizeMakeWithCGSize(CGSize size)
{
return ASLayoutNodeSizeMake(size.width, size.height);
}
ASLayoutNodeSize ASLayoutNodeSizeMake(CGFloat width, CGFloat height)
{
return {ASRelativeDimensionMakeWithPoints(width), ASRelativeDimensionMakeWithPoints(height)};
}
ASDISPLAYNODE_INLINE void ASLNSConstrain(CGFloat minVal, CGFloat exactVal, CGFloat maxVal, CGFloat *outMin, CGFloat *outMax)
{
ASDisplayNodeCAssert(!isnan(minVal), @"minVal must not be NaN");
ASDisplayNodeCAssert(!isnan(maxVal), @"maxVal must not be NaN");
// Avoid use of min/max primitives since they're harder to reason
// about in the presence of NaN (in exactVal)
// Follow CSS: min overrides max overrides exact.
// Begin with the min/max range
*outMin = minVal;
*outMax = maxVal;
if (maxVal <= minVal) {
// min overrides max and exactVal is irrelevant
*outMax = minVal;
return;
}
if (isnan(exactVal)) {
// no exact value, so leave as a min/max range
return;
}
if (exactVal > maxVal) {
// clip to max value
*outMin = maxVal;
} else if (exactVal < minVal) {
// clip to min value
*outMax = minVal;
} else {
// use exact value
*outMin = *outMax = exactVal;
}
}
ASSizeRange ASLayoutNodeSizeResolve(ASLayoutNodeSize nodeSize, CGSize parentSize)
{
CGSize resolvedExact = ASRelativeSizeResolveSize(ASRelativeSizeMake(nodeSize.width, nodeSize.height), parentSize, {NAN, NAN});
CGSize resolvedMin = ASRelativeSizeResolveSize(ASRelativeSizeMake(nodeSize.minWidth, nodeSize.minHeight), parentSize, {0, 0});
CGSize resolvedMax = ASRelativeSizeResolveSize(ASRelativeSizeMake(nodeSize.maxWidth, nodeSize.maxHeight), parentSize, {INFINITY, INFINITY});
CGSize rangeMin, rangeMax;
ASLNSConstrain(resolvedMin.width, resolvedExact.width, resolvedMax.width, &rangeMin.width, &rangeMax.width);
ASLNSConstrain(resolvedMin.height, resolvedExact.height, resolvedMax.height, &rangeMin.height, &rangeMax.height);
return {rangeMin, rangeMax};
}
BOOL ASLayoutNodeSizeEqualToNodeSize(ASLayoutNodeSize lhs, ASLayoutNodeSize rhs)
{
return ASRelativeDimensionEqualToDimension(lhs.width, rhs.width)
&& ASRelativeDimensionEqualToDimension(lhs.height, rhs.height)
&& ASRelativeDimensionEqualToDimension(lhs.minWidth, rhs.minWidth)
&& ASRelativeDimensionEqualToDimension(lhs.minHeight, rhs.minHeight)
&& ASRelativeDimensionEqualToDimension(lhs.maxWidth, rhs.maxWidth)
&& ASRelativeDimensionEqualToDimension(lhs.maxHeight, rhs.maxHeight);
}
NSString *NSStringFromASLayoutNodeSize(ASLayoutNodeSize nodeSize)
{
return [NSString stringWithFormat:@"<ASLayoutNodeSize: exact=%@, min=%@, max=%@>",
NSStringFromASRelativeSize(ASRelativeSizeMake(nodeSize.width, nodeSize.height)),
NSStringFromASRelativeSize(ASRelativeSizeMake(nodeSize.minWidth, nodeSize.minHeight)),
NSStringFromASRelativeSize(ASRelativeSizeMake(nodeSize.maxWidth, nodeSize.maxHeight))];
}

View File

@ -13,54 +13,13 @@
@interface ASLayoutNode ()
/** A constant that indicates that the parent's size is not yet determined in a given dimension. */
extern CGFloat const kASLayoutNodeParentDimensionUndefined;
/** A constant that indicates that the parent's size is not yet determined in either dimension. */
extern CGSize const kASLayoutNodeParentSizeUndefined;
/**
Call this on children layout nodes to compute their layouts within your implementation of -computeLayoutThatFits:.
@warning You may not override this method. Override -computeLayoutThatFits: instead.
@param constrainedSize Specifies a minimum and maximum size. The receiver must choose a size that is in this range.
@param parentSize The parent layout node's size. If the parent layout node does not have a final size in a given dimension,
then it should be passed as kASLayoutNodeParentDimensionUndefined (for example, if the parent's width
depends on the child's size).
@return An ASLayout instance defining the layout of the receiver and its children.
*/
- (ASLayout *)layoutThatFits:(ASSizeRange)constrainedSize
parentSize:(CGSize)parentSize;
/**
Override this method to compute your node's layout.
@discussion Why do you need to override -computeLayoutThatFits: instead of -layoutThatFits:parentSize:?
The base implementation of -layoutThatFits:parentSize: does the following for you:
1. First, it uses the parentSize parameter to resolve the node's size (the one passed into -initWithSize:).
2. Then, it intersects the resolved size with the constrainedSize parameter. If the two don't intersect,
constrainedSize wins. This allows a node to always override its childrens' sizes when computing its layout.
(The analogy for UIView: you might return a certain size from -sizeThatFits:, but a parent view can always override
that size and set your frame to any size.)
@param constrainedSize @param constrainedSize The maximum size the receiver should fit in.
@param constrainedSize A min and max size. This is computed as described in the description. The ASLayout you
return MUST have a size between these two sizes. This is enforced by assertion.
@return An ASLayout instance defining the layout of the receiver and its children.
*/
- (ASLayout *)computeLayoutThatFits:(ASSizeRange)constrainedSize;
/**
ASLayoutNode's implementation of -layoutThatFits:parentSize: calls this method to resolve the node's size
against parentSize, intersect it with constrainedSize, and call -computeLayoutThatFits: with the result.
In certain advanced cases, you may want to customize this logic. Overriding this method allows you to receive all
three parameters and do the computation yourself.
@warning Overriding this method should be done VERY rarely.
*/
- (ASLayout *)computeLayoutThatFits:(ASSizeRange)constrainedSize
restrictedToSize:(ASLayoutNodeSize)size
relativeToParentSize:(CGSize)parentSize;
@end

View File

@ -21,10 +21,9 @@
ASLayoutNode *_node;
}
+ (instancetype)newWithNode:(ASLayoutNode *)node
overlay:(ASLayoutNode *)overlay
+ (instancetype)newWithNode:(ASLayoutNode *)node overlay:(ASLayoutNode *)overlay
{
ASOverlayLayoutNode *n = [super newWithSize:{}];
ASOverlayLayoutNode *n = [super new];
if (n) {
ASDisplayNodeAssertNotNil(node, @"Node that will be overlayed on shouldn't be nil");
n->_overlay = overlay;
@ -33,7 +32,7 @@
return n;
}
+ (instancetype)newWithSize:(ASLayoutNodeSize)size
+ (instancetype)new
{
ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER();
}
@ -42,17 +41,11 @@
First layout the contents, then fit the overlay on top of it.
*/
- (ASLayout *)computeLayoutThatFits:(ASSizeRange)constrainedSize
restrictedToSize:(ASLayoutNodeSize)size
relativeToParentSize:(CGSize)parentSize
{
ASDisplayNodeAssert(ASLayoutNodeSizeEqualToNodeSize(size, ASLayoutNodeSizeZero),
@"ASOverlayLayoutNode only passes size {} to the super class initializer, but received size %@ "
"(node=%@, overlay=%@)", NSStringFromASLayoutNodeSize(size), _node, _overlay);
ASLayout *contentsLayout = [_node layoutThatFits:constrainedSize parentSize:parentSize];
ASLayout *contentsLayout = [_node computeLayoutThatFits:constrainedSize];
NSMutableArray *layoutChildren = [NSMutableArray arrayWithObject:[ASLayoutChild newWithPosition:{0, 0} layout:contentsLayout]];
if (_overlay) {
ASLayout *overlayLayout = [_overlay layoutThatFits:{contentsLayout.size, contentsLayout.size} parentSize:contentsLayout.size];
ASLayout *overlayLayout = [_overlay computeLayoutThatFits:{contentsLayout.size, contentsLayout.size}];
[layoutChildren addObject:[ASLayoutChild newWithPosition:{0, 0} layout:overlayLayout]];
}

View File

@ -30,8 +30,6 @@
**/
@interface ASRatioLayoutNode : ASLayoutNode
+ (instancetype)newWithRatio:(CGFloat)ratio
size:(ASLayoutNodeSize)size
node:(ASLayoutNode *)node;
+ (instancetype)newWithRatio:(CGFloat)ratio node:(ASLayoutNode *)node;
@end

View File

@ -26,16 +26,14 @@
ASLayoutNode *_node;
}
+ (instancetype)newWithRatio:(CGFloat)ratio
size:(ASLayoutNodeSize)size
node:(ASLayoutNode *)node
+ (instancetype)newWithRatio:(CGFloat)ratio node:(ASLayoutNode *)node
{
ASDisplayNodeAssert(ratio > 0, @"Ratio should be strictly positive, but received %f", ratio);
if (ratio <= 0) {
return nil;
}
ASRatioLayoutNode *n = [super newWithSize:size];
ASRatioLayoutNode *n = [super new];
if (n) {
n->_ratio = ratio;
n->_node = node;
@ -43,7 +41,7 @@
return n;
}
+ (instancetype)newWithSize:(ASLayoutNodeSize)size
+ (instancetype)new
{
ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER();
}
@ -71,8 +69,7 @@
// If there is no max size in *either* dimension, we can't apply the ratio, so just pass our size range through.
const ASSizeRange childRange = (bestSize == sizeOptions.end()) ? constrainedSize : ASSizeRangeMake(*bestSize, *bestSize);
const CGSize parentSize = (bestSize == sizeOptions.end()) ? kASLayoutNodeParentSizeUndefined : *bestSize;
ASLayout *childLayout = [_node layoutThatFits:childRange parentSize:parentSize];
ASLayout *childLayout = [_node computeLayoutThatFits:childRange];
return [ASLayout newWithNode:self
size:childLayout.size
children:@[[ASLayoutChild newWithPosition:{0, 0} layout:childLayout]]];

View File

@ -136,12 +136,9 @@ typedef struct {
@interface ASStackLayoutNode : ASLayoutNode
/**
@param size A size, or {} for the default size.
@param style Specifies how children are laid out.
@param children Children to be positioned, each is of type ASStackLayoutNodeChild.
*/
+ (instancetype)newWithSize:(ASLayoutNodeSize)size
style:(ASStackLayoutNodeStyle)style
children:(NSArray *)children;
+ (instancetype)newWithStyle:(ASStackLayoutNodeStyle)style children:(NSArray *)children;
@end

View File

@ -99,9 +99,9 @@
std::vector<ASStackLayoutNodeChild *> _children;
}
+ (instancetype)newWithSize:(ASLayoutNodeSize)size style:(ASStackLayoutNodeStyle)style children:(NSArray *)children
+ (instancetype)newWithStyle:(ASStackLayoutNodeStyle)style children:(NSArray *)children
{
ASStackLayoutNode *n = [super newWithSize:size];
ASStackLayoutNode *n = [super new];
if (n) {
n->_style = style;
n->_children = std::vector<ASStackLayoutNodeChild *>();
@ -114,7 +114,7 @@
return n;
}
+ (instancetype)newWithSize:(ASLayoutNodeSize)size
+ (instancetype)new
{
ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER();
}

View File

@ -39,14 +39,6 @@
@interface ASStaticLayoutNode : ASLayoutNode
/**
@param children Children to be positioned at fixed positions, each is of type ASStaticLayoutNodeChild.
*/
+ (instancetype)newWithSize:(ASLayoutNodeSize)size
children:(NSArray *)children;
/**
Convenience that does not have a size.
@param children Children to be positioned at fixed positions, each is of type ASStaticLayoutNodeChild.
*/
+ (instancetype)newWithChildren:(NSArray *)children;

View File

@ -39,26 +39,25 @@
NSArray *_children;
}
+ (instancetype)newWithSize:(ASLayoutNodeSize)size
children:(NSArray *)children
+ (instancetype)newWithChildren:(NSArray *)children
{
ASStaticLayoutNode *n = [super newWithSize:size];
ASStaticLayoutNode *n = [super new];
if (n) {
n->_children = children;
}
return n;
}
+ (instancetype)newWithChildren:(NSArray *)children
+ (instancetype)new
{
return [self newWithSize:{} children:children];
ASDISPLAYNODE_NOT_DESIGNATED_INITIALIZER();
}
- (ASLayout *)computeLayoutThatFits:(ASSizeRange)constrainedSize
{
CGSize size = {
isinf(constrainedSize.max.width) ? kASLayoutNodeParentDimensionUndefined : constrainedSize.max.width,
isinf(constrainedSize.max.height) ? kASLayoutNodeParentDimensionUndefined : constrainedSize.max.height
constrainedSize.max.width,
constrainedSize.max.height
};
NSMutableArray *layoutChildren = [NSMutableArray arrayWithCapacity:_children.count];
@ -69,7 +68,7 @@
};
ASSizeRange childConstraint = ASRelativeSizeRangeResolveSizeRange(child.size, size, {{0,0}, autoMaxSize});
ASLayoutChild *layoutChild = [ASLayoutChild newWithPosition:child.position
layout:[child.node layoutThatFits:childConstraint parentSize: size]];
layout:[child.node computeLayoutThatFits:childConstraint]];
[layoutChildren addObject:layoutChild];
}

View File

@ -18,22 +18,19 @@
/**
Sizes the child given the parameters specified, and returns the computed layout.
@param size the size of the stack layout node. May be undefined in either or both directions.
*/
static ASLayout *crossChildLayout(const ASStackLayoutNodeChild *child,
const ASStackLayoutNodeStyle style,
const CGFloat stackMin,
const CGFloat stackMax,
const CGFloat crossMin,
const CGFloat crossMax,
const CGSize size)
const CGFloat crossMax)
{
const ASStackLayoutAlignItems alignItems = alignment(child.alignSelf, style.alignItems);
// stretched children will have a cross dimension of at least crossMin
const CGFloat childCrossMin = alignItems == ASStackLayoutAlignItemsStretch ? crossMin : 0;
const ASSizeRange childSizeRange = directionSizeRange(style.direction, stackMin, stackMax, childCrossMin, crossMax);
return [child.node layoutThatFits:childSizeRange parentSize:size];
return [child.node computeLayoutThatFits:childSizeRange];
}
/**
@ -67,11 +64,9 @@ static ASLayout *crossChildLayout(const ASStackLayoutNodeChild *child,
@param layouts pre-computed child layouts; modified in-place as needed
@param style the layout style of the overall stack layout
@param size the size of the stack layout node. May be undefined in either or both directions.
*/
static void stretchChildrenAlongCrossDimension(std::vector<ASStackUnpositionedItem> &layouts,
const ASStackLayoutNodeStyle &style,
const CGSize size)
const ASStackLayoutNodeStyle &style)
{
// Find the maximum cross dimension size among child layouts
const auto it = std::max_element(layouts.begin(), layouts.end(),
@ -90,7 +85,7 @@ static void stretchChildrenAlongCrossDimension(std::vector<ASStackUnpositionedIt
// not crossMax, so that if any of them would choose a larger size just because the min size increased (weird!)
// they are forced to choose the same width as all the other nodes.
if (alignItems == ASStackLayoutAlignItemsStretch && fabs(cross - childCrossMax) > 0.01) {
l.layout = crossChildLayout(l.child, style, stack, stack, childCrossMax, childCrossMax, size);
l.layout = crossChildLayout(l.child, style, stack, stack, childCrossMax, childCrossMax);
}
}
}
@ -217,8 +212,7 @@ ASDISPLAYNODE_INLINE BOOL useOptimizedFlexing(const std::vector<ASStackLayoutNod
*/
static void layoutFlexibleChildrenAtZeroSize(std::vector<ASStackUnpositionedItem> &items,
const ASStackLayoutNodeStyle &style,
const ASSizeRange &sizeRange,
const CGSize size)
const ASSizeRange &sizeRange)
{
for (ASStackUnpositionedItem &item : items) {
if (isFlexibleInBothDirections(item.child)) {
@ -227,8 +221,7 @@ static void layoutFlexibleChildrenAtZeroSize(std::vector<ASStackUnpositionedItem
0,
0,
crossDimension(style.direction, sizeRange.min),
crossDimension(style.direction, sizeRange.max),
size);
crossDimension(style.direction, sizeRange.max));
}
}
}
@ -244,12 +237,10 @@ static void layoutFlexibleChildrenAtZeroSize(std::vector<ASStackUnpositionedItem
@param items Reference to unpositioned items from the original, unconstrained layout pass; modified in-place
@param style layout style to be applied to all children
@param sizeRange the range of allowable sizes for the stack layout node
@param size Size of the stack layout node. May be undefined in either or both directions.
*/
static void flexChildrenAlongStackDimension(std::vector<ASStackUnpositionedItem> &items,
const ASStackLayoutNodeStyle &style,
const ASSizeRange &sizeRange,
const CGSize size,
const BOOL useOptimizedFlexing)
{
const CGFloat stackDimensionSum = computeStackDimensionSum(items, style);
@ -261,7 +252,7 @@ static void flexChildrenAlongStackDimension(std::vector<ASStackUnpositionedItem>
if (flexibleChildren == 0) {
// If optimized flexing was used then we have to clean up the unsized children, and lay them out at zero size
if (useOptimizedFlexing) {
layoutFlexibleChildrenAtZeroSize(items, style, sizeRange, size);
layoutFlexibleChildrenAtZeroSize(items, style, sizeRange);
}
return;
}
@ -283,8 +274,7 @@ static void flexChildrenAlongStackDimension(std::vector<ASStackUnpositionedItem>
MAX(flexedStackSize, 0),
MAX(flexedStackSize, 0),
crossDimension(style.direction, sizeRange.min),
crossDimension(style.direction, sizeRange.max),
size);
crossDimension(style.direction, sizeRange.max));
isFirstFlex = NO;
}
}
@ -313,8 +303,7 @@ static std::vector<ASStackUnpositionedItem> layoutChildrenAlongUnconstrainedStac
ASRelativeDimensionResolve(child.flexBasis, 0, stackDimension(style.direction, size)),
ASRelativeDimensionResolve(child.flexBasis, INFINITY, stackDimension(style.direction, size)),
minCrossDimension,
maxCrossDimension,
size)
maxCrossDimension)
};
}
});
@ -324,11 +313,9 @@ ASStackUnpositionedLayout ASStackUnpositionedLayout::compute(const std::vector<A
const ASStackLayoutNodeStyle &style,
const ASSizeRange &sizeRange)
{
// If we have a fixed size in either dimension, pass it to children so they can resolve percentages against it.
// Otherwise, we pass kASLayoutNodeParentDimensionUndefined since it will depend on the content.
const CGSize size = {
(sizeRange.min.width == sizeRange.max.width) ? sizeRange.min.width : kASLayoutNodeParentDimensionUndefined,
(sizeRange.min.height == sizeRange.max.height) ? sizeRange.min.height : kASLayoutNodeParentDimensionUndefined,
sizeRange.max.width,
sizeRange.max.height
};
// We may be able to avoid some redundant layout passes
@ -343,8 +330,8 @@ ASStackUnpositionedLayout ASStackUnpositionedLayout::compute(const std::vector<A
size,
optimizedFlexing);
flexChildrenAlongStackDimension(items, style, sizeRange, size, optimizedFlexing);
stretchChildrenAlongCrossDimension(items, style, size);
flexChildrenAlongStackDimension(items, style, sizeRange, optimizedFlexing);
stretchChildrenAlongCrossDimension(items, style);
const CGFloat stackDimensionSum = computeStackDimensionSum(items, style);
return {items, stackDimensionSum, computeViolation(stackDimensionSum, style, sizeRange)};

View File

@ -50,7 +50,7 @@
- (void)setLayoutNodeUnderTest:(ASLayoutNode *)layoutNodeUnderTest sizeRange:(ASSizeRange)sizeRange
{
_layoutUnderTest = [layoutNodeUnderTest layoutThatFits:sizeRange parentSize:sizeRange.max];
_layoutUnderTest = [layoutNodeUnderTest calculateLayoutThatFits:sizeRange];
self.frame = CGRectMake(0, 0, _layoutUnderTest.size.width, _layoutUnderTest.size.height);
[self measure:_layoutUnderTest.size];
}