void YogaLayoutableShadowNode::setYogaNodeChildrenBasedOnShadowNodeChildren(YGNode &yogaNode, const SharedShadowNodeSharedList &children) {
  auto yogaNodeChildren = YGVector();

  for (const SharedShadowNode &shadowNode : *children) {
    const SharedYogaLayoutableShadowNode yogaLayoutableShadowNode = std::dynamic_pointer_cast<const YogaLayoutableShadowNode>(shadowNode);

    if (!yogaLayoutableShadowNode) {
      continue;
    }

    yogaNodeChildren.push_back((YGNode *)yogaLayoutableShadowNode->yogaNode_.get());
  }

  yogaNode.setChildren(yogaNodeChildren);
  yogaNode.setDirty(true);
}
Esempio n. 2
0
YGNode::YGNode()
    : context_(nullptr),
      print_(nullptr),
      hasNewLayout_(true),
      nodeType_(YGNodeTypeDefault),
      measure_(nullptr),
      baseline_(nullptr),
      dirtied_(nullptr),
      style_(YGStyle()),
      layout_(YGLayout()),
      lineIndex_(0),
      parent_(nullptr),
      children_(YGVector()),
      nextChild_(nullptr),
      config_(nullptr),
      isDirty_(false),
      resolvedDimensions_({{YGValueUndefined, YGValueUndefined}}) {}
void YogaLayoutableShadowNode::setYogaNodeChildrenBasedOnShadowNodeChildren(YGNode *yogaNodeRawPtr, const SharedShadowNodeSharedList &children) {
  auto yogaNodeChildren = YGVector();

  for (const SharedShadowNode &shadowNode : *children) {
    const SharedYogaLayoutableShadowNode yogaLayoutableShadowNode = std::dynamic_pointer_cast<const YogaLayoutableShadowNode>(shadowNode);

    if (!yogaLayoutableShadowNode) {
      continue;
    }

    auto &&childYogaNodeRawPtr = &yogaLayoutableShadowNode->yogaNode_;

    yogaNodeChildren.push_back(childYogaNodeRawPtr);

    if (childYogaNodeRawPtr->getOwner() == nullptr) {
      yogaLayoutableShadowNode->ensureUnsealed();
      childYogaNodeRawPtr->setOwner(yogaNodeRawPtr);
    }
  }

  yogaNodeRawPtr->setChildren(yogaNodeChildren);
}