Revert "[ASLayoutSpec] Use childrenMap directly to prevent creating an NSArray within ASDK (#1937)"

Something interesting going on here with ARC / Objective-C++ that we are investigating and will re-land.

This reverts commit c90ed08d10.
This commit is contained in:
Scott Goodson
2016-07-31 18:43:20 -07:00
parent c797fdf23a
commit 735b4ebd08
8 changed files with 48 additions and 138 deletions

View File

@@ -13,7 +13,6 @@
#import "ASInternalHelpers.h"
#import "ASLayoutSpec+Private.h"
#import "ASLayoutSpecUtilities.h"
#import "ASStackBaselinePositionedLayout.h"
#import "ASThread.h"
@@ -59,7 +58,7 @@
_alignItems = alignItems;
_justifyContent = justifyContent;
self.children = children;
[self setChildren:children];
return self;
}
@@ -121,9 +120,7 @@
- (ASLayout *)measureWithSizeRange:(ASSizeRange)constrainedSize
{
auto const &children = self.childrenMap;
if (children.size() == 0) {
if (self.children.count == 0) {
return [ASLayout layoutWithLayoutableObject:self
constrainedSizeRange:constrainedSize
size:constrainedSize.min];
@@ -132,9 +129,9 @@
ASStackLayoutSpecStyle style = {.direction = _direction, .spacing = _spacing, .justifyContent = _justifyContent, .alignItems = _alignItems, .baselineRelativeArrangement = _baselineRelativeArrangement};
BOOL needsBaselinePass = _baselineRelativeArrangement || _alignItems == ASStackLayoutAlignItemsBaselineFirst || _alignItems == ASStackLayoutAlignItemsBaselineLast;
std::vector<id<ASLayoutable>> stackChildren;
for (auto const &entry : children) {
stackChildren.push_back(entry.second);
std::vector<id<ASLayoutable>> stackChildren = std::vector<id<ASLayoutable>>();
for (id<ASLayoutable> child in self.children) {
stackChildren.push_back(child);
}
const auto unpositionedLayout = ASStackUnpositionedLayout::compute(stackChildren, style, constrainedSize);
@@ -146,18 +143,14 @@
// regardless of whether or not this stack aligns to baseline, we should let ASStackBaselinePositionedLayout::compute find the max ascender
// and min descender in case this spec is a child in another spec that wants to align to a baseline.
const auto baselinePositionedLayout = ASStackBaselinePositionedLayout::compute(positionedLayout, style, constrainedSize);
{
if (self.direction == ASStackLayoutDirectionVertical) {
ASDN::MutexLocker l(__instanceLock__);
if (self.direction == ASStackLayoutDirectionVertical) {
if (stackChildren.size() > 0) {
self.ascender = stackChildren.front().ascender;
self.descender = stackChildren.back().descender;
}
} else {
self.ascender = baselinePositionedLayout.ascender;
self.descender = baselinePositionedLayout.descender;
}
self.ascender = [[self.children firstObject] ascender];
self.descender = [[self.children lastObject] descender];
} else {
ASDN::MutexLocker l(__instanceLock__);
self.ascender = baselinePositionedLayout.ascender;
self.descender = baselinePositionedLayout.descender;
}
if (needsBaselinePass) {