mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-08 17:46:35 +08: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
@@ -174,6 +174,28 @@ import com.facebook.react.uimanager.ViewProps;
|
||||
notifyChanged(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
/* package */ void updateNodeRegion(float left, float top, float right, float bottom) {
|
||||
if (mDrawCommand == null) {
|
||||
super.updateNodeRegion(left, top, right, bottom);
|
||||
return;
|
||||
}
|
||||
|
||||
NodeRegion nodeRegion = getNodeRegion();
|
||||
Layout layout = null;
|
||||
|
||||
if (nodeRegion instanceof TextNodeRegion) {
|
||||
layout = ((TextNodeRegion) nodeRegion).getLayout();
|
||||
}
|
||||
|
||||
Layout newLayout = mDrawCommand.getLayout();
|
||||
if (nodeRegion.mLeft != left || nodeRegion.mTop != top ||
|
||||
nodeRegion.mRight != right || nodeRegion.mBottom != bottom ||
|
||||
layout != newLayout) {
|
||||
setNodeRegion(new TextNodeRegion(left, top, right, bottom, getReactTag(), newLayout));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getDefaultFontSize() {
|
||||
// top-level <Text /> should always specify font size.
|
||||
|
||||
Reference in New Issue
Block a user