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:
David Aurelio 2019-05-10 18:55:53 -07:00 коммит произвёл Facebook Github Bot
Родитель 1b4678105b
Коммит bd959700db
2 изменённых файлов: 23 добавлений и 3 удалений

Просмотреть файл

@ -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);