move YGMarkerMeasure and YGMarkerBaselineFn to event based system
Summary: Using yoga event listener for adding systrace sections for measure and baseline events Reviewed By: davidaurelio Differential Revision: D16048795 fbshipit-source-id: 3c2161328250184929ed1a3357b8c42ec8ca2e29
This commit is contained in:
committed by
Facebook Github Bot
parent
6d916ab063
commit
7c891db9af
@@ -67,35 +67,6 @@ struct MarkerTest : public ::testing::Test {
|
|||||||
uniquePtr<YGConfig> config;
|
uniquePtr<YGConfig> config;
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST_F(MarkerTest, measure_functions_get_wrapped) {
|
|
||||||
auto root = makeNode();
|
|
||||||
YGNodeSetMeasureFunc(
|
|
||||||
root.get(), [](YGNodeRef, float, YGMeasureMode, float, YGMeasureMode) {
|
|
||||||
return YGSize{};
|
|
||||||
});
|
|
||||||
|
|
||||||
calculateLayout(root);
|
|
||||||
auto& markerCookie = findLastMarker(YGMarkerMeasure);
|
|
||||||
|
|
||||||
ASSERT_EQ(markerCookie.start.marker, YGMarkerMeasure)
|
|
||||||
<< "have " << markerCookies.size() << " recorded markers";
|
|
||||||
}
|
|
||||||
|
|
||||||
TEST_F(MarkerTest, baseline_functions_get_wrapped) {
|
|
||||||
auto root = makeNode();
|
|
||||||
auto child = addChild(root);
|
|
||||||
YGNodeSetBaselineFunc(
|
|
||||||
child.get(), [](YGNodeRef, float, float) { return 0.0f; });
|
|
||||||
YGNodeStyleSetFlexDirection(root.get(), YGFlexDirectionRow);
|
|
||||||
YGNodeStyleSetAlignItems(root.get(), YGAlignBaseline);
|
|
||||||
|
|
||||||
calculateLayout(root);
|
|
||||||
auto& markerCookie = findLastMarker(YGMarkerBaselineFn);
|
|
||||||
|
|
||||||
ASSERT_EQ(markerCookie.start.marker, YGMarkerBaselineFn)
|
|
||||||
<< "have " << markerCookies.size() << " recorded markers";
|
|
||||||
}
|
|
||||||
|
|
||||||
void* MarkerTest::startMarker(
|
void* MarkerTest::startMarker(
|
||||||
YGMarker marker,
|
YGMarker marker,
|
||||||
YGNodeRef node,
|
YGNodeRef node,
|
||||||
@@ -113,11 +84,6 @@ void MarkerTest::endMarker(
|
|||||||
void* id) {
|
void* id) {
|
||||||
auto cookie = static_cast<MarkerCookie*>(id);
|
auto cookie = static_cast<MarkerCookie*>(id);
|
||||||
cookie->end = {{marker, node, data}, id, {}};
|
cookie->end = {{marker, node, data}, id, {}};
|
||||||
switch (marker) {
|
|
||||||
case YGMarkerMeasure:
|
|
||||||
case YGMarkerBaselineFn:
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uniquePtr<YGNode> MarkerTest::makeNode() {
|
uniquePtr<YGNode> MarkerTest::makeNode() {
|
||||||
@@ -141,12 +107,6 @@ void MarkerTest::calculateLayout(
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const char* markerTypeName(YGMarker type) {
|
const char* markerTypeName(YGMarker type) {
|
||||||
switch (type) {
|
|
||||||
case YGMarkerMeasure:
|
|
||||||
return "YGMarkerMeasure";
|
|
||||||
case YGMarkerBaselineFn:
|
|
||||||
return "YGMarkerBaselineFn";
|
|
||||||
}
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,10 +13,8 @@ YG_EXTERN_C_BEGIN
|
|||||||
typedef struct YGNode* YGNodeRef;
|
typedef struct YGNode* YGNodeRef;
|
||||||
typedef struct YGConfig* YGConfigRef;
|
typedef struct YGConfig* YGConfigRef;
|
||||||
|
|
||||||
typedef YG_ENUM_BEGIN(YGMarker){
|
typedef YG_ENUM_BEGIN(YGMarker) {}
|
||||||
YGMarkerMeasure,
|
YG_ENUM_END(YGMarker);
|
||||||
YGMarkerBaselineFn,
|
|
||||||
} YG_ENUM_END(YGMarker);
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int layouts;
|
int layouts;
|
||||||
@@ -62,13 +60,6 @@ struct NoMarkerData {
|
|||||||
using type = YGMarkerNoData;
|
using type = YGMarkerNoData;
|
||||||
static type*& get(YGMarkerData& d) { return d.noData; }
|
static type*& get(YGMarkerData& d) { return d.noData; }
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
|
||||||
struct MarkerData<YGMarkerMeasure> : NoMarkerData {};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct MarkerData<YGMarkerBaselineFn> : NoMarkerData {};
|
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template <YGMarker M>
|
template <YGMarker M>
|
||||||
|
@@ -1000,9 +1000,7 @@ static float YGBaseline(const YGNodeRef node, void* layoutContext) {
|
|||||||
|
|
||||||
Event::publish<Event::NodeBaselineStart>(node);
|
Event::publish<Event::NodeBaselineStart>(node);
|
||||||
|
|
||||||
const float baseline = marker::MarkerSection<YGMarkerBaselineFn>::wrap(
|
const float baseline = node->baseline(
|
||||||
node,
|
|
||||||
&YGNode::baseline,
|
|
||||||
node->getLayout().measuredDimensions[YGDimensionWidth],
|
node->getLayout().measuredDimensions[YGDimensionWidth],
|
||||||
node->getLayout().measuredDimensions[YGDimensionHeight],
|
node->getLayout().measuredDimensions[YGDimensionHeight],
|
||||||
layoutContext);
|
layoutContext);
|
||||||
@@ -1638,9 +1636,7 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(
|
|||||||
Event::publish<Event::MeasureCallbackStart>(node);
|
Event::publish<Event::MeasureCallbackStart>(node);
|
||||||
|
|
||||||
// Measure the text under the current constraints.
|
// Measure the text under the current constraints.
|
||||||
const YGSize measuredSize = marker::MarkerSection<YGMarkerMeasure>::wrap(
|
const YGSize measuredSize = node->measure(
|
||||||
node,
|
|
||||||
&YGNode::measure,
|
|
||||||
innerWidth,
|
innerWidth,
|
||||||
widthMeasureMode,
|
widthMeasureMode,
|
||||||
innerHeight,
|
innerHeight,
|
||||||
|
Reference in New Issue
Block a user