RootShadowNode.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (c) Facebook, Inc. and its affiliates.
  3. *
  4. * This source code is licensed under the MIT license found in the
  5. * LICENSE file in the root directory of this source tree.
  6. */
  7. #include "RootShadowNode.h"
  8. #include <react/components/view/conversions.h>
  9. #include <react/debug/SystraceSection.h>
  10. namespace facebook {
  11. namespace react {
  12. const char RootComponentName[] = "RootView";
  13. bool RootShadowNode::layoutIfNeeded(
  14. std::vector<LayoutableShadowNode const *> *affectedNodes) {
  15. SystraceSection s("RootShadowNode::layout");
  16. if (getIsLayoutClean()) {
  17. return false;
  18. }
  19. ensureUnsealed();
  20. auto layoutContext = getConcreteProps().layoutContext;
  21. layoutContext.affectedNodes = affectedNodes;
  22. layoutTree(layoutContext, getConcreteProps().layoutConstraints);
  23. return true;
  24. }
  25. RootShadowNode::Unshared RootShadowNode::clone(
  26. LayoutConstraints const &layoutConstraints,
  27. LayoutContext const &layoutContext) const {
  28. auto props = std::make_shared<RootProps const>(
  29. getConcreteProps(), layoutConstraints, layoutContext);
  30. auto newRootShadowNode = std::make_shared<RootShadowNode>(
  31. *this,
  32. ShadowNodeFragment{
  33. /* .props = */ props,
  34. });
  35. return newRootShadowNode;
  36. }
  37. } // namespace react
  38. } // namespace facebook