Skip to content

Commit

Permalink
Marker for baseline callbacks
Browse files Browse the repository at this point in the history
Summary:
@public

Wraps baseline callbacks with a marker.

Reviewed By: SidharthGuglani

Differential Revision: D13896861

fbshipit-source-id: 848ec697977a0a68b9943f1159f6562d54724f89
  • Loading branch information
davidaurelio authored and facebook-github-bot committed Feb 1, 2019
1 parent 7835f1b commit 7725d07
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 8 additions & 2 deletions ReactCommon/yoga/yoga/YGMarker.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ typedef struct YGConfig* YGConfigRef;
typedef YG_ENUM_BEGIN(YGMarker){
YGMarkerLayout,
YGMarkerMeasure,
YGMarkerBaselineFn,
} YG_ENUM_END(YGMarker);

typedef struct {
Expand Down Expand Up @@ -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>
Expand Down
4 changes: 3 additions & 1 deletion ReactCommon/yoga/yoga/Yoga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down

0 comments on commit 7725d07

Please sign in to comment.