Allow FlatShadowNode mouting to its own view

Summary: @public This diff adds a `FlatShadowNode.forceMountToView()` method that will render its contents in it own `View`.

Reviewed By: sriramramani

Differential Revision: D2564502
This commit is contained in:
Denis Koroskin
2015-12-13 15:54:52 -08:00
committed by Ahmed El-Helw
parent 7db444c9ae
commit 8de2acd3a9
12 changed files with 472 additions and 118 deletions

View File

@@ -14,35 +14,8 @@ package com.facebook.react.flat;
*/
/* package */ final class FlatRootShadowNode extends FlatShadowNode {
private DrawCommand[] mDrawCommands = DrawCommand.EMPTY_ARRAY;
private AttachDetachListener[] mAttachDetachListeners = AttachDetachListener.EMPTY_ARRAY;
private int mViewLeft;
private int mViewTop;
private int mViewRight;
private int mViewBottom;
private boolean mIsUpdated;
@Override
public int getScreenX() {
return mViewLeft;
}
@Override
public int getScreenY() {
return mViewTop;
}
@Override
public int getScreenWidth() {
return mViewRight - mViewLeft;
}
@Override
public int getScreenHeight() {
return mViewBottom - mViewTop;
}
/**
* Returns true when this CSSNode tree needs to be re-laid out. If true, FlatUIImplementation
* will request LayoutEngine to perform a layout pass to update node boundaries. This is used
@@ -66,72 +39,4 @@ package com.facebook.react.flat;
/* package */ void markUpdated(boolean isUpdated) {
mIsUpdated = isUpdated;
}
/**
* Returns an array of DrawCommands to perform during the View's draw pass.
*/
/* package */ DrawCommand[] getDrawCommands() {
return mDrawCommands;
}
/**
* Sets an array of DrawCommands to perform during the View's draw pass. StateBuilder uses old
* draw commands to compare to new draw commands and see if the View neds to be redrawn.
*/
/* package */ void setDrawCommands(DrawCommand[] drawCommands) {
mDrawCommands = drawCommands;
}
/**
* Sets an array of AttachDetachListeners to call onAttach/onDetach when they are attached to or
* detached from a View that this shadow node maps to.
*/
/* package */ void setAttachDetachListeners(AttachDetachListener[] listeners) {
mAttachDetachListeners = listeners;
}
/**
* Returns an array of AttachDetachListeners associated with this shadow node.
*/
/* package */ AttachDetachListener[] getAttachDetachListeners() {
return mAttachDetachListeners;
}
/**
* Sets boundaries of the View that this node maps to relative to the parent left/top coordinate.
*/
/* package */ void setViewBounds(int left, int top, int right, int bottom) {
mViewLeft = left;
mViewTop = top;
mViewRight = right;
mViewBottom = bottom;
}
/**
* Left position of the View this node maps to relative to the parent View.
*/
/* package */ int getViewLeft() {
return mViewLeft;
}
/**
* Top position of the View this node maps to relative to the parent View.
*/
/* package */ int getViewTop() {
return mViewTop;
}
/**
* Right position of the View this node maps to relative to the parent View.
*/
/* package */ int getViewRight() {
return mViewRight;
}
/**
* Bottom position of the View this node maps to relative to the parent View.
*/
/* package */ int getViewBottom() {
return mViewBottom;
}
}