mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-08 01:00:43 +00:00
Prevent unexpected crash from getComputedTextAnchor
This commit is contained in:
@@ -33,9 +33,6 @@ import com.facebook.react.uimanager.annotations.ReactProp;
|
|||||||
|
|
||||||
public class TextShadowNode extends GroupShadowNode {
|
public class TextShadowNode extends GroupShadowNode {
|
||||||
|
|
||||||
private float mOffsetX = 0;
|
|
||||||
private float mOffsetY = 0;
|
|
||||||
|
|
||||||
private static final int TEXT_ANCHOR_AUTO = 0;
|
private static final int TEXT_ANCHOR_AUTO = 0;
|
||||||
private static final int TEXT_ANCHOR_START = 1;
|
private static final int TEXT_ANCHOR_START = 1;
|
||||||
private static final int TEXT_ANCHOR_MIDDLE = 2;
|
private static final int TEXT_ANCHOR_MIDDLE = 2;
|
||||||
@@ -117,25 +114,28 @@ public class TextShadowNode extends GroupShadowNode {
|
|||||||
popGlyphContext();
|
popGlyphContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTextAnchor() {
|
private int getTextAnchor() {
|
||||||
return mTextAnchor;
|
return mTextAnchor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getComputedTextAnchor() {
|
private int getComputedTextAnchor() {
|
||||||
int anchor = mTextAnchor;
|
int anchor = mTextAnchor;
|
||||||
|
ReactShadowNode shadowNode = this;
|
||||||
|
|
||||||
if (getChildCount() > 0) {
|
while (shadowNode.getChildCount() > 0 &&
|
||||||
TextShadowNode child = (TextShadowNode)getChildAt(0);
|
anchor == TEXT_ANCHOR_AUTO) {
|
||||||
|
shadowNode = shadowNode.getChildAt(0);
|
||||||
|
|
||||||
while (child.getChildCount() > 0 && anchor == TEXT_ANCHOR_AUTO) {
|
if (shadowNode instanceof TextShadowNode) {
|
||||||
anchor = child.getTextAnchor();
|
anchor = ((TextShadowNode) shadowNode).getTextAnchor();
|
||||||
child = (TextShadowNode)child.getChildAt(0);
|
} else {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return anchor;
|
return anchor;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TextShadowNode getTextRoot() {
|
private TextShadowNode getTextRoot() {
|
||||||
if (mTextRoot == null) {
|
if (mTextRoot == null) {
|
||||||
mTextRoot = this;
|
mTextRoot = this;
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ public class TextShadowNode extends GroupShadowNode {
|
|||||||
return mTextRoot;
|
return mTextRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupGlyphContext() {
|
private void setupGlyphContext() {
|
||||||
mGlyphContext = new GlyphContext(mScale, getCanvasWidth(), getCanvasHeight());
|
mGlyphContext = new GlyphContext(mScale, getCanvasWidth(), getCanvasHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user