mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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
This commit is contained in:
committed by
Facebook Github Bot
parent
70ec7e2add
commit
c4876d0313
+4
-1
@@ -8,6 +8,7 @@
|
||||
#include "AndroidTextInputShadowNode.h"
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <react/attributedstring/AttributedStringBox.h>
|
||||
#include <react/attributedstring/TextAttributes.h>
|
||||
#include <react/components/text/BaseTextShadowNode.h>
|
||||
#include <react/core/LayoutConstraints.h>
|
||||
@@ -111,7 +112,9 @@ Size AndroidTextInputShadowNode::measure(
|
||||
}
|
||||
|
||||
return textLayoutManager_->measure(
|
||||
attributedString, getProps()->paragraphAttributes, layoutConstraints);
|
||||
AttributedStringBox{attributedString},
|
||||
getProps()->paragraphAttributes,
|
||||
layoutConstraints);
|
||||
}
|
||||
|
||||
void AndroidTextInputShadowNode::layout(LayoutContext layoutContext) {
|
||||
|
||||
Reference in New Issue
Block a user