diff --git a/CSSLayout/CSSLayout.c b/CSSLayout/CSSLayout.c index 1cacc993..9822e78c 100644 --- a/CSSLayout/CSSLayout.c +++ b/CSSLayout/CSSLayout.c @@ -456,7 +456,7 @@ static void _CSSNodePrint(const CSSNodeRef node, gLogger("{"); if (node->print) { - node->print(node->context); + node->print(node); } if (options & CSSPrintOptionsLayout) { @@ -1263,7 +1263,7 @@ static void layoutNodeImpl(const CSSNodeRef node, } else { // Measure the text under the current constraints. const CSSSize measuredSize = - node->measure(node->context, innerWidth, widthMeasureMode, innerHeight, heightMeasureMode); + node->measure(node, innerWidth, widthMeasureMode, innerHeight, heightMeasureMode); node->layout.measuredDimensions[CSSDimensionWidth] = boundAxis(node, @@ -2284,7 +2284,7 @@ bool layoutNodeInternal(const CSSNodeRef node, if (gPrintChanges && gPrintSkips) { printf("%s%d.{[skipped] ", getSpacer(gDepth), gDepth); if (node->print) { - node->print(node->context); + node->print(node); } printf("wm: %s, hm: %s, aw: %f ah: %f => d: (%f, %f) %s\n", getModeName(widthMeasureMode, performLayout), @@ -2299,7 +2299,7 @@ bool layoutNodeInternal(const CSSNodeRef node, if (gPrintChanges) { printf("%s%d.{%s", getSpacer(gDepth), gDepth, needToVisitNode ? "*" : ""); if (node->print) { - node->print(node->context); + node->print(node); } printf("wm: %s, hm: %s, aw: %f ah: %f %s\n", getModeName(widthMeasureMode, performLayout), @@ -2320,7 +2320,7 @@ bool layoutNodeInternal(const CSSNodeRef node, if (gPrintChanges) { printf("%s%d.}%s", getSpacer(gDepth), gDepth, needToVisitNode ? "*" : ""); if (node->print) { - node->print(node->context); + node->print(node); } printf("wm: %s, hm: %s, d: (%f, %f) %s\n", getModeName(widthMeasureMode, performLayout), diff --git a/CSSLayout/CSSLayout.h b/CSSLayout/CSSLayout.h index 0dd3f1ca..75e1e05c 100644 --- a/CSSLayout/CSSLayout.h +++ b/CSSLayout/CSSLayout.h @@ -116,12 +116,12 @@ typedef struct CSSSize { } CSSSize; typedef struct CSSNode *CSSNodeRef; -typedef CSSSize (*CSSMeasureFunc)(void *context, +typedef CSSSize (*CSSMeasureFunc)(CSSNodeRef node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode); -typedef void (*CSSPrintFunc)(void *context); +typedef void (*CSSPrintFunc)(CSSNodeRef node); typedef int (*CSSLogger)(const char *format, ...); #ifdef CSS_ASSERT_FAIL_ENABLED diff --git a/benchmark/CSSBenchmark.c b/benchmark/CSSBenchmark.c index 0f980a31..6aa0c14d 100644 --- a/benchmark/CSSBenchmark.c +++ b/benchmark/CSSBenchmark.c @@ -11,7 +11,7 @@ #include -static CSSSize _measure(void *context, +static CSSSize _measure(CSSNodeRef node float width, CSSMeasureMode widthMode, float height, diff --git a/csharp/Facebook.CSSLayout/CSSMeasureFunc.cs b/csharp/Facebook.CSSLayout/CSSMeasureFunc.cs index cde50ca2..cd5744d5 100644 --- a/csharp/Facebook.CSSLayout/CSSMeasureFunc.cs +++ b/csharp/Facebook.CSSLayout/CSSMeasureFunc.cs @@ -14,7 +14,7 @@ namespace Facebook.CSSLayout { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate CSSSize CSSMeasureFunc( - IntPtr context, + IntPtr node, float width, CSSMeasureMode widthMode, float height, diff --git a/csharp/Facebook.CSSLayout/CSSNode.cs b/csharp/Facebook.CSSLayout/CSSNode.cs index 1e018946..dff4e5fb 100644 --- a/csharp/Facebook.CSSLayout/CSSNode.cs +++ b/csharp/Facebook.CSSLayout/CSSNode.cs @@ -532,7 +532,7 @@ namespace Facebook.CSSLayout } private CSSSize MeasureInternal( - IntPtr context, + IntPtr node, float width, CSSMeasureMode widthMode, float height, diff --git a/java/jni/CSSJNI.cpp b/java/jni/CSSJNI.cpp index 1e3e2026..944ae211 100644 --- a/java/jni/CSSJNI.cpp +++ b/java/jni/CSSJNI.cpp @@ -14,17 +14,17 @@ using namespace facebook::jni; using namespace std; -static void _jniPrint(void *context) { - auto obj = adopt_local(Environment::current()->NewLocalRef(reinterpret_cast(context))); +static void _jniPrint(CSSNodeRef node) { + auto obj = adopt_local(Environment::current()->NewLocalRef(reinterpret_cast(CSSNodeGetContext(node)))); cout << obj->toString() << endl; } -static CSSSize _jniMeasureFunc(void *context, +static CSSSize _jniMeasureFunc(CSSNodeRef node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) { - auto obj = adopt_local(Environment::current()->NewLocalRef(reinterpret_cast(context))); + auto obj = adopt_local(Environment::current()->NewLocalRef(reinterpret_cast(CSSNodeGetContext(node)))); static auto measureFunc = obj->getClass()->getMethod("measure"); const auto measureResult = measureFunc(obj, width, widthMode, height, heightMode); diff --git a/tests/CSSLayoutMeasureCacheTest.cpp b/tests/CSSLayoutMeasureCacheTest.cpp index afd4a6e8..b2b90bbc 100644 --- a/tests/CSSLayoutMeasureCacheTest.cpp +++ b/tests/CSSLayoutMeasureCacheTest.cpp @@ -10,13 +10,13 @@ #include #include -static CSSSize _measureMax(void *context, +static CSSSize _measureMax(CSSNodeRef node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) { - int *measureCount = (int *)context; + int *measureCount = (int *)CSSNodeGetContext(node); *measureCount = *measureCount + 1; return CSSSize { .width = widthMode == CSSMeasureModeUndefined ? 10 : width, @@ -24,13 +24,13 @@ static CSSSize _measureMax(void *context, }; } -static CSSSize _measureMin(void *context, +static CSSSize _measureMin(CSSNodeRef node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) { - int *measureCount = (int *)context; + int *measureCount = (int *)CSSNodeGetContext(node); *measureCount = *measureCount + 1; return CSSSize { .width = widthMode == CSSMeasureModeUndefined || (widthMode == CSSMeasureModeAtMost && width > 10) ? 10 : width, diff --git a/tests/CSSLayoutMeasureModeTest.cpp b/tests/CSSLayoutMeasureModeTest.cpp index 979a9444..1f091068 100644 --- a/tests/CSSLayoutMeasureModeTest.cpp +++ b/tests/CSSLayoutMeasureModeTest.cpp @@ -22,12 +22,12 @@ struct _MeasureConstraintList { struct _MeasureConstraint *constraints; }; -static CSSSize _measure(void *context, +static CSSSize _measure(CSSNodeRef node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) { - struct _MeasureConstraintList *constraintList = (struct _MeasureConstraintList *)context; + struct _MeasureConstraintList *constraintList = (struct _MeasureConstraintList *)CSSNodeGetContext(node); struct _MeasureConstraint *constraints = constraintList->constraints; uint32_t currentIndex = constraintList->length; (&constraints[currentIndex])->width = width; diff --git a/tests/CSSLayoutMeasureTest.cpp b/tests/CSSLayoutMeasureTest.cpp index b451dcfa..e8362d0d 100644 --- a/tests/CSSLayoutMeasureTest.cpp +++ b/tests/CSSLayoutMeasureTest.cpp @@ -10,12 +10,12 @@ #include #include -static CSSSize _measure(void *context, +static CSSSize _measure(CSSNodeRef node, float width, CSSMeasureMode widthMode, float height, CSSMeasureMode heightMode) { - int *measureCount = (int *)context; + int *measureCount = (int *)CSSNodeGetContext(node); *measureCount = *measureCount + 1; return CSSSize { .width = widthMode == CSSMeasureModeUndefined ? 10 : width, diff --git a/uikit/CSSLayout/UIView+CSSLayout.m b/uikit/CSSLayout/UIView+CSSLayout.m index aa9faebb..81417076 100644 --- a/uikit/CSSLayout/UIView+CSSLayout.m +++ b/uikit/CSSLayout/UIView+CSSLayout.m @@ -206,7 +206,7 @@ static void _updateFrameRecursive(UIView *view); #pragma mark - Private static CSSSize _measure( - void *context, + CSSNodeRef node, float width, CSSMeasureMode widthMode, float height, @@ -222,7 +222,7 @@ static CSSSize _measure( }; } - UIView *view = (__bridge UIView*) context; + UIView *view = (__bridge UIView*) CSSNodeGetContext(node); const CGSize sizeThatFits = [view sizeThatFits:(CGSize) { .width = widthMode == CSSMeasureModeUndefined ? CGFLOAT_MAX : width, .height = heightMode == CSSMeasureModeUndefined ? CGFLOAT_MAX : height,