/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/ReactCommon/react/renderer/components/text/ParagraphComponentDescriptor.h
48 строк
2 KB
Christoph Purrer
Allow to provide a custom TextLayoutManager for cxx platform (#48127)
07 дек 2024, 00:38
07 дек 2024, 00:38
d47ff26
Код
Авторство
О чём код?
/* * 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 <react/renderer/components/text/ParagraphShadowNode.h> #include <react/renderer/core/ConcreteComponentDescriptor.h> #include <react/renderer/textlayoutmanager/TextLayoutManager.h> #include <react/utils/ContextContainer.h> namespace facebook::react { extern const char TextLayoutManagerKey[]; /* * Descriptor for <Paragraph> component. */ class ParagraphComponentDescriptor final : public ConcreteComponentDescriptor<ParagraphShadowNode> { public: explicit ParagraphComponentDescriptor( const ComponentDescriptorParameters& parameters) : ConcreteComponentDescriptor<ParagraphShadowNode>(parameters), textLayoutManager_(getManagerByName<TextLayoutManager>( contextContainer_, TextLayoutManagerKey)) {} protected: void adopt(ShadowNode& shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); auto& paragraphShadowNode = static_cast<ParagraphShadowNode&>(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<const TextLayoutManager> textLayoutManager_; }; } // namespace facebook::react