From eec9e4a2f9ae2dc0787e4ba08028ec2664fda46c Mon Sep 17 00:00:00 2001 From: David Vacca Date: Sun, 25 Nov 2018 17:18:12 -0800 Subject: [PATCH] Expose hash as part of text localdata Summary: In this diff we expose the text local data hash to android, this will be used in the future to cache metadata when rendering text in android Reviewed By: shergin Differential Revision: D13161873 fbshipit-source-id: cd13a4beba75a3fe62ac9ff3def26f88e874834b --- ReactCommon/fabric/attributedstring/conversions.h | 2 ++ ReactCommon/fabric/components/text/paragraph/conversions.h | 1 + 2 files changed, 3 insertions(+) diff --git a/ReactCommon/fabric/attributedstring/conversions.h b/ReactCommon/fabric/attributedstring/conversions.h index 66e4bbc41..fd531cef4 100644 --- a/ReactCommon/fabric/attributedstring/conversions.h +++ b/ReactCommon/fabric/attributedstring/conversions.h @@ -487,6 +487,8 @@ inline folly::dynamic toDynamic(const AttributedString &attributedString) { fragments.push_back(dynamicFragment); } value("fragments", fragments); + value( + "hash", std::hash{}(attributedString)); value("string", attributedString.getString()); return value; } diff --git a/ReactCommon/fabric/components/text/paragraph/conversions.h b/ReactCommon/fabric/components/text/paragraph/conversions.h index bf2f2e1eb..996251c19 100644 --- a/ReactCommon/fabric/components/text/paragraph/conversions.h +++ b/ReactCommon/fabric/components/text/paragraph/conversions.h @@ -14,6 +14,7 @@ inline folly::dynamic toDynamic(const ParagraphLocalData ¶graphLocalData) { folly::dynamic newLocalData = folly::dynamic::object(); newLocalData["attributedString"] = toDynamic(paragraphLocalData.getAttributedString()); + newLocalData["hash"] = newLocalData["attributedString"]["hash"]; return newLocalData; }