Cache textRoot for getTextRootGlyphContext.

Use getTextRootGlyphContext() instead of getTextRoot().getGlyphContext() in TextShadowNode.pushGlyphContext()
This commit is contained in:
Mikael Sand
2017-07-22 03:00:15 +03:00
parent bb6ee3e430
commit b7bfaab63d
2 changed files with 6 additions and 2 deletions
@@ -29,6 +29,7 @@ class GroupShadowNode extends RenderableShadowNode {
@Nullable ReadableMap mFont; @Nullable ReadableMap mFont;
private GlyphContext mGlyphContext; private GlyphContext mGlyphContext;
private GroupShadowNode textRoot;
@ReactProp(name = "font") @ReactProp(name = "font")
public void setFont(@Nullable ReadableMap font) { public void setFont(@Nullable ReadableMap font) {
@@ -47,7 +48,10 @@ class GroupShadowNode extends RenderableShadowNode {
} }
GlyphContext getTextRootGlyphContext() { GlyphContext getTextRootGlyphContext() {
return getTextRoot().getGlyphContext(); if (textRoot == null) {
textRoot = getTextRoot();
}
return textRoot.getGlyphContext();
} }
void pushGlyphContext() { void pushGlyphContext() {
@@ -178,6 +178,6 @@ class TextShadowNode extends GroupShadowNode {
@Override @Override
void pushGlyphContext() { void pushGlyphContext() {
boolean isTextNode = !(this instanceof TextPathShadowNode) && !(this instanceof TSpanShadowNode); boolean isTextNode = !(this instanceof TextPathShadowNode) && !(this instanceof TSpanShadowNode);
getTextRoot().getGlyphContext().pushContext(this, mFont, mRotate, mDeltaX, mDeltaY, mPositionX, mPositionY, isTextNode); getTextRootGlyphContext().pushContext(this, mFont, mRotate, mDeltaX, mDeltaY, mPositionX, mPositionY, isTextNode);
} }
} }