Fix key mismatch in text layout

Summary:
Changelog: [Internal]

There was a key mismatch between what Java and C++.
cacheIdMap was incorrectly initialised.

Differential Revision: D23652342

fbshipit-source-id: 66f54dc887a011afeead9420bda093e9a0c9a8ca
This commit is contained in:
Joshua Gross 2020-09-12 21:50:51 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 250485a94c
Коммит 44229d9149
4 изменённых файлов: 8 добавлений и 7 удалений

Просмотреть файл

@ -45,8 +45,9 @@ AndroidTextInputState::AndroidTextInputState(
"mostRecentEventCount", "mostRecentEventCount",
previousState.mostRecentEventCount) previousState.mostRecentEventCount)
.getInt()), .getInt()),
cachedAttributedStringId( cachedAttributedStringId(data.getDefault(
data.getDefault("cacheId", previousState.cachedAttributedStringId) "opaqueCacheId",
previousState.cachedAttributedStringId)
.getInt()), .getInt()),
attributedString(previousState.attributedString), attributedString(previousState.attributedString),
reactTreeAttributedString(previousState.reactTreeAttributedString), reactTreeAttributedString(previousState.reactTreeAttributedString),

Просмотреть файл

@ -29,7 +29,7 @@ class AndroidTextInputState final {
* Stores an opaque cache ID used on the Java side to refer to a specific * Stores an opaque cache ID used on the Java side to refer to a specific
* AttributedString for measurement purposes only. * AttributedString for measurement purposes only.
*/ */
int cachedAttributedStringId{0}; int64_t cachedAttributedStringId{0};
/* /*
* All content of <TextInput> component represented as an `AttributedString`. * All content of <TextInput> component represented as an `AttributedString`.

Просмотреть файл

@ -37,7 +37,7 @@ TextMeasurement TextLayoutManager::measure(
} }
TextMeasurement TextLayoutManager::measureCachedSpannableById( TextMeasurement TextLayoutManager::measureCachedSpannableById(
int cacheId, int64_t cacheId,
ParagraphAttributes paragraphAttributes, ParagraphAttributes paragraphAttributes,
LayoutConstraints layoutConstraints) const { LayoutConstraints layoutConstraints) const {
const jni::global_ref<jobject> &fabricUIManager = const jni::global_ref<jobject> &fabricUIManager =
@ -64,7 +64,7 @@ TextMeasurement TextLayoutManager::measureCachedSpannableById(
auto maximumSize = layoutConstraints.maximumSize; auto maximumSize = layoutConstraints.maximumSize;
local_ref<JString> componentName = make_jstring("RCTText"); local_ref<JString> componentName = make_jstring("RCTText");
folly::dynamic cacheIdMap; folly::dynamic cacheIdMap = folly::dynamic::object;
cacheIdMap["cacheId"] = cacheId; cacheIdMap["cacheId"] = cacheId;
local_ref<ReadableNativeMap::javaobject> attributedStringRNM = local_ref<ReadableNativeMap::javaobject> attributedStringRNM =
ReadableNativeMap::newObjectCxxArgs(cacheIdMap); ReadableNativeMap::newObjectCxxArgs(cacheIdMap);

Просмотреть файл

@ -42,7 +42,7 @@ class TextLayoutManager {
* opaque cache ID. * opaque cache ID.
*/ */
TextMeasurement measureCachedSpannableById( TextMeasurement measureCachedSpannableById(
int cacheId, int64_t cacheId,
ParagraphAttributes paragraphAttributes, ParagraphAttributes paragraphAttributes,
LayoutConstraints layoutConstraints) const; LayoutConstraints layoutConstraints) const;