Dont create a spacing object for returning margin, padding, border, and position

Summary: The current implementation was made out of simplicity and to keep the same API as before. Now that the java version of csslayout is deprecated it is time to change the API to make the calls more efficient for the JNI version. This diff with reduce allocations as well as reduce the number of JNI calls done.

Differential Revision: D4050773

fbshipit-source-id: 3fd04c27f887a36875e455b5404a17154ac18f91
This commit is contained in:
Emil Sjolander
2016-10-24 10:35:43 -07:00
committed by Facebook Github Bot
parent 69c374e74e
commit e9b9973cae
4 changed files with 28 additions and 92 deletions

View File

@@ -413,8 +413,8 @@ public class CSSNodeDEPRECATED implements CSSNodeAPI<CSSNodeDEPRECATED> {
* Get this node's margin, as defined by style + default margin.
*/
@Override
public Spacing getMargin() {
return style.margin;
public float getMargin(int spacingType) {
return style.margin.get(spacingType);
}
@Override
@@ -428,8 +428,8 @@ public class CSSNodeDEPRECATED implements CSSNodeAPI<CSSNodeDEPRECATED> {
* Get this node's padding, as defined by style + default padding.
*/
@Override
public Spacing getPadding() {
return style.padding;
public float getPadding(int spacingType) {
return style.padding.get(spacingType);
}
@Override
@@ -443,8 +443,8 @@ public class CSSNodeDEPRECATED implements CSSNodeAPI<CSSNodeDEPRECATED> {
* Get this node's border, as defined by style.
*/
@Override
public Spacing getBorder() {
return style.border;
public float getBorder(int spacingType) {
return style.border.get(spacingType);
}
@Override
@@ -458,8 +458,8 @@ public class CSSNodeDEPRECATED implements CSSNodeAPI<CSSNodeDEPRECATED> {
* Get this node's position, as defined by style.
*/
@Override
public Spacing getPosition() {
return style.position;
public float getPosition(int spacingType) {
return style.position.get(spacingType);
}
@Override