From 7551627b581dd68eee403db49995dfb44ccafd64 Mon Sep 17 00:00:00 2001 From: Hannah Troisi Date: Thu, 29 Sep 2016 00:02:47 -0700 Subject: [PATCH] [Layout] Rename ASLayoutable to ASLayoutElement (#2290) * [Layout API] Rename ASLayoutable to ASLayoutElement * arg * fix wrapperWithLayoutElement * [Layout API] Rename ASLayoutable to ASLayoutElement * arg * address Michael's comments * Remove ASLayoutValidation files that were deleted on master since this diff was created. --- AsyncDisplayKit.xcodeproj/project.pbxproj | 56 ++-- AsyncDisplayKit/ASDisplayNode+Subclasses.h | 2 +- AsyncDisplayKit/ASDisplayNode.h | 7 +- AsyncDisplayKit/ASDisplayNode.mm | 56 ++-- AsyncDisplayKit/ASVideoPlayerNode.mm | 1 + AsyncDisplayKit/AsyncDisplayKit.h | 2 +- .../Layout/ASAbsoluteLayoutSpec.mm | 12 +- AsyncDisplayKit/Layout/ASAbsoluteLayoutable.h | 2 +- AsyncDisplayKit/Layout/ASAsciiArtBoxCreator.h | 2 +- .../Layout/ASBackgroundLayoutSpec.h | 8 +- .../Layout/ASBackgroundLayoutSpec.mm | 12 +- AsyncDisplayKit/Layout/ASCenterLayoutSpec.h | 4 +- AsyncDisplayKit/Layout/ASCenterLayoutSpec.mm | 4 +- AsyncDisplayKit/Layout/ASDimension.h | 38 +-- AsyncDisplayKit/Layout/ASDimension.mm | 14 +- AsyncDisplayKit/Layout/ASInsetLayoutSpec.h | 4 +- AsyncDisplayKit/Layout/ASInsetLayoutSpec.mm | 10 +- AsyncDisplayKit/Layout/ASLayout.h | 44 +-- AsyncDisplayKit/Layout/ASLayout.mm | 82 ++--- .../{ASLayoutable.h => ASLayoutElement.h} | 111 ++++--- AsyncDisplayKit/Layout/ASLayoutElement.mm | 305 ++++++++++++++++++ ...ility.h => ASLayoutElementExtensibility.h} | 4 +- ...ablePrivate.h => ASLayoutElementPrivate.h} | 48 +-- .../Layout/ASLayoutSpec+Subclasses.h | 10 +- .../Layout/ASLayoutSpec+Subclasses.mm | 30 +- AsyncDisplayKit/Layout/ASLayoutSpec.h | 24 +- AsyncDisplayKit/Layout/ASLayoutSpec.mm | 64 ++-- AsyncDisplayKit/Layout/ASLayoutable.mm | 305 ------------------ AsyncDisplayKit/Layout/ASOverlayLayoutSpec.h | 6 +- AsyncDisplayKit/Layout/ASOverlayLayoutSpec.mm | 14 +- AsyncDisplayKit/Layout/ASRatioLayoutSpec.h | 4 +- AsyncDisplayKit/Layout/ASRatioLayoutSpec.mm | 10 +- AsyncDisplayKit/Layout/ASRelativeLayoutSpec.h | 6 +- .../Layout/ASRelativeLayoutSpec.mm | 12 +- AsyncDisplayKit/Layout/ASStackLayoutSpec.h | 4 +- AsyncDisplayKit/Layout/ASStackLayoutSpec.mm | 10 +- AsyncDisplayKit/Layout/ASStackLayoutable.h | 2 +- .../Private/ASDisplayNodeInternal.h | 3 +- AsyncDisplayKit/Private/ASLayoutSpecPrivate.h | 2 +- AsyncDisplayKit/Private/ASLayoutTransition.mm | 8 +- .../ASStackBaselinePositionedLayout.mm | 14 +- .../Private/ASStackUnpositionedLayout.h | 4 +- .../Private/ASStackUnpositionedLayout.mm | 38 +-- AsyncDisplayKit/_ASTransitionContext.m | 4 +- ...yleTests.m => ASLayoutElementStyleTests.m} | 28 +- .../ASStackLayoutSpecSnapshotTests.mm | 2 +- .../OverviewASCollectionNode.m | 2 +- .../Node Containers/OverviewASPagerNode.m | 4 +- .../Node Containers/OverviewASTableNode.m | 2 +- examples/PagerNode/Sample/PageNode.m | 2 +- 50 files changed, 719 insertions(+), 723 deletions(-) rename AsyncDisplayKit/Layout/{ASLayoutable.h => ASLayoutElement.h} (73%) create mode 100644 AsyncDisplayKit/Layout/ASLayoutElement.mm rename AsyncDisplayKit/Layout/{ASLayoutableExtensibility.h => ASLayoutElementExtensibility.h} (92%) rename AsyncDisplayKit/Layout/{ASLayoutablePrivate.h => ASLayoutElementPrivate.h} (53%) delete mode 100644 AsyncDisplayKit/Layout/ASLayoutable.mm rename AsyncDisplayKitTests/{ASLayoutableStyleTests.m => ASLayoutElementStyleTests.m} (70%) diff --git a/AsyncDisplayKit.xcodeproj/project.pbxproj b/AsyncDisplayKit.xcodeproj/project.pbxproj index 3cbf2848da..1db3f05eb8 100644 --- a/AsyncDisplayKit.xcodeproj/project.pbxproj +++ b/AsyncDisplayKit.xcodeproj/project.pbxproj @@ -141,7 +141,7 @@ 34EFC7661B701CD200AD841F /* ASRelativeSize.mm in Sources */ = {isa = PBXBuildFile; fileRef = AC47D9441B3BB41900AAEE9D /* ASRelativeSize.mm */; }; 34EFC7671B701CD900AD841F /* ASLayout.h in Headers */ = {isa = PBXBuildFile; fileRef = ACF6ED0B1B17843500DA7C62 /* ASLayout.h */; settings = {ATTRIBUTES = (Public, ); }; }; 34EFC7681B701CDE00AD841F /* ASLayout.mm in Sources */ = {isa = PBXBuildFile; fileRef = ACF6ED0C1B17843500DA7C62 /* ASLayout.mm */; }; - 34EFC7691B701CE100AD841F /* ASLayoutable.h in Headers */ = {isa = PBXBuildFile; fileRef = ACF6ED111B17843500DA7C62 /* ASLayoutable.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 34EFC7691B701CE100AD841F /* ASLayoutElement.h in Headers */ = {isa = PBXBuildFile; fileRef = ACF6ED111B17843500DA7C62 /* ASLayoutElement.h */; settings = {ATTRIBUTES = (Public, ); }; }; 34EFC76A1B701CE600AD841F /* ASLayoutSpec.h in Headers */ = {isa = PBXBuildFile; fileRef = ACF6ED0D1B17843500DA7C62 /* ASLayoutSpec.h */; settings = {ATTRIBUTES = (Public, ); }; }; 34EFC76B1B701CEB00AD841F /* ASLayoutSpec.mm in Sources */ = {isa = PBXBuildFile; fileRef = ACF6ED0E1B17843500DA7C62 /* ASLayoutSpec.mm */; }; 34EFC76C1B701CED00AD841F /* ASOverlayLayoutSpec.h in Headers */ = {isa = PBXBuildFile; fileRef = ACF6ED121B17843500DA7C62 /* ASOverlayLayoutSpec.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -211,7 +211,7 @@ 697796611D8AC8D3007E93D7 /* ASLayoutSpec+Subclasses.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6977965E1D8AC8D3007E93D7 /* ASLayoutSpec+Subclasses.mm */; }; 697B315A1CFE4B410049936F /* ASEditableTextNodeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 697B31591CFE4B410049936F /* ASEditableTextNodeTests.m */; }; 698548641CA9E025008A345F /* ASEnvironment.h in Headers */ = {isa = PBXBuildFile; fileRef = 698548611CA9E025008A345F /* ASEnvironment.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 698C8B621CAB49FC0052DC3F /* ASLayoutableExtensibility.h in Headers */ = {isa = PBXBuildFile; fileRef = 698C8B601CAB49FC0052DC3F /* ASLayoutableExtensibility.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 698C8B621CAB49FC0052DC3F /* ASLayoutElementExtensibility.h in Headers */ = {isa = PBXBuildFile; fileRef = 698C8B601CAB49FC0052DC3F /* ASLayoutElementExtensibility.h */; settings = {ATTRIBUTES = (Public, ); }; }; 69B225671D72535E00B25B22 /* ASDisplayNodeLayoutTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 69B225661D72535E00B25B22 /* ASDisplayNodeLayoutTests.mm */; }; 69CB62AC1CB8165900024920 /* _ASDisplayViewAccessiblity.h in Headers */ = {isa = PBXBuildFile; fileRef = 69CB62A91CB8165900024920 /* _ASDisplayViewAccessiblity.h */; }; 69CB62AD1CB8165900024920 /* _ASDisplayViewAccessiblity.mm in Sources */ = {isa = PBXBuildFile; fileRef = 69CB62AA1CB8165900024920 /* _ASDisplayViewAccessiblity.mm */; }; @@ -222,7 +222,7 @@ 69E100701CA89CB600D88C1B /* ASEnvironmentInternal.mm in Sources */ = {isa = PBXBuildFile; fileRef = 69E1006A1CA89CB600D88C1B /* ASEnvironmentInternal.mm */; }; 69EEA0A11D9AB43900B46420 /* ASLayoutSpecPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 69EEA0A01D9AB43900B46420 /* ASLayoutSpecPrivate.h */; }; 69F10C871C84C35D0026140C /* ASRangeControllerUpdateRangeProtocol+Beta.h in Headers */ = {isa = PBXBuildFile; fileRef = 69F10C851C84C35D0026140C /* ASRangeControllerUpdateRangeProtocol+Beta.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 69FEE53D1D95A9AF0086F066 /* ASLayoutableStyleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 69FEE53C1D95A9AF0086F066 /* ASLayoutableStyleTests.m */; }; + 69FEE53D1D95A9AF0086F066 /* ASLayoutElementStyleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 69FEE53C1D95A9AF0086F066 /* ASLayoutElementStyleTests.m */; }; 7630FFA81C9E267E007A7C0E /* ASVideoNode.h in Headers */ = {isa = PBXBuildFile; fileRef = AEEC47DF1C20C2DD00EC1693 /* ASVideoNode.h */; settings = {ATTRIBUTES = (Public, ); }; }; 764D83D51C8EA515009B4FB8 /* AsyncDisplayKit+Debug.h in Headers */ = {isa = PBXBuildFile; fileRef = 764D83D21C8EA515009B4FB8 /* AsyncDisplayKit+Debug.h */; settings = {ATTRIBUTES = (Public, ); }; }; 764D83D61C8EA515009B4FB8 /* AsyncDisplayKit+Debug.m in Sources */ = {isa = PBXBuildFile; fileRef = 764D83D31C8EA515009B4FB8 /* AsyncDisplayKit+Debug.m */; }; @@ -283,7 +283,7 @@ 9C8898BC1C738BA800D6B02E /* ASTextKitFontSizeAdjuster.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9C8898BA1C738B9800D6B02E /* ASTextKitFontSizeAdjuster.mm */; }; 9C8898BD1C738BB800D6B02E /* ASTextKitFontSizeAdjuster.h in Headers */ = {isa = PBXBuildFile; fileRef = A32FEDD31C501B6A004F642A /* ASTextKitFontSizeAdjuster.h */; }; 9CC606651D24DF9E006581A0 /* NSIndexSet+ASHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = CC4981BB1D1C7F65004E13CC /* NSIndexSet+ASHelpers.m */; }; - 9CDC18CD1B910E12004965E2 /* ASLayoutablePrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 9CDC18CB1B910E12004965E2 /* ASLayoutablePrivate.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 9CDC18CD1B910E12004965E2 /* ASLayoutElementPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = 9CDC18CB1B910E12004965E2 /* ASLayoutElementPrivate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9CFFC6BE1CCAC52B006A6476 /* ASEnvironment.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9CFFC6BD1CCAC52B006A6476 /* ASEnvironment.mm */; }; 9CFFC6C01CCAC73C006A6476 /* ASViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9CFFC6BF1CCAC73C006A6476 /* ASViewController.mm */; }; 9CFFC6C21CCAC768006A6476 /* ASTableNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9CFFC6C11CCAC768006A6476 /* ASTableNode.mm */; }; @@ -475,8 +475,8 @@ DECBD6EA1BE56E1900CF4905 /* ASButtonNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = DECBD6E61BE56E1900CF4905 /* ASButtonNode.mm */; }; DEFAD8131CC48914000527C4 /* ASVideoNode.mm in Sources */ = {isa = PBXBuildFile; fileRef = AEEC47E01C20C2DD00EC1693 /* ASVideoNode.mm */; }; E52405B31C8FEF03004DC8E7 /* ASLayoutTransition.mm in Sources */ = {isa = PBXBuildFile; fileRef = E52405B21C8FEF03004DC8E7 /* ASLayoutTransition.mm */; }; - E55D86321CA8A14000A0C26F /* ASLayoutable.mm in Sources */ = {isa = PBXBuildFile; fileRef = E55D86311CA8A14000A0C26F /* ASLayoutable.mm */; }; - E55D86331CA8A14000A0C26F /* ASLayoutable.mm in Sources */ = {isa = PBXBuildFile; fileRef = E55D86311CA8A14000A0C26F /* ASLayoutable.mm */; }; + E55D86321CA8A14000A0C26F /* ASLayoutElement.mm in Sources */ = {isa = PBXBuildFile; fileRef = E55D86311CA8A14000A0C26F /* ASLayoutElement.mm */; }; + E55D86331CA8A14000A0C26F /* ASLayoutElement.mm in Sources */ = {isa = PBXBuildFile; fileRef = E55D86311CA8A14000A0C26F /* ASLayoutElement.mm */; }; E5711A2C1C840C81009619D4 /* ASIndexedNodeContext.h in Headers */ = {isa = PBXBuildFile; fileRef = E5711A2A1C840C81009619D4 /* ASIndexedNodeContext.h */; }; E5711A2E1C840C96009619D4 /* ASIndexedNodeContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = E5711A2D1C840C96009619D4 /* ASIndexedNodeContext.mm */; }; E5711A301C840C96009619D4 /* ASIndexedNodeContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = E5711A2D1C840C96009619D4 /* ASIndexedNodeContext.mm */; }; @@ -558,8 +558,8 @@ F7CE6C5E1D2CDB3E00BE4C15 /* ASDimension.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = ACF6ED071B17843500DA7C62 /* ASDimension.h */; }; F7CE6C5F1D2CDB3E00BE4C15 /* ASInsetLayoutSpec.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = ACF6ED091B17843500DA7C62 /* ASInsetLayoutSpec.h */; }; F7CE6C601D2CDB3E00BE4C15 /* ASLayout.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = ACF6ED0B1B17843500DA7C62 /* ASLayout.h */; }; - F7CE6C611D2CDB3E00BE4C15 /* ASLayoutable.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = ACF6ED111B17843500DA7C62 /* ASLayoutable.h */; }; - F7CE6C621D2CDB3E00BE4C15 /* ASLayoutablePrivate.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9CDC18CB1B910E12004965E2 /* ASLayoutablePrivate.h */; }; + F7CE6C611D2CDB3E00BE4C15 /* ASLayoutElement.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = ACF6ED111B17843500DA7C62 /* ASLayoutElement.h */; }; + F7CE6C621D2CDB3E00BE4C15 /* ASLayoutElementPrivate.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 9CDC18CB1B910E12004965E2 /* ASLayoutElementPrivate.h */; }; F7CE6C631D2CDB3E00BE4C15 /* ASLayoutSpec.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = ACF6ED0D1B17843500DA7C62 /* ASLayoutSpec.h */; }; F7CE6C641D2CDB3E00BE4C15 /* ASOverlayLayoutSpec.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = ACF6ED121B17843500DA7C62 /* ASOverlayLayoutSpec.h */; }; F7CE6C651D2CDB3E00BE4C15 /* ASRatioLayoutSpec.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = ACF6ED141B17843500DA7C62 /* ASRatioLayoutSpec.h */; }; @@ -617,7 +617,7 @@ F7CE6CA11D2CDB5800BE4C15 /* ASWeakSet.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = CC3B20871C3F7A5400798563 /* ASWeakSet.h */; }; F7CE6CA21D2CDB5800BE4C15 /* ASDefaultPlaybackButton.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8B0768B11CE752EC002E1453 /* ASDefaultPlaybackButton.h */; }; F7CE6CA41D2CDB5800BE4C15 /* ASLayoutManager.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = B30BF6501C5964B0004FCD53 /* ASLayoutManager.h */; }; - F7CE6CB71D2CE2D000BE4C15 /* ASLayoutableExtensibility.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 698C8B601CAB49FC0052DC3F /* ASLayoutableExtensibility.h */; }; + F7CE6CB71D2CE2D000BE4C15 /* ASLayoutElementExtensibility.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 698C8B601CAB49FC0052DC3F /* ASLayoutElementExtensibility.h */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -654,7 +654,7 @@ CC4C2A7A1D8902350039ACAB /* ASTraceEvent.h in CopyFiles */, CC88F7AE1D80AF5E000D6D4E /* ASObjectDescriptionHelpers.h in CopyFiles */, F7CE6C981D2CDB5800BE4C15 /* ASInternalHelpers.h in CopyFiles */, - F7CE6CB71D2CE2D000BE4C15 /* ASLayoutableExtensibility.h in CopyFiles */, + F7CE6CB71D2CE2D000BE4C15 /* ASLayoutElementExtensibility.h in CopyFiles */, F7CE6C131D2CDB3E00BE4C15 /* ASPagerFlowLayout.h in CopyFiles */, F7CE6C141D2CDB3E00BE4C15 /* ASMapNode.h in CopyFiles */, F7CE6C151D2CDB3E00BE4C15 /* ASVideoNode.h in CopyFiles */, @@ -729,8 +729,8 @@ F7CE6C5E1D2CDB3E00BE4C15 /* ASDimension.h in CopyFiles */, F7CE6C5F1D2CDB3E00BE4C15 /* ASInsetLayoutSpec.h in CopyFiles */, F7CE6C601D2CDB3E00BE4C15 /* ASLayout.h in CopyFiles */, - F7CE6C611D2CDB3E00BE4C15 /* ASLayoutable.h in CopyFiles */, - F7CE6C621D2CDB3E00BE4C15 /* ASLayoutablePrivate.h in CopyFiles */, + F7CE6C611D2CDB3E00BE4C15 /* ASLayoutElement.h in CopyFiles */, + F7CE6C621D2CDB3E00BE4C15 /* ASLayoutElementPrivate.h in CopyFiles */, F7CE6C631D2CDB3E00BE4C15 /* ASLayoutSpec.h in CopyFiles */, F7CE6C641D2CDB3E00BE4C15 /* ASOverlayLayoutSpec.h in CopyFiles */, F7CE6C651D2CDB3E00BE4C15 /* ASRatioLayoutSpec.h in CopyFiles */, @@ -988,7 +988,7 @@ 6977965E1D8AC8D3007E93D7 /* ASLayoutSpec+Subclasses.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "ASLayoutSpec+Subclasses.mm"; path = "AsyncDisplayKit/Layout/ASLayoutSpec+Subclasses.mm"; sourceTree = ""; }; 697B31591CFE4B410049936F /* ASEditableTextNodeTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASEditableTextNodeTests.m; sourceTree = ""; }; 698548611CA9E025008A345F /* ASEnvironment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASEnvironment.h; sourceTree = ""; }; - 698C8B601CAB49FC0052DC3F /* ASLayoutableExtensibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASLayoutableExtensibility.h; path = AsyncDisplayKit/Layout/ASLayoutableExtensibility.h; sourceTree = ""; }; + 698C8B601CAB49FC0052DC3F /* ASLayoutElementExtensibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASLayoutElementExtensibility.h; path = AsyncDisplayKit/Layout/ASLayoutElementExtensibility.h; sourceTree = ""; }; 69B225661D72535E00B25B22 /* ASDisplayNodeLayoutTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASDisplayNodeLayoutTests.mm; sourceTree = ""; }; 69B225681D7265DA00B25B22 /* ASXCTExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASXCTExtensions.h; sourceTree = ""; }; 69CB62A91CB8165900024920 /* _ASDisplayViewAccessiblity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _ASDisplayViewAccessiblity.h; sourceTree = ""; }; @@ -997,7 +997,7 @@ 69E1006A1CA89CB600D88C1B /* ASEnvironmentInternal.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASEnvironmentInternal.mm; sourceTree = ""; }; 69EEA0A01D9AB43900B46420 /* ASLayoutSpecPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASLayoutSpecPrivate.h; sourceTree = ""; }; 69F10C851C84C35D0026140C /* ASRangeControllerUpdateRangeProtocol+Beta.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ASRangeControllerUpdateRangeProtocol+Beta.h"; sourceTree = ""; }; - 69FEE53C1D95A9AF0086F066 /* ASLayoutableStyleTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASLayoutableStyleTests.m; sourceTree = ""; }; + 69FEE53C1D95A9AF0086F066 /* ASLayoutElementStyleTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASLayoutElementStyleTests.m; sourceTree = ""; }; 6BDC61F51978FEA400E50D21 /* AsyncDisplayKit.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; path = AsyncDisplayKit.h; sourceTree = ""; }; 764D83D21C8EA515009B4FB8 /* AsyncDisplayKit+Debug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "AsyncDisplayKit+Debug.h"; sourceTree = ""; }; 764D83D31C8EA515009B4FB8 /* AsyncDisplayKit+Debug.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "AsyncDisplayKit+Debug.m"; sourceTree = ""; }; @@ -1032,7 +1032,7 @@ 9C8221931BA237B80037F19A /* ASStackBaselinePositionedLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASStackBaselinePositionedLayout.h; sourceTree = ""; }; 9C8221941BA237B80037F19A /* ASStackBaselinePositionedLayout.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASStackBaselinePositionedLayout.mm; sourceTree = ""; }; 9C8898BA1C738B9800D6B02E /* ASTextKitFontSizeAdjuster.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASTextKitFontSizeAdjuster.mm; path = TextKit/ASTextKitFontSizeAdjuster.mm; sourceTree = ""; }; - 9CDC18CB1B910E12004965E2 /* ASLayoutablePrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASLayoutablePrivate.h; path = AsyncDisplayKit/Layout/ASLayoutablePrivate.h; sourceTree = ""; }; + 9CDC18CB1B910E12004965E2 /* ASLayoutElementPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASLayoutElementPrivate.h; path = AsyncDisplayKit/Layout/ASLayoutElementPrivate.h; sourceTree = ""; }; 9CFFC6BD1CCAC52B006A6476 /* ASEnvironment.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASEnvironment.mm; sourceTree = ""; }; 9CFFC6BF1CCAC73C006A6476 /* ASViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASViewController.mm; sourceTree = ""; }; 9CFFC6C11CCAC768006A6476 /* ASTableNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASTableNode.mm; sourceTree = ""; }; @@ -1067,7 +1067,7 @@ ACF6ED0C1B17843500DA7C62 /* ASLayout.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASLayout.mm; path = AsyncDisplayKit/Layout/ASLayout.mm; sourceTree = ""; }; ACF6ED0D1B17843500DA7C62 /* ASLayoutSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASLayoutSpec.h; path = AsyncDisplayKit/Layout/ASLayoutSpec.h; sourceTree = ""; }; ACF6ED0E1B17843500DA7C62 /* ASLayoutSpec.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; name = ASLayoutSpec.mm; path = AsyncDisplayKit/Layout/ASLayoutSpec.mm; sourceTree = ""; }; - ACF6ED111B17843500DA7C62 /* ASLayoutable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASLayoutable.h; path = AsyncDisplayKit/Layout/ASLayoutable.h; sourceTree = ""; }; + ACF6ED111B17843500DA7C62 /* ASLayoutElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASLayoutElement.h; path = AsyncDisplayKit/Layout/ASLayoutElement.h; sourceTree = ""; }; ACF6ED121B17843500DA7C62 /* ASOverlayLayoutSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASOverlayLayoutSpec.h; path = AsyncDisplayKit/Layout/ASOverlayLayoutSpec.h; sourceTree = ""; }; ACF6ED131B17843500DA7C62 /* ASOverlayLayoutSpec.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; name = ASOverlayLayoutSpec.mm; path = AsyncDisplayKit/Layout/ASOverlayLayoutSpec.mm; sourceTree = ""; }; ACF6ED141B17843500DA7C62 /* ASRatioLayoutSpec.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ASRatioLayoutSpec.h; path = AsyncDisplayKit/Layout/ASRatioLayoutSpec.h; sourceTree = ""; }; @@ -1151,7 +1151,7 @@ DECBD6E61BE56E1900CF4905 /* ASButtonNode.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASButtonNode.mm; sourceTree = ""; }; E52405B21C8FEF03004DC8E7 /* ASLayoutTransition.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASLayoutTransition.mm; sourceTree = ""; }; E52405B41C8FEF16004DC8E7 /* ASLayoutTransition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASLayoutTransition.h; sourceTree = ""; }; - E55D86311CA8A14000A0C26F /* ASLayoutable.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASLayoutable.mm; path = AsyncDisplayKit/Layout/ASLayoutable.mm; sourceTree = ""; }; + E55D86311CA8A14000A0C26F /* ASLayoutElement.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ASLayoutElement.mm; path = AsyncDisplayKit/Layout/ASLayoutElement.mm; sourceTree = ""; }; E5711A2A1C840C81009619D4 /* ASIndexedNodeContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASIndexedNodeContext.h; sourceTree = ""; }; E5711A2D1C840C96009619D4 /* ASIndexedNodeContext.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ASIndexedNodeContext.mm; sourceTree = ""; }; EFA731F0396842FF8AB635EE /* libPods-AsyncDisplayKitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AsyncDisplayKitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -1421,7 +1421,7 @@ 058D09C6195D04C000B7D73C /* Supporting Files */, 052EE06A1A15A0D8002C6279 /* TestResources */, 2538B6F21BC5D2A2003CA0B4 /* ASCollectionViewFlowLayoutInspectorTests.m */, - 69FEE53C1D95A9AF0086F066 /* ASLayoutableStyleTests.m */, + 69FEE53C1D95A9AF0086F066 /* ASLayoutElementStyleTests.m */, ); path = AsyncDisplayKitTests; sourceTree = ""; @@ -1678,10 +1678,10 @@ ACF6ED0A1B17843500DA7C62 /* ASInsetLayoutSpec.mm */, ACF6ED0B1B17843500DA7C62 /* ASLayout.h */, ACF6ED0C1B17843500DA7C62 /* ASLayout.mm */, - 9CDC18CB1B910E12004965E2 /* ASLayoutablePrivate.h */, - ACF6ED111B17843500DA7C62 /* ASLayoutable.h */, - E55D86311CA8A14000A0C26F /* ASLayoutable.mm */, - 698C8B601CAB49FC0052DC3F /* ASLayoutableExtensibility.h */, + ACF6ED111B17843500DA7C62 /* ASLayoutElement.h */, + E55D86311CA8A14000A0C26F /* ASLayoutElement.mm */, + 698C8B601CAB49FC0052DC3F /* ASLayoutElementExtensibility.h */, + 9CDC18CB1B910E12004965E2 /* ASLayoutElementPrivate.h */, ACF6ED0D1B17843500DA7C62 /* ASLayoutSpec.h */, ACF6ED0E1B17843500DA7C62 /* ASLayoutSpec.mm */, 6977965D1D8AC8D3007E93D7 /* ASLayoutSpec+Subclasses.h */, @@ -1741,7 +1741,7 @@ buildActionMask = 2147483647; files = ( 69E0E8A71D356C9400627613 /* ASEqualityHelpers.h in Headers */, - 698C8B621CAB49FC0052DC3F /* ASLayoutableExtensibility.h in Headers */, + 698C8B621CAB49FC0052DC3F /* ASLayoutElementExtensibility.h in Headers */, 698548641CA9E025008A345F /* ASEnvironment.h in Headers */, AC026B6A1BD57D6F00BBC17E /* ASChangeSetDataController.h in Headers */, B35062481B010EFD0018CF92 /* _AS-objc-internal.h in Headers */, @@ -1832,8 +1832,8 @@ 34EFC7671B701CD900AD841F /* ASLayout.h in Headers */, DEC146B71C37A16A004A0EE7 /* ASCollectionInternal.h in Headers */, DBDB83951C6E879900D0098C /* ASPagerFlowLayout.h in Headers */, - 34EFC7691B701CE100AD841F /* ASLayoutable.h in Headers */, - 9CDC18CD1B910E12004965E2 /* ASLayoutablePrivate.h in Headers */, + 34EFC7691B701CE100AD841F /* ASLayoutElement.h in Headers */, + 9CDC18CD1B910E12004965E2 /* ASLayoutElementPrivate.h in Headers */, 68B8A4E21CBDB958007E4543 /* ASWeakProxy.h in Headers */, B35062201B010EFD0018CF92 /* ASLayoutController.h in Headers */, B35062211B010EFD0018CF92 /* ASLayoutRangeType.h in Headers */, @@ -2114,7 +2114,7 @@ files = ( 058D0A22195D050800B7D73C /* _ASAsyncTransaction.mm in Sources */, 8B0768B41CE752EC002E1453 /* ASDefaultPlaybackButton.m in Sources */, - E55D86321CA8A14000A0C26F /* ASLayoutable.mm in Sources */, + E55D86321CA8A14000A0C26F /* ASLayoutElement.mm in Sources */, 68FC85E41CE29B7E00EDD713 /* ASTabBarController.m in Sources */, 058D0A23195D050800B7D73C /* _ASAsyncTransactionContainer.m in Sources */, 058D0A24195D050800B7D73C /* _ASAsyncTransactionGroup.m in Sources */, @@ -2256,7 +2256,7 @@ CCB2F34D1D63CCC6004E6DE9 /* ASDisplayNodeSnapshotTests.m in Sources */, 058D0A3A195D057000B7D73C /* ASDisplayNodeTests.m in Sources */, 696FCB311D6E46050093471E /* ASBackgroundLayoutSpecSnapshotTests.mm in Sources */, - 69FEE53D1D95A9AF0086F066 /* ASLayoutableStyleTests.m in Sources */, + 69FEE53D1D95A9AF0086F066 /* ASLayoutElementStyleTests.m in Sources */, CC4981B31D1A02BE004E13CC /* ASTableViewThrashTests.m in Sources */, CC54A81E1D7008B300296A24 /* ASDispatchTests.m in Sources */, 058D0A3B195D057000B7D73C /* ASDisplayNodeTestsHelper.m in Sources */, @@ -2328,7 +2328,7 @@ AC47D9421B3B891B00AAEE9D /* ASCellNode.mm in Sources */, 34EFC7641B701CC600AD841F /* ASCenterLayoutSpec.mm in Sources */, 18C2ED831B9B7DE800F627B3 /* ASCollectionNode.mm in Sources */, - E55D86331CA8A14000A0C26F /* ASLayoutable.mm in Sources */, + E55D86331CA8A14000A0C26F /* ASLayoutElement.mm in Sources */, 68FC85EC1CE29C7D00EDD713 /* ASVisibilityProtocols.m in Sources */, 68B8A4E41CBDB958007E4543 /* ASWeakProxy.m in Sources */, 9C70F20A1CDBE949007D6C76 /* ASTableNode.mm in Sources */, diff --git a/AsyncDisplayKit/ASDisplayNode+Subclasses.h b/AsyncDisplayKit/ASDisplayNode+Subclasses.h index cce25a4c21..7ca966b1bf 100644 --- a/AsyncDisplayKit/ASDisplayNode+Subclasses.h +++ b/AsyncDisplayKit/ASDisplayNode+Subclasses.h @@ -128,7 +128,7 @@ NS_ASSUME_NONNULL_BEGIN * @warning Overriding this method should be done VERY rarely. */ - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize - restrictedToSize:(ASLayoutableSize)size + restrictedToSize:(ASLayoutElementSize)size relativeToParentSize:(CGSize)parentSize; /** diff --git a/AsyncDisplayKit/ASDisplayNode.h b/AsyncDisplayKit/ASDisplayNode.h index 2fe4b504f1..bc029dfc96 100644 --- a/AsyncDisplayKit/ASDisplayNode.h +++ b/AsyncDisplayKit/ASDisplayNode.h @@ -15,7 +15,7 @@ #import #import #import -#import +#import #import NS_ASSUME_NONNULL_BEGIN @@ -104,8 +104,7 @@ extern NSInteger const ASDefaultDrawingPriority; * */ -@interface ASDisplayNode : ASDealloc2MainObject - +@interface ASDisplayNode : ASDealloc2MainObject /** @name Initializing a node object */ @@ -608,7 +607,7 @@ extern NSInteger const ASDefaultDrawingPriority; /** * Convenience methods for debugging. */ -@interface ASDisplayNode (Debugging) +@interface ASDisplayNode (Debugging) /** * @abstract Return a description of the node hierarchy. diff --git a/AsyncDisplayKit/ASDisplayNode.mm b/AsyncDisplayKit/ASDisplayNode.mm index 1b2b7d37fe..469e6d6f96 100644 --- a/AsyncDisplayKit/ASDisplayNode.mm +++ b/AsyncDisplayKit/ASDisplayNode.mm @@ -69,10 +69,10 @@ NSString * const ASRenderingEngineDidDisplayNodesScheduledBeforeTimestamp = @"AS @implementation ASDisplayNode -@dynamic layoutableType; +@dynamic layoutElementType; @synthesize name = _name; -@synthesize isFinalLayoutable = _isFinalLayoutable; +@synthesize isFinalLayoutElement = _isFinalLayoutElement; @synthesize threadSafeBounds = _threadSafeBounds; @synthesize layoutSpecBlock = _layoutSpecBlock; @@ -299,8 +299,8 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c) _contentsScaleForDisplay = ASScreenScale(); _displaySentinel = [[ASSentinel alloc] init]; - _style = [[ASLayoutableStyle alloc] init]; - _size = ASLayoutableSizeMake(); + // TODO: We should lazily initialize the style object. + _style = [[ASLayoutElementStyle alloc] init]; _environmentState = ASEnvironmentStateMakeDefault(); _calculatedDisplayNodeLayout = std::make_shared(); @@ -722,7 +722,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c) #pragma mark - Style -- (ASLayoutableStyle *)style +- (ASLayoutElementStyle *)style { ASDN::MutexLocker l(__instanceLock__); return _style; @@ -744,7 +744,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c) if ([self shouldCalculateLayoutWithConstrainedSize:constrainedSize parentSize:parentSize] == NO) { ASDisplayNodeAssertNotNil(_calculatedDisplayNodeLayout->layout, @"-[ASDisplayNode layoutThatFits:parentSize:] _layout should not be nil! %@", self); - return _calculatedDisplayNodeLayout->layout ? : [ASLayout layoutWithLayoutable:self size:{0, 0}]; + return _calculatedDisplayNodeLayout->layout ? : [ASLayout layoutWithLayoutElement:self size:{0, 0}]; } [self cancelLayoutTransition]; @@ -777,8 +777,8 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c) // Don't remeasure if in layout pending state and a new transition already started if (ASHierarchyStateIncludesLayoutPending(_hierarchyState)) { - ASLayoutableContext context = ASLayoutableGetCurrentContext(); - if (ASLayoutableContextIsNull(context) || _pendingTransitionID != context.transitionID) { + ASLayoutElementContext context = ASLayoutElementGetCurrentContext(); + if (ASLayoutElementContextIsNull(context) || _pendingTransitionID != context.transitionID) { return NO; } } @@ -787,9 +787,9 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c) return _calculatedDisplayNodeLayout->isValidForConstrainedSizeParentSize(constrainedSize, parentSize) == NO; } -- (ASLayoutableType)layoutableType +- (ASLayoutElementType)layoutElementType { - return ASLayoutableTypeDisplayNode; + return ASLayoutElementTypeDisplayNode; } - (BOOL)canLayoutAsynchronous @@ -863,7 +863,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c) ASLayout *newLayout; { - ASLayoutableSetCurrentContext(ASLayoutableContextMake(transitionID, NO)); + ASLayoutElementSetCurrentContext(ASLayoutElementContextMake(transitionID, NO)); ASDN::MutexLocker l(__instanceLock__); BOOL automaticallyManagesSubnodesDisabled = (self.automaticallyManagesSubnodes == NO); @@ -875,7 +875,7 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c) self.automaticallyManagesSubnodes = NO; // Temporary flag for 1.9.x } - ASLayoutableClearCurrentContext(); + ASLayoutElementClearCurrentContext(); } if ([self _shouldAbortTransitionWithID:transitionID]) { @@ -1484,8 +1484,8 @@ static ASDisplayNodeMethodOverrides GetASDisplayNodeMethodOverrides(Class c) // Check if it's a subnode in a layout transition. In this case no measurement is needed as it's part of // the layout transition if (ASHierarchyStateIncludesLayoutPending(_hierarchyState)) { - ASLayoutableContext context = ASLayoutableGetCurrentContext(); - if (ASLayoutableContextIsNull(context) || _pendingTransitionID != context.transitionID) { + ASLayoutElementContext context = ASLayoutElementGetCurrentContext(); + if (ASLayoutElementContextIsNull(context) || _pendingTransitionID != context.transitionID) { return; } } @@ -2203,7 +2203,7 @@ static NSInteger incrementIfFound(NSInteger i) { // is in fly if (ASHierarchyStateIncludesLayoutPending(stateToEnterOrExit)) { int32_t pendingTransitionId = newSupernode.pendingTransitionID; - if (pendingTransitionId != ASLayoutableContextInvalidTransitionID) { + if (pendingTransitionId != ASLayoutElementContextInvalidTransitionID) { { ASDN::MutexLocker l(__instanceLock__); _pendingTransitionID = pendingTransitionId; @@ -2397,10 +2397,10 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock) #pragma mark - For Subclasses - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize - restrictedToSize:(ASLayoutableSize)size + restrictedToSize:(ASLayoutElementSize)size relativeToParentSize:(CGSize)parentSize { - const ASSizeRange resolvedRange = ASSizeRangeIntersect(constrainedSize, ASLayoutableSizeResolve(_style.size, parentSize)); + const ASSizeRange resolvedRange = ASSizeRangeIntersect(constrainedSize, ASLayoutElementSizeResolve(_style.size, parentSize)); return [self calculateLayoutThatFits:resolvedRange]; } @@ -2422,7 +2422,7 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock) ASDisplayNodeAssert(layoutSpec.isMutable, @"Node %@ returned layout spec %@ that has already been used. Layout specs should always be regenerated.", self, layoutSpec); - layoutSpec.parent = self; // This causes upward propogation of any non-default layoutable values. + layoutSpec.parent = self; // This causes upward propogation of any non-default layoutElement values. // manually propagate the trait collection here so that any layoutSpec children of layoutSpec will get a traitCollection { @@ -2443,18 +2443,18 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock) ASDisplayNodeAssertNotNil(layout, @"[ASLayoutSpec measureWithSizeRange:] should never return nil! %@, %@", self, layoutSpec); - // Make sure layoutableObject of the root layout is `self`, so that the flattened layout will be structurally correct. - BOOL isFinalLayoutable = (layout.layoutable != self); - if (isFinalLayoutable) { + // Make sure layoutElementObject of the root layout is `self`, so that the flattened layout will be structurally correct. + BOOL isFinalLayoutElement = (layout.layoutElement != self); + if (isFinalLayoutElement) { layout.position = CGPointZero; - layout = [ASLayout layoutWithLayoutable:self size:layout.size sublayouts:@[layout]]; + layout = [ASLayout layoutWithLayoutElement:self size:layout.size sublayouts:@[layout]]; } ASDisplayNodeLogEvent(self, @"computedLayout: %@", layout); return [layout filteredNodeLayoutTree]; } else { CGSize size = [self calculateSizeThatFits:constrainedSize.max]; ASDisplayNodeLogEvent(self, @"calculatedSize: %@", NSStringFromCGSize(size)); - return [ASLayout layoutWithLayoutable:self size:ASSizeRangeClamp(constrainedSize, size) sublayouts:nil]; + return [ASLayout layoutWithLayoutElement:self size:ASSizeRangeClamp(constrainedSize, size) sublayouts:nil]; } } @@ -2504,7 +2504,7 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock) { ASDN::MutexLocker l(__instanceLock__); - ASDisplayNodeAssertTrue(displayNodeLayout->layout.layoutable == self); + ASDisplayNodeAssertTrue(displayNodeLayout->layout.layoutElement == self); ASDisplayNodeAssertTrue(displayNodeLayout->layout.size.width >= 0.0); ASDisplayNodeAssertTrue(displayNodeLayout->layout.size.height >= 0.0); @@ -2933,7 +2933,7 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock) // Leaving layout pending state, reset related properties { ASDN::MutexLocker l(__instanceLock__); - _pendingTransitionID = ASLayoutableContextInvalidTransitionID; + _pendingTransitionID = ASLayoutElementContextInvalidTransitionID; _pendingLayoutTransition = nil; } } @@ -2977,7 +2977,7 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock) - (void)__layoutSublayouts { for (ASLayout *subnodeLayout in _calculatedDisplayNodeLayout->layout.sublayouts) { - ((ASDisplayNode *)subnodeLayout.layoutable).frame = subnodeLayout.frame; + ((ASDisplayNode *)subnodeLayout.layoutElement).frame = subnodeLayout.frame; } } @@ -3267,7 +3267,7 @@ static const char *ASDisplayNodeDrawingPriorityKey = "ASDrawingPriority"; _flags.isInHierarchy = inHierarchy; } -- (id)finalLayoutable +- (id)finalLayoutElement { return self; } @@ -3525,7 +3525,7 @@ ASEnvironmentLayoutExtensibilityForwarding return subtree; } -#pragma mark - ASLayoutableAsciiArtProtocol +#pragma mark - ASLayoutElementAsciiArtProtocol - (NSString *)asciiArtString { diff --git a/AsyncDisplayKit/ASVideoPlayerNode.mm b/AsyncDisplayKit/ASVideoPlayerNode.mm index a099eaecdc..408d45d6b9 100644 --- a/AsyncDisplayKit/ASVideoPlayerNode.mm +++ b/AsyncDisplayKit/ASVideoPlayerNode.mm @@ -705,6 +705,7 @@ static void *ASVideoPlayerNodeContext = &ASVideoPlayerNodeContext; ASDisplayNodeAssert(NO, @"Infinite width or height in ASVideoPlayerNode"); maxSize = CGSizeZero; } + [_videoNode.style setSizeWithCGSize:maxSize]; ASLayoutSpec *layoutSpec; diff --git a/AsyncDisplayKit/AsyncDisplayKit.h b/AsyncDisplayKit/AsyncDisplayKit.h index 2d89f9a272..eb80a5dc0b 100644 --- a/AsyncDisplayKit/AsyncDisplayKit.h +++ b/AsyncDisplayKit/AsyncDisplayKit.h @@ -48,7 +48,7 @@ #import #import #import -#import +#import #import #import #import diff --git a/AsyncDisplayKit/Layout/ASAbsoluteLayoutSpec.mm b/AsyncDisplayKit/Layout/ASAbsoluteLayoutSpec.mm index 1b86fdcb15..b6d228a842 100644 --- a/AsyncDisplayKit/Layout/ASAbsoluteLayoutSpec.mm +++ b/AsyncDisplayKit/Layout/ASAbsoluteLayoutSpec.mm @@ -38,21 +38,21 @@ { // TODO: layout: isValidForLayout() call should not be necessary if INFINITY is used CGSize size = { - (isinf(constrainedSize.max.width) || !ASPointsAreValidForLayout(constrainedSize.max.width)) ? ASLayoutableParentDimensionUndefined : constrainedSize.max.width, - (isinf(constrainedSize.max.height) || !ASPointsAreValidForLayout(constrainedSize.max.height)) ? ASLayoutableParentDimensionUndefined : constrainedSize.max.height + (isinf(constrainedSize.max.width) || !ASPointsAreValidForLayout(constrainedSize.max.width)) ? ASLayoutElementParentDimensionUndefined : constrainedSize.max.width, + (isinf(constrainedSize.max.height) || !ASPointsAreValidForLayout(constrainedSize.max.height)) ? ASLayoutElementParentDimensionUndefined : constrainedSize.max.height }; NSArray *children = self.children; NSMutableArray *sublayouts = [NSMutableArray arrayWithCapacity:children.count]; - for (id child in children) { + for (id child in children) { CGPoint layoutPosition = child.style.layoutPosition; CGSize autoMaxSize = { constrainedSize.max.width - layoutPosition.x, constrainedSize.max.height - layoutPosition.y }; - const ASSizeRange childConstraint = ASLayoutableSizeResolveAutoSize(child.style.size, size, {{0,0}, autoMaxSize}); + const ASSizeRange childConstraint = ASLayoutElementSizeResolveAutoSize(child.style.size, size, {{0,0}, autoMaxSize}); ASLayout *sublayout = [child layoutThatFits:childConstraint parentSize:size]; sublayout.position = layoutPosition; @@ -73,7 +73,7 @@ } } - return [ASLayout layoutWithLayoutable:self size:ASSizeRangeClamp(constrainedSize, size) sublayouts:sublayouts]; + return [ASLayout layoutWithLayoutElement:self size:ASSizeRangeClamp(constrainedSize, size) sublayouts:sublayouts]; } @end @@ -89,7 +89,7 @@ @implementation ASAbsoluteLayoutSpec (Debugging) -#pragma mark - ASLayoutableAsciiArtProtocol +#pragma mark - ASLayoutElementAsciiArtProtocol - (NSString *)debugBoxString { diff --git a/AsyncDisplayKit/Layout/ASAbsoluteLayoutable.h b/AsyncDisplayKit/Layout/ASAbsoluteLayoutable.h index 0b07b474ae..25c168e4e9 100644 --- a/AsyncDisplayKit/Layout/ASAbsoluteLayoutable.h +++ b/AsyncDisplayKit/Layout/ASAbsoluteLayoutable.h @@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN /** - * Layout options that can be defined for an ASLayoutable being added to a ASAbsoluteLayoutSpec. + * Layout options that can be defined for an ASLayoutElement being added to a ASAbsoluteLayoutSpec. */ @protocol ASAbsoluteLayoutable diff --git a/AsyncDisplayKit/Layout/ASAsciiArtBoxCreator.h b/AsyncDisplayKit/Layout/ASAsciiArtBoxCreator.h index 78463d8e46..76c7f41b66 100644 --- a/AsyncDisplayKit/Layout/ASAsciiArtBoxCreator.h +++ b/AsyncDisplayKit/Layout/ASAsciiArtBoxCreator.h @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN -@protocol ASLayoutableAsciiArtProtocol +@protocol ASLayoutElementAsciiArtProtocol /** * Returns an ascii-art representation of this object and its children. * For example, an ASInsetSpec may return something like this: diff --git a/AsyncDisplayKit/Layout/ASBackgroundLayoutSpec.h b/AsyncDisplayKit/Layout/ASBackgroundLayoutSpec.h index 9e39086afa..f722f9c644 100644 --- a/AsyncDisplayKit/Layout/ASBackgroundLayoutSpec.h +++ b/AsyncDisplayKit/Layout/ASBackgroundLayoutSpec.h @@ -13,22 +13,22 @@ NS_ASSUME_NONNULL_BEGIN /** - Lays out a single layoutable child, then lays out a background layoutable instance behind it stretched to its size. + Lays out a single layoutElement child, then lays out a background layoutElement instance behind it stretched to its size. */ @interface ASBackgroundLayoutSpec : ASLayoutSpec /** * Background layoutable for this layout spec */ -@property (nullable, nonatomic, strong) id background; +@property (nullable, nonatomic, strong) id background; /** * Creates and returns an ASBackgroundLayoutSpec object * * @param child A child that is laid out to determine the size of this spec. - * @param background A layoutable object that is laid out behind the child. If this is nil, the background is omitted. + * @param background A layoutElement object that is laid out behind the child. If this is nil, the background is omitted. */ -+ (instancetype)backgroundLayoutSpecWithChild:(id)child background:(nullable id)background; ++ (instancetype)backgroundLayoutSpecWithChild:(id)child background:(nullable id)background; @end diff --git a/AsyncDisplayKit/Layout/ASBackgroundLayoutSpec.mm b/AsyncDisplayKit/Layout/ASBackgroundLayoutSpec.mm index ecba89ab82..9271d70d70 100644 --- a/AsyncDisplayKit/Layout/ASBackgroundLayoutSpec.mm +++ b/AsyncDisplayKit/Layout/ASBackgroundLayoutSpec.mm @@ -21,14 +21,14 @@ static NSUInteger const kBackgroundChildIndex = 1; #pragma mark - Class -+ (instancetype)backgroundLayoutSpecWithChild:(id)child background:(id)background; ++ (instancetype)backgroundLayoutSpecWithChild:(id)child background:(id)background; { return [[self alloc] initWithChild:child background:background]; } #pragma mark - Lifecycle -- (instancetype)initWithChild:(id)child background:(id)background +- (instancetype)initWithChild:(id)child background:(id)background { if (!(self = [super init])) { return nil; @@ -46,7 +46,7 @@ static NSUInteger const kBackgroundChildIndex = 1; * First layout the contents, then fit the background image. */ - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize - restrictedToSize:(ASLayoutableSize)size + restrictedToSize:(ASLayoutElementSize)size relativeToParentSize:(CGSize)parentSize { ASLayout *contentsLayout = [[super childAtIndex:kForegroundChildIndex] layoutThatFits:constrainedSize parentSize:parentSize]; @@ -62,17 +62,17 @@ static NSUInteger const kBackgroundChildIndex = 1; contentsLayout.position = CGPointZero; [sublayouts addObject:contentsLayout]; - return [ASLayout layoutWithLayoutable:self size:contentsLayout.size sublayouts:sublayouts]; + return [ASLayout layoutWithLayoutElement:self size:contentsLayout.size sublayouts:sublayouts]; } #pragma mark - Background -- (void)setBackground:(id)background +- (void)setBackground:(id)background { [super setChild:background atIndex:kBackgroundChildIndex]; } -- (id)background +- (id)background { return [super childAtIndex:kBackgroundChildIndex]; } diff --git a/AsyncDisplayKit/Layout/ASCenterLayoutSpec.h b/AsyncDisplayKit/Layout/ASCenterLayoutSpec.h index 346f7f69b9..32f192e328 100644 --- a/AsyncDisplayKit/Layout/ASCenterLayoutSpec.h +++ b/AsyncDisplayKit/Layout/ASCenterLayoutSpec.h @@ -36,7 +36,7 @@ typedef NS_OPTIONS(NSUInteger, ASCenterLayoutSpecSizingOptions) { NS_ASSUME_NONNULL_BEGIN -/** Lays out a single layoutable child and position it so that it is centered into the layout bounds. +/** Lays out a single layoutElement child and position it so that it is centered into the layout bounds. * NOTE: ASRelativeLayoutSpec offers all of the capabilities of Center, and more. * Check it out if you would like to be able to position the child at any corner or the middle of an edge. */ @@ -56,7 +56,7 @@ NS_ASSUME_NONNULL_BEGIN */ + (instancetype)centerLayoutSpecWithCenteringOptions:(ASCenterLayoutSpecCenteringOptions)centeringOptions sizingOptions:(ASCenterLayoutSpecSizingOptions)sizingOptions - child:(id)child; + child:(id)child; @end diff --git a/AsyncDisplayKit/Layout/ASCenterLayoutSpec.mm b/AsyncDisplayKit/Layout/ASCenterLayoutSpec.mm index e5ffb8d6d7..a1610671d6 100644 --- a/AsyncDisplayKit/Layout/ASCenterLayoutSpec.mm +++ b/AsyncDisplayKit/Layout/ASCenterLayoutSpec.mm @@ -20,7 +20,7 @@ - (instancetype)initWithCenteringOptions:(ASCenterLayoutSpecCenteringOptions)centeringOptions sizingOptions:(ASCenterLayoutSpecSizingOptions)sizingOptions - child:(id)child; + child:(id)child; { ASRelativeLayoutSpecPosition verticalPosition = [self verticalPositionFromCenteringOptions:centeringOptions]; ASRelativeLayoutSpecPosition horizontalPosition = [self horizontalPositionFromCenteringOptions:centeringOptions]; @@ -35,7 +35,7 @@ + (instancetype)centerLayoutSpecWithCenteringOptions:(ASCenterLayoutSpecCenteringOptions)centeringOptions sizingOptions:(ASCenterLayoutSpecSizingOptions)sizingOptions - child:(id)child + child:(id)child { return [[self alloc] initWithCenteringOptions:centeringOptions sizingOptions:sizingOptions child:child]; } diff --git a/AsyncDisplayKit/Layout/ASDimension.h b/AsyncDisplayKit/Layout/ASDimension.h index d801cd51b2..963b070e19 100644 --- a/AsyncDisplayKit/Layout/ASDimension.h +++ b/AsyncDisplayKit/Layout/ASDimension.h @@ -56,15 +56,15 @@ typedef struct { } ASSizeRange; /** - * A struct specifying a ASLayoutable's size. Example: + * A struct specifying a ASLayoutElement's size. Example: * - * ASLayoutableSize size = (ASLayoutableSize){ + * ASLayoutElementSize size = (ASLayoutElementSize){ * .width = ASDimensionMakeWithFraction(0.25), * .maxWidth = ASDimensionMakeWithPoints(200), * .minHeight = ASDimensionMakeWithFraction(0.50) * }; * - * Description: + * Description: * */ typedef struct { @@ -74,7 +74,7 @@ typedef struct { ASDimension maxWidth; ASDimension minHeight; ASDimension maxHeight; -} ASLayoutableSize; +} ASLayoutElementSize; extern ASDimension const ASDimensionAuto; @@ -230,14 +230,14 @@ ASDISPLAYNODE_INLINE BOOL ASSizeRangeEqualToSizeRange(ASSizeRange lhs, ASSizeRan extern NSString *NSStringFromASSizeRange(ASSizeRange sizeRange); -#pragma mark - ASLayoutableSize +#pragma mark - ASLayoutElementSize /** - * Returns an ASLayoutableSize with default values. + * Returns an ASLayoutElementSize with default values. */ -ASDISPLAYNODE_INLINE ASLayoutableSize ASLayoutableSizeMake() +ASDISPLAYNODE_INLINE ASLayoutElementSize ASLayoutElementSizeMake() { - return (ASLayoutableSize){ + return (ASLayoutElementSize){ .width = ASDimensionAuto, .height = ASDimensionAuto, .minWidth = ASDimensionAuto, @@ -248,11 +248,11 @@ ASDISPLAYNODE_INLINE ASLayoutableSize ASLayoutableSizeMake() } /** - * Returns an ASLayoutableSize with the specified CGSize values as width and height. + * Returns an ASLayoutElementSize with the specified CGSize values as width and height. */ -ASDISPLAYNODE_INLINE ASLayoutableSize ASLayoutableSizeMakeFromCGSize(CGSize size) +ASDISPLAYNODE_INLINE ASLayoutElementSize ASLayoutElementSizeMakeFromCGSize(CGSize size) { - ASLayoutableSize s = ASLayoutableSizeMake(); + ASLayoutElementSize s = ASLayoutElementSizeMake(); s.width = ASDimensionMakeWithPoints(size.width); s.height = ASDimensionMakeWithPoints(size.height); return s; @@ -261,7 +261,7 @@ ASDISPLAYNODE_INLINE ASLayoutableSize ASLayoutableSizeMakeFromCGSize(CGSize size /** * Returns whether two sizes are equal. */ -ASDISPLAYNODE_INLINE BOOL ASLayoutableSizeEqualToLayoutableSize(ASLayoutableSize lhs, ASLayoutableSize rhs) +ASDISPLAYNODE_INLINE BOOL ASLayoutElementSizeEqualToLayoutElementSize(ASLayoutElementSize lhs, ASLayoutElementSize rhs) { return (ASDimensionEqualToDimension(lhs.width, rhs.width) && ASDimensionEqualToDimension(lhs.height, rhs.height) @@ -272,9 +272,9 @@ ASDISPLAYNODE_INLINE BOOL ASLayoutableSizeEqualToLayoutableSize(ASLayoutableSize } /** - * Returns a string formatted to contain the data from an ASLayoutableSize. + * Returns a string formatted to contain the data from an ASLayoutElementSize. */ -extern NSString *NSStringFromASLayoutableSize(ASLayoutableSize size); +extern NSString *NSStringFromASLayoutElementSize(ASLayoutElementSize size); /** * Resolve the given size relative to a parent size and an auto size. @@ -283,15 +283,15 @@ extern NSString *NSStringFromASLayoutableSize(ASLayoutableSize size); * dimension with unit ASDimensionUnitAuto the given autoASSizeRange value will be used. * Based on the calculated exact, min and max size constraints the final size range will be calculated. */ -extern ASSizeRange ASLayoutableSizeResolveAutoSize(ASLayoutableSize size, const CGSize parentSize, ASSizeRange autoASSizeRange); +extern ASSizeRange ASLayoutElementSizeResolveAutoSize(ASLayoutElementSize size, const CGSize parentSize, ASSizeRange autoASSizeRange); /** - * Resolve the given size to a parent size. Uses internally ASLayoutableSizeResolveAutoSize with {INFINITY, INFINITY} as - * as autoASSizeRange. For more information look at ASLayoutableSizeResolveAutoSize. + * Resolve the given size to a parent size. Uses internally ASLayoutElementSizeResolveAutoSize with {INFINITY, INFINITY} as + * as autoASSizeRange. For more information look at ASLayoutElementSizeResolveAutoSize. */ -ASDISPLAYNODE_INLINE ASSizeRange ASLayoutableSizeResolve(ASLayoutableSize size, const CGSize parentSize) +ASDISPLAYNODE_INLINE ASSizeRange ASLayoutElementSizeResolve(ASLayoutElementSize size, const CGSize parentSize) { - return ASLayoutableSizeResolveAutoSize(size, parentSize, ASSizeRangeMake(CGSizeZero, CGSizeMake(INFINITY, INFINITY))); + return ASLayoutElementSizeResolveAutoSize(size, parentSize, ASSizeRangeMake(CGSizeZero, CGSizeMake(INFINITY, INFINITY))); } diff --git a/AsyncDisplayKit/Layout/ASDimension.mm b/AsyncDisplayKit/Layout/ASDimension.mm index 6f5f232d96..a51389a18c 100644 --- a/AsyncDisplayKit/Layout/ASDimension.mm +++ b/AsyncDisplayKit/Layout/ASDimension.mm @@ -111,18 +111,18 @@ ASDISPLAYNODE_INLINE NSString *NSStringFromASRelativeSize(ASRelativeSize size) } -#pragma mark - ASLayoutableSize +#pragma mark - ASLayoutElementSize -NSString *NSStringFromASLayoutableSize(ASLayoutableSize size) +NSString *NSStringFromASLayoutElementSize(ASLayoutElementSize size) { return [NSString stringWithFormat: - @"", + @"", NSStringFromASRelativeSize(ASRelativeSizeMake(size.width, size.height)), NSStringFromASRelativeSize(ASRelativeSizeMake(size.minWidth, size.minHeight)), NSStringFromASRelativeSize(ASRelativeSizeMake(size.maxWidth, size.maxHeight))]; } -ASDISPLAYNODE_INLINE void ASLayoutableSizeConstrain(CGFloat minVal, CGFloat exactVal, CGFloat maxVal, CGFloat *outMin, CGFloat *outMax) +ASDISPLAYNODE_INLINE void ASLayoutElementSizeConstrain(CGFloat minVal, CGFloat exactVal, CGFloat maxVal, CGFloat *outMin, CGFloat *outMax) { NSCAssert(!isnan(minVal), @"minVal must not be NaN"); NSCAssert(!isnan(maxVal), @"maxVal must not be NaN"); @@ -154,15 +154,15 @@ ASDISPLAYNODE_INLINE void ASLayoutableSizeConstrain(CGFloat minVal, CGFloat exac } } -ASSizeRange ASLayoutableSizeResolveAutoSize(ASLayoutableSize size, const CGSize parentSize, ASSizeRange autoASSizeRange) +ASSizeRange ASLayoutElementSizeResolveAutoSize(ASLayoutElementSize size, const CGSize parentSize, ASSizeRange autoASSizeRange) { CGSize resolvedExact = ASRelativeSizeResolveSize(ASRelativeSizeMake(size.width, size.height), parentSize, {NAN, NAN}); CGSize resolvedMin = ASRelativeSizeResolveSize(ASRelativeSizeMake(size.minWidth, size.minHeight), parentSize, autoASSizeRange.min); CGSize resolvedMax = ASRelativeSizeResolveSize(ASRelativeSizeMake(size.maxWidth, size.maxHeight), parentSize, autoASSizeRange.max); CGSize rangeMin, rangeMax; - ASLayoutableSizeConstrain(resolvedMin.width, resolvedExact.width, resolvedMax.width, &rangeMin.width, &rangeMax.width); - ASLayoutableSizeConstrain(resolvedMin.height, resolvedExact.height, resolvedMax.height, &rangeMin.height, &rangeMax.height); + ASLayoutElementSizeConstrain(resolvedMin.width, resolvedExact.width, resolvedMax.width, &rangeMin.width, &rangeMax.width); + ASLayoutElementSizeConstrain(resolvedMin.height, resolvedExact.height, resolvedMax.height, &rangeMin.height, &rangeMax.height); return {rangeMin, rangeMax}; } diff --git a/AsyncDisplayKit/Layout/ASInsetLayoutSpec.h b/AsyncDisplayKit/Layout/ASInsetLayoutSpec.h index b41e66fb5f..1e25b27a44 100644 --- a/AsyncDisplayKit/Layout/ASInsetLayoutSpec.h +++ b/AsyncDisplayKit/Layout/ASInsetLayoutSpec.h @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN /** - A layout spec that wraps another layoutable child, applying insets around it. + A layout spec that wraps another layoutElement child, applying insets around it. If the child has a size specified as a fraction, the fraction is resolved against this spec's parent size **after** applying insets. @@ -37,7 +37,7 @@ NS_ASSUME_NONNULL_BEGIN @param insets The amount of space to inset on each side. @param child The wrapped child to inset. */ -+ (instancetype)insetLayoutSpecWithInsets:(UIEdgeInsets)insets child:(id)child; ++ (instancetype)insetLayoutSpecWithInsets:(UIEdgeInsets)insets child:(id)child; @end diff --git a/AsyncDisplayKit/Layout/ASInsetLayoutSpec.mm b/AsyncDisplayKit/Layout/ASInsetLayoutSpec.mm index 3c7f49857d..986d2e4002 100644 --- a/AsyncDisplayKit/Layout/ASInsetLayoutSpec.mm +++ b/AsyncDisplayKit/Layout/ASInsetLayoutSpec.mm @@ -41,7 +41,7 @@ static CGFloat centerInset(CGFloat outer, CGFloat inner) @implementation ASInsetLayoutSpec -- (instancetype)initWithInsets:(UIEdgeInsets)insets child:(id)child; +- (instancetype)initWithInsets:(UIEdgeInsets)insets child:(id)child; { if (!(self = [super init])) { return nil; @@ -52,7 +52,7 @@ static CGFloat centerInset(CGFloat outer, CGFloat inner) return self; } -+ (instancetype)insetLayoutSpecWithInsets:(UIEdgeInsets)insets child:(id)child ++ (instancetype)insetLayoutSpecWithInsets:(UIEdgeInsets)insets child:(id)child { return [[self alloc] initWithInsets:insets child:child]; } @@ -68,12 +68,12 @@ static CGFloat centerInset(CGFloat outer, CGFloat inner) the child to respect the inset. */ - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize - restrictedToSize:(ASLayoutableSize)size + restrictedToSize:(ASLayoutElementSize)size relativeToParentSize:(CGSize)parentSize { if (self.child == nil) { ASDisplayNodeAssert(NO, @"Inset spec measured without a child. The spec will do nothing."); - return [ASLayout layoutWithLayoutable:self size:CGSizeZero]; + return [ASLayout layoutWithLayoutElement:self size:CGSizeZero]; } const CGFloat insetsX = (finiteOrZero(_insets.left) + finiteOrZero(_insets.right)); @@ -118,7 +118,7 @@ static CGFloat centerInset(CGFloat outer, CGFloat inner) sublayout.position = CGPointMake(x, y); - return [ASLayout layoutWithLayoutable:self size:computedSize sublayouts:@[sublayout]]; + return [ASLayout layoutWithLayoutElement:self size:computedSize sublayouts:@[sublayout]]; } @end diff --git a/AsyncDisplayKit/Layout/ASLayout.h b/AsyncDisplayKit/Layout/ASLayout.h index c5f66b21d2..19cf8e5924 100644 --- a/AsyncDisplayKit/Layout/ASLayout.h +++ b/AsyncDisplayKit/Layout/ASLayout.h @@ -12,7 +12,7 @@ #import #import -#import +#import #import NS_ASSUME_NONNULL_BEGIN @@ -24,11 +24,11 @@ extern CGPoint const CGPointNull; extern BOOL CGPointIsNull(CGPoint point); /** - * Safely calculates the layout of the given root layoutable by guarding against nil nodes. - * @param rootLayoutable The root node to calculate the layout for. + * Safely calculates the layout of the given root layoutElement by guarding against nil nodes. + * @param rootLayoutElement The root node to calculate the layout for. * @param sizeRange The size range to calculate the root layout within. */ -extern ASLayout *ASCalculateRootLayout(id rootLayoutable, const ASSizeRange sizeRange); +extern ASLayout *ASCalculateRootLayout(id rootLayoutElement, const ASSizeRange sizeRange); /** * Safely computes the layout of the given node by guarding against nil nodes. @@ -36,24 +36,24 @@ extern ASLayout *ASCalculateRootLayout(id rootLayoutable, const AS * @param sizeRange The size range to calculate the node layout within. * @param parentSize The parent size of the node to calculate the layout for. */ -extern ASLayout *ASCalculateLayout(id layoutable, const ASSizeRange sizeRange, const CGSize parentSize); +extern ASLayout *ASCalculateLayout(id layoutElement, const ASSizeRange sizeRange, const CGSize parentSize); ASDISPLAYNODE_EXTERN_C_END /** - * A node in the layout tree that represents the size and position of the object that created it (ASLayoutable). + * A node in the layout tree that represents the size and position of the object that created it (ASLayoutElement). */ @interface ASLayout : NSObject /** * The underlying object described by this layout */ -@property (nonatomic, weak, readonly) id layoutable; +@property (nonatomic, weak, readonly) id layoutElement; /** - * The type of ASLayoutable that created this layout + * The type of ASLayoutElement that created this layout */ -@property (nonatomic, assign, readonly) ASLayoutableType type; +@property (nonatomic, assign, readonly) ASLayoutElementType type; /** * Size of the current layout @@ -81,7 +81,7 @@ ASDISPLAYNODE_EXTERN_C_END /** * Designated initializer */ -- (instancetype)initWithLayoutable:(id)layoutable +- (instancetype)initWithLayoutElement:(id)layoutElement size:(CGSize)size position:(CGPoint)position sublayouts:(nullable NSArray *)sublayouts NS_DESIGNATED_INITIALIZER; @@ -89,15 +89,15 @@ ASDISPLAYNODE_EXTERN_C_END /** * Convenience class initializer for layout construction. * - * @param layoutable The backing ASLayoutable object. + * @param layoutElement The backing ASLayoutElement object. * @param size The size of this layout. * @param position The position of this layout within its parent (if available). * @param sublayouts Sublayouts belong to the new layout. */ -+ (instancetype)layoutWithLayoutable:(id)layoutable - size:(CGSize)size - position:(CGPoint)position - sublayouts:(nullable NSArray *)sublayouts; ++ (instancetype)layoutWithLayoutElement:(id)layoutElement + size:(CGSize)size + position:(CGPoint)position + sublayouts:(nullable NSArray *)sublayouts; /** * Convenience initializer that has CGPointNull position. @@ -105,24 +105,24 @@ ASDISPLAYNODE_EXTERN_C_END * or for ASLayoutSpec subclasses that are referencing the "self" level in the layout tree, * or for creating a sublayout of which the position is yet to be determined. * - * @param layoutable The backing ASLayoutable object. + * @param layoutElement The backing ASLayoutElement object. * @param size The size of this layout. * @param sublayouts Sublayouts belong to the new layout. */ -+ (instancetype)layoutWithLayoutable:(id)layoutable - size:(CGSize)size - sublayouts:(nullable NSArray *)sublayouts; ++ (instancetype)layoutWithLayoutElement:(id)layoutElement + size:(CGSize)size + sublayouts:(nullable NSArray *)sublayouts; /** * Convenience that has CGPointNull position and no sublayouts. * Best used for creating a layout that has no sublayouts, and is either a root one * or a sublayout of which the position is yet to be determined. * - * @param layoutable The backing ASLayoutable object. + * @param layoutElement The backing ASLayoutElement object. * @param size The size of this layout. */ -+ (instancetype)layoutWithLayoutable:(id)layoutable - size:(CGSize)size; ++ (instancetype)layoutWithLayoutElement:(id)layoutElement + size:(CGSize)size; /** * Convenience initializer that creates a layout based on the values of the given layout, with a new position * diff --git a/AsyncDisplayKit/Layout/ASLayout.mm b/AsyncDisplayKit/Layout/ASLayout.mm index f43d37b5a3..1ccc3d4447 100644 --- a/AsyncDisplayKit/Layout/ASLayout.mm +++ b/AsyncDisplayKit/Layout/ASLayout.mm @@ -52,12 +52,12 @@ static inline NSString * descriptionIndents(NSUInteger indents) @dynamic frame, type; -- (instancetype)initWithLayoutable:(id)layoutable - size:(CGSize)size - position:(CGPoint)position - sublayouts:(nullable NSArray *)sublayouts +- (instancetype)initWithLayoutElement:(id)layoutElement + size:(CGSize)size + position:(CGPoint)position + sublayouts:(nullable NSArray *)sublayouts { - NSParameterAssert(layoutable); + NSParameterAssert(layoutElement); self = [super init]; if (self) { @@ -67,10 +67,10 @@ static inline NSString * descriptionIndents(NSUInteger indents) } #endif - _layoutable = layoutable; + _layoutElement = layoutElement; if (!ASIsCGSizeValidForLayout(size)) { - ASDisplayNodeAssert(NO, @"layoutSize is invalid and unsafe to provide to Core Animation! Release configurations will force to 0, 0. Size = %@, node = %@", NSStringFromCGSize(size), layoutable); + ASDisplayNodeAssert(NO, @"layoutSize is invalid and unsafe to provide to Core Animation! Release configurations will force to 0, 0. Size = %@, node = %@", NSStringFromCGSize(size), layoutElement); size = CGSizeZero; } else { size = CGSizeMake(ASCeilPixelValue(size.width), ASCeilPixelValue(size.height)); @@ -97,41 +97,41 @@ static inline NSString * descriptionIndents(NSUInteger indents) #pragma mark - Class Constructors -+ (instancetype)layoutWithLayoutable:(id)layoutable - size:(CGSize)size - position:(CGPoint)position - sublayouts:(nullable NSArray *)sublayouts ++ (instancetype)layoutWithLayoutElement:(id)layoutElement + size:(CGSize)size + position:(CGPoint)position + sublayouts:(nullable NSArray *)sublayouts { - return [[self alloc] initWithLayoutable:layoutable - size:size - position:position - sublayouts:sublayouts]; + return [[self alloc] initWithLayoutElement:layoutElement + size:size + position:position + sublayouts:sublayouts]; } -+ (instancetype)layoutWithLayoutable:(id)layoutable - size:(CGSize)size - sublayouts:(nullable NSArray *)sublayouts ++ (instancetype)layoutWithLayoutElement:(id)layoutElement + size:(CGSize)size + sublayouts:(nullable NSArray *)sublayouts { - return [self layoutWithLayoutable:layoutable - size:size - position:CGPointNull - sublayouts:sublayouts]; + return [self layoutWithLayoutElement:layoutElement + size:size + position:CGPointNull + sublayouts:sublayouts]; } -+ (instancetype)layoutWithLayoutable:(id)layoutable size:(CGSize)size ++ (instancetype)layoutWithLayoutElement:(id)layoutElement size:(CGSize)size { - return [self layoutWithLayoutable:layoutable - size:size - position:CGPointNull - sublayouts:nil]; + return [self layoutWithLayoutElement:layoutElement + size:size + position:CGPointNull + sublayouts:nil]; } + (instancetype)layoutWithLayout:(ASLayout *)layout position:(CGPoint)position { - return [self layoutWithLayoutable:layout.layoutable - size:layout.size - position:position - sublayouts:layout.sublayouts]; + return [self layoutWithLayoutElement:layout.layoutElement + size:layout.size + position:position + sublayouts:layout.sublayouts]; } #pragma mark - Layout Flattening @@ -153,7 +153,7 @@ static inline NSString * descriptionIndents(NSUInteger indents) Context context = queue.front(); queue.pop(); - if (self != context.layout && context.layout.type == ASLayoutableTypeDisplayNode) { + if (self != context.layout && context.layout.type == ASLayoutElementTypeDisplayNode) { ASLayout *layout = [ASLayout layoutWithLayout:context.layout position:context.absolutePosition]; layout.flattened = YES; [flattenedSublayouts addObject:layout]; @@ -166,14 +166,14 @@ static inline NSString * descriptionIndents(NSUInteger indents) } } - return [ASLayout layoutWithLayoutable:_layoutable size:_size sublayouts:flattenedSublayouts]; + return [ASLayout layoutWithLayoutElement:_layoutElement size:_size sublayouts:flattenedSublayouts]; } #pragma mark - Accessors -- (ASLayoutableType)type +- (ASLayoutElementType)type { - return _layoutable.layoutableType; + return _layoutElement.layoutElementType; } - (CGRect)frame @@ -209,7 +209,7 @@ static inline NSString * descriptionIndents(NSUInteger indents) - (NSMutableArray *)propertiesForDescription { NSMutableArray *result = [NSMutableArray array]; - [result addObject:@{ @"layoutable" : (self.layoutable ?: (id)kCFNull) }]; + [result addObject:@{ @"layoutElement" : (self.layoutElement ?: (id)kCFNull) }]; [result addObject:@{ @"position" : [NSValue valueWithCGPoint:self.position] }]; [result addObject:@{ @"size" : [NSValue valueWithCGSize:self.size] }]; return result; @@ -239,16 +239,16 @@ static inline NSString * descriptionIndents(NSUInteger indents) @end -ASLayout *ASCalculateLayout(id layoutable, const ASSizeRange sizeRange, const CGSize parentSize) +ASLayout *ASCalculateLayout(id layoutElement, const ASSizeRange sizeRange, const CGSize parentSize) { - ASDisplayNodeCAssertNotNil(layoutable, @"Not valid layoutable passed in."); + ASDisplayNodeCAssertNotNil(layoutElement, @"Not valid layoutElement passed in."); - return [layoutable layoutThatFits:sizeRange parentSize:parentSize]; + return [layoutElement layoutThatFits:sizeRange parentSize:parentSize]; } -ASLayout *ASCalculateRootLayout(id rootLayoutable, const ASSizeRange sizeRange) +ASLayout *ASCalculateRootLayout(id rootLayoutElement, const ASSizeRange sizeRange) { - ASLayout *layout = ASCalculateLayout(rootLayoutable, sizeRange, sizeRange.max); + ASLayout *layout = ASCalculateLayout(rootLayoutElement, sizeRange, sizeRange.max); // Here could specific verfication happen return layout; } diff --git a/AsyncDisplayKit/Layout/ASLayoutable.h b/AsyncDisplayKit/Layout/ASLayoutElement.h similarity index 73% rename from AsyncDisplayKit/Layout/ASLayoutable.h rename to AsyncDisplayKit/Layout/ASLayoutElement.h index 9801901a95..b3ebc6c8f2 100644 --- a/AsyncDisplayKit/Layout/ASLayoutable.h +++ b/AsyncDisplayKit/Layout/ASLayoutElement.h @@ -1,5 +1,5 @@ // -// ASLayoutable.h +// ASLayoutElement.h // AsyncDisplayKit // // Copyright (c) 2014-present, Facebook, Inc. All rights reserved. @@ -12,62 +12,61 @@ #import #import #import - -#import +#import #import -#import +#import @class ASLayout; @class ASLayoutSpec; /** A constant that indicates that the parent's size is not yet determined in a given dimension. */ -extern CGFloat const ASLayoutableParentDimensionUndefined; +extern CGFloat const ASLayoutElementParentDimensionUndefined; /** A constant that indicates that the parent's size is not yet determined in either dimension. */ -extern CGSize const ASLayoutableParentSizeUndefined; +extern CGSize const ASLayoutElementParentSizeUndefined; -/** Type of ASLayoutable */ -typedef NS_ENUM(NSUInteger, ASLayoutableType) { - ASLayoutableTypeLayoutSpec, - ASLayoutableTypeDisplayNode +/** Type of ASLayoutElement */ +typedef NS_ENUM(NSUInteger, ASLayoutElementType) { + ASLayoutElementTypeLayoutSpec, + ASLayoutElementTypeDisplayNode }; NS_ASSUME_NONNULL_BEGIN /** - * The ASLayoutable protocol declares a method for measuring the layout of an object. A layout + * The ASLayoutElement protocol declares a method for measuring the layout of an object. A layout * is defined by an ASLayout return value, and must specify 1) the size (but not position) of the - * layoutable object, and 2) the size and position of all of its immediate child objects. The tree + * layoutElement object, and 2) the size and position of all of its immediate child objects. The tree * recursion is driven by parents requesting layouts from their children in order to determine their * size, followed by the parents setting the position of the children once the size is known * - * The protocol also implements a "family" of Layoutable protocols. These protocols contain layout + * The protocol also implements a "family" of LayoutElement protocols. These protocols contain layout * options that can be used for specific layout specs. For example, ASStackLayoutSpec has options - * defining how a layoutable should shrink or grow based upon available space. + * defining how a layoutElement should shrink or grow based upon available space. * - * These layout options are all stored in an ASLayoutOptions class (that is defined in ASLayoutablePrivate). - * Generally you needn't worry about the layout options class, as the layoutable protocols allow all direct + * These layout options are all stored in an ASLayoutOptions class (that is defined in ASLayoutElementPrivate). + * Generally you needn't worry about the layout options class, as the layoutElement protocols allow all direct * access to the options via convenience properties. If you are creating custom layout spec, then you can * extend the backing layout options class to accommodate any new layout options. */ -@protocol ASLayoutable +@protocol ASLayoutElement #pragma mark - Getter /** - * @abstract Returns type of layoutable + * @abstract Returns type of layoutElement */ -@property (nonatomic, assign, readonly) ASLayoutableType layoutableType; +@property (nonatomic, assign, readonly) ASLayoutElementType layoutElementType; /** - * @abstract Returns if the layoutable can be used to layout in an asynchronous way on a background thread. + * @abstract Returns if the layoutElement can be used to layout in an asynchronous way on a background thread. */ @property (nonatomic, assign, readonly) BOOL canLayoutAsynchronous; /** - * @abstract A size constraint that should apply to this ASLayoutable. + * @abstract A size constraint that should apply to this ASLayoutElement. */ -@property (nonatomic, assign, readonly) ASLayoutableStyle *style; +@property (nonatomic, assign, readonly) ASLayoutElementStyle *style; #pragma mark - Calculate layout @@ -89,14 +88,14 @@ NS_ASSUME_NONNULL_BEGIN - (ASLayout *)layoutThatFits:(ASSizeRange)constrainedSize; /** - * Call this on children layoutables to compute their layouts within your implementation of -calculateLayoutThatFits:. + * Call this on children layoutElements to compute their layouts within your implementation of -calculateLayoutThatFits:. * * @warning You may not override this method. Override -calculateLayoutThatFits: instead. * @warning In almost all cases, prefer the use of ASCalculateLayout in ASLayout * * @param constrainedSize Specifies a minimum and maximum size. The receiver must choose a size that is in this range. * @param parentSize The parent node's size. If the parent component does not have a final size in a given dimension, - * then it should be passed as ASLayoutableParentDimensionUndefined (for example, if the parent's width + * then it should be passed as ASLayoutElementParentDimensionUndefined (for example, if the parent's width * depends on the child's size). * * @discussion Though this method does not set the bounds of the view, it does have side effects--caching both the @@ -107,7 +106,7 @@ NS_ASSUME_NONNULL_BEGIN - (ASLayout *)layoutThatFits:(ASSizeRange)constrainedSize parentSize:(CGSize)parentSize; /** - * Override this method to compute your layoutable's layout. + * Override this method to compute your layoutElement's layout. * * @discussion Why do you need to override -calculateLayoutThatFits: instead of -layoutThatFits:parentSize:? * The base implementation of -layoutThatFits:parentSize: does the following for you: @@ -125,13 +124,13 @@ NS_ASSUME_NONNULL_BEGIN /** * In certain advanced cases, you may want to override this method. Overriding this method allows you to receive the - * layoutable's size, parentSize, and constrained size. With these values you could calculate the final constrained size + * layoutElement's size, parentSize, and constrained size. With these values you could calculate the final constrained size * and call -calculateLayoutThatFits: with the result. * * @warning Overriding this method should be done VERY rarely. */ - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize - restrictedToSize:(ASLayoutableSize)size + restrictedToSize:(ASLayoutElementSize)size relativeToParentSize:(CGSize)parentSize; @@ -150,62 +149,61 @@ NS_ASSUME_NONNULL_BEGIN @end +extern NSString * const ASLayoutElementStyleWidthProperty; +extern NSString * const ASLayoutElementStyleMinWidthProperty; +extern NSString * const ASLayoutElementStyleMaxWidthProperty; -#pragma mark - ASLayoutableStyle +extern NSString * const ASLayoutElementStyleHeightProperty; +extern NSString * const ASLayoutElementStyleMinHeightProperty; +extern NSString * const ASLayoutElementStyleMaxHeightProperty; -extern NSString * const ASLayoutableStyleWidthProperty; -extern NSString * const ASLayoutableStyleMinWidthProperty; -extern NSString * const ASLayoutableStyleMaxWidthProperty; +extern NSString * const ASLayoutElementStyleSpacingBeforeProperty; +extern NSString * const ASLayoutElementStyleSpacingAfterProperty; +extern NSString * const ASLayoutElementStyleFlexGrowProperty; +extern NSString * const ASLayoutElementStyleFlexShrinkProperty; +extern NSString * const ASLayoutElementStyleFlexBasisProperty; +extern NSString * const ASLayoutElementStyleAlignSelfProperty; +extern NSString * const ASLayoutElementStyleAscenderProperty; +extern NSString * const ASLayoutElementStyleDescenderProperty; -extern NSString * const ASLayoutableStyleHeightProperty; -extern NSString * const ASLayoutableStyleMinHeightProperty; -extern NSString * const ASLayoutableStyleMaxHeightProperty; +extern NSString * const ASLayoutElementStyleLayoutPositionProperty; -extern NSString * const ASLayoutableStyleSpacingBeforeProperty; -extern NSString * const ASLayoutableStyleSpacingAfterProperty; -extern NSString * const ASLayoutableStyleFlexGrowProperty; -extern NSString * const ASLayoutableStyleFlexShrinkProperty; -extern NSString * const ASLayoutableStyleFlexBasisProperty; -extern NSString * const ASLayoutableStyleAlignSelfProperty; -extern NSString * const ASLayoutableStyleAscenderProperty; -extern NSString * const ASLayoutableStyleDescenderProperty; +#pragma mark - ASLayoutElementStyle -extern NSString * const ASLayoutableStyleLayoutPositionProperty; - -@protocol ASLayoutableStyleDelegate -- (void)style:(__kindof ASLayoutableStyle *)style propertyDidChange:(NSString *)propertyName; +@protocol ASLayoutElementStyleDelegate +- (void)style:(__kindof ASLayoutElementStyle *)style propertyDidChange:(NSString *)propertyName; @end -@interface ASLayoutableStyle : NSObject - -#pragma mark - Delegate +@interface ASLayoutElementStyle : NSObject /** * @abstract Initializes the layoutable style with a specified delegate */ -- (instancetype)initWithDelegate:(id)delegate; +- (instancetype)initWithDelegate:(id)delegate; /** * @abstract The object that acts as the delegate of the style. * - * @discussion The delegate must adopt the ASLayoutableStyleDelegate protocol. The delegate is not retained. + * @discussion The delegate must adopt the ASLayoutElementStyleDelegate protocol. The delegate is not retained. */ -@property (nullable, nonatomic, weak, readonly) id delegate; +@property (nullable, nonatomic, weak, readonly) id delegate; + +#pragma mark - Sizing /** - * @abstract A size constraint that should apply to this ASLayoutable. + * @abstract A size constraint that should apply to this ASLayoutElement. */ -@property (nonatomic, assign, readonly) ASLayoutableSize size; +@property (nonatomic, assign, readwrite) ASLayoutElementSize size; /** - * @abstract The width property specifies the height of the content area of an ASLayoutable. + * @abstract The width property specifies the height of the content area of an ASLayoutElement. * The minWidth and maxWidth properties override width. * Defaults to ASRelativeDimensionTypeAuto */ @property (nonatomic, assign, readwrite) ASDimension width; /** - * @abstract The height property specifies the height of the content area of an ASLayoutable + * @abstract The height property specifies the height of the content area of an ASLayoutElement * The minHeight and maxHeight properties override height. * Defaults to ASDimensionTypeAuto */ @@ -305,7 +303,6 @@ extern NSString * const ASLayoutableStyleLayoutPositionProperty; */ @property (nonatomic, assign) CGFloat descender; - #pragma mark - ASAbsoluteLayoutable /** diff --git a/AsyncDisplayKit/Layout/ASLayoutElement.mm b/AsyncDisplayKit/Layout/ASLayoutElement.mm new file mode 100644 index 0000000000..5a25a48320 --- /dev/null +++ b/AsyncDisplayKit/Layout/ASLayoutElement.mm @@ -0,0 +1,305 @@ +// +// ASLayoutElement.mm +// AsyncDisplayKit +// +// Created by Huy Nguyen on 3/27/16. +// +// 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 "ASLayoutElementPrivate.h" +#import "ASEnvironmentInternal.h" +#import "ASDisplayNodeInternal.h" +#import "ASThread.h" + +#import + +CGFloat const ASLayoutElementParentDimensionUndefined = NAN; +CGSize const ASLayoutElementParentSizeUndefined = {ASLayoutElementParentDimensionUndefined, ASLayoutElementParentDimensionUndefined}; + +int32_t const ASLayoutElementContextInvalidTransitionID = 0; +int32_t const ASLayoutElementContextDefaultTransitionID = ASLayoutElementContextInvalidTransitionID + 1; + +static inline ASLayoutElementContext _ASLayoutElementContextMake(int32_t transitionID, BOOL needsVisualizeNode) +{ + struct ASLayoutElementContext context; + context.transitionID = transitionID; + context.needsVisualizeNode = needsVisualizeNode; + return context; +} + +static inline BOOL _IsValidTransitionID(int32_t transitionID) +{ + return transitionID > ASLayoutElementContextInvalidTransitionID; +} + +struct ASLayoutElementContext const ASLayoutElementContextNull = _ASLayoutElementContextMake(ASLayoutElementContextInvalidTransitionID, NO); + +BOOL ASLayoutElementContextIsNull(struct ASLayoutElementContext context) +{ + return !_IsValidTransitionID(context.transitionID); +} + +ASLayoutElementContext ASLayoutElementContextMake(int32_t transitionID, BOOL needsVisualizeNode) +{ + NSCAssert(_IsValidTransitionID(transitionID), @"Invalid transition ID"); + return _ASLayoutElementContextMake(transitionID, needsVisualizeNode); +} + +// Note: This is a non-recursive static lock. If it needs to be recursive, use ASDISPLAYNODE_MUTEX_RECURSIVE_INITIALIZER +static ASDN::StaticMutex _layoutElementContextLock = ASDISPLAYNODE_MUTEX_INITIALIZER; +static std::map layoutElementContextMap; + +static inline mach_port_t ASLayoutElementGetCurrentContextKey() +{ + return pthread_mach_thread_np(pthread_self()); +} + +void ASLayoutElementSetCurrentContext(struct ASLayoutElementContext context) +{ + const mach_port_t key = ASLayoutElementGetCurrentContextKey(); + ASDN::StaticMutexLocker l(_layoutElementContextLock); + layoutElementContextMap[key] = context; +} + +struct ASLayoutElementContext ASLayoutElementGetCurrentContext() +{ + const mach_port_t key = ASLayoutElementGetCurrentContextKey(); + ASDN::StaticMutexLocker l(_layoutElementContextLock); + const auto it = layoutElementContextMap.find(key); + if (it != layoutElementContextMap.end()) { + // Found an interator with above key. "it->first" is the key itself, "it->second" is the context value. + return it->second; + } + return ASLayoutElementContextNull; +} + +void ASLayoutElementClearCurrentContext() +{ + const mach_port_t key = ASLayoutElementGetCurrentContextKey(); + ASDN::StaticMutexLocker l(_layoutElementContextLock); + layoutElementContextMap.erase(key); +} + +#pragma mark - ASLayoutElementStyle + +NSString * const ASLayoutElementStyleWidthProperty = @"ASLayoutElementStyleWidthProperty"; +NSString * const ASLayoutElementStyleMinWidthProperty = @"ASLayoutElementStyleMinWidthProperty"; +NSString * const ASLayoutElementStyleMaxWidthProperty = @"ASLayoutElementStyleMaxWidthProperty"; + +NSString * const ASLayoutElementStyleHeightProperty = @"ASLayoutElementStyleHeightProperty"; +NSString * const ASLayoutElementStyleMinHeightProperty = @"ASLayoutElementStyleMinHeightProperty"; +NSString * const ASLayoutElementStyleMaxHeightProperty = @"ASLayoutElementStyleMaxHeightProperty"; + +NSString * const ASLayoutElementStyleSpacingBeforeProperty = @"ASLayoutElementStyleSpacingBeforeProperty"; +NSString * const ASLayoutElementStyleSpacingAfterProperty = @"ASLayoutElementStyleSpacingAfterProperty"; +NSString * const ASLayoutElementStyleFlexGrowProperty = @"ASLayoutElementStyleFlexGrowProperty"; +NSString * const ASLayoutElementStyleFlexShrinkProperty = @"ASLayoutElementStyleFlexShrinkProperty"; +NSString * const ASLayoutElementStyleFlexBasisProperty = @"ASLayoutElementStyleFlexBasisProperty"; +NSString * const ASLayoutElementStyleAlignSelfProperty = @"ASLayoutElementStyleAlignSelfProperty"; +NSString * const ASLayoutElementStyleAscenderProperty = @"ASLayoutElementStyleAscenderProperty"; +NSString * const ASLayoutElementStyleDescenderProperty = @"ASLayoutElementStyleDescenderProperty"; + +NSString * const ASLayoutElementStyleLayoutPositionProperty = @"ASLayoutElementStyleLayoutPositionProperty"; + +#define ASLayoutElementStyleCallDelegate(propertyName)\ +do {\ + [_delegate style:self propertyDidChange:propertyName];\ +} while(0) + +@interface ASLayoutElementStyle () +@property (nullable, nonatomic, weak) id delegate; +@end + +@implementation ASLayoutElementStyle { + ASDN::RecursiveMutex __instanceLock__; + ASLayoutElementSize _size; +} + +@dynamic width, height, minWidth, maxWidth, minHeight, maxHeight; + +#pragma mark - Lifecycle + +- (instancetype)initWithDelegate:(id)delegate +{ + self = [self init]; + if (self) { + _delegate = delegate; + } + return self; +} + +- (instancetype)init +{ + self = [super init]; + if (self) { + _size = ASLayoutElementSizeMake(); + } + return self; +} + +#pragma mark - ASLayoutElementSizeForwarding + +- (ASDimension)width +{ + ASDN::MutexLocker l(__instanceLock__); + return _size.width; +} + +- (void)setWidth:(ASDimension)width +{ + ASDN::MutexLocker l(__instanceLock__); + _size.width = width; + ASLayoutElementStyleCallDelegate(ASLayoutElementStyleWidthProperty); +} + +- (ASDimension)height +{ + ASDN::MutexLocker l(__instanceLock__); + return _size.height; +} + +- (void)setHeight:(ASDimension)height +{ + ASDN::MutexLocker l(__instanceLock__); + _size.height = height; + ASLayoutElementStyleCallDelegate(ASLayoutElementStyleHeightProperty); +} + +- (ASDimension)minWidth +{ + ASDN::MutexLocker l(__instanceLock__); + return _size.minWidth; +} + +- (void)setMinWidth:(ASDimension)minWidth +{ + ASDN::MutexLocker l(__instanceLock__); + _size.minWidth = minWidth; + ASLayoutElementStyleCallDelegate(ASLayoutElementStyleMinWidthProperty); +} + +- (ASDimension)maxWidth +{ + ASDN::MutexLocker l(__instanceLock__); + return _size.maxWidth; +} + +- (void)setMaxWidth:(ASDimension)maxWidth +{ + ASDN::MutexLocker l(__instanceLock__); + _size.maxWidth = maxWidth; + ASLayoutElementStyleCallDelegate(ASLayoutElementStyleMaxWidthProperty); +} + +- (ASDimension)minHeight +{ + ASDN::MutexLocker l(__instanceLock__); + return _size.minHeight; +} + +- (void)setMinHeight:(ASDimension)minHeight +{ + ASDN::MutexLocker l(__instanceLock__); + _size.minHeight = minHeight; + ASLayoutElementStyleCallDelegate(ASLayoutElementStyleMinHeightProperty); +} + +- (ASDimension)maxHeight +{ + ASDN::MutexLocker l(__instanceLock__); + return _size.maxHeight; +} + +- (void)setMaxHeight:(ASDimension)maxHeight +{ + ASDN::MutexLocker l(__instanceLock__); + _size.maxHeight = maxHeight; + ASLayoutElementStyleCallDelegate(ASLayoutElementStyleMaxHeightProperty); +} + +- (void)setSizeWithCGSize:(CGSize)size +{ + self.width = ASDimensionMakeWithPoints(size.width); + self.height = ASDimensionMakeWithPoints(size.height); +} + +- (void)setExactSizeWithCGSize:(CGSize)size +{ + self.minWidth = ASDimensionMakeWithPoints(size.width); + self.minHeight = ASDimensionMakeWithPoints(size.height); + self.maxWidth = ASDimensionMakeWithPoints(size.width); + self.maxHeight = ASDimensionMakeWithPoints(size.height); +} + +#pragma mark - ASStackLayoutable + +- (void)setSpacingBefore:(CGFloat)spacingBefore +{ + ASDN::MutexLocker l(__instanceLock__); + _spacingBefore = spacingBefore; + ASLayoutElementStyleCallDelegate(ASLayoutElementStyleSpacingBeforeProperty); +} + +- (void)setSpacingAfter:(CGFloat)spacingAfter +{ + ASDN::MutexLocker l(__instanceLock__); + _spacingAfter = spacingAfter; + ASLayoutElementStyleCallDelegate(ASLayoutElementStyleSpacingAfterProperty); +} + +- (void)setFlexGrow:(CGFloat)flexGrow +{ + ASDN::MutexLocker l(__instanceLock__); + _flexGrow = flexGrow; + ASLayoutElementStyleCallDelegate(ASLayoutElementStyleFlexGrowProperty); +} + +- (void)setFlexShrink:(CGFloat)flexShrink +{ + ASDN::MutexLocker l(__instanceLock__); + _flexShrink = flexShrink; + ASLayoutElementStyleCallDelegate(ASLayoutElementStyleFlexShrinkProperty); +} + +- (void)setFlexBasis:(ASDimension)flexBasis +{ + ASDN::MutexLocker l(__instanceLock__); + _flexBasis = flexBasis; + ASLayoutElementStyleCallDelegate(ASLayoutElementStyleFlexBasisProperty); +} + +- (void)setAlignSelf:(ASStackLayoutAlignSelf)alignSelf +{ + ASDN::MutexLocker l(__instanceLock__); + _alignSelf = alignSelf; + ASLayoutElementStyleCallDelegate(ASLayoutElementStyleAlignSelfProperty); +} + +- (void)setAscender:(CGFloat)ascender +{ + ASDN::MutexLocker l(__instanceLock__); + _ascender = ascender; + ASLayoutElementStyleCallDelegate(ASLayoutElementStyleAscenderProperty); +} + +- (void)setDescender:(CGFloat)descender +{ + ASDN::MutexLocker l(__instanceLock__); + _descender = descender; + ASLayoutElementStyleCallDelegate(ASLayoutElementStyleDescenderProperty); +} + +#pragma mark - ASStaticLayoutable + +- (void)setLayoutPosition:(CGPoint)layoutPosition +{ + ASDN::MutexLocker l(__instanceLock__); + _layoutPosition = layoutPosition; + ASLayoutElementStyleCallDelegate(ASLayoutElementStyleLayoutPositionProperty); +} + +@end diff --git a/AsyncDisplayKit/Layout/ASLayoutableExtensibility.h b/AsyncDisplayKit/Layout/ASLayoutElementExtensibility.h similarity index 92% rename from AsyncDisplayKit/Layout/ASLayoutableExtensibility.h rename to AsyncDisplayKit/Layout/ASLayoutElementExtensibility.h index 7dce553996..7c9095e5f2 100644 --- a/AsyncDisplayKit/Layout/ASLayoutableExtensibility.h +++ b/AsyncDisplayKit/Layout/ASLayoutElementExtensibility.h @@ -1,5 +1,5 @@ // -// ASLayoutableExtensibility.h +// ASLayoutElementExtensibility.h // AsyncDisplayKit // // Created by Michael Schneider on 3/29/16. @@ -12,7 +12,7 @@ #import -@protocol ASLayoutableExtensibility +@protocol ASLayoutElementExtensibility // The maximum number of extended values per type are defined in ASEnvironment.h above the ASEnvironmentStateExtensions // struct definition. If you try to set a value at an index after the maximum it will throw an assertion. diff --git a/AsyncDisplayKit/Layout/ASLayoutablePrivate.h b/AsyncDisplayKit/Layout/ASLayoutElementPrivate.h similarity index 53% rename from AsyncDisplayKit/Layout/ASLayoutablePrivate.h rename to AsyncDisplayKit/Layout/ASLayoutElementPrivate.h index d227911df5..8dded8c36f 100644 --- a/AsyncDisplayKit/Layout/ASLayoutablePrivate.h +++ b/AsyncDisplayKit/Layout/ASLayoutElementPrivate.h @@ -1,5 +1,5 @@ // -// ASLayoutablePrivate.h +// ASLayoutElementPrivate.h // AsyncDisplayKit // // Copyright (c) 2014-present, Facebook, Inc. All rights reserved. @@ -10,58 +10,58 @@ #import "ASDimension.h" -@protocol ASLayoutable; -@class ASLayoutableStyle; +@protocol ASLayoutElement; +@class ASLayoutElementStyle; -struct ASLayoutableContext { +struct ASLayoutElementContext { int32_t transitionID; BOOL needsVisualizeNode; }; -extern int32_t const ASLayoutableContextInvalidTransitionID; +extern int32_t const ASLayoutElementContextInvalidTransitionID; -extern int32_t const ASLayoutableContextDefaultTransitionID; +extern int32_t const ASLayoutElementContextDefaultTransitionID; -extern struct ASLayoutableContext const ASLayoutableContextNull; +extern struct ASLayoutElementContext const ASLayoutElementContextNull; -extern BOOL ASLayoutableContextIsNull(struct ASLayoutableContext context); +extern BOOL ASLayoutElementContextIsNull(struct ASLayoutElementContext context); -extern struct ASLayoutableContext ASLayoutableContextMake(int32_t transitionID, BOOL needsVisualizeNode); +extern struct ASLayoutElementContext ASLayoutElementContextMake(int32_t transitionID, BOOL needsVisualizeNode); -extern void ASLayoutableSetCurrentContext(struct ASLayoutableContext context); +extern void ASLayoutElementSetCurrentContext(struct ASLayoutElementContext context); -extern struct ASLayoutableContext ASLayoutableGetCurrentContext(); +extern struct ASLayoutElementContext ASLayoutElementGetCurrentContext(); -extern void ASLayoutableClearCurrentContext(); +extern void ASLayoutElementClearCurrentContext(); /** - * The base protocol for ASLayoutable. Generally the methods/properties in this class do not need to be + * The base protocol for ASLayoutElement. Generally the methods/properties in this class do not need to be * called by the end user and are only called internally. However, there may be a case where the methods are useful. */ -@protocol ASLayoutablePrivate +@protocol ASLayoutElementPrivate /** - * @abstract This method can be used to give the user a chance to wrap an ASLayoutable in an ASLayoutSpec + * @abstract This method can be used to give the user a chance to wrap an ASLayoutElement in an ASLayoutSpec * just before it is added to a parent ASLayoutSpec. For example, if you wanted an ASTextNode that was always - * inside of an ASInsetLayoutSpec, you could subclass ASTextNode and implement finalLayoutable so that it wraps + * inside of an ASInsetLayoutSpec, you could subclass ASTextNode and implement finalLayoutElement so that it wraps * itself in an inset spec. * - * Note that any ASLayoutable other than self that is returned MUST set isFinalLayoutable to YES. Make sure - * to do this BEFORE adding a child to the ASLayoutable. + * Note that any ASLayoutElement other than self that is returned MUST set isFinalLayoutElement to YES. Make sure + * to do this BEFORE adding a child to the ASLayoutElement. * - * @return The layoutable that will be added to the parent layout spec. Defaults to self. + * @return The layoutElement that will be added to the parent layout spec. Defaults to self. */ -- (id)finalLayoutable; +- (id)finalLayoutElement; /** - * A flag to indicate that this ASLayoutable was created in finalLayoutable. This MUST be set to YES - * before adding a child to this layoutable. + * A flag to indicate that this ASLayoutElement was created in finalLayoutElement. This MUST be set to YES + * before adding a child to this layoutElement. */ -@property (nonatomic, assign) BOOL isFinalLayoutable; +@property (nonatomic, assign) BOOL isFinalLayoutElement; @end -#pragma mark - ASLayoutableExtensibility +#pragma mark - ASLayoutElementExtensibility #define ASEnvironmentLayoutExtensibilityForwarding \ - (void)setLayoutOptionExtensionBool:(BOOL)value atIndex:(int)idx\ diff --git a/AsyncDisplayKit/Layout/ASLayoutSpec+Subclasses.h b/AsyncDisplayKit/Layout/ASLayoutSpec+Subclasses.h index f9ea6d0d95..2109231ec9 100644 --- a/AsyncDisplayKit/Layout/ASLayoutSpec+Subclasses.h +++ b/AsyncDisplayKit/Layout/ASLayoutSpec+Subclasses.h @@ -17,10 +17,10 @@ NS_ASSUME_NONNULL_BEGIN * * @warning If you are getting recursion crashes here after implementing finalLayoutable, make sure * that you are setting isFinalLayoutable flag to YES. This must be one BEFORE adding a child - * to the new ASLayoutable. + * to the new ASLayoutElement. * * For example: - * - (id)finalLayoutable + * - (id)finalLayoutable * { * ASInsetLayoutSpec *insetSpec = [[ASInsetLayoutSpec alloc] init]; * insetSpec.insets = UIEdgeInsetsMake(10,10,10,10); @@ -31,7 +31,7 @@ NS_ASSUME_NONNULL_BEGIN * * @see finalLayoutable */ -- (id)layoutableToAddFromLayoutable:(id)child; +- (id)layoutableToAddFromLayoutable:(id)child; /** * Adds a child with the given identifier to this layout spec. @@ -50,14 +50,14 @@ NS_ASSUME_NONNULL_BEGIN * setChild:forIndex: internally. For example, ASBackgroundLayoutSpec exposes a backgroundChild * property that behind the scenes is calling setChild:forIndex:. */ -- (void)setChild:(id)child atIndex:(NSUInteger)index; +- (void)setChild:(id)child atIndex:(NSUInteger)index; /** * Returns the child added to this layout spec using the given index. * * @param index An identifier associated with the the child. */ -- (nullable id)childAtIndex:(NSUInteger)index; +- (nullable id)childAtIndex:(NSUInteger)index; @end diff --git a/AsyncDisplayKit/Layout/ASLayoutSpec+Subclasses.mm b/AsyncDisplayKit/Layout/ASLayoutSpec+Subclasses.mm index 61f4f86714..b54e72de37 100644 --- a/AsyncDisplayKit/Layout/ASLayoutSpec+Subclasses.mm +++ b/AsyncDisplayKit/Layout/ASLayoutSpec+Subclasses.mm @@ -36,7 +36,7 @@ - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize { - return [ASLayout layoutWithLayoutable:self size:CGSizeZero]; + return [ASLayout layoutWithLayoutElement:self size:CGSizeZero]; } @end @@ -48,20 +48,20 @@ #pragma mark - Final layoutable -- (id)layoutableToAddFromLayoutable:(id)child +- (id)layoutableToAddFromLayoutable:(id)child { - if (self.isFinalLayoutable == NO) { - id finalLayoutable = [child finalLayoutable]; - if (finalLayoutable != child) { + if (self.isFinalLayoutElement == NO) { + id finalLayoutElement = [child finalLayoutElement]; + if (finalLayoutElement != child) { if (ASEnvironmentStatePropagationEnabled()) { - ASEnvironmentStatePropagateUp(finalLayoutable, child.environmentState.layoutOptionsState); + ASEnvironmentStatePropagateUp(finalLayoutElement, child.environmentState.layoutOptionsState); } else { // If state propagation is not enabled the layout options state needs to be copied manually - ASEnvironmentState finalLayoutableEnvironmentState = finalLayoutable.environmentState; - finalLayoutableEnvironmentState.layoutOptionsState = child.environmentState.layoutOptionsState; - finalLayoutable.environmentState = finalLayoutableEnvironmentState; + ASEnvironmentState finalLayoutElementEnvironmentState = finalLayoutElement.environmentState; + finalLayoutElementEnvironmentState.layoutOptionsState = child.environmentState.layoutOptionsState; + finalLayoutElement.environmentState = finalLayoutElementEnvironmentState; } - return finalLayoutable; + return finalLayoutElement; } } return child; @@ -69,11 +69,11 @@ #pragma mark - Child with index -- (void)setChild:(id)child atIndex:(NSUInteger)index +- (void)setChild:(id)child atIndex:(NSUInteger)index { ASDisplayNodeAssert(self.isMutable, @"Cannot set properties when layout spec is not mutable"); - id layoutable = child ? [self layoutableToAddFromLayoutable:child] : [ASNullLayoutSpec null]; + id layoutable = child ? [self layoutableToAddFromLayoutable:child] : [ASNullLayoutSpec null]; if (child) { if (_childrenArray.count < index) { @@ -91,12 +91,12 @@ // TODO: Should we propagate up the layoutable at it could happen that multiple children will propagated up their // layout options and one child will overwrite values from another child - // [self propagateUpLayoutable:finalLayoutable]; + // [self propagateUpLayoutable:finalLayoutElement]; } -- (id)childAtIndex:(NSUInteger)index +- (id)childAtIndex:(NSUInteger)index { - id layoutable = nil; + id layoutable = nil; if (index < _childrenArray.count) { layoutable = _childrenArray[index]; } diff --git a/AsyncDisplayKit/Layout/ASLayoutSpec.h b/AsyncDisplayKit/Layout/ASLayoutSpec.h index 30d49d8061..1b6f365a92 100644 --- a/AsyncDisplayKit/Layout/ASLayoutSpec.h +++ b/AsyncDisplayKit/Layout/ASLayoutSpec.h @@ -8,7 +8,7 @@ // of patent rights can be found in the PATENTS file in the same directory. // -#import +#import #import NS_ASSUME_NONNULL_BEGIN @@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN /** * A layout spec is an immutable object that describes a layout, loosely inspired by React. */ -@interface ASLayoutSpec : NSObject +@interface ASLayoutSpec : NSObject /** * Creation of a layout spec should only happen by a user in layoutSpecThatFits:. During that method, a @@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Parent of the layout spec */ -@property (nullable, nonatomic, weak) id parent; +@property (nullable, nonatomic, weak) id parent; /** * Adds a child to this layout spec using a default identifier. @@ -45,12 +45,12 @@ NS_ASSUME_NONNULL_BEGIN * setChild:forIdentifier: internally. For example, ASBackgroundLayoutSpec exposes a backgroundChild * property that behind the scenes is calling setChild:forIdentifier:. */ -@property (nullable, strong, nonatomic) id child; +@property (nullable, strong, nonatomic) id child; /** * Adds childen to this layout spec. * - * @param children An array of ASLayoutable children to be added. + * @param children An array of ASLayoutElement children to be added. * * @discussion Every ASLayoutSpec must act on at least one child. The ASLayoutSpec base class takes the * reponsibility of holding on to the spec children. Some layout specs, like ASStackLayoutSpec, @@ -58,24 +58,24 @@ NS_ASSUME_NONNULL_BEGIN * For good measure, in these layout specs it probably makes sense to define * setChild: and setChild:forIdentifier: methods to do something appropriate or to assert. */ -@property (nullable, strong, nonatomic) NSArray> *children; +@property (nullable, strong, nonatomic) NSArray> *children; @end /** - * An ASLayoutSpec subclass that can wrap a ASLayoutable and calculates the layout of the child. + * An ASLayoutSpec subclass that can wrap a ASLayoutElement and calculates the layout of the child. */ @interface ASWrapperLayoutSpec : ASLayoutSpec /* - * Returns an ASWrapperLayoutSpec object with the given layoutable as child + * Returns an ASWrapperLayoutSpec object with the given layoutElement as child */ -+ (instancetype)wrapperWithLayoutable:(id)layoutable; ++ (instancetype)wrapperWithLayoutElement:(id)layoutElement; /* - * Returns an ASWrapperLayoutSpec object initialized with the given layoutable as child + * Returns an ASWrapperLayoutSpec object initialized with the given layoutElement as child */ -- (instancetype)initWithLayoutable:(id)layoutable NS_DESIGNATED_INITIALIZER;; +- (instancetype)initWithLayoutElement:(id)layoutElement NS_DESIGNATED_INITIALIZER;; /* * Init not available for ASWrapperLayoutSpec @@ -84,7 +84,7 @@ NS_ASSUME_NONNULL_BEGIN @end -@interface ASLayoutSpec (Debugging) +@interface ASLayoutSpec (Debugging) /** * Used by other layout specs to create ascii art debug strings */ diff --git a/AsyncDisplayKit/Layout/ASLayoutSpec.mm b/AsyncDisplayKit/Layout/ASLayoutSpec.mm index 6e0b09a67f..f50f92ee5e 100644 --- a/AsyncDisplayKit/Layout/ASLayoutSpec.mm +++ b/AsyncDisplayKit/Layout/ASLayoutSpec.mm @@ -14,9 +14,9 @@ @implementation ASLayoutSpec -// Dynamic properties for ASLayoutables -@dynamic layoutableType; -@synthesize isFinalLayoutable = _isFinalLayoutable; +// Dynamic properties for ASLayoutElements +@dynamic layoutElementType; +@synthesize isFinalLayoutElement = _isFinalLayoutElement; #pragma mark - Class @@ -39,15 +39,15 @@ _isMutable = YES; _environmentState = ASEnvironmentStateMakeDefault(); - _style = [[ASLayoutableStyle alloc] init]; + _style = [[ASLayoutElementStyle alloc] init]; _childrenArray = [[NSMutableArray alloc] init]; return self; } -- (ASLayoutableType)layoutableType +- (ASLayoutElementType)layoutElementType { - return ASLayoutableTypeLayoutSpec; + return ASLayoutElementTypeLayoutSpec; } - (BOOL)canLayoutAsynchronous @@ -57,14 +57,14 @@ #pragma mark - Final Layoutable -- (id)finalLayoutable +- (id)finalLayoutElement { return self; } #pragma mark - Style -- (ASLayoutableStyle *)style +- (ASLayoutElementStyle *)style { ASDN::MutexLocker l(__instanceLock__); return _style; @@ -89,22 +89,22 @@ } - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize - restrictedToSize:(ASLayoutableSize)size + restrictedToSize:(ASLayoutElementSize)size relativeToParentSize:(CGSize)parentSize { - const ASSizeRange resolvedRange = ASSizeRangeIntersect(constrainedSize, ASLayoutableSizeResolve(_style.size, parentSize)); + const ASSizeRange resolvedRange = ASSizeRangeIntersect(constrainedSize, ASLayoutElementSizeResolve(_style.size, parentSize)); return [self calculateLayoutThatFits:resolvedRange]; } - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize { - return [ASLayout layoutWithLayoutable:self size:constrainedSize.min]; + return [ASLayout layoutWithLayoutElement:self size:constrainedSize.min]; } #pragma mark - Parent -- (void)setParent:(id)parent +- (void)setParent:(id)parent { // FIXME: Locking should be evaluated here. _parent is not widely used yet, though. _parent = parent; @@ -114,19 +114,18 @@ } } - #pragma mark - Child -- (void)setChild:(id)child +- (void)setChild:(id)child { ASDisplayNodeAssert(self.isMutable, @"Cannot set properties when layout spec is not mutable");; ASDisplayNodeAssert(_childrenArray.count < 2, @"This layout spec does not support more than one child. Use the setChildren: or the setChild:AtIndex: API"); if (child) { - id finalLayoutable = [self layoutableToAddFromLayoutable:child]; - if (finalLayoutable) { - _childrenArray[0] = finalLayoutable; - [self propagateUpLayoutable:finalLayoutable]; + id finalLayoutElement = [self layoutableToAddFromLayoutable:child]; + if (finalLayoutElement) { + _childrenArray[0] = finalLayoutElement; + [self propagateUpLayoutElement:finalLayoutElement]; } } else { if (_childrenArray.count) { @@ -135,7 +134,7 @@ } } -- (id)child +- (id)child { ASDisplayNodeAssert(_childrenArray.count < 2, @"This layout spec does not support more than one child. Use the setChildren: or the setChild:AtIndex: API"); @@ -148,14 +147,15 @@ #pragma mark - Children -- (void)setChildren:(NSArray> *)children +- (void)setChildren:(NSArray> *)children { ASDisplayNodeAssert(self.isMutable, @"Cannot set properties when layout spec is not mutable"); [_childrenArray removeAllObjects]; NSUInteger i = 0; - for (id child in children) { + for (id child in children) { + ASDisplayNodeAssert([child conformsToProtocol:NSProtocolFromString(@"ASLayoutElement")], @"Child %@ of spec %@ is not an ASLayoutElement!", child, self); _childrenArray[i] = [self layoutableToAddFromLayoutable:child]; i += 1; } @@ -198,12 +198,12 @@ return ASEnvironmentStateTraitCollectionPropagationEnabled(); } -- (void)propagateUpLayoutable:(id)layoutable +- (void)propagateUpLayoutElement:(id)layoutElement { - if ([layoutable isKindOfClass:[ASLayoutSpec class]]) { - [(ASLayoutSpec *)layoutable setParent:self]; // This will trigger upward propogation if needed. + if ([layoutElement isKindOfClass:[ASLayoutSpec class]]) { + [(ASLayoutSpec *)layoutElement setParent:self]; // This will trigger upward propogation if needed. } else if ([self supportsUpwardPropagation]) { - ASEnvironmentStatePropagateUp(self, layoutable.environmentState.layoutOptionsState); // Probably an ASDisplayNode + ASEnvironmentStatePropagateUp(self, layoutElement.environmentState.layoutOptionsState); // Probably an ASDisplayNode } } @@ -231,16 +231,16 @@ ASEnvironmentLayoutExtensibilityForwarding @implementation ASWrapperLayoutSpec -+ (instancetype)wrapperWithLayoutable:(id)layoutable ++ (instancetype)wrapperWithLayoutElement:(id)layoutElement { - return [[self alloc] initWithLayoutable:layoutable]; + return [[self alloc] initWithLayoutElement:layoutElement]; } -- (instancetype)initWithLayoutable:(id)layoutable +- (instancetype)initWithLayoutElement:(id)layoutElement { self = [super init]; if (self) { - self.child = layoutable; + self.child = layoutElement; } return self; } @@ -249,7 +249,7 @@ ASEnvironmentLayoutExtensibilityForwarding { ASLayout *sublayout = [self.child layoutThatFits:constrainedSize parentSize:constrainedSize.max]; sublayout.position = CGPointZero; - return [ASLayout layoutWithLayoutable:self size:sublayout.size sublayouts:@[sublayout]]; + return [ASLayout layoutWithLayoutElement:self size:sublayout.size sublayouts:@[sublayout]]; } @end @@ -259,12 +259,12 @@ ASEnvironmentLayoutExtensibilityForwarding @implementation ASLayoutSpec (Debugging) -#pragma mark - ASLayoutableAsciiArtProtocol +#pragma mark - ASLayoutElementAsciiArtProtocol + (NSString *)asciiArtStringForChildren:(NSArray *)children parentName:(NSString *)parentName direction:(ASStackLayoutDirection)direction { NSMutableArray *childStrings = [NSMutableArray array]; - for (id layoutChild in children) { + for (id layoutChild in children) { NSString *childString = [layoutChild asciiArtString]; if (childString) { [childStrings addObject:childString]; diff --git a/AsyncDisplayKit/Layout/ASLayoutable.mm b/AsyncDisplayKit/Layout/ASLayoutable.mm deleted file mode 100644 index 5ea595189e..0000000000 --- a/AsyncDisplayKit/Layout/ASLayoutable.mm +++ /dev/null @@ -1,305 +0,0 @@ -// -// ASLayoutable.mm -// AsyncDisplayKit -// -// Created by Huy Nguyen on 3/27/16. -// -// 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 "ASLayoutablePrivate.h" -#import "ASEnvironmentInternal.h" -#import "ASDisplayNodeInternal.h" -#import "ASThread.h" - -#import - -CGFloat const ASLayoutableParentDimensionUndefined = NAN; -CGSize const ASLayoutableParentSizeUndefined = {ASLayoutableParentDimensionUndefined, ASLayoutableParentDimensionUndefined}; - -int32_t const ASLayoutableContextInvalidTransitionID = 0; -int32_t const ASLayoutableContextDefaultTransitionID = ASLayoutableContextInvalidTransitionID + 1; - -static inline ASLayoutableContext _ASLayoutableContextMake(int32_t transitionID, BOOL needsVisualizeNode) -{ - struct ASLayoutableContext context; - context.transitionID = transitionID; - context.needsVisualizeNode = needsVisualizeNode; - return context; -} - -static inline BOOL _IsValidTransitionID(int32_t transitionID) -{ - return transitionID > ASLayoutableContextInvalidTransitionID; -} - -struct ASLayoutableContext const ASLayoutableContextNull = _ASLayoutableContextMake(ASLayoutableContextInvalidTransitionID, NO); - -BOOL ASLayoutableContextIsNull(struct ASLayoutableContext context) -{ - return !_IsValidTransitionID(context.transitionID); -} - -ASLayoutableContext ASLayoutableContextMake(int32_t transitionID, BOOL needsVisualizeNode) -{ - NSCAssert(_IsValidTransitionID(transitionID), @"Invalid transition ID"); - return _ASLayoutableContextMake(transitionID, needsVisualizeNode); -} - -// Note: This is a non-recursive static lock. If it needs to be recursive, use ASDISPLAYNODE_MUTEX_RECURSIVE_INITIALIZER -static ASDN::StaticMutex _layoutableContextLock = ASDISPLAYNODE_MUTEX_INITIALIZER; -static std::map layoutableContextMap; - -static inline mach_port_t ASLayoutableGetCurrentContextKey() -{ - return pthread_mach_thread_np(pthread_self()); -} - -void ASLayoutableSetCurrentContext(struct ASLayoutableContext context) -{ - const mach_port_t key = ASLayoutableGetCurrentContextKey(); - ASDN::StaticMutexLocker l(_layoutableContextLock); - layoutableContextMap[key] = context; -} - -struct ASLayoutableContext ASLayoutableGetCurrentContext() -{ - const mach_port_t key = ASLayoutableGetCurrentContextKey(); - ASDN::StaticMutexLocker l(_layoutableContextLock); - const auto it = layoutableContextMap.find(key); - if (it != layoutableContextMap.end()) { - // Found an interator with above key. "it->first" is the key itself, "it->second" is the context value. - return it->second; - } - return ASLayoutableContextNull; -} - -void ASLayoutableClearCurrentContext() -{ - const mach_port_t key = ASLayoutableGetCurrentContextKey(); - ASDN::StaticMutexLocker l(_layoutableContextLock); - layoutableContextMap.erase(key); -} - -#pragma mark - ASLayoutableStyle - -NSString * const ASLayoutableStyleWidthProperty = @"ASLayoutableStyleWidthProperty"; -NSString * const ASLayoutableStyleMinWidthProperty = @"ASLayoutableStyleMinWidthProperty"; -NSString * const ASLayoutableStyleMaxWidthProperty = @"ASLayoutableStyleMaxWidthProperty"; - -NSString * const ASLayoutableStyleHeightProperty = @"ASLayoutableStyleHeightProperty"; -NSString * const ASLayoutableStyleMinHeightProperty = @"ASLayoutableStyleMinHeightProperty"; -NSString * const ASLayoutableStyleMaxHeightProperty = @"ASLayoutableStyleMaxHeightProperty"; - -NSString * const ASLayoutableStyleSpacingBeforeProperty = @"ASLayoutableStyleSpacingBeforeProperty"; -NSString * const ASLayoutableStyleSpacingAfterProperty = @"ASLayoutableStyleSpacingAfterProperty"; -NSString * const ASLayoutableStyleFlexGrowProperty = @"ASLayoutableStyleFlexGrowProperty"; -NSString * const ASLayoutableStyleFlexShrinkProperty = @"ASLayoutableStyleFlexShrinkProperty"; -NSString * const ASLayoutableStyleFlexBasisProperty = @"ASLayoutableStyleFlexBasisProperty"; -NSString * const ASLayoutableStyleAlignSelfProperty = @"ASLayoutableStyleAlignSelfProperty"; -NSString * const ASLayoutableStyleAscenderProperty = @"ASLayoutableStyleAscenderProperty"; -NSString * const ASLayoutableStyleDescenderProperty = @"ASLayoutableStyleDescenderProperty"; - -NSString * const ASLayoutableStyleLayoutPositionProperty = @"ASLayoutableStyleLayoutPositionProperty"; - -#define ASLayoutableStyleCallDelegate(propertyName)\ -do {\ - [_delegate style:self propertyDidChange:propertyName];\ -} while(0) - -@interface ASLayoutableStyle () -@property (nullable, nonatomic, weak) id delegate; -@end - -@implementation ASLayoutableStyle { - ASDN::RecursiveMutex __instanceLock__; - ASLayoutableSize _size; -} - -@dynamic width, height, minWidth, maxWidth, minHeight, maxHeight; - -#pragma mark - Lifecycle - -- (instancetype)initWithDelegate:(id)delegate -{ - self = [self init]; - if (self) { - _delegate = delegate; - } - return self; -} - -- (instancetype)init -{ - self = [super init]; - if (self) { - _size = ASLayoutableSizeMake(); - } - return self; -} - -#pragma mark - ASLayoutableSizeForwarding - -- (ASDimension)width -{ - ASDN::MutexLocker l(__instanceLock__); - return _size.width; -} - -- (void)setWidth:(ASDimension)width -{ - ASDN::MutexLocker l(__instanceLock__); - _size.width = width; - ASLayoutableStyleCallDelegate(ASLayoutableStyleWidthProperty); -} - -- (ASDimension)height -{ - ASDN::MutexLocker l(__instanceLock__); - return _size.height; -} - -- (void)setHeight:(ASDimension)height -{ - ASDN::MutexLocker l(__instanceLock__); - _size.height = height; - ASLayoutableStyleCallDelegate(ASLayoutableStyleHeightProperty); -} - -- (ASDimension)minWidth -{ - ASDN::MutexLocker l(__instanceLock__); - return _size.minWidth; -} - -- (void)setMinWidth:(ASDimension)minWidth -{ - ASDN::MutexLocker l(__instanceLock__); - _size.minWidth = minWidth; - ASLayoutableStyleCallDelegate(ASLayoutableStyleMinWidthProperty); -} - -- (ASDimension)maxWidth -{ - ASDN::MutexLocker l(__instanceLock__); - return _size.maxWidth; -} - -- (void)setMaxWidth:(ASDimension)maxWidth -{ - ASDN::MutexLocker l(__instanceLock__); - _size.maxWidth = maxWidth; - ASLayoutableStyleCallDelegate(ASLayoutableStyleMaxWidthProperty); -} - -- (ASDimension)minHeight -{ - ASDN::MutexLocker l(__instanceLock__); - return _size.minHeight; -} - -- (void)setMinHeight:(ASDimension)minHeight -{ - ASDN::MutexLocker l(__instanceLock__); - _size.minHeight = minHeight; - ASLayoutableStyleCallDelegate(ASLayoutableStyleMinHeightProperty); -} - -- (ASDimension)maxHeight -{ - ASDN::MutexLocker l(__instanceLock__); - return _size.maxHeight; -} - -- (void)setMaxHeight:(ASDimension)maxHeight -{ - ASDN::MutexLocker l(__instanceLock__); - _size.maxHeight = maxHeight; - ASLayoutableStyleCallDelegate(ASLayoutableStyleMaxHeightProperty); -} - -- (void)setSizeWithCGSize:(CGSize)size -{ - self.width = ASDimensionMakeWithPoints(size.width); - self.height = ASDimensionMakeWithPoints(size.height); -} - -- (void)setExactSizeWithCGSize:(CGSize)size -{ - self.minWidth = ASDimensionMakeWithPoints(size.width); - self.minHeight = ASDimensionMakeWithPoints(size.height); - self.maxWidth = ASDimensionMakeWithPoints(size.width); - self.maxHeight = ASDimensionMakeWithPoints(size.height); -} - -#pragma mark - ASStackLayoutable - -- (void)setSpacingBefore:(CGFloat)spacingBefore -{ - ASDN::MutexLocker l(__instanceLock__); - _spacingBefore = spacingBefore; - ASLayoutableStyleCallDelegate(ASLayoutableStyleSpacingBeforeProperty); -} - -- (void)setSpacingAfter:(CGFloat)spacingAfter -{ - ASDN::MutexLocker l(__instanceLock__); - _spacingAfter = spacingAfter; - ASLayoutableStyleCallDelegate(ASLayoutableStyleSpacingAfterProperty); -} - -- (void)setFlexGrow:(CGFloat)flexGrow -{ - ASDN::MutexLocker l(__instanceLock__); - _flexGrow = flexGrow; - ASLayoutableStyleCallDelegate(ASLayoutableStyleFlexGrowProperty); -} - -- (void)setFlexShrink:(CGFloat)flexShrink -{ - ASDN::MutexLocker l(__instanceLock__); - _flexShrink = flexShrink; - ASLayoutableStyleCallDelegate(ASLayoutableStyleFlexShrinkProperty); -} - -- (void)setFlexBasis:(ASDimension)flexBasis -{ - ASDN::MutexLocker l(__instanceLock__); - _flexBasis = flexBasis; - ASLayoutableStyleCallDelegate(ASLayoutableStyleFlexBasisProperty); -} - -- (void)setAlignSelf:(ASStackLayoutAlignSelf)alignSelf -{ - ASDN::MutexLocker l(__instanceLock__); - _alignSelf = alignSelf; - ASLayoutableStyleCallDelegate(ASLayoutableStyleAlignSelfProperty); -} - -- (void)setAscender:(CGFloat)ascender -{ - ASDN::MutexLocker l(__instanceLock__); - _ascender = ascender; - ASLayoutableStyleCallDelegate(ASLayoutableStyleAscenderProperty); -} - -- (void)setDescender:(CGFloat)descender -{ - ASDN::MutexLocker l(__instanceLock__); - _descender = descender; - ASLayoutableStyleCallDelegate(ASLayoutableStyleDescenderProperty); -} - -#pragma mark - ASStaticLayoutable - -- (void)setLayoutPosition:(CGPoint)layoutPosition -{ - ASDN::MutexLocker l(__instanceLock__); - _layoutPosition = layoutPosition; - ASLayoutableStyleCallDelegate(ASLayoutableStyleLayoutPositionProperty); -} - -@end diff --git a/AsyncDisplayKit/Layout/ASOverlayLayoutSpec.h b/AsyncDisplayKit/Layout/ASOverlayLayoutSpec.h index 7687f55288..4e8a6220c2 100644 --- a/AsyncDisplayKit/Layout/ASOverlayLayoutSpec.h +++ b/AsyncDisplayKit/Layout/ASOverlayLayoutSpec.h @@ -13,14 +13,14 @@ NS_ASSUME_NONNULL_BEGIN /** - This layout spec lays out a single layoutable child and then overlays a layoutable object on top of it streched to its size + This layout spec lays out a single layoutElement child and then overlays a layoutElement object on top of it streched to its size */ @interface ASOverlayLayoutSpec : ASLayoutSpec /** * Overlay layoutable of this layout spec */ -@property (nullable, nonatomic, strong) id overlay; +@property (nullable, nonatomic, strong) id overlay; /** * Creates and returns an ASOverlayLayoutSpec object with a given child and an layoutable that act as overlay. @@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN * @param child A child that is laid out to determine the size of this spec. * @param overlay A layoutable object that is laid out over the child. If this is nil, the overlay is omitted. */ -+ (instancetype)overlayLayoutSpecWithChild:(id)child overlay:(nullable id)overlay; ++ (instancetype)overlayLayoutSpecWithChild:(id)child overlay:(nullable id)overlay; @end diff --git a/AsyncDisplayKit/Layout/ASOverlayLayoutSpec.mm b/AsyncDisplayKit/Layout/ASOverlayLayoutSpec.mm index 571c84ad44..dbd329cceb 100644 --- a/AsyncDisplayKit/Layout/ASOverlayLayoutSpec.mm +++ b/AsyncDisplayKit/Layout/ASOverlayLayoutSpec.mm @@ -21,14 +21,14 @@ static NSUInteger const kOverlayChildIndex = 1; #pragma mark - Class -+ (instancetype)overlayLayoutSpecWithChild:(id)child overlay:(id)overlay ++ (instancetype)overlayLayoutSpecWithChild:(id)child overlay:(id)overlay { return [[self alloc] initWithChild:child overlay:overlay]; } #pragma mark - Lifecycle -- (instancetype)initWithChild:(id)child overlay:(id)overlay +- (instancetype)initWithChild:(id)child overlay:(id)overlay { if (!(self = [super init])) { return nil; @@ -41,12 +41,12 @@ static NSUInteger const kOverlayChildIndex = 1; #pragma mark - Setter / Getter -- (void)setOverlay:(id)overlay +- (void)setOverlay:(id)overlay { [super setChild:overlay atIndex:kOverlayChildIndex]; } -- (id)overlay +- (id)overlay { return [super childAtIndex:kOverlayChildIndex]; } @@ -57,7 +57,7 @@ static NSUInteger const kOverlayChildIndex = 1; First layout the contents, then fit the overlay on top of it. */ - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize - restrictedToSize:(ASLayoutableSize)size + restrictedToSize:(ASLayoutElementSize)size relativeToParentSize:(CGSize)parentSize { ASLayout *contentsLayout = [[super childAtIndex:kUnderlayChildIndex] layoutThatFits:constrainedSize parentSize:parentSize]; @@ -70,14 +70,14 @@ static NSUInteger const kOverlayChildIndex = 1; [sublayouts addObject:overlayLayout]; } - return [ASLayout layoutWithLayoutable:self size:contentsLayout.size sublayouts:sublayouts]; + return [ASLayout layoutWithLayoutElement:self size:contentsLayout.size sublayouts:sublayouts]; } @end @implementation ASOverlayLayoutSpec (Debugging) -#pragma mark - ASLayoutableAsciiArtProtocol +#pragma mark - ASLayoutElementAsciiArtProtocol - (NSString *)debugBoxString { diff --git a/AsyncDisplayKit/Layout/ASRatioLayoutSpec.h b/AsyncDisplayKit/Layout/ASRatioLayoutSpec.h index c596f9cdeb..289e632da2 100644 --- a/AsyncDisplayKit/Layout/ASRatioLayoutSpec.h +++ b/AsyncDisplayKit/Layout/ASRatioLayoutSpec.h @@ -9,7 +9,7 @@ // #import -#import +#import NS_ASSUME_NONNULL_BEGIN @@ -35,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, assign) CGFloat ratio; -+ (instancetype)ratioLayoutSpecWithRatio:(CGFloat)ratio child:(id)child; ++ (instancetype)ratioLayoutSpecWithRatio:(CGFloat)ratio child:(id)child; @end diff --git a/AsyncDisplayKit/Layout/ASRatioLayoutSpec.mm b/AsyncDisplayKit/Layout/ASRatioLayoutSpec.mm index 1d7ab611f3..520f8b3bd0 100644 --- a/AsyncDisplayKit/Layout/ASRatioLayoutSpec.mm +++ b/AsyncDisplayKit/Layout/ASRatioLayoutSpec.mm @@ -24,12 +24,12 @@ CGFloat _ratio; } -+ (instancetype)ratioLayoutSpecWithRatio:(CGFloat)ratio child:(id)child ++ (instancetype)ratioLayoutSpecWithRatio:(CGFloat)ratio child:(id)child { return [[self alloc] initWithRatio:ratio child:child]; } -- (instancetype)initWithRatio:(CGFloat)ratio child:(id)child; +- (instancetype)initWithRatio:(CGFloat)ratio child:(id)child; { if (!(self = [super init])) { return nil; @@ -72,17 +72,17 @@ // 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()) ? ASLayoutableParentSizeUndefined : *bestSize; + const CGSize parentSize = (bestSize == sizeOptions.end()) ? ASLayoutElementParentSizeUndefined : *bestSize; ASLayout *sublayout = [self.child layoutThatFits:childRange parentSize:parentSize]; sublayout.position = CGPointZero; - return [ASLayout layoutWithLayoutable:self size:sublayout.size sublayouts:@[sublayout]]; + return [ASLayout layoutWithLayoutElement:self size:sublayout.size sublayouts:@[sublayout]]; } @end @implementation ASRatioLayoutSpec (Debugging) -#pragma mark - ASLayoutableAsciiArtProtocol +#pragma mark - ASLayoutElementAsciiArtProtocol - (NSString *)asciiArtName { diff --git a/AsyncDisplayKit/Layout/ASRelativeLayoutSpec.h b/AsyncDisplayKit/Layout/ASRelativeLayoutSpec.h index d2130fe5bc..305b654dde 100644 --- a/AsyncDisplayKit/Layout/ASRelativeLayoutSpec.h +++ b/AsyncDisplayKit/Layout/ASRelativeLayoutSpec.h @@ -36,7 +36,7 @@ typedef NS_OPTIONS(NSUInteger, ASRelativeLayoutSpecSizingOption) { NS_ASSUME_NONNULL_BEGIN -/** Lays out a single layoutable child and positions it within the layout bounds according to vertical and horizontal positional specifiers. +/** Lays out a single layoutElement child and positions it within the layout bounds according to vertical and horizontal positional specifiers. * Can position the child at any of the 4 corners, or the middle of any of the 4 edges, as well as the center - similar to "9-part" image areas. */ @interface ASRelativeLayoutSpec : ASLayoutSpec @@ -57,7 +57,7 @@ NS_ASSUME_NONNULL_BEGIN + (instancetype)relativePositionLayoutSpecWithHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition verticalPosition:(ASRelativeLayoutSpecPosition)verticalPosition sizingOption:(ASRelativeLayoutSpecSizingOption)sizingOption - child:(id)child; + child:(id)child; /*! * @discussion convenience initializer for a ASRelativeLayoutSpec @@ -70,7 +70,7 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition verticalPosition:(ASRelativeLayoutSpecPosition)verticalPosition sizingOption:(ASRelativeLayoutSpecSizingOption)sizingOption - child:(id)child; + child:(id)child; @end diff --git a/AsyncDisplayKit/Layout/ASRelativeLayoutSpec.mm b/AsyncDisplayKit/Layout/ASRelativeLayoutSpec.mm index 8907de7209..6918681ce1 100644 --- a/AsyncDisplayKit/Layout/ASRelativeLayoutSpec.mm +++ b/AsyncDisplayKit/Layout/ASRelativeLayoutSpec.mm @@ -17,7 +17,7 @@ @implementation ASRelativeLayoutSpec -- (instancetype)initWithHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition verticalPosition:(ASRelativeLayoutSpecPosition)verticalPosition sizingOption:(ASRelativeLayoutSpecSizingOption)sizingOption child:(id)child +- (instancetype)initWithHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition verticalPosition:(ASRelativeLayoutSpecPosition)verticalPosition sizingOption:(ASRelativeLayoutSpecSizingOption)sizingOption child:(id)child { if (!(self = [super init])) { return nil; @@ -30,7 +30,7 @@ return self; } -+ (instancetype)relativePositionLayoutSpecWithHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition verticalPosition:(ASRelativeLayoutSpecPosition)verticalPosition sizingOption:(ASRelativeLayoutSpecSizingOption)sizingOption child:(id)child ++ (instancetype)relativePositionLayoutSpecWithHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition verticalPosition:(ASRelativeLayoutSpecPosition)verticalPosition sizingOption:(ASRelativeLayoutSpecSizingOption)sizingOption child:(id)child { return [[self alloc] initWithHorizontalPosition:horizontalPosition verticalPosition:verticalPosition sizingOption:sizingOption child:child]; } @@ -55,12 +55,12 @@ - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize { // If we have a finite size in any direction, pass this so that the child can - // resolve percentages against it. Otherwise pass ASLayoutableParentDimensionUndefined + // resolve percentages against it. Otherwise pass ASLayoutElementParentDimensionUndefined // as the size will depend on the content // TODO: layout: isValidForLayout() call should not be necessary if INFINITY is used CGSize size = { - isinf(constrainedSize.max.width) || !ASPointsAreValidForLayout(constrainedSize.max.width) ? ASLayoutableParentDimensionUndefined : constrainedSize.max.width, - isinf(constrainedSize.max.height) || !ASPointsAreValidForLayout(constrainedSize.max.height) ? ASLayoutableParentDimensionUndefined : constrainedSize.max.height + isinf(constrainedSize.max.width) || !ASPointsAreValidForLayout(constrainedSize.max.width) ? ASLayoutElementParentDimensionUndefined : constrainedSize.max.width, + isinf(constrainedSize.max.height) || !ASPointsAreValidForLayout(constrainedSize.max.height) ? ASLayoutElementParentDimensionUndefined : constrainedSize.max.height }; BOOL reduceWidth = (_horizontalPosition & ASRelativeLayoutSpecPositionCenter) != 0 || @@ -99,7 +99,7 @@ ASRoundPixelValue((size.height - sublayout.size.height) * yPosition) }; - return [ASLayout layoutWithLayoutable:self size:size sublayouts:@[sublayout]]; + return [ASLayout layoutWithLayoutElement:self size:size sublayouts:@[sublayout]]; } - (CGFloat)proportionOfAxisForAxisPosition:(ASRelativeLayoutSpecPosition)position diff --git a/AsyncDisplayKit/Layout/ASStackLayoutSpec.h b/AsyncDisplayKit/Layout/ASStackLayoutSpec.h index 289dc234b1..557dc0e43e 100644 --- a/AsyncDisplayKit/Layout/ASStackLayoutSpec.h +++ b/AsyncDisplayKit/Layout/ASStackLayoutSpec.h @@ -69,9 +69,9 @@ NS_ASSUME_NONNULL_BEGIN @param spacing The spacing between the children @param justifyContent If no children are flexible, this describes how to fill any extra space @param alignItems Orientation of the children along the cross axis - @param children ASLayoutable children to be positioned. + @param children ASLayoutElement children to be positioned. */ -+ (instancetype)stackLayoutSpecWithDirection:(ASStackLayoutDirection)direction spacing:(CGFloat)spacing justifyContent:(ASStackLayoutJustifyContent)justifyContent alignItems:(ASStackLayoutAlignItems)alignItems children:(NSArray> *)children; ++ (instancetype)stackLayoutSpecWithDirection:(ASStackLayoutDirection)direction spacing:(CGFloat)spacing justifyContent:(ASStackLayoutJustifyContent)justifyContent alignItems:(ASStackLayoutAlignItems)alignItems children:(NSArray> *)children; /** * @return A stack layout spec with direction of ASStackLayoutDirectionVertical diff --git a/AsyncDisplayKit/Layout/ASStackLayoutSpec.mm b/AsyncDisplayKit/Layout/ASStackLayoutSpec.mm index 9c5e106930..463327dcf6 100644 --- a/AsyncDisplayKit/Layout/ASStackLayoutSpec.mm +++ b/AsyncDisplayKit/Layout/ASStackLayoutSpec.mm @@ -120,13 +120,13 @@ - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize { - std::vector> stackChildren; - for (id child in self.children) { + std::vector> stackChildren; + for (id child in self.children) { stackChildren.push_back(child); } if (stackChildren.empty()) { - return [ASLayout layoutWithLayoutable:self size:constrainedSize.min]; + return [ASLayout layoutWithLayoutElement:self size:constrainedSize.min]; } ASStackLayoutSpecStyle style = {.direction = _direction, .spacing = _spacing, .justifyContent = _justifyContent, .alignItems = _alignItems, .baselineRelativeArrangement = _baselineRelativeArrangement}; @@ -159,7 +159,7 @@ sublayouts = [NSArray arrayWithObjects:&positionedLayout.sublayouts[0] count:positionedLayout.sublayouts.size()]; } - return [ASLayout layoutWithLayoutable:self size:ASSizeRangeClamp(constrainedSize, finalSize) sublayouts:sublayouts]; + return [ASLayout layoutWithLayoutElement:self size:ASSizeRangeClamp(constrainedSize, finalSize) sublayouts:sublayouts]; } - (void)resolveHorizontalAlignment @@ -193,7 +193,7 @@ @implementation ASStackLayoutSpec (Debugging) -#pragma mark - ASLayoutableAsciiArtProtocol +#pragma mark - ASLayoutElementAsciiArtProtocol - (NSString *)asciiArtString { diff --git a/AsyncDisplayKit/Layout/ASStackLayoutable.h b/AsyncDisplayKit/Layout/ASStackLayoutable.h index 82e6652d47..b0fa2f8360 100644 --- a/AsyncDisplayKit/Layout/ASStackLayoutable.h +++ b/AsyncDisplayKit/Layout/ASStackLayoutable.h @@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN /** - * Layout options that can be defined for an ASLayoutable being added to a ASStackLayoutSpec. + * Layout options that can be defined for an ASLayoutElement being added to a ASStackLayoutSpec. */ @protocol ASStackLayoutable diff --git a/AsyncDisplayKit/Private/ASDisplayNodeInternal.h b/AsyncDisplayKit/Private/ASDisplayNodeInternal.h index f5c99168be..9e7579d376 100644 --- a/AsyncDisplayKit/Private/ASDisplayNodeInternal.h +++ b/AsyncDisplayKit/Private/ASDisplayNodeInternal.h @@ -106,8 +106,7 @@ FOUNDATION_EXPORT NSString * const ASRenderingEngineDidDisplayNodesScheduledBefo @protected ASDisplayNode * __weak _supernode; - ASLayoutableStyle *_style; - ASLayoutableSize _size; + ASLayoutElementStyle *_style; ASSentinel *_displaySentinel; diff --git a/AsyncDisplayKit/Private/ASLayoutSpecPrivate.h b/AsyncDisplayKit/Private/ASLayoutSpecPrivate.h index d4a55fce43..7cea216551 100644 --- a/AsyncDisplayKit/Private/ASLayoutSpecPrivate.h +++ b/AsyncDisplayKit/Private/ASLayoutSpecPrivate.h @@ -18,7 +18,7 @@ @interface ASLayoutSpec() { ASDN::RecursiveMutex __instanceLock__; ASEnvironmentState _environmentState; - ASLayoutableStyle *_style; + ASLayoutElementStyle *_style; NSMutableArray *_childrenArray; } @end diff --git a/AsyncDisplayKit/Private/ASLayoutTransition.mm b/AsyncDisplayKit/Private/ASLayoutTransition.mm index dbe95dc75a..c1bd80e013 100644 --- a/AsyncDisplayKit/Private/ASLayoutTransition.mm +++ b/AsyncDisplayKit/Private/ASLayoutTransition.mm @@ -22,7 +22,7 @@ #import "ASEqualityHelpers.h" /** - * Search the whole layout stack if at least one layout has a layoutable object that can not be layed out asynchronous. + * Search the whole layout stack if at least one layout has a layoutElement object that can not be layed out asynchronous. * This can be the case for example if a node was already loaded */ static inline BOOL ASLayoutCanTransitionAsynchronous(ASLayout *layout) { @@ -34,7 +34,7 @@ static inline BOOL ASLayoutCanTransitionAsynchronous(ASLayout *layout) { layout = queue.front(); queue.pop(); - if (layout.layoutable.canLayoutAsynchronous == NO) { + if (layout.layoutElement.canLayoutAsynchronous == NO) { return NO; } @@ -128,7 +128,7 @@ static inline BOOL ASLayoutCanTransitionAsynchronous(ASLayout *layout) { insertions:&insertions deletions:&deletions compareBlock:^BOOL(ASLayout *lhs, ASLayout *rhs) { - return ASObjectIsEqual(lhs.layoutable, rhs.layoutable); + return ASObjectIsEqual(lhs.layoutElement, rhs.layoutElement); }]; _insertedSubnodePositions = findNodesInLayoutAtIndexes(pendingLayout, insertions, &_insertedSubnodes); _removedSubnodePositions = findNodesInLayoutAtIndexesWithFilteredNodes(previousLayout, @@ -221,7 +221,7 @@ static inline std::vector findNodesInLayoutAtIndexesWithFilteredNode for (ASLayout *sublayout in layout.sublayouts) { if (idx > lastIndex) { break; } if (idx >= firstIndex && [indexes containsIndex:idx]) { - ASDisplayNode *node = (ASDisplayNode *)sublayout.layoutable; + ASDisplayNode *node = (ASDisplayNode *)sublayout.layoutElement; ASDisplayNodeCAssert(node, @"A flattened layout must consist exclusively of node sublayouts"); // Ignore the odd case in which a non-node sublayout is accessed and the type cast fails if (node != nil) { diff --git a/AsyncDisplayKit/Private/ASStackBaselinePositionedLayout.mm b/AsyncDisplayKit/Private/ASStackBaselinePositionedLayout.mm index 9a62f183db..5956568105 100644 --- a/AsyncDisplayKit/Private/ASStackBaselinePositionedLayout.mm +++ b/AsyncDisplayKit/Private/ASStackBaselinePositionedLayout.mm @@ -15,7 +15,7 @@ static CGFloat baselineForItem(const ASStackLayoutSpecStyle &style, const ASLayout *layout) { - __weak id child = layout.layoutable; + __weak id child = layout.layoutElement; switch (style.alignItems) { case ASStackLayoutAlignItemsBaselineFirst: return child.style.ascender; @@ -33,7 +33,7 @@ static CGFloat baselineOffset(const ASStackLayoutSpecStyle &style, const CGFloat maxBaseline) { if (style.direction == ASStackLayoutDirectionHorizontal) { - __weak id child = l.layoutable; + __weak id child = l.layoutElement; switch (style.alignItems) { case ASStackLayoutAlignItemsBaselineFirst: return maxAscender - child.style.ascender; @@ -89,9 +89,9 @@ ASStackBaselinePositionedLayout ASStackBaselinePositionedLayout::compute(const A our layoutSpec to have it so that it can be baseline aligned with another text node or baseline layout spec. */ const auto ascenderIt = std::max_element(positionedLayout.sublayouts.begin(), positionedLayout.sublayouts.end(), [&](const ASLayout *a, const ASLayout *b){ - return a.layoutable.style.ascender < b.layoutable.style.ascender; + return a.layoutElement.style.ascender < b.layoutElement.style.ascender; }); - const CGFloat maxAscender = ascenderIt == positionedLayout.sublayouts.end() ? 0 : (*ascenderIt).layoutable.style.ascender; + const CGFloat maxAscender = ascenderIt == positionedLayout.sublayouts.end() ? 0 : (*ascenderIt).layoutElement.style.ascender; /* Step 3: Take each child and update its layout position based on the baseline offset. @@ -108,7 +108,7 @@ ASStackBaselinePositionedLayout ASStackBaselinePositionedLayout::compute(const A CGPoint p = CGPointZero; BOOL first = YES; stackedChildren = AS::map(positionedLayout.sublayouts, [&](ASLayout *l) -> ASLayout *{ - __weak id child = l.layoutable; + __weak id child = l.layoutElement; p = p + directionPoint(style.direction, child.style.spacingBefore, 0); if (first) { // if this is the first item use the previously computed start point @@ -156,12 +156,12 @@ ASStackBaselinePositionedLayout ASStackBaselinePositionedLayout::compute(const A /* Step 5: finally, we must find the smallest descender (descender is negative). This is since ASBaselineLayoutSpec implements - ASLayoutable and needs an ascender and descender to lay itself out properly. + ASLayoutElement and needs an ascender and descender to lay itself out properly. */ const auto descenderIt = std::max_element(stackedChildren.begin(), stackedChildren.end(), [&](const ASLayout *a, const ASLayout *b){ return a.position.y + a.size.height < b.position.y + b.size.height; }); - const CGFloat minDescender = descenderIt == stackedChildren.end() ? 0 : (*descenderIt).layoutable.style.descender; + const CGFloat minDescender = descenderIt == stackedChildren.end() ? 0 : (*descenderIt).layoutElement.style.descender; return {stackedChildren, crossSize, maxAscender, minDescender}; } diff --git a/AsyncDisplayKit/Private/ASStackUnpositionedLayout.h b/AsyncDisplayKit/Private/ASStackUnpositionedLayout.h index 9e51e44801..adfd5565f4 100644 --- a/AsyncDisplayKit/Private/ASStackUnpositionedLayout.h +++ b/AsyncDisplayKit/Private/ASStackUnpositionedLayout.h @@ -16,7 +16,7 @@ struct ASStackUnpositionedItem { /** The original source child. */ - id child; + id child; /** The proposed layout. */ ASLayout *layout; }; @@ -31,7 +31,7 @@ struct ASStackUnpositionedLayout { const CGFloat violation; /** Given a set of children, computes the unpositioned layouts for those children. */ - static ASStackUnpositionedLayout compute(const std::vector> &children, + static ASStackUnpositionedLayout compute(const std::vector> &children, const ASStackLayoutSpecStyle &style, const ASSizeRange &sizeRange); }; diff --git a/AsyncDisplayKit/Private/ASStackUnpositionedLayout.mm b/AsyncDisplayKit/Private/ASStackUnpositionedLayout.mm index 1d812ae500..98c4da8aca 100644 --- a/AsyncDisplayKit/Private/ASStackUnpositionedLayout.mm +++ b/AsyncDisplayKit/Private/ASStackUnpositionedLayout.mm @@ -16,34 +16,34 @@ #import "ASLayoutSpecUtilities.h" static CGFloat resolveCrossDimensionMaxForStretchChild(const ASStackLayoutSpecStyle &style, - const idchild, + const idchild, const CGFloat stackMax, const CGFloat crossMax) { // stretched children may have a cross direction max that is smaller than the minimum size constraint of the parent. const CGFloat computedMax = (style.direction == ASStackLayoutDirectionVertical ? - ASLayoutableSizeResolve(child.style.size, ASLayoutableParentSizeUndefined).max.width : - ASLayoutableSizeResolve(child.style.size, ASLayoutableParentSizeUndefined).max.height); + ASLayoutElementSizeResolve(child.style.size, ASLayoutElementParentSizeUndefined).max.width : + ASLayoutElementSizeResolve(child.style.size, ASLayoutElementParentSizeUndefined).max.height); return computedMax == INFINITY ? crossMax : computedMax; } static CGFloat resolveCrossDimensionMinForStretchChild(const ASStackLayoutSpecStyle &style, - const idchild, + const idchild, const CGFloat stackMax, const CGFloat crossMin) { // stretched children will have a cross dimension of at least crossMin, unless they explicitly define a child size // that is smaller than the constraint of the parent. return (style.direction == ASStackLayoutDirectionVertical ? - ASLayoutableSizeResolve(child.style.size, ASLayoutableParentSizeUndefined).min.width : - ASLayoutableSizeResolve(child.style.size, ASLayoutableParentSizeUndefined).min.height) ?: crossMin; + ASLayoutElementSizeResolve(child.style.size, ASLayoutElementParentSizeUndefined).min.width : + ASLayoutElementSizeResolve(child.style.size, ASLayoutElementParentSizeUndefined).min.height) ?: crossMin; } /** Sizes the child given the parameters specified, and returns the computed layout. */ -static ASLayout *crossChildLayout(const id child, +static ASLayout *crossChildLayout(const id child, const ASStackLayoutSpecStyle style, const CGFloat stackMin, const CGFloat stackMax, @@ -60,7 +60,7 @@ static ASLayout *crossChildLayout(const id child, const ASSizeRange childSizeRange = directionSizeRange(style.direction, stackMin, stackMax, childCrossMin, childCrossMax); ASLayout *layout = [child layoutThatFits:childSizeRange parentSize:size]; ASDisplayNodeCAssertNotNil(layout, @"ASLayout returned from measureWithSizeRange: must not be nil: %@", child); - return layout ? : [ASLayout layoutWithLayoutable:child size:{0, 0}]; + return layout ? : [ASLayout layoutWithLayoutElement:child size:{0, 0}]; } /** @@ -207,7 +207,7 @@ static std::function flexAdjustm } } -ASDISPLAYNODE_INLINE BOOL isFlexibleInBothDirections(id child) +ASDISPLAYNODE_INLINE BOOL isFlexibleInBothDirections(id child) { return child.style.flexGrow > 0 && child.style.flexShrink > 0; } @@ -222,7 +222,7 @@ static void layoutFlexibleChildrenAtZeroSize(std::vector child = item.child; + const id child = item.child; if (isFlexibleInBothDirections(child)) { item.layout = crossChildLayout(child, style, @@ -257,7 +257,7 @@ static CGFloat computeStackDimensionSum(const std::vector child = l.child; + const id child = l.child; return x + child.style.spacingBefore + child.style.spacingAfter; }); @@ -318,7 +318,7 @@ static CGFloat computeViolation(const CGFloat stackDimensionSum, If we have a single flexible (both shrinkable and growable) child, and our allowed size range is set to a specific number then we may avoid the first "intrinsic" size calculation. */ -ASDISPLAYNODE_INLINE BOOL useOptimizedFlexing(const std::vector> &children, +ASDISPLAYNODE_INLINE BOOL useOptimizedFlexing(const std::vector> &children, const ASStackLayoutSpecStyle &style, const ASSizeRange &sizeRange) { @@ -389,7 +389,7 @@ static void flexChildrenAlongStackDimension(std::vector Performs the first unconstrained layout of the children, generating the unpositioned items that are then flexed and stretched. */ -static std::vector layoutChildrenAlongUnconstrainedStackDimension(const std::vector> &children, +static std::vector layoutChildrenAlongUnconstrainedStackDimension(const std::vector> &children, const ASStackLayoutSpecStyle &style, const ASSizeRange &sizeRange, const CGSize size, @@ -397,9 +397,9 @@ static std::vector layoutChildrenAlongUnconstrainedStac { const CGFloat minCrossDimension = crossDimension(style.direction, sizeRange.min); const CGFloat maxCrossDimension = crossDimension(style.direction, sizeRange.max); - return AS::map(children, [&](id child) -> ASStackUnpositionedItem { + return AS::map(children, [&](id child) -> ASStackUnpositionedItem { if (useOptimizedFlexing && isFlexibleInBothDirections(child)) { - return { child, [ASLayout layoutWithLayoutable:child size:{0, 0}] }; + return { child, [ASLayout layoutWithLayoutElement:child size:{0, 0}] }; } else { return { child, @@ -415,15 +415,15 @@ static std::vector layoutChildrenAlongUnconstrainedStac }); } -ASStackUnpositionedLayout ASStackUnpositionedLayout::compute(const std::vector> &children, +ASStackUnpositionedLayout ASStackUnpositionedLayout::compute(const std::vector> &children, const ASStackLayoutSpecStyle &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 ASLayoutableParentDimensionUndefined since it will depend on the content. + // Otherwise, we pass ASLayoutElementParentDimensionUndefined since it will depend on the content. const CGSize size = { - (sizeRange.min.width == sizeRange.max.width) ? sizeRange.min.width : ASLayoutableParentDimensionUndefined, - (sizeRange.min.height == sizeRange.max.height) ? sizeRange.min.height : ASLayoutableParentDimensionUndefined, + (sizeRange.min.width == sizeRange.max.width) ? sizeRange.min.width : ASLayoutElementParentDimensionUndefined, + (sizeRange.min.height == sizeRange.max.height) ? sizeRange.min.height : ASLayoutElementParentDimensionUndefined, }; // We may be able to avoid some redundant layout passes diff --git a/AsyncDisplayKit/_ASTransitionContext.m b/AsyncDisplayKit/_ASTransitionContext.m index 750d6806c0..4ce9554701 100644 --- a/AsyncDisplayKit/_ASTransitionContext.m +++ b/AsyncDisplayKit/_ASTransitionContext.m @@ -65,7 +65,7 @@ NSString * const ASTransitionContextToLayoutKey = @"org.asyncdisplaykit.ASTransi - (CGRect)finalFrameForNode:(ASDisplayNode *)node { for (ASLayout *layout in [self layoutForKey:ASTransitionContextToLayoutKey].sublayouts) { - if (layout.layoutable == node) { + if (layout.layoutElement == node) { return [layout frame]; } } @@ -76,7 +76,7 @@ NSString * const ASTransitionContextToLayoutKey = @"org.asyncdisplaykit.ASTransi { NSMutableArray *subnodes = [NSMutableArray array]; for (ASLayout *sublayout in [self layoutForKey:key].sublayouts) { - [subnodes addObject:(ASDisplayNode *)sublayout.layoutable]; + [subnodes addObject:(ASDisplayNode *)sublayout.layoutElement]; } return subnodes; } diff --git a/AsyncDisplayKitTests/ASLayoutableStyleTests.m b/AsyncDisplayKitTests/ASLayoutElementStyleTests.m similarity index 70% rename from AsyncDisplayKitTests/ASLayoutableStyleTests.m rename to AsyncDisplayKitTests/ASLayoutElementStyleTests.m index 46d7013114..e51dc6819b 100644 --- a/AsyncDisplayKitTests/ASLayoutableStyleTests.m +++ b/AsyncDisplayKitTests/ASLayoutElementStyleTests.m @@ -1,5 +1,5 @@ // -// ASLayoutableStyleTests.mm +// ASLayoutElementStyleTests.mm // AsyncDisplayKit // // Copyright (c) 2014-present, Facebook, Inc. All rights reserved. @@ -9,15 +9,15 @@ // #import -#import "ASLayoutable.h" +#import "ASLayoutElement.h" -#pragma mark - ASLayoutableStyleTestsDelegate +#pragma mark - ASLayoutElementStyleTestsDelegate -@interface ASLayoutableStyleTestsDelegate : NSObject +@interface ASLayoutElementStyleTestsDelegate : NSObject @property (copy, nonatomic) NSString *propertyNameChanged; @end -@implementation ASLayoutableStyleTestsDelegate +@implementation ASLayoutElementStyleTestsDelegate - (void)style:(id)style propertyDidChange:(NSString *)propertyName { @@ -26,17 +26,17 @@ @end -#pragma mark - ASLayoutableStyleTests +#pragma mark - ASLayoutElementStyleTests -@interface ASLayoutableStyleTests : XCTestCase +@interface ASLayoutElementStyleTests : XCTestCase @end -@implementation ASLayoutableStyleTests +@implementation ASLayoutElementStyleTests - (void)testSettingSizeProperties { - ASLayoutableStyle *style = [ASLayoutableStyle new]; + ASLayoutElementStyle *style = [ASLayoutElementStyle new]; style.width = ASDimensionMake(100); style.height = ASDimensionMake(100); @@ -46,7 +46,7 @@ - (void)testSettingSizeViaHelper { - ASLayoutableStyle *style = [ASLayoutableStyle new]; + ASLayoutElementStyle *style = [ASLayoutElementStyle new]; [style setSizeWithCGSize:CGSizeMake(100, 100)]; XCTAssertTrue(ASDimensionEqualToDimension(style.width, ASDimensionMake(100))); @@ -55,7 +55,7 @@ - (void)testSettingExactSize { - ASLayoutableStyle *style = [ASLayoutableStyle new]; + ASLayoutElementStyle *style = [ASLayoutElementStyle new]; [style setExactSizeWithCGSize:CGSizeMake(100, 100)]; XCTAssertTrue(ASDimensionEqualToDimension(style.minWidth, ASDimensionMake(100))); @@ -66,12 +66,12 @@ - (void)testSettingPropertiesWillCallDelegate { - ASLayoutableStyleTestsDelegate *delegate = [ASLayoutableStyleTestsDelegate new]; - ASLayoutableStyle *style = [[ASLayoutableStyle alloc] initWithDelegate:delegate]; + ASLayoutElementStyleTestsDelegate *delegate = [ASLayoutElementStyleTestsDelegate new]; + ASLayoutElementStyle *style = [[ASLayoutElementStyle alloc] initWithDelegate:delegate]; XCTAssertTrue(ASDimensionEqualToDimension(style.width, ASDimensionAuto)); style.width = ASDimensionMake(100); XCTAssertTrue(ASDimensionEqualToDimension(style.width, ASDimensionMake(100))); - XCTAssertTrue([delegate.propertyNameChanged isEqualToString:ASLayoutableStyleWidthProperty]); + XCTAssertTrue([delegate.propertyNameChanged isEqualToString:ASLayoutElementStyleWidthProperty]); } @end diff --git a/AsyncDisplayKitTests/ASStackLayoutSpecSnapshotTests.mm b/AsyncDisplayKitTests/ASStackLayoutSpecSnapshotTests.mm index 49354e7586..18566e69c0 100644 --- a/AsyncDisplayKitTests/ASStackLayoutSpecSnapshotTests.mm +++ b/AsyncDisplayKitTests/ASStackLayoutSpecSnapshotTests.mm @@ -48,7 +48,7 @@ static void setCGSizeToNode(CGSize size, ASDisplayNode *node) node.style.height = ASDimensionMakeWithPoints(size.height); } -- (void)testDefaultStackLayoutableFlexProperties +- (void)testDefaultStackLayoutElementFlexProperties { ASDisplayNode *displayNode = [[ASDisplayNode alloc] init]; diff --git a/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASCollectionNode.m b/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASCollectionNode.m index b18b0bc3be..ce09ceeb9c 100644 --- a/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASCollectionNode.m +++ b/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASCollectionNode.m @@ -48,7 +48,7 @@ // 100% of container _node.style.width = ASDimensionMakeWithFraction(1.0); _node.style.height = ASDimensionMakeWithFraction(1.0); - return [ASWrapperLayoutSpec wrapperWithLayoutable:_node]; + return [ASWrapperLayoutSpec wrapperWithLayoutElement:_node]; } #pragma mark - diff --git a/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASPagerNode.m b/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASPagerNode.m index 3c3e9e52e8..ac91a7a3d0 100644 --- a/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASPagerNode.m +++ b/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASPagerNode.m @@ -37,7 +37,7 @@ static UIColor *OverViewASPagerNodeRandomColor() { - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize { - return [ASLayout layoutWithLayoutable:self size:constrainedSize.max]; + return [ASLayout layoutWithLayoutElement:self size:constrainedSize.max]; } @end @@ -70,7 +70,7 @@ static UIColor *OverViewASPagerNodeRandomColor() { // 100% of container _node.style.width = ASDimensionMakeWithFraction(1.0); _node.style.height = ASDimensionMakeWithFraction(1.0); - return [ASWrapperLayoutSpec wrapperWithLayoutable:_node]; + return [ASWrapperLayoutSpec wrapperWithLayoutElement:_node]; } - (NSInteger)numberOfPagesInPagerNode:(ASPagerNode *)pagerNode diff --git a/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASTableNode.m b/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASTableNode.m index fcccc49341..3d1e65ddba 100644 --- a/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASTableNode.m +++ b/examples/AsyncDisplayKitOverview/Sample/Node Containers/OverviewASTableNode.m @@ -45,7 +45,7 @@ // 100% of container _node.style.width = ASDimensionMakeWithFraction(1.0); _node.style.height = ASDimensionMakeWithFraction(1.0); - return [ASWrapperLayoutSpec wrapperWithLayoutable:_node]; + return [ASWrapperLayoutSpec wrapperWithLayoutElement:_node]; } diff --git a/examples/PagerNode/Sample/PageNode.m b/examples/PagerNode/Sample/PageNode.m index 264809ce17..75f9942e7d 100644 --- a/examples/PagerNode/Sample/PageNode.m +++ b/examples/PagerNode/Sample/PageNode.m @@ -23,7 +23,7 @@ - (ASLayout *)calculateLayoutThatFits:(ASSizeRange)constrainedSize { - return [ASLayout layoutWithLayoutable:self size:constrainedSize.max]; + return [ASLayout layoutWithLayoutElement:self size:constrainedSize.max]; } - (void)fetchData