Fabric: Changing the shape of ShadowViewNodePair class

Summary:
I am not sure why it compiled before, it clearly should not, IMO. The `const` types (and references!) are not allowed inside `std::vector` because they are not assignable.
Some experiments that I did caused compilation errors here, so I am changing that to be actually correct.

Reviewed By: JoshuaGross

Differential Revision: D14249199

fbshipit-source-id: 07a22ef13f5de9dfc7ab307493419e6006994bc2
This commit is contained in:
Valentin Shergin
2019-03-04 09:57:01 -08:00
committed by Facebook Github Bot
parent b9a7880434
commit 56501dcc47
3 changed files with 10 additions and 10 deletions

View File

@@ -39,7 +39,7 @@ static void sliceChildShadowNodeViewPairsRecursively(
*childShadowNode);
} else {
shadowView.layoutMetrics.frame.origin += layoutOffset;
pairList.push_back({shadowView, *childShadowNode});
pairList.push_back({shadowView, childShadowNode.get()});
}
}
}
@@ -98,9 +98,9 @@ static void calculateShadowViewMutations(
}
const auto oldGrandChildPairs =
sliceChildShadowNodeViewPairs(oldChildPair.shadowNode);
sliceChildShadowNodeViewPairs(*oldChildPair.shadowNode);
const auto newGrandChildPairs =
sliceChildShadowNodeViewPairs(newChildPair.shadowNode);
sliceChildShadowNodeViewPairs(*newChildPair.shadowNode);
calculateShadowViewMutations(
*(newGrandChildPairs.size() ? &downwardMutations
: &destructiveDownwardMutations),
@@ -145,7 +145,7 @@ static void calculateShadowViewMutations(
calculateShadowViewMutations(
destructiveDownwardMutations,
oldChildPair.shadowView,
sliceChildShadowNodeViewPairs(oldChildPair.shadowNode),
sliceChildShadowNodeViewPairs(*oldChildPair.shadowNode),
{});
} else {
// The old view *was* (re)inserted.
@@ -154,9 +154,9 @@ static void calculateShadowViewMutations(
const auto &newChildPair = it->second;
if (newChildPair.shadowView != oldChildPair.shadowView) {
const auto oldGrandChildPairs =
sliceChildShadowNodeViewPairs(oldChildPair.shadowNode);
sliceChildShadowNodeViewPairs(*oldChildPair.shadowNode);
const auto newGrandChildPairs =
sliceChildShadowNodeViewPairs(newChildPair.shadowNode);
sliceChildShadowNodeViewPairs(*newChildPair.shadowNode);
calculateShadowViewMutations(
*(newGrandChildPairs.size() ? &downwardMutations
: &destructiveDownwardMutations),
@@ -191,7 +191,7 @@ static void calculateShadowViewMutations(
downwardMutations,
newChildPair.shadowView,
{},
sliceChildShadowNodeViewPairs(newChildPair.shadowNode));
sliceChildShadowNodeViewPairs(*newChildPair.shadowNode));
}
// All mutations in an optimal order:

View File

@@ -51,7 +51,7 @@ bool ShadowView::operator!=(const ShadowView &rhs) const {
}
bool ShadowViewNodePair::operator==(const ShadowViewNodePair &rhs) const {
return &this->shadowNode == &rhs.shadowNode;
return this->shadowNode == rhs.shadowNode;
}
bool ShadowViewNodePair::operator!=(const ShadowViewNodePair &rhs) const {

View File

@@ -49,8 +49,8 @@ struct ShadowView final {
* Describes pair of a `ShadowView` and a `ShadowNode`.
*/
struct ShadowViewNodePair final {
const ShadowView shadowView;
const ShadowNode &shadowNode;
ShadowView shadowView;
ShadowNode const *shadowNode;
/*
* The stored pointer to `ShadowNode` represents an indentity of the pair.