RootShadowNode.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #pragma once
  8. #include <memory>
  9. #include <react/components/root/RootProps.h>
  10. #include <react/components/view/ConcreteViewShadowNode.h>
  11. #include <react/core/LayoutContext.h>
  12. namespace facebook {
  13. namespace react {
  14. class RootShadowNode;
  15. extern const char RootComponentName[];
  16. /*
  17. * `ShadowNode` for the root component.
  18. * Besides all functionality of the `View` component, `RootShadowNode` contains
  19. * props which represent external layout constraints and context of the
  20. * shadow tree.
  21. */
  22. class RootShadowNode final
  23. : public ConcreteViewShadowNode<RootComponentName, RootProps> {
  24. public:
  25. using ConcreteViewShadowNode::ConcreteViewShadowNode;
  26. using Shared = std::shared_ptr<RootShadowNode const>;
  27. using Unshared = std::shared_ptr<RootShadowNode>;
  28. /*
  29. * Layouts the shadow tree if needed.
  30. * Returns `false` if the three is already laid out.
  31. */
  32. bool layoutIfNeeded(
  33. std::vector<LayoutableShadowNode const *> *affectedNodes = {});
  34. /*
  35. * Clones the node with given `layoutConstraints` and `layoutContext`.
  36. */
  37. RootShadowNode::Unshared clone(
  38. LayoutConstraints const &layoutConstraints,
  39. LayoutContext const &layoutContext) const;
  40. };
  41. } // namespace react
  42. } // namespace facebook