[ASLayoutSpec] Remove cached ASTraitCollection

This commit is contained in:
ricky
2016-06-07 10:50:42 -07:00
parent cb67671f1d
commit 3c34d51a19
3 changed files with 4 additions and 13 deletions

View File

@@ -1901,7 +1901,10 @@ void recursivelyTriggerDisplayForLayer(CALayer *layer, BOOL shouldBlock)
if ((_methodOverrides & ASDisplayNodeMethodOverrideLayoutSpecThatFits) || _layoutSpecBlock != NULL) { if ((_methodOverrides & ASDisplayNodeMethodOverrideLayoutSpecThatFits) || _layoutSpecBlock != NULL) {
ASLayoutSpec *layoutSpec = [self layoutSpecThatFits:constrainedSize]; ASLayoutSpec *layoutSpec = [self layoutSpecThatFits:constrainedSize];
layoutSpec.parent = self; // This causes upward propogation of any non-default layoutable values. layoutSpec.parent = self; // This causes upward propogation of any non-default layoutable values.
layoutSpec.traitCollection = self.asyncTraitCollection;
// manually propagate the trait collection here so that any layoutSpec children of layoutSpec will get a traitCollection
ASEnvironmentStatePropagateDown(layoutSpec, self.environmentTraitCollection);
layoutSpec.isMutable = NO; layoutSpec.isMutable = NO;
ASLayout *layout = [layoutSpec measureWithSizeRange:constrainedSize]; ASLayout *layout = [layoutSpec measureWithSizeRange:constrainedSize];
// Make sure layoutableObject of the root layout is `self`, so that the flattened layout will be structurally correct. // Make sure layoutableObject of the root layout is `self`, so that the flattened layout will be structurally correct.

View File

@@ -11,8 +11,6 @@
#import <AsyncDisplayKit/ASLayoutable.h> #import <AsyncDisplayKit/ASLayoutable.h>
#import <AsyncDisplayKit/ASAsciiArtBoxCreator.h> #import <AsyncDisplayKit/ASAsciiArtBoxCreator.h>
@class ASTraitCollection;
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
/** A layout spec is an immutable object that describes a layout, loosely inspired by React. */ /** A layout spec is an immutable object that describes a layout, loosely inspired by React. */
@@ -25,8 +23,6 @@ NS_ASSUME_NONNULL_BEGIN
*/ */
@property (nonatomic, assign) BOOL isMutable; @property (nonatomic, assign) BOOL isMutable;
@property (nonatomic, strong, nullable) ASTraitCollection *traitCollection;
- (instancetype)init; - (instancetype)init;
/** /**

View File

@@ -185,14 +185,6 @@
return _children; return _children;
} }
- (void)setTraitCollection:(ASTraitCollection *)traitCollection
{
if ([traitCollection isEqualToTraitCollection:self.traitCollection] == NO) {
_traitCollection = traitCollection;
ASEnvironmentStatePropagateDown(self, [traitCollection environmentTraitCollection]);
}
}
#pragma mark - ASEnvironment #pragma mark - ASEnvironment
- (ASEnvironmentState)environmentState - (ASEnvironmentState)environmentState