Publish events for layout pass
Summary: Adds `LayoutPassStart` and `LayoutPassEnd` events. The existing `NodeLayout` event in isolation is not as useful as it could be. Having events that mark start and end of a layout pass are a useful addition. Differential Revision: D15305467 fbshipit-source-id: 14af6f65e698fb1e3112eb2ffd87a74d31df4840
This commit is contained in:
committed by
Facebook Github Bot
parent
74fc37efc8
commit
a15bf6e701
@@ -127,6 +127,10 @@ void EventTest::listen(const YGNode& node, Event::Type type, Event::Data data) {
|
||||
case Event::NodeLayout:
|
||||
events.push_back(createArgs<Event::NodeLayout>(node, data));
|
||||
break;
|
||||
case Event::LayoutPassStart:
|
||||
break;
|
||||
case Event::LayoutPassEnd:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -9,6 +9,7 @@
|
||||
#include <float.h>
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include "Utils.h"
|
||||
#include "YGNode.h"
|
||||
#include "YGNodePrint.h"
|
||||
@@ -4002,7 +4003,13 @@ void YGNodeCalculateLayoutWithContext(
|
||||
const float ownerHeight,
|
||||
const YGDirection ownerDirection,
|
||||
void* layoutContext) {
|
||||
marker::MarkerSection<YGMarkerLayout> marker{node};
|
||||
|
||||
#ifdef YG_ENABLE_EVENTS
|
||||
Event::publish<Event::LayoutPassStart>(node);
|
||||
#endif
|
||||
// unique pointer to allow ending the marker early
|
||||
std::unique_ptr<marker::MarkerSection<YGMarkerLayout>> marker{
|
||||
new marker::MarkerSection<YGMarkerLayout>{node}};
|
||||
|
||||
// Increment the generation count. This will force the recursive routine to
|
||||
// visit all dirty nodes at least once. Subsequent visits will be skipped if
|
||||
@@ -4061,7 +4068,7 @@ void YGNodeCalculateLayoutWithContext(
|
||||
true,
|
||||
"initial",
|
||||
node->getConfig(),
|
||||
marker.data,
|
||||
marker->data,
|
||||
layoutContext)) {
|
||||
node->setPosition(
|
||||
node->getLayout().direction, ownerWidth, ownerHeight, ownerWidth);
|
||||
@@ -4078,6 +4085,13 @@ void YGNodeCalculateLayoutWithContext(
|
||||
#endif
|
||||
}
|
||||
|
||||
// end marker here
|
||||
marker = nullptr;
|
||||
|
||||
#ifdef YG_ENABLE_EVENTS
|
||||
Event::publish<Event::LayoutPassEnd>(node);
|
||||
#endif
|
||||
|
||||
// We want to get rid off `useLegacyStretchBehaviour` from YGConfig. But we
|
||||
// aren't sure whether client's of yoga have gotten rid off this flag or not.
|
||||
// So logging this in YGLayout would help to find out the call sites depending
|
||||
|
@@ -15,7 +15,13 @@ namespace facebook {
|
||||
namespace yoga {
|
||||
|
||||
struct Event {
|
||||
enum Type { NodeAllocation, NodeDeallocation, NodeLayout };
|
||||
enum Type {
|
||||
NodeAllocation,
|
||||
NodeDeallocation,
|
||||
NodeLayout,
|
||||
LayoutPassStart,
|
||||
LayoutPassEnd
|
||||
};
|
||||
class Data;
|
||||
using Subscriber = void(const YGNode&, Type, Data);
|
||||
|
||||
|
Reference in New Issue
Block a user