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() |
ReactShadowNodeImpl(ReactShadowNodeImpl original) |
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 |
dirty() |
boolean |
dispatchUpdates(float absoluteX,
float absoluteY,
UIViewOperationQueue uiViewOperationQueue,
NativeViewHierarchyOptimizer nativeViewHierarchyOptimizer) |
void |
dispose() |
ReactShadowNodeImpl |
getChildAt(int i) |
int |
getChildCount() |
java.lang.String |
getHierarchyInfo() |
YogaDirection |
getLayoutDirection() |
float |
getLayoutHeight() |
float |
getLayoutWidth() |
float |
getLayoutX() |
float |
getLayoutY() |
int |
getNativeChildCount() |
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() |
ReactStylesDiffMap |
getNewProps() |
float |
getPadding(int spacingType) |
ReactShadowNodeImpl |
getParent() |
int |
getReactTag() |
ReactShadowNodeImpl |
getRootNode() |
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() |
boolean |
hasNewLayout() |
boolean |
hasUnseenUpdates() |
boolean |
hasUpdates() |
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() |
ReactShadowNodeImpl |
mutableCopy() |
ReactShadowNodeImpl |
mutableCopyWithNewChildren() |
ReactShadowNodeImpl |
mutableCopyWithNewChildrenAndProps(ReactStylesDiffMap newProps) |
ReactShadowNodeImpl |
mutableCopyWithNewProps(ReactStylesDiffMap newProps) |
void |
onAfterUpdateTransaction() |
void |
onBeforeLayout()
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 |
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 |
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 |
setRootNode(ReactShadowNodeImpl rootNode) |
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 ReactShadowNodeImpl()
public ReactShadowNodeImpl(ReactShadowNodeImpl original)
public ReactShadowNodeImpl mutableCopy()
mutableCopy
in interface ReactShadowNode<ReactShadowNodeImpl>
ReactShadowNode
public ReactShadowNodeImpl mutableCopyWithNewChildren()
mutableCopyWithNewChildren
in interface ReactShadowNode<ReactShadowNodeImpl>
public ReactShadowNodeImpl mutableCopyWithNewProps(@Nullable ReactStylesDiffMap newProps)
mutableCopyWithNewProps
in interface ReactShadowNode<ReactShadowNodeImpl>
public ReactShadowNodeImpl mutableCopyWithNewChildrenAndProps(@Nullable ReactStylesDiffMap newProps)
mutableCopyWithNewChildrenAndProps
in interface ReactShadowNode<ReactShadowNodeImpl>
public boolean isVirtual()
true
will be treated as "virtual" nodes. That is, nodes that are not
mapped into native views (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 NativeViewHierarchyManager
will not try to perform manageChildren
operation on such views. 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 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()
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>
@Nullable public ReactStylesDiffMap getNewProps()
getNewProps
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, @Nullable 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 ReactShadowNodeImpl getRootNode()
getRootNode
in interface ReactShadowNode<ReactShadowNodeImpl>
public final void setRootNode(ReactShadowNodeImpl rootNode)
setRootNode
in interface ReactShadowNode<ReactShadowNodeImpl>
public final void setViewClassName(java.lang.String viewClassName)
setViewClassName
in interface ReactShadowNode<ReactShadowNodeImpl>
@Nullable public final ReactShadowNodeImpl getParent()
getParent
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 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>
@Nullable 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 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.Object
public 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 ReactShadowNode
public void dispose()
dispose
in interface ReactShadowNode<ReactShadowNodeImpl>