Marker for baseline callbacks

Summary:
@public

Wraps baseline callbacks with a marker.

Reviewed By: SidharthGuglani

Differential Revision: D13896861

fbshipit-source-id: 848ec697977a0a68b9943f1159f6562d54724f89
This commit is contained in:
David Aurelio 2019-02-01 03:31:12 -08:00 committed by Facebook Github Bot
parent d2b2316722
commit e2bd70afff
2 changed files with 11 additions and 3 deletions

View File

@ -16,6 +16,7 @@ typedef struct YGConfig* YGConfigRef;
typedef YG_ENUM_BEGIN(YGMarker){
YGMarkerLayout,
YGMarkerMeasure,
YGMarkerBaselineFn,
} YG_ENUM_END(YGMarker);
typedef struct {
@ -66,14 +67,19 @@ struct MarkerData<YGMarkerLayout> {
}
};
template <>
struct MarkerData<YGMarkerMeasure> {
struct NoMarkerData {
using type = YGMarkerNoData;
static type*& get(YGMarkerData& d) {
return d.noData;
}
};
template <>
struct MarkerData<YGMarkerMeasure> : NoMarkerData {};
template <>
struct MarkerData<YGMarkerBaselineFn> : NoMarkerData {};
} // namespace detail
template <YGMarker M>

View File

@ -1074,7 +1074,9 @@ static inline YGAlign YGNodeAlignItem(
static float YGBaseline(const YGNodeRef node) {
if (node->getBaseline() != nullptr) {
const float baseline = node->getBaseline()(
const float baseline = marker::MarkerSection<YGMarkerBaselineFn>::wrap(
node,
node->getBaseline(),
node,
node->getLayout().measuredDimensions[YGDimensionWidth],
node->getLayout().measuredDimensions[YGDimensionHeight]);