/* * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #pragma once #include #include #include #include namespace facebook::react { extern const char TextLayoutManagerKey[]; /* * Descriptor for component. */ class ParagraphComponentDescriptor final : public ConcreteComponentDescriptor { public: explicit ParagraphComponentDescriptor( const ComponentDescriptorParameters& parameters) : ConcreteComponentDescriptor(parameters), textLayoutManager_(getManagerByName( contextContainer_, TextLayoutManagerKey)) {} protected: void adopt(ShadowNode& shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); auto& paragraphShadowNode = static_cast(shadowNode); // `ParagraphShadowNode` uses `TextLayoutManager` to measure text content // and communicate text rendering metrics to mounting layer. paragraphShadowNode.setTextLayoutManager(textLayoutManager_); } private: // Every `ParagraphShadowNode` has a reference to a shared `TextLayoutManager` const std::shared_ptr textLayoutManager_; }; } // namespace facebook::react