Commit Graph

2 Commits

Author SHA1 Message Date
Valentin Shergin 909b0fe0e7 Fabric: operator== and std::hash for AttributedStringBox
Summary:
That will allow building a custom caching table for boxed stings to cache text measurements for them in TextLayoutManager.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18950428

fbshipit-source-id: 8ceef29543dc6ed540043e32d65f3295030ae90f
2019-12-12 12:53:12 -08:00
Valentin Shergin c4876d0313 Fabric: Introducing AttributedStringBox
Summary:
The diff implements a new class called `AttributedStringBox` that represents an object storing a shared `AttributedString` *or* a shared pointer to some opaque platform-specific object that can be used as an attributed string. The class serves two main purposes:
- Represent type-erased attributed string entity (which can be platform-specific or platform-independent);
- Represent a container that can be copied with constant complexity.

Why? Several reasons:
- Sometimes it makes sense to keep an attributed string as a shared resource. This way we don't need to pay for expensive copying and we also implement a copy-on-write semantics on top of that if needed.
- We need to extend a TextLayoutMeasure API to support measuring some platform-specific attributed string implementation to remove the necessity of converting a string back and forth between representations. That's especially important for TextInput because we will need to measure that very efficiently (and the source of measuring, in this case, is a platform attributed string).

In other words, we need something to store inside TextInputState to measure and update very efficiently. The source of this data might be a native TextInput control or a data from React, to represent that kinda object we need this data structure (and interfaces that deal with it).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: sammy-SC

Differential Revision: D18670793

fbshipit-source-id: bc0164f801f28642f7c6da340af12acf33b85d24
2019-12-04 18:36:48 -08:00