Fabric: Removing AttributedString::Fragment::shadowNode

Summary:
Before this change `AttributedString::Fragment` had two ShadowView objects (`shadowView` and `parentShadowView`). This diff unifies those two things into one. That allows us to save some CPU and memory and makes things a bit simpler. Besides that, now the length of NSAttributedString and AttributedString is now always the same (it's one Unicode character for an attachment for both).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: JoshuaGross

Differential Revision: D18607658

fbshipit-source-id: 502ae244e98a52694adc0d646650f8ea0d7922ae
This commit is contained in:
Valentin Shergin
2019-11-22 22:25:06 -08:00
committed by Facebook Github Bot
parent 890968cc2c
commit ed909b619c
4 changed files with 22 additions and 12 deletions
@@ -17,13 +17,17 @@ using Fragments = AttributedString::Fragments;
#pragma mark - Fragment
std::string Fragment::AttachmentCharacter() {
return "\uFFFC"; // Unicode `OBJECT REPLACEMENT CHARACTER`
}
bool Fragment::isAttachment() const {
return string == AttachmentCharacter();
}
bool Fragment::operator==(const Fragment &rhs) const {
return std::tie(string, textAttributes, shadowView, parentShadowView) ==
std::tie(
rhs.string,
rhs.textAttributes,
rhs.shadowView,
rhs.parentShadowView);
return std::tie(string, textAttributes, parentShadowView) ==
std::tie(rhs.string, rhs.textAttributes, rhs.parentShadowView);
}
bool Fragment::operator!=(const Fragment &rhs) const {