mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Implement TextNodeRegion
Summary: NodeRegion is only able to describe a rectangular region for touch, which is not good enough for text, where we want to be able to assign different touch ids to individual words (and those can span more than one line and in general have non-rectangular structure). This diff adds TextNodeRegion which inserts additional markers into text Layout to allow individual words to have unique react tags. Reviewed By: ahmedre Differential Revision: D2757387
This commit is contained in:
committed by
Ahmed El-Helw
parent
85cdfcd1f7
commit
381bf1b76f
@@ -18,17 +18,9 @@ import com.facebook.react.uimanager.ReactShadowNode;
|
||||
*/
|
||||
/* package */ abstract class FlatTextShadowNode extends FlatShadowNode {
|
||||
|
||||
/**
|
||||
* Recursively visits FlatTextShadowNode and its children,
|
||||
* appending text to SpannableStringBuilder.
|
||||
*/
|
||||
protected abstract void collectText(SpannableStringBuilder builder);
|
||||
|
||||
/**
|
||||
* Recursively visits FlatTextShadowNode and its children,
|
||||
* applying spans to SpannableStringBuilder.
|
||||
*/
|
||||
protected abstract void applySpans(SpannableStringBuilder builder);
|
||||
// these 2 are only used between collectText() and applySpans() calls.
|
||||
private int mTextBegin;
|
||||
private int mTextEnd;
|
||||
|
||||
/**
|
||||
* Propagates changes up to RCTText without dirtying current node.
|
||||
@@ -44,4 +36,27 @@ import com.facebook.react.uimanager.ReactShadowNode;
|
||||
public boolean isVirtual() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively visits FlatTextShadowNode and its children,
|
||||
* appending text to SpannableStringBuilder.
|
||||
*/
|
||||
/* package */ final void collectText(SpannableStringBuilder builder) {
|
||||
mTextBegin = builder.length();
|
||||
performCollectText(builder);
|
||||
mTextEnd = builder.length();
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursively visits FlatTextShadowNode and its children,
|
||||
* applying spans to SpannableStringBuilder.
|
||||
*/
|
||||
/* package */ final void applySpans(SpannableStringBuilder builder) {
|
||||
if (mTextBegin != mTextEnd) {
|
||||
performApplySpans(builder, mTextBegin, mTextEnd);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void performCollectText(SpannableStringBuilder builder);
|
||||
protected abstract void performApplySpans(SpannableStringBuilder builder, int begin, int end);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user