<commit_before>// Copyright 2004-present Facebook. All Rights Reserved.

#include "UIManager.h"

#include <react/core/ShadowNodeFragment.h>
#include <react/debug/SystraceSection.h>
#include <react/uimanager/TimeUtils.h>

namespace facebook {
namespace react {

SharedShadowNode UIManager::createNode(
    Tag tag,
    const ComponentName &name,
    SurfaceId surfaceId,
    const RawProps &rawProps,
    SharedEventTarget eventTarget) const {
  SystraceSection s("UIManager::createNode");

  auto &componentDescriptor = componentDescriptorRegistry_->at(name);

  auto shadowNode = componentDescriptor.createShadowNode(
      {.tag = tag,
       .rootTag = surfaceId,
       .eventEmitter =
           componentDescriptor.createEventEmitter(std::move(eventTarget), tag),
       .props = componentDescriptor.cloneProps(nullptr, rawProps)});

  if (delegate_) {
    delegate_->uiManagerDidCreateShadowNode(shadowNode);
  }

  return std::const_pointer_cast<ShadowNode>(shadowNode);
}

SharedShadowNode UIManager::cloneNode(
    const SharedShadowNode &shadowNode,
    const SharedShadowNodeSharedList &children,
    const RawProps *rawProps) const {
  SystraceSection s("UIManager::cloneNode");

  auto &componentDescriptor =
      componentDescriptorRegistry_->at(shadowNode->getComponentHandle());

  auto clonedShadowNode = componentDescriptor.cloneShadowNode(
      *shadowNode,
      {
          .props = rawProps ? componentDescriptor.cloneProps(
                                  shadowNode->getProps(), *rawProps)
                            : ShadowNodeFragment::propsPlaceholder(),
          .children = children,
      });

  return std::const_pointer_cast<ShadowNode>(clonedShadowNode);
}

void UIManager::appendChild(
    const SharedShadowNode &parentShadowNode,
    const SharedShadowNode &childShadowNode) const {
  SystraceSection s("UIManager::appendChild");

  auto &componentDescriptor =
      componentDescriptorRegistry_->at(parentShadowNode->getComponentHandle());
  componentDescriptor.appendChild(parentShadowNode, childShadowNode);
}

void UIManager::completeSurface(<commit_msg>Fabric: Removed unnecessary const_cast leftovers<commit_after>// Copyright 2004-present Facebook. All Rights Reserved.

#include "UIManager.h"

#include <react/core/ShadowNodeFragment.h>
#include <react/debug/SystraceSection.h>
#include <react/uimanager/TimeUtils.h>

namespace facebook {
namespace react {

SharedShadowNode UIManager::createNode(
    Tag tag,
    const ComponentName &name,
    SurfaceId surfaceId,
    const RawProps &rawProps,
    SharedEventTarget eventTarget) const {
  SystraceSection s("UIManager::createNode");

  auto &componentDescriptor = componentDescriptorRegistry_->at(name);

  auto shadowNode = componentDescriptor.createShadowNode(
      {.tag = tag,
       .rootTag = surfaceId,
       .eventEmitter =
           componentDescriptor.createEventEmitter(std::move(eventTarget), tag),
       .props = componentDescriptor.cloneProps(nullptr, rawProps)});

  if (delegate_) {
    delegate_->uiManagerDidCreateShadowNode(shadowNode);
  }

  return shadowNode;
}

SharedShadowNode UIManager::cloneNode(
    const SharedShadowNode &shadowNode,
    const SharedShadowNodeSharedList &children,
    const RawProps *rawProps) const {
  SystraceSection s("UIManager::cloneNode");

  auto &componentDescriptor =
      componentDescriptorRegistry_->at(shadowNode->getComponentHandle());

  auto clonedShadowNode = componentDescriptor.cloneShadowNode(
      *shadowNode,
      {
          .props = rawProps ? componentDescriptor.cloneProps(
                                  shadowNode->getProps(), *rawProps)
                            : ShadowNodeFragment::propsPlaceholder(),
          .children = children,
      });

  return clonedShadowNode;
}

void UIManager::appendChild(
    const SharedShadowNode &parentShadowNode,
    const SharedShadowNode &childShadowNode) const {
  SystraceSection s("UIManager::appendChild");

  auto &componentDescriptor =
      componentDescriptorRegistry_->at(parentShadowNode->getComponentHandle());
  componentDescriptor.appendChild(parentShadowNode, childShadowNode);
}

void UIManager::completeSurface(
{'fraction_non_alphanumeric': 0.0957983193277311, 'fraction_numerical': 0.0019207683073229293, 'mean_word_length': 4.188044831880449, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1548810', 'n_tokens_mistral': 1126, 'n_tokens_neox': 1106, 'n_words': 215}