Rename java API

Reviewed By: IanChilds

Differential Revision: D4265345

fbshipit-source-id: 69ecfd8fac214f86b8b70647b9b909acd83d78b5
This commit is contained in:
Emil Sjolander 2016-12-03 04:40:23 -08:00 committed by Facebook Github Bot
parent 85ac5fc354
commit b9cedaefa6
16 changed files with 173 additions and 154 deletions

View File

@ -12,11 +12,11 @@ package com.facebook.csslayout;
import com.facebook.proguard.annotations.DoNotStrip;
/**
* Inteface for recieving logs from native layer. Use by setting CSSNode.setLogger(myLogger);
* Inteface for recieving logs from native layer. Use by setting YogaNode.setLogger(myLogger);
* See YogaLogLevel for the different log levels.
*/
@DoNotStrip
public interface CSSLogger {
public interface YogaLogger {
@DoNotStrip
void log(YogaLogLevel level, String message);
}

View File

@ -0,0 +1,26 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
package com.facebook.csslayout;
import com.facebook.proguard.annotations.DoNotStrip;
@DoNotStrip
public interface YogaMeasureFunction {
/**
* Return a value created by YogaMeasureOutput.make(width, height);
*/
@DoNotStrip
long measure(
YogaNodeAPI node,
float width,
YogaMeasureMode widthMode,
float height,
YogaMeasureMode heightMode);
}

View File

@ -12,7 +12,7 @@ package com.facebook.csslayout;
/**
* Helpers for building measure output value.
*/
public class MeasureOutput {
public class YogaMeasureOutput {
public static long make(float width, float height) {
return make((int) width, (int) height);

View File

@ -18,10 +18,10 @@ import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.soloader.SoLoader;
@DoNotStrip
public class CSSNode implements CSSNodeAPI<CSSNode> {
public class YogaNode implements YogaNodeAPI<YogaNode> {
static {
SoLoader.loadLibrary("csslayout");
SoLoader.loadLibrary("yoga");
}
/**
@ -31,7 +31,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
static native void jni_YGLog(int level, String message);
private static native void jni_YGSetLogger(Object logger);
public static void setLogger(CSSLogger logger) {
public static void setLogger(YogaLogger logger) {
jni_YGSetLogger(logger);
}
@ -49,9 +49,9 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
return jni_YGIsExperimentalFeatureEnabled(feature.intValue());
}
private CSSNode mParent;
private List<CSSNode> mChildren;
private MeasureFunction mMeasureFunction;
private YogaNode mParent;
private List<YogaNode> mChildren;
private YogaMeasureFunction mMeasureFunction;
private long mNativePointer;
private Object mData;
@ -72,7 +72,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
private int mLayoutDirection = 0;
private native long jni_YGNodeNew();
public CSSNode() {
public YogaNode() {
mNativePointer = jni_YGNodeNew();
if (mNativePointer == 0) {
throw new IllegalStateException("Failed to allocate native memory");
@ -115,13 +115,13 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
}
@Override
public CSSNode getChildAt(int i) {
public YogaNode getChildAt(int i) {
return mChildren.get(i);
}
private native void jni_YGNodeInsertChild(long nativePointer, long childPointer, int index);
@Override
public void addChildAt(CSSNode child, int i) {
public void addChildAt(YogaNode child, int i) {
if (child.mParent != null) {
throw new IllegalStateException("Child already has a parent, it must be removed first.");
}
@ -136,9 +136,9 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
private native void jni_YGNodeRemoveChild(long nativePointer, long childPointer);
@Override
public CSSNode removeChildAt(int i) {
public YogaNode removeChildAt(int i) {
final CSSNode child = mChildren.remove(i);
final YogaNode child = mChildren.remove(i);
child.mParent = null;
jni_YGNodeRemoveChild(mNativePointer, child.mNativePointer);
return child;
@ -146,12 +146,12 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
@Override
public @Nullable
CSSNode getParent() {
YogaNode getParent() {
return mParent;
}
@Override
public int indexOf(CSSNode child) {
public int indexOf(YogaNode child) {
return mChildren == null ? -1 : mChildren.indexOf(child);
}
@ -187,7 +187,7 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
private native void jni_YGNodeCopyStyle(long dstNativePointer, long srcNativePointer);
@Override
public void copyStyle(CSSNode srcNode) {
public void copyStyle(YogaNode srcNode) {
jni_YGNodeCopyStyle(mNativePointer, srcNode.mNativePointer);
}
@ -508,14 +508,14 @@ public class CSSNode implements CSSNodeAPI<CSSNode> {
private native void jni_YGNodeSetHasMeasureFunc(long nativePointer, boolean hasMeasureFunc);
@Override
public void setMeasureFunction(MeasureFunction measureFunction) {
public void setMeasureFunction(YogaMeasureFunction measureFunction) {
mMeasureFunction = measureFunction;
jni_YGNodeSetHasMeasureFunc(mNativePointer, measureFunction != null);
}
// Implementation Note: Why this method needs to stay final
//
// We cache the jmethodid for this method in CSSLayout code. This means that even if a subclass
// We cache the jmethodid for this method in Yoga code. This means that even if a subclass
// were to override measure, we'd still call this implementation from layout code since the
// overriding method will have a different jmethodid. This is final to prevent that mistake.
@DoNotStrip

View File

@ -9,34 +9,22 @@
package com.facebook.csslayout;
public interface CSSNodeAPI<CSSNodeType extends CSSNodeAPI> {
interface MeasureFunction {
/**
* Return a value created by MeasureOutput.make(width, height);
*/
long measure(
CSSNodeAPI node,
float width,
YogaMeasureMode widthMode,
float height,
YogaMeasureMode heightMode);
}
// This only exists for legacy reasons. It will be removed sometime in the near future.
public interface YogaNodeAPI<YogaNodeType extends YogaNodeAPI> {
int getChildCount();
CSSNodeType getChildAt(int i);
void addChildAt(CSSNodeType child, int i);
CSSNodeType removeChildAt(int i);
CSSNodeType getParent();
int indexOf(CSSNodeType child);
void setMeasureFunction(MeasureFunction measureFunction);
YogaNodeType getChildAt(int i);
void addChildAt(YogaNodeType child, int i);
YogaNodeType removeChildAt(int i);
YogaNodeType getParent();
int indexOf(YogaNodeType child);
void setMeasureFunction(YogaMeasureFunction measureFunction);
boolean isMeasureDefined();
void calculateLayout();
boolean isDirty();
boolean hasNewLayout();
void dirty();
void markLayoutSeen();
void copyStyle(CSSNodeType srcNode);
void copyStyle(YogaNodeType srcNode);
YogaDirection getStyleDirection();
void setDirection(YogaDirection direction);
YogaFlexDirection getFlexDirection();

View File

@ -19,8 +19,8 @@ import com.facebook.csslayout.YogaConstants;
import com.facebook.csslayout.YogaDirection;
import com.facebook.csslayout.YogaFlexDirection;
import com.facebook.csslayout.YogaJustify;
import com.facebook.csslayout.CSSNode;
import com.facebook.csslayout.CSSNodeAPI;
import com.facebook.csslayout.YogaMeasureFunction;
import com.facebook.csslayout.YogaNode;
import com.facebook.csslayout.YogaOverflow;
import com.facebook.csslayout.YogaPositionType;
import com.facebook.csslayout.YogaWrap;
@ -29,9 +29,9 @@ import com.facebook.react.uimanager.annotations.ReactPropertyHolder;
/**
* Base node class for representing virtual tree of React nodes. Shadow nodes are used primarily
* for layouting therefore it extends {@link CSSNode} to allow that. They also help with handling
* Common base subclass of {@link CSSNode} for all layout nodes for react-based view. It extends
* {@link CSSNode} by adding additional capabilities.
* for layouting therefore it extends {@link YogaNode} to allow that. They also help with handling
* Common base subclass of {@link YogaNode} for all layout nodes for react-based view. It extends
* {@link YogaNode} by adding additional capabilities.
*
* Instances of this class receive property updates from JS via @{link UIManagerModule}. Subclasses
* may use {@link #updateShadowNode} to persist some of the updated fields in the node instance that
@ -43,7 +43,7 @@ import com.facebook.react.uimanager.annotations.ReactPropertyHolder;
* custom subclass of it if necessary.
*
* The primary use-case for {@link ReactShadowNode} nodes is to calculate layouting. Although this
* might be extended. For some examples please refer to ARTGroupCSSNode or ReactTextCSSNode.
* 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. {@link #getChildCount()} and separately native
@ -73,17 +73,17 @@ public class ReactShadowNode {
private float mAbsoluteBottom;
private final Spacing mDefaultPadding = new Spacing(0);
private final Spacing mPadding = new Spacing(YogaConstants.UNDEFINED);
private final CSSNode mCSSNode;
private final YogaNode mYogaNode;
public ReactShadowNode() {
if (!isVirtual()) {
CSSNode node = CSSNodePool.get().acquire();
YogaNode node = YogaNodePool.get().acquire();
if (node == null) {
node = new CSSNode();
node = new YogaNode();
}
mCSSNode = node;
mYogaNode = node;
} else {
mCSSNode = null;
mYogaNode = null;
}
}
@ -138,12 +138,12 @@ public class ReactShadowNode {
public void dirty() {
if (!isVirtual()) {
mCSSNode.dirty();
mYogaNode.dirty();
}
}
public final boolean isDirty() {
return mCSSNode != null && mCSSNode.isDirty();
return mYogaNode != null && mYogaNode.isDirty();
}
public void addChildAt(ReactShadowNode child, int i) {
@ -159,13 +159,13 @@ public class ReactShadowNode {
// If a CSS node has measure defined, the layout algorithm will not visit its children. Even
// more, it asserts that you don't add children to nodes with measure functions.
if (mCSSNode != null && !mCSSNode.isMeasureDefined()) {
CSSNode childCSSNode = child.mCSSNode;
if (childCSSNode == null) {
if (mYogaNode != null && !mYogaNode.isMeasureDefined()) {
YogaNode childYogaNode = child.mYogaNode;
if (childYogaNode == null) {
throw new RuntimeException(
"Cannot add a child that doesn't have a CSS node to a node without a measure function!");
}
mCSSNode.addChildAt(childCSSNode, i);
mYogaNode.addChildAt(childYogaNode, i);
}
markUpdated();
@ -183,8 +183,8 @@ public class ReactShadowNode {
ReactShadowNode removed = mChildren.remove(i);
removed.mParent = null;
if (mCSSNode != null && !mCSSNode.isMeasureDefined()) {
mCSSNode.removeChildAt(i);
if (mYogaNode != null && !mYogaNode.isMeasureDefined()) {
mYogaNode.removeChildAt(i);
}
markUpdated();
@ -217,8 +217,8 @@ public class ReactShadowNode {
int decrease = 0;
for (int i = getChildCount() - 1; i >= 0; i--) {
if (mCSSNode != null && !mCSSNode.isMeasureDefined()) {
mCSSNode.removeChildAt(i);
if (mYogaNode != null && !mYogaNode.isMeasureDefined()) {
mYogaNode.removeChildAt(i);
}
ReactShadowNode toRemove = getChildAt(i);
toRemove.mParent = null;
@ -339,16 +339,16 @@ public class ReactShadowNode {
}
public void calculateLayout() {
mCSSNode.calculateLayout();
mYogaNode.calculateLayout();
}
public final boolean hasNewLayout() {
return mCSSNode == null ? false : mCSSNode.hasNewLayout();
return mYogaNode == null ? false : mYogaNode.hasNewLayout();
}
public final void markLayoutSeen() {
if (mCSSNode != null) {
mCSSNode.markLayoutSeen();
if (mYogaNode != null) {
mYogaNode.markLayoutSeen();
}
}
@ -463,19 +463,19 @@ public class ReactShadowNode {
}
public final float getLayoutX() {
return mCSSNode.getLayoutX();
return mYogaNode.getLayoutX();
}
public final float getLayoutY() {
return mCSSNode.getLayoutY();
return mYogaNode.getLayoutY();
}
public final float getLayoutWidth() {
return mCSSNode.getLayoutWidth();
return mYogaNode.getLayoutWidth();
}
public final float getLayoutHeight() {
return mCSSNode.getLayoutHeight();
return mYogaNode.getLayoutHeight();
}
/**
@ -507,95 +507,95 @@ public class ReactShadowNode {
}
public final YogaDirection getLayoutDirection() {
return mCSSNode.getLayoutDirection();
return mYogaNode.getLayoutDirection();
}
public void setLayoutDirection(YogaDirection direction) {
mCSSNode.setDirection(direction);
mYogaNode.setDirection(direction);
}
public final float getStyleWidth() {
return mCSSNode.getWidth();
return mYogaNode.getWidth();
}
public void setStyleWidth(float widthPx) {
mCSSNode.setWidth(widthPx);
mYogaNode.setWidth(widthPx);
}
public void setStyleMinWidth(float widthPx) {
mCSSNode.setMinWidth(widthPx);
mYogaNode.setMinWidth(widthPx);
}
public void setStyleMaxWidth(float widthPx) {
mCSSNode.setMaxWidth(widthPx);
mYogaNode.setMaxWidth(widthPx);
}
public final float getStyleHeight() {
return mCSSNode.getHeight();
return mYogaNode.getHeight();
}
public void setStyleHeight(float heightPx) {
mCSSNode.setHeight(heightPx);
mYogaNode.setHeight(heightPx);
}
public void setStyleMinHeight(float widthPx) {
mCSSNode.setMinHeight(widthPx);
mYogaNode.setMinHeight(widthPx);
}
public void setStyleMaxHeight(float widthPx) {
mCSSNode.setMaxHeight(widthPx);
mYogaNode.setMaxHeight(widthPx);
}
public void setFlex(float flex) {
mCSSNode.setFlex(flex);
mYogaNode.setFlex(flex);
}
public void setFlexGrow(float flexGrow) {
mCSSNode.setFlexGrow(flexGrow);
mYogaNode.setFlexGrow(flexGrow);
}
public void setFlexShrink(float flexShrink) {
mCSSNode.setFlexShrink(flexShrink);
mYogaNode.setFlexShrink(flexShrink);
}
public void setFlexBasis(float flexBasis) {
mCSSNode.setFlexBasis(flexBasis);
mYogaNode.setFlexBasis(flexBasis);
}
public void setStyleAspectRatio(float aspectRatio) {
mCSSNode.setAspectRatio(aspectRatio);
mYogaNode.setAspectRatio(aspectRatio);
}
public void setFlexDirection(YogaFlexDirection flexDirection) {
mCSSNode.setFlexDirection(flexDirection);
mYogaNode.setFlexDirection(flexDirection);
}
public void setFlexWrap(YogaWrap wrap) {
mCSSNode.setWrap(wrap);
mYogaNode.setWrap(wrap);
}
public void setAlignSelf(YogaAlign alignSelf) {
mCSSNode.setAlignSelf(alignSelf);
mYogaNode.setAlignSelf(alignSelf);
}
public void setAlignItems(YogaAlign alignItems) {
mCSSNode.setAlignItems(alignItems);
mYogaNode.setAlignItems(alignItems);
}
public void setJustifyContent(YogaJustify justifyContent) {
mCSSNode.setJustifyContent(justifyContent);
mYogaNode.setJustifyContent(justifyContent);
}
public void setOverflow(YogaOverflow overflow) {
mCSSNode.setOverflow(overflow);
mYogaNode.setOverflow(overflow);
}
public void setMargin(int spacingType, float margin) {
mCSSNode.setMargin(YogaEdge.fromInt(spacingType), margin);
mYogaNode.setMargin(YogaEdge.fromInt(spacingType), margin);
}
public final float getPadding(int spacingType) {
return mCSSNode.getPadding(YogaEdge.fromInt(spacingType));
return mYogaNode.getPadding(YogaEdge.fromInt(spacingType));
}
public void setDefaultPadding(int spacingType, float padding) {
@ -617,63 +617,63 @@ public class ReactShadowNode {
if (YogaConstants.isUndefined(mPadding.getRaw(spacingType)) &&
YogaConstants.isUndefined(mPadding.getRaw(Spacing.HORIZONTAL)) &&
YogaConstants.isUndefined(mPadding.getRaw(Spacing.ALL))) {
mCSSNode.setPadding(YogaEdge.fromInt(spacingType), mDefaultPadding.getRaw(spacingType));
mYogaNode.setPadding(YogaEdge.fromInt(spacingType), mDefaultPadding.getRaw(spacingType));
} else {
mCSSNode.setPadding(YogaEdge.fromInt(spacingType), mPadding.getRaw(spacingType));
mYogaNode.setPadding(YogaEdge.fromInt(spacingType), mPadding.getRaw(spacingType));
}
} else if (spacingType == Spacing.TOP || spacingType == Spacing.BOTTOM) {
if (YogaConstants.isUndefined(mPadding.getRaw(spacingType)) &&
YogaConstants.isUndefined(mPadding.getRaw(Spacing.VERTICAL)) &&
YogaConstants.isUndefined(mPadding.getRaw(Spacing.ALL))) {
mCSSNode.setPadding(YogaEdge.fromInt(spacingType), mDefaultPadding.getRaw(spacingType));
mYogaNode.setPadding(YogaEdge.fromInt(spacingType), mDefaultPadding.getRaw(spacingType));
} else {
mCSSNode.setPadding(YogaEdge.fromInt(spacingType), mPadding.getRaw(spacingType));
mYogaNode.setPadding(YogaEdge.fromInt(spacingType), mPadding.getRaw(spacingType));
}
} else {
if (YogaConstants.isUndefined(mPadding.getRaw(spacingType))) {
mCSSNode.setPadding(YogaEdge.fromInt(spacingType), mDefaultPadding.getRaw(spacingType));
mYogaNode.setPadding(YogaEdge.fromInt(spacingType), mDefaultPadding.getRaw(spacingType));
} else {
mCSSNode.setPadding(YogaEdge.fromInt(spacingType), mPadding.getRaw(spacingType));
mYogaNode.setPadding(YogaEdge.fromInt(spacingType), mPadding.getRaw(spacingType));
}
}
}
}
public void setBorder(int spacingType, float borderWidth) {
mCSSNode.setBorder(YogaEdge.fromInt(spacingType), borderWidth);
mYogaNode.setBorder(YogaEdge.fromInt(spacingType), borderWidth);
}
public void setPosition(int spacingType, float position) {
mCSSNode.setPosition(YogaEdge.fromInt(spacingType), position);
mYogaNode.setPosition(YogaEdge.fromInt(spacingType), position);
}
public void setPositionType(YogaPositionType positionType) {
mCSSNode.setPositionType(positionType);
mYogaNode.setPositionType(positionType);
}
public void setShouldNotifyOnLayout(boolean shouldNotifyOnLayout) {
mShouldNotifyOnLayout = shouldNotifyOnLayout;
}
public void setMeasureFunction(CSSNodeAPI.MeasureFunction measureFunction) {
if ((measureFunction == null ^ mCSSNode.isMeasureDefined()) &&
public void setMeasureFunction(YogaMeasureFunction measureFunction) {
if ((measureFunction == null ^ mYogaNode.isMeasureDefined()) &&
getChildCount() != 0) {
throw new RuntimeException(
"Since a node with a measure function does not add any native CSSLayout children, it's " +
"not safe to transition to/from having a measure function unless a node has no children");
}
mCSSNode.setMeasureFunction(measureFunction);
mYogaNode.setMeasureFunction(measureFunction);
}
@Override
public String toString() {
return mCSSNode.toString();
return mYogaNode.toString();
}
public void dispose() {
if (mCSSNode != null) {
mCSSNode.reset();
CSSNodePool.get().release(mCSSNode);
if (mYogaNode != null) {
mYogaNode.reset();
YogaNodePool.get().release(mYogaNode);
}
}
}

View File

@ -144,7 +144,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
mEventDispatcher.onCatalystInstanceDestroyed();
getReactApplicationContext().unregisterComponentCallbacks(mMemoryTrimCallback);
CSSNodePool.get().clear();
YogaNodePool.get().clear();
}
private static Map<String, Object> createConstants(List<ViewManager> viewManagerList) {
@ -570,7 +570,7 @@ public class UIManagerModule extends ReactContextBaseJavaModule implements
@Override
public void onTrimMemory(int level) {
if (level >= TRIM_MEMORY_MODERATE) {
CSSNodePool.get().clear();
YogaNodePool.get().clear();
}
}

View File

@ -2,25 +2,25 @@
package com.facebook.react.uimanager;
import com.facebook.csslayout.CSSNode;
import com.facebook.csslayout.YogaNode;
import com.facebook.react.common.ClearableSynchronizedPool;
/**
* Static holder for a recycling pool of CSSNodes.
* Static holder for a recycling pool of YogaNodes.
*/
public class CSSNodePool {
public class YogaNodePool {
private static final Object sInitLock = new Object();
private static ClearableSynchronizedPool<CSSNode> sPool;
private static ClearableSynchronizedPool<YogaNode> sPool;
public static ClearableSynchronizedPool<CSSNode> get() {
public static ClearableSynchronizedPool<YogaNode> get() {
if (sPool != null) {
return sPool;
}
synchronized (sInitLock) {
if (sPool == null) {
sPool = new ClearableSynchronizedPool<CSSNode>(1024);
sPool = new ClearableSynchronizedPool<YogaNode>(1024);
}
return sPool;
}

View File

@ -10,8 +10,8 @@
package com.facebook.react.views.art;
import com.facebook.csslayout.YogaMeasureMode;
import com.facebook.csslayout.CSSNodeAPI;
import com.facebook.csslayout.MeasureOutput;
import com.facebook.csslayout.YogaMeasureFunction;
import com.facebook.csslayout.YogaNodeAPI;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.ThemedReactContext;
@ -26,10 +26,10 @@ public class ARTSurfaceViewManager extends
protected static final String REACT_CLASS = "ARTSurfaceView";
private static final CSSNodeAPI.MeasureFunction MEASURE_FUNCTION = new CSSNodeAPI.MeasureFunction() {
private static final YogaMeasureFunction MEASURE_FUNCTION = new YogaMeasureFunction() {
@Override
public long measure(
CSSNodeAPI node,
YogaNodeAPI node,
float width,
YogaMeasureMode widthMode,
float height,

View File

@ -20,8 +20,9 @@ import android.view.ViewGroup;
import android.widget.ProgressBar;
import com.facebook.csslayout.YogaMeasureMode;
import com.facebook.csslayout.CSSNodeAPI;
import com.facebook.csslayout.MeasureOutput;
import com.facebook.csslayout.YogaMeasureFunction;
import com.facebook.csslayout.YogaNodeAPI;
import com.facebook.csslayout.YogaMeasureOutput;
import com.facebook.react.uimanager.LayoutShadowNode;
import com.facebook.react.uimanager.annotations.ReactProp;
@ -30,7 +31,7 @@ import com.facebook.react.uimanager.annotations.ReactProp;
* {@link android.R.attr.progressBarStyle} for possible styles. ReactProgressBarViewManager
* manages how this style is applied to the ProgressBar.
*/
public class ProgressBarShadowNode extends LayoutShadowNode implements CSSNodeAPI.MeasureFunction {
public class ProgressBarShadowNode extends LayoutShadowNode implements YogaMeasureFunction {
private String mStyle = ReactProgressBarViewManager.DEFAULT_STYLE;
@ -53,7 +54,7 @@ public class ProgressBarShadowNode extends LayoutShadowNode implements CSSNodeAP
@Override
public long measure(
CSSNodeAPI node,
YogaNodeAPI node,
float width,
YogaMeasureMode widthMode,
float height,
@ -70,6 +71,6 @@ public class ProgressBarShadowNode extends LayoutShadowNode implements CSSNodeAP
mMeasured.add(style);
}
return MeasureOutput.make(mWidth.get(style), mHeight.get(style));
return YogaMeasureOutput.make(mWidth.get(style), mHeight.get(style));
}
}

View File

@ -16,8 +16,9 @@ import android.view.ViewGroup;
import android.widget.SeekBar;
import com.facebook.csslayout.YogaMeasureMode;
import com.facebook.csslayout.CSSNodeAPI;
import com.facebook.csslayout.MeasureOutput;
import com.facebook.csslayout.YogaMeasureFunction;
import com.facebook.csslayout.YogaNodeAPI;
import com.facebook.csslayout.YogaMeasureOutput;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.uimanager.LayoutShadowNode;
@ -39,7 +40,7 @@ public class ReactSliderManager extends SimpleViewManager<ReactSlider> {
private static final String REACT_CLASS = "RCTSlider";
static class ReactSliderShadowNode extends LayoutShadowNode implements
CSSNodeAPI.MeasureFunction {
YogaMeasureFunction {
private int mWidth;
private int mHeight;
@ -51,7 +52,7 @@ public class ReactSliderManager extends SimpleViewManager<ReactSlider> {
@Override
public long measure(
CSSNodeAPI node,
YogaNodeAPI node,
float width,
YogaMeasureMode widthMode,
float height,
@ -67,7 +68,7 @@ public class ReactSliderManager extends SimpleViewManager<ReactSlider> {
mMeasured = true;
}
return MeasureOutput.make(mWidth, mHeight);
return YogaMeasureOutput.make(mWidth, mHeight);
}
}
@ -79,7 +80,7 @@ public class ReactSliderManager extends SimpleViewManager<ReactSlider> {
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
new ReactSliderEvent(
seekbar.getId(),
((ReactSlider)seekbar).toRealProgress(progress),
((ReactSlider) seekbar).toRealProgress(progress),
fromUser));
}
@ -93,7 +94,7 @@ public class ReactSliderManager extends SimpleViewManager<ReactSlider> {
reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent(
new ReactSlidingCompleteEvent(
seekbar.getId(),
((ReactSlider)seekbar).toRealProgress(seekbar.getProgress())));
((ReactSlider) seekbar).toRealProgress(seekbar.getProgress())));
}
};

View File

@ -15,8 +15,9 @@ import android.view.ViewGroup;
import android.widget.CompoundButton;
import com.facebook.csslayout.YogaMeasureMode;
import com.facebook.csslayout.CSSNodeAPI;
import com.facebook.csslayout.MeasureOutput;
import com.facebook.csslayout.YogaMeasureFunction;
import com.facebook.csslayout.YogaNodeAPI;
import com.facebook.csslayout.YogaMeasureOutput;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.uimanager.LayoutShadowNode;
import com.facebook.react.uimanager.SimpleViewManager;
@ -33,7 +34,7 @@ public class ReactSwitchManager extends SimpleViewManager<ReactSwitch> {
private static final String REACT_CLASS = "AndroidSwitch";
static class ReactSwitchShadowNode extends LayoutShadowNode implements
CSSNodeAPI.MeasureFunction {
YogaMeasureFunction {
private int mWidth;
private int mHeight;
@ -45,7 +46,7 @@ public class ReactSwitchManager extends SimpleViewManager<ReactSwitch> {
@Override
public long measure(
CSSNodeAPI node,
YogaNodeAPI node,
float width,
YogaMeasureMode widthMode,
float height,
@ -64,7 +65,7 @@ public class ReactSwitchManager extends SimpleViewManager<ReactSwitch> {
mMeasured = true;
}
return MeasureOutput.make(mWidth, mHeight);
return YogaMeasureOutput.make(mWidth, mHeight);
}
}

View File

@ -9,11 +9,11 @@
package com.facebook.react.views.text;
import com.facebook.csslayout.CSSNode;
import com.facebook.csslayout.YogaNode;
import com.facebook.react.uimanager.LayoutShadowNode;
/**
* Base class for {@link CSSNode}s that represent inline images.
* Base class for {@link YogaNode}s that represent inline images.
*/
public abstract class ReactTextInlineImageShadowNode extends LayoutShadowNode {

View File

@ -33,8 +33,9 @@ import android.widget.TextView;
import com.facebook.csslayout.YogaDirection;
import com.facebook.csslayout.YogaConstants;
import com.facebook.csslayout.YogaMeasureMode;
import com.facebook.csslayout.CSSNodeAPI;
import com.facebook.csslayout.MeasureOutput;
import com.facebook.csslayout.YogaMeasureFunction;
import com.facebook.csslayout.YogaNodeAPI;
import com.facebook.csslayout.YogaMeasureOutput;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.bridge.JSApplicationIllegalArgumentException;
import com.facebook.react.bridge.ReadableMap;
@ -218,11 +219,11 @@ public class ReactTextShadowNode extends LayoutShadowNode {
return sb;
}
private final CSSNodeAPI.MeasureFunction mTextMeasureFunction =
new CSSNodeAPI.MeasureFunction() {
private final YogaMeasureFunction mTextMeasureFunction =
new YogaMeasureFunction() {
@Override
public long measure(
CSSNodeAPI node,
YogaNodeAPI node,
float width,
YogaMeasureMode widthMode,
float height,
@ -279,11 +280,11 @@ public class ReactTextShadowNode extends LayoutShadowNode {
if (mNumberOfLines != UNSET &&
mNumberOfLines < layout.getLineCount()) {
return MeasureOutput.make(
return YogaMeasureOutput.make(
layout.getWidth(),
layout.getLineBottom(mNumberOfLines - 1));
} else {
return MeasureOutput.make(layout.getWidth(), layout.getHeight());
return YogaMeasureOutput.make(layout.getWidth(), layout.getHeight());
}
}
};

View File

@ -18,8 +18,9 @@ import android.widget.EditText;
import com.facebook.csslayout.YogaDirection;
import com.facebook.csslayout.YogaMeasureMode;
import com.facebook.csslayout.CSSNodeAPI;
import com.facebook.csslayout.MeasureOutput;
import com.facebook.csslayout.YogaMeasureFunction;
import com.facebook.csslayout.YogaNodeAPI;
import com.facebook.csslayout.YogaMeasureOutput;
import com.facebook.infer.annotation.Assertions;
import com.facebook.react.common.annotations.VisibleForTesting;
import com.facebook.react.uimanager.PixelUtil;
@ -34,7 +35,7 @@ import com.facebook.react.views.text.ReactTextUpdate;
@VisibleForTesting
public class ReactTextInputShadowNode extends ReactTextShadowNode implements
CSSNodeAPI.MeasureFunction {
YogaMeasureFunction {
private @Nullable EditText mEditText;
private @Nullable float[] mComputedPadding;
@ -71,7 +72,7 @@ public class ReactTextInputShadowNode extends ReactTextShadowNode implements
@Override
public long measure(
CSSNodeAPI node,
YogaNodeAPI node,
float width,
YogaMeasureMode widthMode,
float height,
@ -103,7 +104,7 @@ public class ReactTextInputShadowNode extends ReactTextShadowNode implements
MeasureUtil.getMeasureSpec(width, widthMode),
MeasureUtil.getMeasureSpec(height, heightMode));
return MeasureOutput.make(editText.getMeasuredWidth(), editText.getMeasuredHeight());
return YogaMeasureOutput.make(editText.getMeasuredWidth(), editText.getMeasuredHeight());
}
@Override

View File

@ -58,7 +58,7 @@ static YGSize YGJNIMeasureFunc(YGNodeRef node,
float height,
YGMeasureMode heightMode) {
if (auto obj = YGNodeJobject(node)->lockLocal()) {
static auto measureFunc = findClassLocal("com/facebook/csslayout/CSSNode")
static auto measureFunc = findClassLocal("com/facebook/csslayout/YogaNode")
->getMethod<jlong(jfloat, jint, jfloat, jint)>("measure");
YGTransferLayoutDirection(node, obj);
@ -89,7 +89,7 @@ static int YGLog(YGLogLevel level, const char *format, va_list args) {
char buffer[256];
int result = vsnprintf(buffer, sizeof(buffer), format, args);
static auto logFunc = findClassLocal("com/facebook/csslayout/CSSLogger")
static auto logFunc = findClassLocal("com/facebook/csslayout/YogaLogger")
->getMethod<void(local_ref<JYogaLogLevel>, jstring)>("log");
static auto logLevelFromInt =
@ -261,7 +261,7 @@ YG_NODE_JNI_STYLE_PROP(jfloat, float, AspectRatio);
jint JNI_OnLoad(JavaVM *vm, void *) {
return initialize(vm, [] {
registerNatives("com/facebook/csslayout/CSSNode",
registerNatives("com/facebook/csslayout/YogaNode",
{
YGMakeNativeMethod(jni_YGNodeNew),
YGMakeNativeMethod(jni_YGNodeFree),