/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #include "TextLayoutManager.h" #include #include #include using namespace facebook::jni; namespace facebook { namespace react { TextLayoutManager::~TextLayoutManager() {} void *TextLayoutManager::getNativeTextLayoutManager() const { return self_; } Size TextLayoutManager::measure( AttributedString attributedString, ParagraphAttributes paragraphAttributes, LayoutConstraints layoutConstraints) const { const jni::global_ref &fabricUIManager = contextContainer_->getInstance>( "FabricUIManager"); static auto measure = jni::findClassStatic("com/facebook/react/fabric/FabricUIManager") ->getMethod("measure"); auto minimumSize = layoutConstraints.minimumSize; auto maximumSize = layoutConstraints.maximumSize; local_ref componentName = make_jstring("RCTText"); local_ref attributedStringRNM = ReadableNativeMap::newObjectCxxArgs(toDynamic(attributedString)); local_ref paragraphAttributesRNM = ReadableNativeMap::newObjectCxxArgs(toDynamic(paragraphAttributes)); local_ref attributedStringRM = make_local( reinterpret_cast(attributedStringRNM.get())); local_ref paragraphAttributesRM = make_local( reinterpret_cast(paragraphAttributesRNM.get())); return yogaMeassureToSize(measure( fabricUIManager, componentName.get(), attributedStringRM.get(), paragraphAttributesRM.get(), nullptr, minimumSize.width, maximumSize.width, minimumSize.height, maximumSize.height)); } } // namespace react } // namespace facebook