public class ReactShadowNodeImpl extends java.lang.Object implements ReactShadowNode<ReactShadowNodeImpl>
YogaNode to allow that. They also help with handling
Common base subclass of YogaNode for all layout nodes for react-based view. It extends
YogaNode by adding additional capabilities.
Instances of this class receive property updates from JS via @{link UIManagerModule}.
Subclasses may use #updateShadowNode to persist some of the updated fields in the node
instance that corresponds to a particular view type.
Subclasses of ReactShadowNodeImpl should be created only from ViewManager that
corresponds to a certain type of native view. They will be updated and accessed only from JS
thread. Subclasses of ViewManager may choose to use base class ReactShadowNodeImpl or custom subclass of it if necessary.
The primary use-case for ReactShadowNodeImpl nodes is to calculate layouting. Although
this might be extended. For some examples please refer to ARTGroupYogaNode or ReactTextYogaNode.
This class allows for the native view hierarchy to not be an exact copy of the hierarchy
received from JS by keeping track of both JS children (e.g. getChildCount() and
separately native children (e.g. getNativeChildCount()). See NativeViewHierarchyOptimizer for more information.
| Constructor and Description |
|---|
ReactShadowNodeImpl() |
| Modifier and Type | Method and Description |
|---|---|
void |
addChildAt(ReactShadowNodeImpl child,
int i) |
void |
addNativeChildAt(ReactShadowNodeImpl child,
int nativeIndex)
Adds a child that the native view hierarchy will have at this index in the native view
corresponding to this node.
|
void |
calculateLayout() |
void |
calculateLayout(float width,
float height) |
java.lang.Iterable<? extends ReactShadowNode> |
calculateLayoutOnChildren() |
void |
dirty() |
boolean |
dispatchUpdates(float absoluteX,
float absoluteY,
UIViewOperationQueue uiViewOperationQueue,
NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer) |
void |
dispose() |
ReactShadowNodeImpl |
getChildAt(int i) |
int |
getChildCount() |
java.lang.Integer |
getHeightMeasureSpec() |
java.lang.String |
getHierarchyInfo() |
YogaDirection |
getLayoutDirection() |
float |
getLayoutHeight() |
ReactShadowNodeImpl |
getLayoutParent() |
float |
getLayoutWidth() |
float |
getLayoutX() |
float |
getLayoutY() |
int |
getNativeChildCount() |
NativeKind |
getNativeKind() |
int |
getNativeOffsetForChild(ReactShadowNodeImpl child)
Returns the offset within the native children owned by all layout-only nodes in the subtree
rooted at this node for the given child.
|
ReactShadowNodeImpl |
getNativeParent() |
float |
getPadding(int spacingType) |
ReactShadowNodeImpl |
getParent() |
int |
getReactTag() |
int |
getRootTag() |
int |
getScreenHeight() |
int |
getScreenWidth() |
int |
getScreenX() |
int |
getScreenY() |
YogaValue |
getStyleHeight() |
YogaValue |
getStylePadding(int spacingType) |
YogaValue |
getStyleWidth() |
ThemedReactContext |
getThemedContext()
Get the
ThemedReactContext associated with this ReactShadowNodeImpl. |
int |
getTotalNativeChildren() |
java.lang.String |
getViewClass() |
java.lang.Integer |
getWidthMeasureSpec() |
boolean |
hasNewLayout() |
boolean |
hasUnseenUpdates() |
boolean |
hasUpdates() |
boolean |
hoistNativeChildren()
When constructing the native tree, nodes that return
true will be treated as leaves. |
int |
indexOf(ReactShadowNodeImpl child) |
int |
indexOfNativeChild(ReactShadowNodeImpl nativeChild) |
boolean |
isDescendantOf(ReactShadowNodeImpl ancestorNode) |
boolean |
isDirty() |
boolean |
isLayoutOnly() |
boolean |
isMeasureDefined() |
boolean |
isVirtual()
Nodes that return
true will be treated as "virtual" nodes. |
boolean |
isVirtualAnchor()
Nodes that return
true will be treated as a root view for the virtual nodes tree. |
boolean |
isYogaLeafNode()
Nodes that return
true will not manage (and and remove) child Yoga nodes. |
void |
markLayoutSeen() |
void |
markUpdated() |
void |
markUpdateSeen() |
void |
onAfterUpdateTransaction() |
void |
onBeforeLayout(NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer)
This method will be called by
UIManagerModule once per batch, before calculating
layout. |
void |
onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue)
Called after layout step at the end of the UI batch from
UIManagerModule. |
void |
removeAllNativeChildren() |
void |
removeAndDisposeAllChildren() |
ReactShadowNodeImpl |
removeChildAt(int i) |
ReactShadowNodeImpl |
removeNativeChildAt(int i) |
void |
setAlignContent(YogaAlign alignContent) |
void |
setAlignItems(YogaAlign alignItems) |
void |
setAlignSelf(YogaAlign alignSelf) |
void |
setBaselineFunction(YogaBaselineFunction baselineFunction) |
void |
setBorder(int spacingType,
float borderWidth) |
void |
setDefaultPadding(int spacingType,
float padding) |
void |
setDisplay(YogaDisplay display) |
void |
setFlex(float flex) |
void |
setFlexBasis(float flexBasis) |
void |
setFlexBasisAuto() |
void |
setFlexBasisPercent(float percent) |
void |
setFlexDirection(YogaFlexDirection flexDirection) |
void |
setFlexGrow(float flexGrow) |
void |
setFlexShrink(float flexShrink) |
void |
setFlexWrap(YogaWrap wrap) |
void |
setIsLayoutOnly(boolean isLayoutOnly)
Sets whether this node only contributes to the layout of its children without doing any drawing
or functionality itself.
|
void |
setJustifyContent(YogaJustify justifyContent) |
void |
setLayoutDirection(YogaDirection direction) |
void |
setLayoutParent(ReactShadowNodeImpl layoutParent) |
void |
setLocalData(java.lang.Object data) |
void |
setMargin(int spacingType,
float margin) |
void |
setMarginAuto(int spacingType) |
void |
setMarginPercent(int spacingType,
float percent) |
void |
setMeasureFunction(YogaMeasureFunction measureFunction) |
void |
setMeasureSpecs(int widthMeasureSpec,
int heightMeasureSpec) |
void |
setOverflow(YogaOverflow overflow) |
void |
setPadding(int spacingType,
float padding) |
void |
setPaddingPercent(int spacingType,
float percent) |
void |
setPosition(int spacingType,
float position) |
void |
setPositionPercent(int spacingType,
float percent) |
void |
setPositionType(YogaPositionType positionType) |
void |
setReactTag(int reactTag) |
void |
setRootTag(int rootTag) |
void |
setShouldNotifyOnLayout(boolean shouldNotifyOnLayout) |
void |
setStyleAspectRatio(float aspectRatio) |
void |
setStyleHeight(float heightPx) |
void |
setStyleHeightAuto() |
void |
setStyleHeightPercent(float percent) |
void |
setStyleMaxHeight(float widthPx) |
void |
setStyleMaxHeightPercent(float percent) |
void |
setStyleMaxWidth(float widthPx) |
void |
setStyleMaxWidthPercent(float percent) |
void |
setStyleMinHeight(float widthPx) |
void |
setStyleMinHeightPercent(float percent) |
void |
setStyleMinWidth(float widthPx) |
void |
setStyleMinWidthPercent(float percent) |
void |
setStyleWidth(float widthPx) |
void |
setStyleWidthAuto() |
void |
setStyleWidthPercent(float percent) |
void |
setThemedContext(ThemedReactContext themedContext) |
void |
setViewClassName(java.lang.String viewClassName) |
boolean |
shouldNotifyOnLayout() |
java.lang.String |
toString() |
void |
updateProperties(ReactStylesDiffMap props) |
public boolean isVirtual()
true will be treated as "virtual" nodes. That is, nodes that are not
mapped into native views or Yoga nodes (e.g. nested text node). By default this method returns
false.isVirtual in interface ReactShadowNode<ReactShadowNodeImpl>public boolean isVirtualAnchor()
true will be treated as a root view for the virtual nodes tree. It
means that all of its descendants will be "virtual" nodes. Good example is InputText
view that may have children Text nodes but this whole hierarchy will be mapped to a
single android EditText view.isVirtualAnchor in interface ReactShadowNode<ReactShadowNodeImpl>public boolean isYogaLeafNode()
true will not manage (and and remove) child Yoga nodes. For example
ReactTextInputShadowNode or ReactTextShadowNode have child nodes, which do not
want Yoga to lay out, so in the eyes of Yoga it is a leaf node. Override this method in
subclass to enforce this requirement.isYogaLeafNode in interface ReactShadowNode<ReactShadowNodeImpl>public boolean hoistNativeChildren()
true will be treated as leaves.
Instead of adding this view's native children as subviews of it, they will be added as subviews
of an ancestor. In other words, this view wants to support native children but it cannot host
them itself (e.g. it isn't a ViewGroup).hoistNativeChildren in interface ReactShadowNode<ReactShadowNodeImpl>public final java.lang.String getViewClass()
getViewClass in interface ReactShadowNode<ReactShadowNodeImpl>public final boolean hasUpdates()
hasUpdates in interface ReactShadowNode<ReactShadowNodeImpl>public final void markUpdateSeen()
markUpdateSeen in interface ReactShadowNode<ReactShadowNodeImpl>public void markUpdated()
markUpdated in interface ReactShadowNode<ReactShadowNodeImpl>public final boolean hasUnseenUpdates()
hasUnseenUpdates in interface ReactShadowNode<ReactShadowNodeImpl>public void dirty()
dirty in interface ReactShadowNode<ReactShadowNodeImpl>public final boolean isDirty()
isDirty in interface ReactShadowNode<ReactShadowNodeImpl>public void addChildAt(ReactShadowNodeImpl child, int i)
addChildAt in interface ReactShadowNode<ReactShadowNodeImpl>public ReactShadowNodeImpl removeChildAt(int i)
removeChildAt in interface ReactShadowNode<ReactShadowNodeImpl>public final int getChildCount()
getChildCount in interface ReactShadowNode<ReactShadowNodeImpl>public final ReactShadowNodeImpl getChildAt(int i)
getChildAt in interface ReactShadowNode<ReactShadowNodeImpl>public final int indexOf(ReactShadowNodeImpl child)
indexOf in interface ReactShadowNode<ReactShadowNodeImpl>public void removeAndDisposeAllChildren()
removeAndDisposeAllChildren in interface ReactShadowNode<ReactShadowNodeImpl>public void onBeforeLayout(NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer)
UIManagerModule once per batch, before calculating
layout. Will be only called for nodes that are marked as updated with markUpdated() or
require layouting (marked with dirty()).onBeforeLayout in interface ReactShadowNode<ReactShadowNodeImpl>public final void updateProperties(ReactStylesDiffMap props)
updateProperties in interface ReactShadowNode<ReactShadowNodeImpl>public void onAfterUpdateTransaction()
onAfterUpdateTransaction in interface ReactShadowNode<ReactShadowNodeImpl>public void onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue)
UIManagerModule. May be used
to enqueue additional ui operations for the native view. Will only be called on nodes marked as
updated either with dirty() or markUpdated().onCollectExtraUpdates in interface ReactShadowNode<ReactShadowNodeImpl>uiViewOperationQueue - interface for enqueueing UI operationspublic boolean dispatchUpdates(float absoluteX,
float absoluteY,
UIViewOperationQueue uiViewOperationQueue,
NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer)
dispatchUpdates in interface ReactShadowNode<ReactShadowNodeImpl>public final int getReactTag()
getReactTag in interface ReactShadowNode<ReactShadowNodeImpl>public void setReactTag(int reactTag)
setReactTag in interface ReactShadowNode<ReactShadowNodeImpl>public final int getRootTag()
getRootTag in interface ReactShadowNode<ReactShadowNodeImpl>public final void setRootTag(int rootTag)
setRootTag in interface ReactShadowNode<ReactShadowNodeImpl>public final void setViewClassName(java.lang.String viewClassName)
setViewClassName in interface ReactShadowNode<ReactShadowNodeImpl>public final ReactShadowNodeImpl getParent()
getParent in interface ReactShadowNode<ReactShadowNodeImpl>public final ReactShadowNodeImpl getLayoutParent()
getLayoutParent in interface ReactShadowNode<ReactShadowNodeImpl>public final void setLayoutParent(ReactShadowNodeImpl layoutParent)
setLayoutParent in interface ReactShadowNode<ReactShadowNodeImpl>public final ThemedReactContext getThemedContext()
ThemedReactContext associated with this ReactShadowNodeImpl. This will
never change during the lifetime of a ReactShadowNodeImpl instance, but different
instances can have different contexts; don't cache any calculations based on theme values
globally.getThemedContext in interface ReactShadowNode<ReactShadowNodeImpl>public void setThemedContext(ThemedReactContext themedContext)
setThemedContext in interface ReactShadowNode<ReactShadowNodeImpl>public final boolean shouldNotifyOnLayout()
shouldNotifyOnLayout in interface ReactShadowNode<ReactShadowNodeImpl>public void calculateLayout()
calculateLayout in interface ReactShadowNode<ReactShadowNodeImpl>public void calculateLayout(float width,
float height)
calculateLayout in interface ReactShadowNode<ReactShadowNodeImpl>public final boolean hasNewLayout()
hasNewLayout in interface ReactShadowNode<ReactShadowNodeImpl>public final void markLayoutSeen()
markLayoutSeen in interface ReactShadowNode<ReactShadowNodeImpl>public final void addNativeChildAt(ReactShadowNodeImpl child, int nativeIndex)
addNativeChildAt in interface ReactShadowNode<ReactShadowNodeImpl>public final ReactShadowNodeImpl removeNativeChildAt(int i)
removeNativeChildAt in interface ReactShadowNode<ReactShadowNodeImpl>public final void removeAllNativeChildren()
removeAllNativeChildren in interface ReactShadowNode<ReactShadowNodeImpl>public final int getNativeChildCount()
getNativeChildCount in interface ReactShadowNode<ReactShadowNodeImpl>public final int indexOfNativeChild(ReactShadowNodeImpl nativeChild)
indexOfNativeChild in interface ReactShadowNode<ReactShadowNodeImpl>public final ReactShadowNodeImpl getNativeParent()
getNativeParent in interface ReactShadowNode<ReactShadowNodeImpl>public final void setIsLayoutOnly(boolean isLayoutOnly)
setIsLayoutOnly in interface ReactShadowNode<ReactShadowNodeImpl>public final boolean isLayoutOnly()
isLayoutOnly in interface ReactShadowNode<ReactShadowNodeImpl>public NativeKind getNativeKind()
getNativeKind in interface ReactShadowNode<ReactShadowNodeImpl>public final int getTotalNativeChildren()
getTotalNativeChildren in interface ReactShadowNode<ReactShadowNodeImpl>public boolean isDescendantOf(ReactShadowNodeImpl ancestorNode)
isDescendantOf in interface ReactShadowNode<ReactShadowNodeImpl>public java.lang.String toString()
toString in class java.lang.Objectpublic void setLocalData(java.lang.Object data)
setLocalData in interface ReactShadowNode<ReactShadowNodeImpl>public final int getNativeOffsetForChild(ReactShadowNodeImpl child)
Basically, a view might have children that have been optimized away by NativeViewHierarchyOptimizer. Since those children will then add their native children to this
view, we now have ranges of native children that correspond to single unoptimized children. The
purpose of this method is to return the index within the native children that corresponds to
the **start** of the native children that belong to the given child. Also, note that all of the
children of a view might be optimized away, so this could return the same value for multiple
different children.
Example. Native children are represented by (N) where N is the no-opt child they came from. If no children are optimized away it'd look like this: (0) (1) (2) (3) ... (n)
In case some children are optimized away, it might look like this: (0) (1) (1) (1) (3) (3) (4)
In that case: getNativeOffsetForChild(Node 0) => 0 getNativeOffsetForChild(Node 1) => 1 getNativeOffsetForChild(Node 2) => 4 getNativeOffsetForChild(Node 3) => 4
getNativeOffsetForChild(Node 4) => 6
getNativeOffsetForChild in interface ReactShadowNode<ReactShadowNodeImpl>public final float getLayoutX()
getLayoutX in interface ReactShadowNode<ReactShadowNodeImpl>public final float getLayoutY()
getLayoutY in interface ReactShadowNode<ReactShadowNodeImpl>public final float getLayoutWidth()
getLayoutWidth in interface ReactShadowNode<ReactShadowNodeImpl>public final float getLayoutHeight()
getLayoutHeight in interface ReactShadowNode<ReactShadowNodeImpl>public int getScreenX()
getScreenX in interface ReactShadowNode<ReactShadowNodeImpl>public int getScreenY()
getScreenY in interface ReactShadowNode<ReactShadowNodeImpl>public int getScreenWidth()
getScreenWidth in interface ReactShadowNode<ReactShadowNodeImpl>public int getScreenHeight()
getScreenHeight in interface ReactShadowNode<ReactShadowNodeImpl>public final YogaDirection getLayoutDirection()
getLayoutDirection in interface ReactShadowNode<ReactShadowNodeImpl>public void setLayoutDirection(YogaDirection direction)
setLayoutDirection in interface ReactShadowNode<ReactShadowNodeImpl>public final YogaValue getStyleWidth()
getStyleWidth in interface ReactShadowNode<ReactShadowNodeImpl>public void setStyleWidth(float widthPx)
setStyleWidth in interface ReactShadowNode<ReactShadowNodeImpl>public void setStyleWidthPercent(float percent)
setStyleWidthPercent in interface ReactShadowNode<ReactShadowNodeImpl>public void setStyleWidthAuto()
setStyleWidthAuto in interface ReactShadowNode<ReactShadowNodeImpl>public void setStyleMinWidth(float widthPx)
setStyleMinWidth in interface ReactShadowNode<ReactShadowNodeImpl>public void setStyleMinWidthPercent(float percent)
setStyleMinWidthPercent in interface ReactShadowNode<ReactShadowNodeImpl>public void setStyleMaxWidth(float widthPx)
setStyleMaxWidth in interface ReactShadowNode<ReactShadowNodeImpl>public void setStyleMaxWidthPercent(float percent)
setStyleMaxWidthPercent in interface ReactShadowNode<ReactShadowNodeImpl>public final YogaValue getStyleHeight()
getStyleHeight in interface ReactShadowNode<ReactShadowNodeImpl>public void setStyleHeight(float heightPx)
setStyleHeight in interface ReactShadowNode<ReactShadowNodeImpl>public void setStyleHeightPercent(float percent)
setStyleHeightPercent in interface ReactShadowNode<ReactShadowNodeImpl>public void setStyleHeightAuto()
setStyleHeightAuto in interface ReactShadowNode<ReactShadowNodeImpl>public void setStyleMinHeight(float widthPx)
setStyleMinHeight in interface ReactShadowNode<ReactShadowNodeImpl>public void setStyleMinHeightPercent(float percent)
setStyleMinHeightPercent in interface ReactShadowNode<ReactShadowNodeImpl>public void setStyleMaxHeight(float widthPx)
setStyleMaxHeight in interface ReactShadowNode<ReactShadowNodeImpl>public void setStyleMaxHeightPercent(float percent)
setStyleMaxHeightPercent in interface ReactShadowNode<ReactShadowNodeImpl>public void setFlex(float flex)
setFlex in interface ReactShadowNode<ReactShadowNodeImpl>public void setFlexGrow(float flexGrow)
setFlexGrow in interface ReactShadowNode<ReactShadowNodeImpl>public void setFlexShrink(float flexShrink)
setFlexShrink in interface ReactShadowNode<ReactShadowNodeImpl>public void setFlexBasis(float flexBasis)
setFlexBasis in interface ReactShadowNode<ReactShadowNodeImpl>public void setFlexBasisAuto()
setFlexBasisAuto in interface ReactShadowNode<ReactShadowNodeImpl>public void setFlexBasisPercent(float percent)
setFlexBasisPercent in interface ReactShadowNode<ReactShadowNodeImpl>public void setStyleAspectRatio(float aspectRatio)
setStyleAspectRatio in interface ReactShadowNode<ReactShadowNodeImpl>public void setFlexDirection(YogaFlexDirection flexDirection)
setFlexDirection in interface ReactShadowNode<ReactShadowNodeImpl>public void setFlexWrap(YogaWrap wrap)
setFlexWrap in interface ReactShadowNode<ReactShadowNodeImpl>public void setAlignSelf(YogaAlign alignSelf)
setAlignSelf in interface ReactShadowNode<ReactShadowNodeImpl>public void setAlignItems(YogaAlign alignItems)
setAlignItems in interface ReactShadowNode<ReactShadowNodeImpl>public void setAlignContent(YogaAlign alignContent)
setAlignContent in interface ReactShadowNode<ReactShadowNodeImpl>public void setJustifyContent(YogaJustify justifyContent)
setJustifyContent in interface ReactShadowNode<ReactShadowNodeImpl>public void setOverflow(YogaOverflow overflow)
setOverflow in interface ReactShadowNode<ReactShadowNodeImpl>public void setDisplay(YogaDisplay display)
setDisplay in interface ReactShadowNode<ReactShadowNodeImpl>public void setMargin(int spacingType,
float margin)
setMargin in interface ReactShadowNode<ReactShadowNodeImpl>public void setMarginPercent(int spacingType,
float percent)
setMarginPercent in interface ReactShadowNode<ReactShadowNodeImpl>public void setMarginAuto(int spacingType)
setMarginAuto in interface ReactShadowNode<ReactShadowNodeImpl>public final float getPadding(int spacingType)
getPadding in interface ReactShadowNode<ReactShadowNodeImpl>public final YogaValue getStylePadding(int spacingType)
getStylePadding in interface ReactShadowNode<ReactShadowNodeImpl>public void setDefaultPadding(int spacingType,
float padding)
setDefaultPadding in interface ReactShadowNode<ReactShadowNodeImpl>public void setPadding(int spacingType,
float padding)
setPadding in interface ReactShadowNode<ReactShadowNodeImpl>public void setPaddingPercent(int spacingType,
float percent)
setPaddingPercent in interface ReactShadowNode<ReactShadowNodeImpl>public void setBorder(int spacingType,
float borderWidth)
setBorder in interface ReactShadowNode<ReactShadowNodeImpl>public void setPosition(int spacingType,
float position)
setPosition in interface ReactShadowNode<ReactShadowNodeImpl>public void setPositionPercent(int spacingType,
float percent)
setPositionPercent in interface ReactShadowNode<ReactShadowNodeImpl>public void setPositionType(YogaPositionType positionType)
setPositionType in interface ReactShadowNode<ReactShadowNodeImpl>public void setShouldNotifyOnLayout(boolean shouldNotifyOnLayout)
setShouldNotifyOnLayout in interface ReactShadowNode<ReactShadowNodeImpl>public void setBaselineFunction(YogaBaselineFunction baselineFunction)
setBaselineFunction in interface ReactShadowNode<ReactShadowNodeImpl>public void setMeasureFunction(YogaMeasureFunction measureFunction)
setMeasureFunction in interface ReactShadowNode<ReactShadowNodeImpl>public boolean isMeasureDefined()
isMeasureDefined in interface ReactShadowNode<ReactShadowNodeImpl>public java.lang.String getHierarchyInfo()
getHierarchyInfo in interface ReactShadowNode<ReactShadowNodeImpl>String representation of the Yoga hierarchy of this ReactShadowNodepublic void dispose()
dispose in interface ReactShadowNode<ReactShadowNodeImpl>public void setMeasureSpecs(int widthMeasureSpec,
int heightMeasureSpec)
setMeasureSpecs in interface ReactShadowNode<ReactShadowNodeImpl>public java.lang.Integer getWidthMeasureSpec()
getWidthMeasureSpec in interface ReactShadowNode<ReactShadowNodeImpl>public java.lang.Integer getHeightMeasureSpec()
getHeightMeasureSpec in interface ReactShadowNode<ReactShadowNodeImpl>public java.lang.Iterable<? extends ReactShadowNode> calculateLayoutOnChildren()
calculateLayoutOnChildren in interface ReactShadowNode<ReactShadowNodeImpl>