remove YGMarker code
Summary: Removes code for now unused marker based approach Reviewed By: davidaurelio Differential Revision: D16048800 fbshipit-source-id: 228e0e906252782ee0bed543728b666d1f9cc854
This commit is contained in:
committed by
Facebook Github Bot
parent
7c891db9af
commit
5e40e4b682
@@ -15,7 +15,6 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <yoga/YGEnums.h>
|
#include <yoga/YGEnums.h>
|
||||||
#include <yoga/YGMarker.h>
|
|
||||||
|
|
||||||
namespace facebook {
|
namespace facebook {
|
||||||
namespace yoga {
|
namespace yoga {
|
||||||
@@ -27,7 +26,7 @@ struct TypedEventTestData {};
|
|||||||
template <>
|
template <>
|
||||||
struct TypedEventTestData<Event::LayoutPassEnd> {
|
struct TypedEventTestData<Event::LayoutPassEnd> {
|
||||||
void* layoutContext;
|
void* layoutContext;
|
||||||
YGMarkerLayoutData layoutData;
|
LayoutData layoutData;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EventArgs {
|
struct EventArgs {
|
||||||
@@ -147,7 +146,7 @@ TEST_F(EventTest, layout_events_single_node) {
|
|||||||
ASSERT_EQ(events[3].node, root);
|
ASSERT_EQ(events[3].node, root);
|
||||||
ASSERT_EQ(events[3].type, Event::LayoutPassEnd);
|
ASSERT_EQ(events[3].type, Event::LayoutPassEnd);
|
||||||
|
|
||||||
YGMarkerLayoutData layoutData =
|
LayoutData layoutData =
|
||||||
events[3].eventTestData<Event::LayoutPassEnd>().layoutData;
|
events[3].eventTestData<Event::LayoutPassEnd>().layoutData;
|
||||||
|
|
||||||
ASSERT_EQ(layoutData.layouts, 1);
|
ASSERT_EQ(layoutData.layouts, 1);
|
||||||
@@ -170,7 +169,7 @@ TEST_F(EventTest, layout_events_counts_multi_node_layout) {
|
|||||||
ASSERT_EQ(events[11].node, root);
|
ASSERT_EQ(events[11].node, root);
|
||||||
ASSERT_EQ(events[11].type, Event::LayoutPassEnd);
|
ASSERT_EQ(events[11].type, Event::LayoutPassEnd);
|
||||||
|
|
||||||
YGMarkerLayoutData layoutData =
|
LayoutData layoutData =
|
||||||
events[11].eventTestData<Event::LayoutPassEnd>().layoutData;
|
events[11].eventTestData<Event::LayoutPassEnd>().layoutData;
|
||||||
|
|
||||||
ASSERT_EQ(layoutData.layouts, 3);
|
ASSERT_EQ(layoutData.layouts, 3);
|
||||||
@@ -191,7 +190,7 @@ TEST_F(EventTest, layout_events_counts_cache_hits_single_node_layout) {
|
|||||||
ASSERT_EQ(events[6].node, root);
|
ASSERT_EQ(events[6].node, root);
|
||||||
ASSERT_EQ(events[6].type, Event::LayoutPassEnd);
|
ASSERT_EQ(events[6].type, Event::LayoutPassEnd);
|
||||||
|
|
||||||
YGMarkerLayoutData layoutData =
|
LayoutData layoutData =
|
||||||
events[6].eventTestData<Event::LayoutPassEnd>().layoutData;
|
events[6].eventTestData<Event::LayoutPassEnd>().layoutData;
|
||||||
|
|
||||||
ASSERT_EQ(layoutData.layouts, 0);
|
ASSERT_EQ(layoutData.layouts, 0);
|
||||||
@@ -215,7 +214,7 @@ TEST_F(EventTest, layout_events_counts_cache_hits_multi_node_layout) {
|
|||||||
ASSERT_EQ(lastEvent().node, root);
|
ASSERT_EQ(lastEvent().node, root);
|
||||||
ASSERT_EQ(lastEvent().type, Event::LayoutPassEnd);
|
ASSERT_EQ(lastEvent().type, Event::LayoutPassEnd);
|
||||||
|
|
||||||
YGMarkerLayoutData layoutData =
|
LayoutData layoutData =
|
||||||
lastEvent().eventTestData<Event::LayoutPassEnd>().layoutData;
|
lastEvent().eventTestData<Event::LayoutPassEnd>().layoutData;
|
||||||
|
|
||||||
ASSERT_EQ(layoutData.layouts, 3);
|
ASSERT_EQ(layoutData.layouts, 3);
|
||||||
@@ -240,7 +239,7 @@ TEST_F(EventTest, layout_events_has_max_measure_cache) {
|
|||||||
ASSERT_EQ(lastEvent().node, root);
|
ASSERT_EQ(lastEvent().node, root);
|
||||||
ASSERT_EQ(lastEvent().type, Event::LayoutPassEnd);
|
ASSERT_EQ(lastEvent().type, Event::LayoutPassEnd);
|
||||||
|
|
||||||
YGMarkerLayoutData layoutData =
|
LayoutData layoutData =
|
||||||
lastEvent().eventTestData<Event::LayoutPassEnd>().layoutData;
|
lastEvent().eventTestData<Event::LayoutPassEnd>().layoutData;
|
||||||
|
|
||||||
ASSERT_EQ(layoutData.layouts, 3);
|
ASSERT_EQ(layoutData.layouts, 3);
|
||||||
|
@@ -1,164 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
|
||||||
* file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
#include <gtest/gtest.h>
|
|
||||||
#include <yoga/Yoga.h>
|
|
||||||
#include <yoga/YGMarker.h>
|
|
||||||
#include <yoga/instrumentation.h>
|
|
||||||
|
|
||||||
#include <cstring>
|
|
||||||
#include <deque>
|
|
||||||
#include <exception>
|
|
||||||
#include <functional>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
bool operator==(const YGMarkerLayoutData&, const YGMarkerLayoutData&);
|
|
||||||
void PrintTo(const YGMarkerLayoutData, std::ostream*);
|
|
||||||
|
|
||||||
namespace facebook {
|
|
||||||
namespace yoga {
|
|
||||||
namespace marker {
|
|
||||||
namespace test {
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
using uniquePtr = std::unique_ptr<T, std::function<void(T*)>>;
|
|
||||||
|
|
||||||
struct MarkerTest : public ::testing::Test {
|
|
||||||
struct Data {
|
|
||||||
YGMarker marker;
|
|
||||||
YGNodeRef node;
|
|
||||||
YGMarkerData markerData;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct EndData {
|
|
||||||
Data data;
|
|
||||||
void* cookie;
|
|
||||||
union {
|
|
||||||
YGMarkerLayoutData layout;
|
|
||||||
} markerData;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct MarkerCookie {
|
|
||||||
Data start;
|
|
||||||
EndData end;
|
|
||||||
};
|
|
||||||
|
|
||||||
// std::deque will keep pointers stable on reallocation, whereas std::vector
|
|
||||||
// does not
|
|
||||||
static std::deque<MarkerCookie> markerCookies;
|
|
||||||
|
|
||||||
static void* startMarker(YGMarker, YGNodeRef, YGMarkerData);
|
|
||||||
static void endMarker(YGMarker, YGNodeRef, YGMarkerData, void*);
|
|
||||||
uniquePtr<YGNode> makeNode();
|
|
||||||
uniquePtr<YGNode> addChild(uniquePtr<YGNode>& owner);
|
|
||||||
static void calculateLayout(
|
|
||||||
uniquePtr<YGNode>& node,
|
|
||||||
float width = YGUndefined,
|
|
||||||
float height = YGUndefined);
|
|
||||||
static MarkerCookie& findMarker(YGMarker);
|
|
||||||
static MarkerCookie& findLastMarker(YGMarker);
|
|
||||||
|
|
||||||
void SetUp() override;
|
|
||||||
void TearDown() override;
|
|
||||||
uniquePtr<YGConfig> config;
|
|
||||||
};
|
|
||||||
|
|
||||||
void* MarkerTest::startMarker(
|
|
||||||
YGMarker marker,
|
|
||||||
YGNodeRef node,
|
|
||||||
YGMarkerData data) {
|
|
||||||
markerCookies.emplace_back();
|
|
||||||
MarkerCookie* cookie = &markerCookies.back();
|
|
||||||
cookie->start = {marker, node, data};
|
|
||||||
return cookie;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarkerTest::endMarker(
|
|
||||||
YGMarker marker,
|
|
||||||
YGNodeRef node,
|
|
||||||
YGMarkerData data,
|
|
||||||
void* id) {
|
|
||||||
auto cookie = static_cast<MarkerCookie*>(id);
|
|
||||||
cookie->end = {{marker, node, data}, id, {}};
|
|
||||||
}
|
|
||||||
|
|
||||||
uniquePtr<YGNode> MarkerTest::makeNode() {
|
|
||||||
auto n = uniquePtr<YGNode>{YGNodeNewWithConfig(config.get()), &YGNodeFree};
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
uniquePtr<YGNode> MarkerTest::addChild(uniquePtr<YGNode>& owner) {
|
|
||||||
auto n = makeNode();
|
|
||||||
YGNodeInsertChild(owner.get(), n.get(), YGNodeGetChildCount(owner.get()));
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarkerTest::calculateLayout(
|
|
||||||
uniquePtr<YGNode>& node,
|
|
||||||
float width,
|
|
||||||
float height) {
|
|
||||||
YGNodeCalculateLayout(node.get(), width, height, YGDirectionLTR);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
const char* markerTypeName(YGMarker type) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename It>
|
|
||||||
MarkerTest::MarkerCookie& find(It begin, It end, YGMarker type) {
|
|
||||||
auto result = std::find_if(begin, end, [type](MarkerTest::MarkerCookie& c) {
|
|
||||||
return c.start.marker == type;
|
|
||||||
});
|
|
||||||
if (result == end) {
|
|
||||||
throw std::runtime_error{std::string{"No marker recorded for type: "} +
|
|
||||||
markerTypeName(type)};
|
|
||||||
}
|
|
||||||
return *result;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
MarkerTest::MarkerCookie& MarkerTest::findMarker(YGMarker markerType) {
|
|
||||||
return find(markerCookies.begin(), markerCookies.end(), markerType);
|
|
||||||
}
|
|
||||||
|
|
||||||
MarkerTest::MarkerCookie& MarkerTest::findLastMarker(YGMarker markerType) {
|
|
||||||
return find(markerCookies.rbegin(), markerCookies.rend(), markerType);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarkerTest::SetUp() {
|
|
||||||
config = uniquePtr<YGConfig>{YGConfigNew(), &YGConfigFree};
|
|
||||||
YGConfigSetMarkerCallbacks(config.get(), {startMarker, endMarker});
|
|
||||||
}
|
|
||||||
|
|
||||||
void MarkerTest::TearDown() {
|
|
||||||
markerCookies.resize(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
decltype(MarkerTest::markerCookies) MarkerTest::markerCookies = {};
|
|
||||||
|
|
||||||
} // namespace test
|
|
||||||
} // namespace marker
|
|
||||||
} // namespace yoga
|
|
||||||
} // namespace facebook
|
|
||||||
|
|
||||||
bool operator==(const YGMarkerLayoutData& lhs, const YGMarkerLayoutData& rhs) {
|
|
||||||
return lhs.layouts == rhs.layouts && lhs.measures == rhs.measures &&
|
|
||||||
lhs.maxMeasureCache == rhs.maxMeasureCache &&
|
|
||||||
lhs.cachedLayouts == rhs.cachedLayouts &&
|
|
||||||
lhs.cachedMeasures == rhs.cachedMeasures;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintTo(const YGMarkerLayoutData data, std::ostream* os) {
|
|
||||||
*os << "YGMarkerLayoutData{ layouts = " << data.layouts
|
|
||||||
<< ", measures = " << data.measures
|
|
||||||
<< ", maxMeasureCache = " << data.maxMeasureCache
|
|
||||||
<< ", cachedLayouts = " << data.cachedLayouts
|
|
||||||
<< ", cachedMeasures = " << data.cachedMeasures << " }";
|
|
||||||
}
|
|
@@ -5,7 +5,6 @@
|
|||||||
* file in the root directory of this source tree.
|
* file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "YGMarker.h"
|
|
||||||
#include "Yoga-internal.h"
|
#include "Yoga-internal.h"
|
||||||
#include "Yoga.h"
|
#include "Yoga.h"
|
||||||
|
|
||||||
@@ -44,7 +43,6 @@ public:
|
|||||||
std::array<bool, facebook::yoga::enums::count<YGExperimentalFeature>()>
|
std::array<bool, facebook::yoga::enums::count<YGExperimentalFeature>()>
|
||||||
experimentalFeatures = {};
|
experimentalFeatures = {};
|
||||||
void* context = nullptr;
|
void* context = nullptr;
|
||||||
YGMarkerCallbacks markerCallbacks = {nullptr, nullptr};
|
|
||||||
|
|
||||||
YGConfig(YGLogger logger);
|
YGConfig(YGLogger logger);
|
||||||
void log(YGConfig*, YGNode*, YGLogLevel, void*, const char*, va_list);
|
void log(YGConfig*, YGNode*, YGLogLevel, void*, const char*, va_list);
|
||||||
|
@@ -1,14 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
|
||||||
* file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
#include "YGMarker.h"
|
|
||||||
#include "YGConfig.h"
|
|
||||||
|
|
||||||
void YGConfigSetMarkerCallbacks(
|
|
||||||
YGConfigRef config,
|
|
||||||
YGMarkerCallbacks markerCallbacks) {
|
|
||||||
config->markerCallbacks = markerCallbacks;
|
|
||||||
}
|
|
@@ -1,74 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
|
||||||
* file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "YGMacros.h"
|
|
||||||
|
|
||||||
YG_EXTERN_C_BEGIN
|
|
||||||
|
|
||||||
typedef struct YGNode* YGNodeRef;
|
|
||||||
typedef struct YGConfig* YGConfigRef;
|
|
||||||
|
|
||||||
typedef YG_ENUM_BEGIN(YGMarker) {}
|
|
||||||
YG_ENUM_END(YGMarker);
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int layouts;
|
|
||||||
int measures;
|
|
||||||
int maxMeasureCache;
|
|
||||||
int cachedLayouts;
|
|
||||||
int cachedMeasures;
|
|
||||||
int measureCallbacks;
|
|
||||||
} YGMarkerLayoutData;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
bool _unused;
|
|
||||||
} YGMarkerNoData;
|
|
||||||
|
|
||||||
typedef union {
|
|
||||||
YGMarkerNoData* noData;
|
|
||||||
} YGMarkerData;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
// accepts marker type, a node ref, and marker data (depends on marker type)
|
|
||||||
// can return a handle or id that Yoga will pass to endMarker
|
|
||||||
void* (*startMarker)(YGMarker, YGNodeRef, YGMarkerData);
|
|
||||||
// accepts marker type, a node ref, marker data, and marker id as returned by
|
|
||||||
// startMarker
|
|
||||||
void (*endMarker)(YGMarker, YGNodeRef, YGMarkerData, void* id);
|
|
||||||
} YGMarkerCallbacks;
|
|
||||||
|
|
||||||
void YGConfigSetMarkerCallbacks(YGConfigRef, YGMarkerCallbacks);
|
|
||||||
|
|
||||||
YG_EXTERN_C_END
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
|
|
||||||
namespace facebook {
|
|
||||||
namespace yoga {
|
|
||||||
namespace marker {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
template <YGMarker M>
|
|
||||||
struct MarkerData;
|
|
||||||
|
|
||||||
struct NoMarkerData {
|
|
||||||
using type = YGMarkerNoData;
|
|
||||||
static type*& get(YGMarkerData& d) { return d.noData; }
|
|
||||||
};
|
|
||||||
} // namespace detail
|
|
||||||
|
|
||||||
template <YGMarker M>
|
|
||||||
typename detail::MarkerData<M>::type* data(YGMarkerData d) {
|
|
||||||
return detail::MarkerData<M>::get(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace marker
|
|
||||||
} // namespace yoga
|
|
||||||
} // namespace facebook
|
|
||||||
|
|
||||||
#endif // __cplusplus
|
|
@@ -15,7 +15,6 @@
|
|||||||
#include "YGNodePrint.h"
|
#include "YGNodePrint.h"
|
||||||
#include "Yoga-internal.h"
|
#include "Yoga-internal.h"
|
||||||
#include "event/event.h"
|
#include "event/event.h"
|
||||||
#include "instrumentation.h"
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
|
||||||
@@ -941,7 +940,7 @@ bool YGLayoutNodeInternal(
|
|||||||
const bool performLayout,
|
const bool performLayout,
|
||||||
const char* reason,
|
const char* reason,
|
||||||
const YGConfigRef config,
|
const YGConfigRef config,
|
||||||
YGMarkerLayoutData& layoutMarkerData,
|
LayoutData& layoutMarkerData,
|
||||||
void* const layoutContext,
|
void* const layoutContext,
|
||||||
const uint32_t depth,
|
const uint32_t depth,
|
||||||
const uint32_t generationCount);
|
const uint32_t generationCount);
|
||||||
@@ -1191,7 +1190,7 @@ static void YGNodeComputeFlexBasisForChild(
|
|||||||
const YGMeasureMode heightMode,
|
const YGMeasureMode heightMode,
|
||||||
const YGDirection direction,
|
const YGDirection direction,
|
||||||
const YGConfigRef config,
|
const YGConfigRef config,
|
||||||
YGMarkerLayoutData& layoutMarkerData,
|
LayoutData& layoutMarkerData,
|
||||||
void* const layoutContext,
|
void* const layoutContext,
|
||||||
const uint32_t depth,
|
const uint32_t depth,
|
||||||
const uint32_t generationCount) {
|
const uint32_t generationCount) {
|
||||||
@@ -1387,7 +1386,7 @@ static void YGNodeAbsoluteLayoutChild(
|
|||||||
const float height,
|
const float height,
|
||||||
const YGDirection direction,
|
const YGDirection direction,
|
||||||
const YGConfigRef config,
|
const YGConfigRef config,
|
||||||
YGMarkerLayoutData& layoutMarkerData,
|
LayoutData& layoutMarkerData,
|
||||||
void* const layoutContext,
|
void* const layoutContext,
|
||||||
const uint32_t depth,
|
const uint32_t depth,
|
||||||
const uint32_t generationCount) {
|
const uint32_t generationCount) {
|
||||||
@@ -1588,7 +1587,7 @@ static void YGNodeWithMeasureFuncSetMeasuredDimensions(
|
|||||||
const YGMeasureMode heightMeasureMode,
|
const YGMeasureMode heightMeasureMode,
|
||||||
const float ownerWidth,
|
const float ownerWidth,
|
||||||
const float ownerHeight,
|
const float ownerHeight,
|
||||||
YGMarkerLayoutData& layoutMarkerData,
|
LayoutData& layoutMarkerData,
|
||||||
void* const layoutContext) {
|
void* const layoutContext) {
|
||||||
YGAssertWithNode(
|
YGAssertWithNode(
|
||||||
node,
|
node,
|
||||||
@@ -1836,7 +1835,7 @@ static float YGNodeComputeFlexBasisForChildren(
|
|||||||
YGFlexDirection mainAxis,
|
YGFlexDirection mainAxis,
|
||||||
const YGConfigRef config,
|
const YGConfigRef config,
|
||||||
bool performLayout,
|
bool performLayout,
|
||||||
YGMarkerLayoutData& layoutMarkerData,
|
LayoutData& layoutMarkerData,
|
||||||
void* const layoutContext,
|
void* const layoutContext,
|
||||||
const uint32_t depth,
|
const uint32_t depth,
|
||||||
const uint32_t generationCount) {
|
const uint32_t generationCount) {
|
||||||
@@ -2020,7 +2019,7 @@ static float YGDistributeFreeSpaceSecondPass(
|
|||||||
const YGMeasureMode measureModeCrossDim,
|
const YGMeasureMode measureModeCrossDim,
|
||||||
const bool performLayout,
|
const bool performLayout,
|
||||||
const YGConfigRef config,
|
const YGConfigRef config,
|
||||||
YGMarkerLayoutData& layoutMarkerData,
|
LayoutData& layoutMarkerData,
|
||||||
void* const layoutContext,
|
void* const layoutContext,
|
||||||
const uint32_t depth,
|
const uint32_t depth,
|
||||||
const uint32_t generationCount) {
|
const uint32_t generationCount) {
|
||||||
@@ -2321,7 +2320,7 @@ static void YGResolveFlexibleLength(
|
|||||||
const YGMeasureMode measureModeCrossDim,
|
const YGMeasureMode measureModeCrossDim,
|
||||||
const bool performLayout,
|
const bool performLayout,
|
||||||
const YGConfigRef config,
|
const YGConfigRef config,
|
||||||
YGMarkerLayoutData& layoutMarkerData,
|
LayoutData& layoutMarkerData,
|
||||||
void* const layoutContext,
|
void* const layoutContext,
|
||||||
const uint32_t depth,
|
const uint32_t depth,
|
||||||
const uint32_t generationCount) {
|
const uint32_t generationCount) {
|
||||||
@@ -2651,7 +2650,7 @@ static void YGNodelayoutImpl(
|
|||||||
const float ownerHeight,
|
const float ownerHeight,
|
||||||
const bool performLayout,
|
const bool performLayout,
|
||||||
const YGConfigRef config,
|
const YGConfigRef config,
|
||||||
YGMarkerLayoutData& layoutMarkerData,
|
LayoutData& layoutMarkerData,
|
||||||
void* const layoutContext,
|
void* const layoutContext,
|
||||||
const uint32_t depth,
|
const uint32_t depth,
|
||||||
const uint32_t generationCount) {
|
const uint32_t generationCount) {
|
||||||
@@ -3707,7 +3706,7 @@ bool YGLayoutNodeInternal(
|
|||||||
const bool performLayout,
|
const bool performLayout,
|
||||||
const char* reason,
|
const char* reason,
|
||||||
const YGConfigRef config,
|
const YGConfigRef config,
|
||||||
YGMarkerLayoutData& layoutMarkerData,
|
LayoutData& layoutMarkerData,
|
||||||
void* const layoutContext,
|
void* const layoutContext,
|
||||||
uint32_t depth,
|
uint32_t depth,
|
||||||
const uint32_t generationCount) {
|
const uint32_t generationCount) {
|
||||||
@@ -4065,7 +4064,7 @@ void YGNodeCalculateLayoutWithContext(
|
|||||||
void* layoutContext) {
|
void* layoutContext) {
|
||||||
|
|
||||||
Event::publish<Event::LayoutPassStart>(node, {layoutContext});
|
Event::publish<Event::LayoutPassStart>(node, {layoutContext});
|
||||||
YGMarkerLayoutData markerData = {};
|
LayoutData markerData = {};
|
||||||
|
|
||||||
// Increment the generation count. This will force the recursive routine to
|
// Increment the generation count. This will force the recursive routine to
|
||||||
// visit all dirty nodes at least once. Subsequent visits will be skipped if
|
// visit all dirty nodes at least once. Subsequent visits will be skipped if
|
||||||
@@ -4161,7 +4160,7 @@ void YGNodeCalculateLayoutWithContext(
|
|||||||
gCurrentGenerationCount++;
|
gCurrentGenerationCount++;
|
||||||
// Rerun the layout, and calculate the diff
|
// Rerun the layout, and calculate the diff
|
||||||
unsetUseLegacyFlagRecursively(nodeWithoutLegacyFlag);
|
unsetUseLegacyFlagRecursively(nodeWithoutLegacyFlag);
|
||||||
YGMarkerLayoutData layoutMarkerData = {};
|
LayoutData layoutMarkerData = {};
|
||||||
if (YGLayoutNodeInternal(
|
if (YGLayoutNodeInternal(
|
||||||
nodeWithoutLegacyFlag,
|
nodeWithoutLegacyFlag,
|
||||||
width,
|
width,
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <yoga/YGEnums.h>
|
#include <yoga/YGEnums.h>
|
||||||
#include <yoga/YGMarker.h>
|
|
||||||
|
|
||||||
struct YGConfig;
|
struct YGConfig;
|
||||||
struct YGNode;
|
struct YGNode;
|
||||||
@@ -24,6 +23,15 @@ enum LayoutType : int {
|
|||||||
kCachedMeasure = 3
|
kCachedMeasure = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct LayoutData {
|
||||||
|
int layouts;
|
||||||
|
int measures;
|
||||||
|
int maxMeasureCache;
|
||||||
|
int cachedLayouts;
|
||||||
|
int cachedMeasures;
|
||||||
|
int measureCallbacks;
|
||||||
|
};
|
||||||
|
|
||||||
struct Event {
|
struct Event {
|
||||||
enum Type {
|
enum Type {
|
||||||
NodeAllocation,
|
NodeAllocation,
|
||||||
@@ -94,7 +102,7 @@ struct Event::TypedData<Event::LayoutPassStart> {
|
|||||||
template <>
|
template <>
|
||||||
struct Event::TypedData<Event::LayoutPassEnd> {
|
struct Event::TypedData<Event::LayoutPassEnd> {
|
||||||
void* layoutContext;
|
void* layoutContext;
|
||||||
YGMarkerLayoutData* layoutData;
|
LayoutData* layoutData;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
@@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the LICENSE
|
|
||||||
* file in the root directory of this source tree.
|
|
||||||
*/
|
|
||||||
#include "YGConfig.h"
|
|
||||||
#include "YGMarker.h"
|
|
||||||
#include "YGNode.h"
|
|
||||||
|
|
||||||
namespace facebook {
|
|
||||||
namespace yoga {
|
|
||||||
namespace marker {
|
|
||||||
|
|
||||||
template <YGMarker MarkerType>
|
|
||||||
class MarkerSection {
|
|
||||||
private:
|
|
||||||
using Data = detail::MarkerData<MarkerType>;
|
|
||||||
|
|
||||||
public:
|
|
||||||
MarkerSection(YGNodeRef node) : MarkerSection{node, node->getConfig()} {}
|
|
||||||
void end() {
|
|
||||||
if (endMarker_) {
|
|
||||||
endMarker_(MarkerType, node_, markerData(&data), userData_);
|
|
||||||
endMarker_ = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
~MarkerSection() { end(); }
|
|
||||||
|
|
||||||
typename Data::type data = {};
|
|
||||||
|
|
||||||
template <typename Ret, typename... Args>
|
|
||||||
static Ret wrap(
|
|
||||||
YGNodeRef node,
|
|
||||||
Ret (YGNode::*method)(Args...),
|
|
||||||
Args... args) {
|
|
||||||
MarkerSection<MarkerType> section{node};
|
|
||||||
return (node->*method)(std::forward<Args>(args)...);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
decltype(YGMarkerCallbacks{}.endMarker) endMarker_;
|
|
||||||
YGNodeRef node_;
|
|
||||||
void* userData_;
|
|
||||||
|
|
||||||
MarkerSection(YGNodeRef node, YGConfigRef config)
|
|
||||||
: MarkerSection{node, config ? &config->markerCallbacks : nullptr} {}
|
|
||||||
MarkerSection(YGNodeRef node, YGMarkerCallbacks* callbacks)
|
|
||||||
: endMarker_{callbacks ? callbacks->endMarker : nullptr},
|
|
||||||
node_{node},
|
|
||||||
userData_{
|
|
||||||
callbacks && callbacks->startMarker
|
|
||||||
? callbacks->startMarker(MarkerType, node, markerData(&data))
|
|
||||||
: nullptr} {}
|
|
||||||
|
|
||||||
static YGMarkerData markerData(typename Data::type* d) {
|
|
||||||
YGMarkerData markerData = {};
|
|
||||||
Data::get(markerData) = d;
|
|
||||||
return markerData;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace marker
|
|
||||||
} // namespace yoga
|
|
||||||
} // namespace facebook
|
|
Reference in New Issue
Block a user