mirror of
https://github.com/status-im/react-native.git
synced 2025-01-18 05:23:26 +00:00
db92b16e04
Summary: Quite obvious. We have to check `sealable` flag of the child (not a parent) before mutating it. Reviewed By: mdvacca Differential Revision: D7526407 fbshipit-source-id: ce8e0d6446ff7eb23baee9c92f246d5e198fe377
99 lines
2.3 KiB
C++
99 lines
2.3 KiB
C++
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#include "LayoutableShadowNode.h"
|
|
|
|
#include <fabric/core/LayoutConstraints.h>
|
|
#include <fabric/core/LayoutContext.h>
|
|
#include <fabric/core/LayoutMetrics.h>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
LayoutMetrics LayoutableShadowNode::getLayoutMetrics() const {
|
|
return layoutMetrics_;
|
|
}
|
|
|
|
bool LayoutableShadowNode::setLayoutMetrics(LayoutMetrics layoutMetrics) {
|
|
if (layoutMetrics_ == layoutMetrics) {
|
|
return false;
|
|
}
|
|
|
|
ensureUnsealed();
|
|
|
|
layoutMetrics_ = layoutMetrics;
|
|
return true;
|
|
}
|
|
|
|
void LayoutableShadowNode::cleanLayout() {
|
|
isLayoutClean_ = true;
|
|
}
|
|
|
|
void LayoutableShadowNode::dirtyLayout() {
|
|
isLayoutClean_ = false;
|
|
}
|
|
|
|
bool LayoutableShadowNode::getIsLayoutClean() const {
|
|
return isLayoutClean_;
|
|
}
|
|
|
|
bool LayoutableShadowNode::getHasNewLayout() const {
|
|
return hasNewLayout_;
|
|
};
|
|
|
|
void LayoutableShadowNode::setHasNewLayout(bool hasNewLayout) {
|
|
hasNewLayout_ = hasNewLayout;
|
|
}
|
|
|
|
Size LayoutableShadowNode::measure(LayoutConstraints layoutConstraints) const {
|
|
return Size();
|
|
}
|
|
|
|
Float LayoutableShadowNode::firstBaseline(Size size) const {
|
|
return 0;
|
|
}
|
|
|
|
Float LayoutableShadowNode::lastBaseline(Size size) const {
|
|
return 0;
|
|
}
|
|
|
|
void LayoutableShadowNode::layout(LayoutContext layoutContext) {
|
|
layoutChildren(layoutContext);
|
|
|
|
for (auto child : getChildren()) {
|
|
if (!child->getHasNewLayout()) {
|
|
continue;
|
|
}
|
|
|
|
child->ensureUnsealed();
|
|
|
|
// The assumption:
|
|
// All `sealed` children were replaced with not-yet-sealed clones
|
|
// somewhere in `layoutChildren`.
|
|
auto nonConstChild = std::const_pointer_cast<LayoutableShadowNode>(child);
|
|
|
|
nonConstChild->setHasNewLayout(false);
|
|
|
|
const LayoutMetrics childLayoutMetrics = nonConstChild->getLayoutMetrics();
|
|
if (childLayoutMetrics.displayType == None) {
|
|
continue;
|
|
}
|
|
|
|
LayoutContext childLayoutContext = LayoutContext(layoutContext);
|
|
childLayoutContext.absolutePosition += childLayoutMetrics.frame.origin;
|
|
|
|
nonConstChild->layout(layoutContext);
|
|
}
|
|
}
|
|
|
|
void LayoutableShadowNode::layoutChildren(LayoutContext layoutContext) {
|
|
// Default implementation does nothing.
|
|
}
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|